|
@@ -360,4 +360,41 @@ public class advertiseAction extends ActionSupport implements ServletRequestAwar
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String operateState(){
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+ if (id==null || state==null){
|
|
|
|
|
+ resultJson.put("message", "数据格式不对");
|
|
|
|
|
+ resultJson.put("code", 205);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Advertise advertise = advertiseService.queryById(id);
|
|
|
|
|
+ if (advertise==null){
|
|
|
|
|
+ resultJson.put("message", "当前广告已删除");
|
|
|
|
|
+ resultJson.put("code", 205);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Advertise> open = advertiseService.queryOpenAdvertise();
|
|
|
|
|
+ List<Integer> ids = open.stream().map(Advertise::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (open.size()>=3 && advertise.getJumpWay().equals("小程序") && !ids.contains(advertise.getId()) && state==1){
|
|
|
|
|
+ resultJson.put("message", "小程序最多开启三个广告");
|
|
|
|
|
+ resultJson.put("code", 500);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ int m = advertiseService.updateState(id,state);
|
|
|
|
|
+ if (m>0){
|
|
|
|
|
+ resultJson.put("message", "操作成功");
|
|
|
|
|
+ resultJson.put("code", 200);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
|
|
+ resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ resultJson.put("message", "操作失败");
|
|
|
|
|
+ resultJson.put("code", 205);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
|
|
+ resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|