Bläddra i källkod

轮播图开屏广告

魏超 5 år sedan
förälder
incheckning
1fafdcab63

+ 55
- 5
src/main/java/com/huiju/estateagents/controller/ExtendContentController.java Visa fil

@@ -6,10 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.estateagents.base.BaseController;
7 7
 import com.huiju.estateagents.base.ResponseBean;
8 8
 import com.huiju.estateagents.entity.ExtendContent;
9
+import com.huiju.estateagents.entity.TaBuilding;
9 10
 import com.huiju.estateagents.entity.TaBuildingDynamic;
11
+import com.huiju.estateagents.entity.TdCity;
10 12
 import com.huiju.estateagents.service.IExtendContentService;
11 13
 import com.huiju.estateagents.service.ITaBuildingDynamicService;
12 14
 import com.huiju.estateagents.service.ITaBuildingService;
15
+import com.huiju.estateagents.service.ITdCityService;
13 16
 import io.swagger.annotations.Api;
14 17
 import io.swagger.annotations.ApiImplicitParam;
15 18
 import io.swagger.annotations.ApiImplicitParams;
@@ -53,6 +56,9 @@ public class ExtendContentController extends BaseController {
53 56
     @Autowired
54 57
     private ITaBuildingService iTaBuildingService;
55 58
 
59
+    @Autowired
60
+    private ITdCityService iTdCityService;
61
+
56 62
     /**
57 63
      * 分页查询列表
58 64
      * @param pageNum
@@ -72,22 +78,39 @@ public class ExtendContentController extends BaseController {
72 78
     @RequestMapping(value="/admin/extendContent",method= RequestMethod.GET)
73 79
     public ResponseBean extendContentList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
74 80
                                           @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
81
+                                          @RequestParam(value = "cityId", required = false) Integer cityId,
75 82
                                           @RequestParam(value = "buildingId", required = false) String buildingId,
76 83
                                           @RequestParam(value = "contentType", required = false) String contentType,
77 84
                                           @RequestParam(value = "showPosition", required = false) String showPosition,
78 85
                                           @RequestParam(value = "status", required = false) Integer status,
79 86
                                           @RequestParam(value = "showType", required = false) String showType,HttpServletRequest request){
80
-        ResponseBean responseBean = new ResponseBean();
87
+            ResponseBean responseBean = new ResponseBean();
81 88
             IPage<ExtendContent> pg = new Page<>(pageNum, pageSize);
82 89
             QueryWrapper<ExtendContent> queryWrapper = new QueryWrapper<>();
90
+            queryWrapper.eq(cityId != null, "city_id", cityId);
83 91
             queryWrapper.eq(StringUtils.isNotBlank(buildingId), "building_id", buildingId);
84 92
             queryWrapper.eq(StringUtils.isNotBlank(showType), "show_type", showType);
85 93
             queryWrapper.eq(StringUtils.isNotBlank(contentType), "content_type", contentType);
86 94
             queryWrapper.eq(StringUtils.isNotBlank(showPosition), "show_position", showPosition);
87
-            queryWrapper.eq(null!=status, "status", status);
95
+            queryWrapper.ne("status",9);
96
+            queryWrapper.eq(status != null, "status", status);
88 97
             queryWrapper.eq( "org_id", getOrgId(request));
89 98
             queryWrapper.orderByDesc("create_date");
90 99
             IPage<ExtendContent> result = iExtendContentService.page(pg, queryWrapper);
100
+
101
+            result.getRecords().forEach(e -> {
102
+                QueryWrapper<TdCity> tdCityQueryWrapper = new QueryWrapper<>();
103
+                tdCityQueryWrapper.eq("id", e.getCityId());
104
+                TdCity tdCity = iTdCityService.getOne(tdCityQueryWrapper);
105
+                QueryWrapper<TaBuilding> taBuildingQueryWrapper = new QueryWrapper<>();
106
+                taBuildingQueryWrapper.eq("building_id", e.getBuildingId());
107
+                TaBuilding taBuilding = iTaBuildingService.getOne(taBuildingQueryWrapper);
108
+                e.setCityName(tdCity.getName());
109
+                if (taBuilding != null){
110
+                    e.setBuildingName(taBuilding.getBuildingName());
111
+                }
112
+            });
113
+            result.setRecords(result.getRecords());
91 114
             responseBean.addSuccess(result);
92 115
             return responseBean;
93 116
     }
@@ -130,8 +153,10 @@ public class ExtendContentController extends BaseController {
130 153
     })
131 154
     @RequestMapping(value="/admin/extendContent",method= RequestMethod.POST)
132 155
     public ResponseBean extendContentAdd(@RequestBody ExtendContent extendContent, HttpServletRequest request){
133
-        Integer cityId = iTaBuildingService.getCityById(extendContent.getBuildingId());
134
-        extendContent.setCityId(cityId);
156
+        if (extendContent.getCityId() == null){
157
+            Integer cityId = iTaBuildingService.getCityById(extendContent.getBuildingId());
158
+            extendContent.setCityId(cityId);
159
+        }
135 160
         extendContent.setCreateDate(LocalDateTime.now());
136 161
         extendContent.setOrgId(getOrgId(request));
137 162
         ResponseBean  responseBean= iExtendContentService.extendContentAdd(extendContent);
@@ -173,7 +198,7 @@ public class ExtendContentController extends BaseController {
173 198
      */
174 199
     @ApiOperation(value = "后台轮播图保存", notes = "后台轮播图保存")
175 200
     @ApiImplicitParams({
176
-            @ApiImplicitParam(dataType = "Integer", name = "id", paramType = "payh",value = "轮播图id"),
201
+            @ApiImplicitParam(dataType = "Integer", name = "id", paramType = "path",value = "轮播图id"),
177 202
             @ApiImplicitParam(dataType = "ExtendContent", name = "extendContent", paramType = "body",value = "轮播图内容")
178 203
     })
179 204
     @RequestMapping(value="/admin/extendContent/{id}",method= RequestMethod.PUT)
@@ -198,6 +223,31 @@ public class ExtendContentController extends BaseController {
198 223
         return responseBean;
199 224
     }
200 225
 
226
+    /**
227
+     * 删除对象,逻辑删除,修改状态为9
228
+     * @param id  实体ID
229
+     * @return
230
+     */
231
+    @ApiOperation(value = "后台轮播图删除", notes = "后台轮播图删除")
232
+    @ApiImplicitParams({
233
+            @ApiImplicitParam(dataType = "Integer", name = "id", paramType = "path",value = "轮播图id")
234
+    })
235
+    @RequestMapping(value="/admin/extendContentDelete/{id}",method= RequestMethod.PUT)
236
+    public ResponseBean extendContentUpdate(@PathVariable Integer id, HttpServletRequest request){
237
+        ResponseBean responseBean = new ResponseBean();
238
+        ExtendContent extendContent = new ExtendContent();
239
+        extendContent.setContentId(id);
240
+        extendContent.setStatus(9);
241
+        try {
242
+            iExtendContentService.updateById(extendContent);
243
+        }catch (Exception e){
244
+            e.printStackTrace();
245
+            logger.error("extendContentDelete -=- {}",e.toString());
246
+            responseBean.addError(e.getMessage());
247
+        }
248
+        return responseBean;
249
+    }
250
+
201 251
     /**
202 252
      * 根据id查询对象
203 253
      * @param id  实体ID

+ 6
- 0
src/main/java/com/huiju/estateagents/entity/ExtendContent.java Visa fil

@@ -55,6 +55,12 @@ public class ExtendContent implements Serializable {
55 55
     @TableField(exist = false)
56 56
     private String targetName;
57 57
 
58
+    @TableField(exist = false)
59
+    private String cityName;
60
+
61
+    @TableField(exist = false)
62
+    private String buildingName;
63
+
58 64
     /**
59 65
      * 图片
60 66
      */

+ 3
- 0
src/main/java/com/huiju/estateagents/service/impl/ExtendContentServiceImpl.java Visa fil

@@ -29,6 +29,9 @@ public class ExtendContentServiceImpl extends ServiceImpl<ExtendContentMapper, E
29 29
     @Override
30 30
     public ResponseBean extendContentAdd(ExtendContent extendContent) {
31 31
         ResponseBean responseBean= new ResponseBean<>();
32
+        if (extendContent.getStatus() == null){
33
+            extendContent.setStatus(0);
34
+        }
32 35
         extendContentMapper.insert(extendContent);
33 36
         responseBean.addSuccess("成功");
34 37
         return  responseBean;