魏超 5 anos atrás
pai
commit
58fded9e08

+ 15
- 18
src/main/java/com/huiju/estateagents/controller/ExtendContentController.java Ver arquivo

@@ -164,6 +164,14 @@ public class ExtendContentController extends BaseController {
164 164
     })
165 165
     @RequestMapping(value="/admin/extendContent",method= RequestMethod.POST)
166 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 175
         if (extendContent.getCityId() == null){
168 176
             Integer cityId = iTaBuildingService.getCityById(extendContent.getBuildingId());
169 177
             extendContent.setCityId(cityId);
@@ -173,9 +181,9 @@ public class ExtendContentController extends BaseController {
173 181
         if (StringUtils.isEmpty(extendContent.getContentType())){
174 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,8 +235,6 @@ public class ExtendContentController extends BaseController {
227 235
             }
228 236
             extendContent.setOrgId(getOrgId(request));
229 237
 
230
-            iExtendContentService.judgleRelationBuildAndActivity(extendContent);
231
-
232 238
             if (extendContent.getStatus() == 1){
233 239
                 boolean publishFlag = iExtendContentService.judgleRelationBuildAndActivity(extendContent);
234 240
                 if (!publishFlag){
@@ -238,21 +244,12 @@ public class ExtendContentController extends BaseController {
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 253
             if (iExtendContentService.updateById(extendContent)){
257 254
                 responseBean.addSuccess(extendContent);
258 255
             }else {

+ 2
- 0
src/main/java/com/huiju/estateagents/service/IExtendContentService.java Ver arquivo

@@ -47,4 +47,6 @@ public interface IExtendContentService extends IService<ExtendContent> {
47 47
     void updateActivity(String dynamicId, String type,Integer orgId);
48 48
 
49 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 Ver arquivo

@@ -9,6 +9,7 @@ import com.huiju.estateagents.drainage.mapper.TaDrainageMapper;
9 9
 import com.huiju.estateagents.entity.*;
10 10
 import com.huiju.estateagents.mapper.*;
11 11
 import com.huiju.estateagents.service.IExtendContentService;
12
+import io.jsonwebtoken.lang.Collections;
12 13
 import org.apache.commons.lang3.StringUtils;
13 14
 import org.springframework.beans.factory.annotation.Autowired;
14 15
 import org.springframework.stereotype.Service;
@@ -168,4 +169,24 @@ public class ExtendContentServiceImpl extends ServiceImpl<ExtendContentMapper, E
168 169
 
169 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
 }