魏超 5 лет назад
Родитель
Сommit
58fded9e08

+ 15
- 18
src/main/java/com/huiju/estateagents/controller/ExtendContentController.java Просмотреть файл

164
     })
164
     })
165
     @RequestMapping(value="/admin/extendContent",method= RequestMethod.POST)
165
     @RequestMapping(value="/admin/extendContent",method= RequestMethod.POST)
166
     public ResponseBean extendContentAdd(@RequestBody ExtendContent extendContent, HttpServletRequest request){
166
     public ResponseBean extendContentAdd(@RequestBody ExtendContent extendContent, HttpServletRequest request){
167
+        ResponseBean  responseBean = new ResponseBean();
168
+        //一个城市只能有一个开屏广告
169
+        boolean existFlag = iExtendContentService.advertistExistFlag(extendContent, getOrgId(request));
170
+        if (!existFlag){
171
+            responseBean.addError("该城市已有开屏广告,请勿再次上架");
172
+            return responseBean;
173
+        }
174
+
167
         if (extendContent.getCityId() == null){
175
         if (extendContent.getCityId() == null){
168
             Integer cityId = iTaBuildingService.getCityById(extendContent.getBuildingId());
176
             Integer cityId = iTaBuildingService.getCityById(extendContent.getBuildingId());
169
             extendContent.setCityId(cityId);
177
             extendContent.setCityId(cityId);
173
         if (StringUtils.isEmpty(extendContent.getContentType())){
181
         if (StringUtils.isEmpty(extendContent.getContentType())){
174
             extendContent.setContentType("nothing");
182
             extendContent.setContentType("nothing");
175
         }
183
         }
176
-        ResponseBean  responseBean= iExtendContentService.extendContentAdd(extendContent);
177
-          responseBean.addSuccess(extendContent);
178
-          return responseBean;
184
+        responseBean = iExtendContentService.extendContentAdd(extendContent);
185
+        responseBean.addSuccess(extendContent);
186
+        return responseBean;
179
     }
187
     }
180
 
188
 
181
     /**
189
     /**
227
             }
235
             }
228
             extendContent.setOrgId(getOrgId(request));
236
             extendContent.setOrgId(getOrgId(request));
229
 
237
 
230
-            iExtendContentService.judgleRelationBuildAndActivity(extendContent);
231
-
232
             if (extendContent.getStatus() == 1){
238
             if (extendContent.getStatus() == 1){
233
                 boolean publishFlag = iExtendContentService.judgleRelationBuildAndActivity(extendContent);
239
                 boolean publishFlag = iExtendContentService.judgleRelationBuildAndActivity(extendContent);
234
                 if (!publishFlag){
240
                 if (!publishFlag){
238
             }
244
             }
239
 
245
 
240
             //一个城市只能有一个开屏广告
246
             //一个城市只能有一个开屏广告
241
-            if (extendContent.getStatus() == 1 && CommConstant.OPEN_SCREEN.equals(extendContent.getShowType())){
242
-                QueryWrapper<ExtendContent> taExtendContentQueryWrapper = new QueryWrapper<>();
243
-                taExtendContentQueryWrapper.eq("city_id", extendContent.getCityId());
244
-                taExtendContentQueryWrapper.eq("org_id", getOrgId(request));
245
-                taExtendContentQueryWrapper.eq("status", 1);
246
-                taExtendContentQueryWrapper.eq("show_type", extendContent.getShowType());
247
-                taExtendContentQueryWrapper.ne("content_id", extendContent.getTargetId());
248
-                List<ExtendContent> extContentInfo = iExtendContentService.list(taExtendContentQueryWrapper);
249
-                if (!Collections.isEmpty(extContentInfo)){
250
-                    responseBean.addError("该城市已有开屏广告,请勿再次上架");
251
-                    return responseBean;
252
-                }
247
+            boolean existFlag = iExtendContentService.advertistExistFlag(extendContent, getOrgId(request));
248
+            if (!existFlag){
249
+                responseBean.addError("该城市已有开屏广告,请勿再次上架");
250
+                return responseBean;
253
             }
251
             }
254
 
252
 
255
-
256
             if (iExtendContentService.updateById(extendContent)){
253
             if (iExtendContentService.updateById(extendContent)){
257
                 responseBean.addSuccess(extendContent);
254
                 responseBean.addSuccess(extendContent);
258
             }else {
255
             }else {

+ 2
- 0
src/main/java/com/huiju/estateagents/service/IExtendContentService.java Просмотреть файл

47
     void updateActivity(String dynamicId, String type,Integer orgId);
47
     void updateActivity(String dynamicId, String type,Integer orgId);
48
 
48
 
49
     boolean judgleRelationBuildAndActivity(ExtendContent extendContent);
49
     boolean judgleRelationBuildAndActivity(ExtendContent extendContent);
50
+
51
+    boolean advertistExistFlag(ExtendContent extendContent, Integer orgId);
50
 }
52
 }

+ 21
- 0
src/main/java/com/huiju/estateagents/service/impl/ExtendContentServiceImpl.java Просмотреть файл

9
 import com.huiju.estateagents.entity.*;
9
 import com.huiju.estateagents.entity.*;
10
 import com.huiju.estateagents.mapper.*;
10
 import com.huiju.estateagents.mapper.*;
11
 import com.huiju.estateagents.service.IExtendContentService;
11
 import com.huiju.estateagents.service.IExtendContentService;
12
+import io.jsonwebtoken.lang.Collections;
12
 import org.apache.commons.lang3.StringUtils;
13
 import org.apache.commons.lang3.StringUtils;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.stereotype.Service;
15
 import org.springframework.stereotype.Service;
168
 
169
 
169
         return true;
170
         return true;
170
     }
171
     }
172
+
173
+    @Override
174
+    public boolean advertistExistFlag(ExtendContent extendContent, Integer orgId) {
175
+        //一个城市只能有一个开屏广告
176
+        if (extendContent.getStatus() == 1 && CommConstant.OPEN_SCREEN.equals(extendContent.getShowType())){
177
+            QueryWrapper<ExtendContent> taExtendContentQueryWrapper = new QueryWrapper<>();
178
+            taExtendContentQueryWrapper.eq("city_id", extendContent.getCityId());
179
+            taExtendContentQueryWrapper.eq("org_id", orgId);
180
+            taExtendContentQueryWrapper.eq("status", 1);
181
+            taExtendContentQueryWrapper.eq("show_type", extendContent.getShowType());
182
+            if (null != extendContent.getContentId()){
183
+                taExtendContentQueryWrapper.ne("content_id", extendContent.getContentId());
184
+            }
185
+            List<ExtendContent> extContentInfo = extendContentMapper.selectList(taExtendContentQueryWrapper);
186
+            if (!Collections.isEmpty(extContentInfo)){
187
+                return false;
188
+            }
189
+        }
190
+        return true;
191
+    }
171
 }
192
 }