Przeglądaj źródła

品牌商管理

fuxingfan 4 lat temu
rodzic
commit
70c01f057c

+ 4
- 0
src/main/java/com/yunzhi/marketing/center/taUser/controller/TaUserController.java Wyświetl plik

@@ -19,6 +19,8 @@ import com.yunzhi.marketing.common.MD5Utils;
19 19
 import com.yunzhi.marketing.mapper.TaRoleMapper;
20 20
 import com.yunzhi.marketing.entity.*;
21 21
 import com.yunzhi.marketing.service.*;
22
+import io.swagger.annotations.Api;
23
+import io.swagger.annotations.ApiOperation;
22 24
 import org.slf4j.Logger;
23 25
 import org.slf4j.LoggerFactory;
24 26
 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +44,7 @@ import java.util.Map;
42 44
  */
43 45
 @RestController
44 46
 @RequestMapping("/api")
47
+@Api(value = "用户登录相关", tags = "用户登录相关")
45 48
 public class TaUserController extends BaseController {
46 49
 
47 50
     private final Logger logger = LoggerFactory.getLogger(TaUserController.class);
@@ -328,6 +331,7 @@ public class TaUserController extends BaseController {
328 331
      * @return
329 332
      */
330 333
     @PostMapping("/admin/taUser/signin")
334
+    @ApiOperation(value = "admin端登录", notes = "admin端登录")
331 335
     public ResponseBean signin(@RequestBody String paramStr) {
332 336
         JSONObject params = JSONObject.parseObject(paramStr);
333 337
         if (params == null) {

+ 8
- 8
src/main/java/com/yunzhi/marketing/interceptor/AccessInterceptor.java Wyświetl plik

@@ -179,14 +179,14 @@ public class AccessInterceptor implements HandlerInterceptor {
179 179
         }
180 180
 
181 181
 //        按钮权限校验
182
-        boolean state = checkButtonRole(request);
183
-        if (!state){
184
-            ResponseBean resp = ResponseBean.error("权限验证非法" , ResponseBean.ERROR_AUTH_FAIL);
185
-
186
-            response.addHeader("Content-type", "application/json");
187
-            response.getOutputStream().write(JSONObject.toJSONBytes(resp));
188
-            return false;
189
-        }
182
+//        boolean state = checkButtonRole(request);
183
+//        if (!state){
184
+//            ResponseBean resp = ResponseBean.error("权限验证非法" , ResponseBean.ERROR_AUTH_FAIL);
185
+//
186
+//            response.addHeader("Content-type", "application/json");
187
+//            response.getOutputStream().write(JSONObject.toJSONBytes(resp));
188
+//            return false;
189
+//        }
190 190
         
191 191
         return true;
192 192
     }

+ 64
- 18
src/main/java/com/yunzhi/marketing/xlk/controller/BrandController.java Wyświetl plik

@@ -1,15 +1,23 @@
1 1
 package com.yunzhi.marketing.xlk.controller;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 7
 import com.yunzhi.marketing.base.BaseController;
7 8
 import com.yunzhi.marketing.base.ResponseBean;
9
+import com.yunzhi.marketing.entity.TaBuilding;
10
+import com.yunzhi.marketing.service.ITaBuildingService;
11
+import com.yunzhi.marketing.xlk.dto.BrandDTO;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiOperation;
8 14
 import org.slf4j.Logger;
9 15
 import org.slf4j.LoggerFactory;
16
+import org.springframework.beans.BeanUtils;
10 17
 import org.springframework.beans.factory.annotation.Autowired;
11 18
 import org.springframework.web.bind.annotation.PathVariable;
12 19
 import org.springframework.web.bind.annotation.RequestBody;
20
+import org.springframework.web.bind.annotation.RequestHeader;
13 21
 import org.springframework.web.bind.annotation.RequestMapping;
14 22
 import org.springframework.web.bind.annotation.RequestMethod;
15 23
 import org.springframework.web.bind.annotation.RequestParam;
@@ -18,6 +26,10 @@ import com.yunzhi.marketing.xlk.service.IBrandService;
18 26
 import com.yunzhi.marketing.xlk.entity.Brand;
19 27
 import org.springframework.web.bind.annotation.RestController;
20 28
 
29
+import javax.servlet.http.HttpServletRequest;
30
+import java.time.LocalDateTime;
31
+import java.util.List;
32
+
21 33
 /**
22 34
  * <p>
23 35
     * 品牌开发商表  前端控制器
@@ -27,7 +39,8 @@ import org.springframework.web.bind.annotation.RestController;
27 39
  * @since 2021-05-13
28 40
  */
29 41
 @RestController
30
-@RequestMapping("/")
42
+@RequestMapping("/api")
43
+@Api(value = "品牌开发商表", tags = "xlk-品牌开发商表")
31 44
 public class BrandController extends BaseController {
32 45
 
33 46
     private final Logger logger = LoggerFactory.getLogger(BrandController.class);
@@ -35,6 +48,9 @@ public class BrandController extends BaseController {
35 48
     @Autowired
36 49
     public IBrandService iBrandService;
37 50
 
51
+    @Autowired
52
+    private ITaBuildingService taBuildingService;
53
+
38 54
 
39 55
     /**
40 56
      * 分页查询列表
@@ -42,15 +58,17 @@ public class BrandController extends BaseController {
42 58
      * @param pageSize
43 59
      * @return
44 60
      */
45
-    @RequestMapping(value="/brand",method= RequestMethod.GET)
61
+    @ApiOperation(value = "品牌开发商表列表", notes = "品牌开发商表列表")
62
+    @RequestMapping(value="/admin/brand",method= RequestMethod.GET)
46 63
     public ResponseBean brandList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
-                                  @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
64
+                                  @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize, @RequestHeader("authorization") String token,HttpServletRequest request){
48 65
         ResponseBean responseBean = new ResponseBean();
49 66
         try {
50 67
             //使用分页插件
51 68
 		    IPage<Brand> pg = new Page<>(pageNum, pageSize);
52
-            QueryWrapper<Brand> queryWrapper = new QueryWrapper<>();
53
-            queryWrapper.orderByDesc("create_date");
69
+            LambdaQueryWrapper<Brand> queryWrapper = new LambdaQueryWrapper<>();
70
+            queryWrapper.eq(Brand::getOrgId,getOrgId(request));
71
+            queryWrapper.orderByDesc(Brand::getCreatedTime);
54 72
 
55 73
             IPage<Brand> result = iBrandService.page(pg, queryWrapper);
56 74
             responseBean.addSuccess(result);
@@ -64,13 +82,19 @@ public class BrandController extends BaseController {
64 82
 
65 83
     /**
66 84
      * 保存对象
67
-     * @param brand 实体对象
85
+     * @param brandDTO 实体对象
68 86
      * @return
69 87
      */
70
-    @RequestMapping(value="/brand",method= RequestMethod.POST)
71
-    public ResponseBean brandAdd(@RequestBody Brand brand){
88
+    @ApiOperation(value = "添加品牌开发商表", notes = "添加品牌开发商表")
89
+    @RequestMapping(value="/admin/brand",method= RequestMethod.POST)
90
+    public ResponseBean brandAdd(@RequestBody BrandDTO brandDTO, @RequestHeader("authorization") String token, HttpServletRequest request){
72 91
         ResponseBean responseBean = new ResponseBean();
73 92
         try {
93
+            Brand brand = new Brand();
94
+            BeanUtils.copyProperties(brandDTO,brand);
95
+            brand.setCreatedTime(LocalDateTime.now());
96
+            brand.setCreatedBy(getUserId(request));
97
+            brand.setOrgId(getOrgId(request));
74 98
             if (iBrandService.save(brand)){
75 99
                 responseBean.addSuccess(brand);
76 100
             }else {
@@ -88,12 +112,21 @@ public class BrandController extends BaseController {
88 112
      * 根据id删除对象
89 113
      * @param id  实体ID
90 114
      */
91
-    @ResponseBody
92
-    @RequestMapping(value="/brand/{id}", method= RequestMethod.DELETE)
93
-    public ResponseBean brandDelete(@PathVariable Integer id){
115
+    @ApiOperation(value = "删除品牌开发商表", notes = "删除品牌开发商表")
116
+    @RequestMapping(value="/admin/brand/{id}", method= RequestMethod.DELETE)
117
+    public ResponseBean brandDelete(@PathVariable String id, @RequestHeader("authorization") String token){
94 118
         ResponseBean responseBean = new ResponseBean();
95 119
         try {
96 120
             if(iBrandService.removeById(id)){
121
+                // 同时更新项目里面的品牌商id和name为空
122
+                LambdaQueryWrapper<TaBuilding> queryWrapper = new LambdaQueryWrapper<>();
123
+                queryWrapper.eq(TaBuilding::getBrandId,id);
124
+                List<TaBuilding> list = taBuildingService.list(queryWrapper);
125
+                list.forEach(e -> {
126
+                    e.setBrandId(null);
127
+                    e.setBrandName(null);
128
+                    taBuildingService.updateById(e);
129
+                });
97 130
                 responseBean.addSuccess("success");
98 131
             }else {
99 132
                 responseBean.addError("fail");
@@ -108,16 +141,28 @@ public class BrandController extends BaseController {
108 141
 
109 142
     /**
110 143
      * 修改对象
111
-     * @param id  实体ID
112
-     * @param brand 实体对象
144
+     * @param brandDTO 实体对象
113 145
      * @return
114 146
      */
115
-    @RequestMapping(value="/brand/{id}",method= RequestMethod.PUT)
116
-    public ResponseBean brandUpdate(@PathVariable Integer id,
117
-                                        @RequestBody Brand brand){
147
+    @ApiOperation(value = "修改品牌开发商表", notes = "修改品牌开发商表")
148
+    @RequestMapping(value="/admin/brand/{id}",method= RequestMethod.PUT)
149
+    public ResponseBean brandUpdate(@PathVariable("id") String id,@RequestBody BrandDTO brandDTO,@RequestHeader("authorization") String token,HttpServletRequest request){
118 150
         ResponseBean responseBean = new ResponseBean();
119 151
         try {
152
+            Brand brand = new Brand();
153
+            BeanUtils.copyProperties(brandDTO,brand);
154
+            brand.setBrandId(id);
155
+            brand.setUpdatedBy(getUserId(request));
156
+            brand.setUpdatedTime(LocalDateTime.now());
120 157
             if (iBrandService.updateById(brand)){
158
+                // 同时更新项目里面的品牌商id和name为更新后的名称
159
+                LambdaQueryWrapper<TaBuilding> queryWrapper = new LambdaQueryWrapper<>();
160
+                queryWrapper.eq(TaBuilding::getBrandId,brand.getBrandId());
161
+                List<TaBuilding> list = taBuildingService.list(queryWrapper);
162
+                list.forEach(e -> {
163
+                    e.setBrandName(brand.getBrandName());
164
+                    taBuildingService.updateById(e);
165
+                });
121 166
                 responseBean.addSuccess(brand);
122 167
             }else {
123 168
                 responseBean.addError("fail");
@@ -134,8 +179,9 @@ public class BrandController extends BaseController {
134 179
      * 根据id查询对象
135 180
      * @param id  实体ID
136 181
      */
137
-    @RequestMapping(value="/brand/{id}",method= RequestMethod.GET)
138
-    public ResponseBean brandGet(@PathVariable Integer id){
182
+    @ApiOperation(value = "获取品牌开发商表详情数据", notes = "获取品牌开发商表详情数据")
183
+    @RequestMapping(value="/admin/brand/{id}",method= RequestMethod.GET)
184
+    public ResponseBean brandGet(@PathVariable String id, @RequestHeader("authorization") String token){
139 185
         ResponseBean responseBean = new ResponseBean();
140 186
         try {
141 187
             responseBean.addSuccess(iBrandService.getById(id));

+ 45
- 0
src/main/java/com/yunzhi/marketing/xlk/dto/BrandDTO.java Wyświetl plik

@@ -0,0 +1,45 @@
1
+package com.yunzhi.marketing.xlk.dto;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import lombok.Data;
8
+import lombok.EqualsAndHashCode;
9
+import lombok.experimental.Accessors;
10
+
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
14
+/**
15
+ * <p>
16
+ * 品牌开发商表 
17
+ * </p>
18
+ *
19
+ * @author jobob
20
+ * @since 2021-05-13
21
+ */
22
+@Data
23
+public class BrandDTO implements Serializable {
24
+
25
+    /**
26
+     * 索引字母
27
+     */
28
+    @TableField("Index_letter")
29
+    private String indexLetter;
30
+
31
+    /**
32
+     * 品牌商名称
33
+     */
34
+    private String brandName;
35
+
36
+    /**
37
+     * 品牌商宣传图
38
+     */
39
+    private String brandImg;
40
+
41
+    /**
42
+     * 品牌商简介
43
+     */
44
+    private String brandRemark;
45
+}

+ 6
- 3
src/main/java/com/yunzhi/marketing/xlk/entity/Brand.java Wyświetl plik

@@ -57,7 +57,7 @@ public class Brand implements Serializable {
57 57
      * 创建人
58 58
      */
59 59
     @TableField("CREATED_BY")
60
-    private String createdBy;
60
+    private Integer createdBy;
61 61
 
62 62
     /**
63 63
      * 创建时间
@@ -69,7 +69,7 @@ public class Brand implements Serializable {
69 69
      * 更新人
70 70
      */
71 71
     @TableField("UPDATED_BY")
72
-    private String updatedBy;
72
+    private Integer updatedBy;
73 73
 
74 74
     /**
75 75
      * 更新时间
@@ -77,5 +77,8 @@ public class Brand implements Serializable {
77 77
     @TableField("UPDATED_TIME")
78 78
     private LocalDateTime updatedTime;
79 79
 
80
-
80
+    /**
81
+     * 公司id
82
+     */
83
+    private Integer orgId;
81 84
 }

+ 14
- 2
src/main/resources/db/marketing.pdman.json Wyświetl plik

@@ -19173,7 +19173,7 @@
19173 19173
             },
19174 19174
             {
19175 19175
               "name": "CREATED_BY",
19176
-              "type": "IdOrKey",
19176
+              "type": "Integer",
19177 19177
               "remark": "",
19178 19178
               "chnname": "创建人"
19179 19179
             },
@@ -19185,7 +19185,7 @@
19185 19185
             },
19186 19186
             {
19187 19187
               "name": "UPDATED_BY",
19188
-              "type": "IdOrKey",
19188
+              "type": "Integer",
19189 19189
               "remark": "",
19190 19190
               "chnname": "更新人"
19191 19191
             },
@@ -19194,6 +19194,12 @@
19194 19194
               "type": "DateTime",
19195 19195
               "remark": "",
19196 19196
               "chnname": "更新时间"
19197
+            },
19198
+            {
19199
+              "name": "ORG_ID",
19200
+              "type": "Integer",
19201
+              "remark": "",
19202
+              "chnname": "公司id"
19197 19203
             }
19198 19204
           ],
19199 19205
           "indexs": [],
@@ -20009,6 +20015,12 @@
20009 20015
         "type": "DateTime",
20010 20016
         "remark": "",
20011 20017
         "chnname": "更新时间"
20018
+      },
20019
+      {
20020
+        "name": "ORG_ID",
20021
+        "type": "Integer",
20022
+        "remark": "",
20023
+        "chnname": "公司id"
20012 20024
       }
20013 20025
     ],
20014 20026
     "defaultFieldsType": "1",