|
@@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
public class advertiseAction extends ActionSupport implements ServletRequestAware {
|
|
public class advertiseAction extends ActionSupport implements ServletRequestAware {
|
|
|
|
|
|
|
@@ -145,6 +146,13 @@ public class advertiseAction extends ActionSupport implements ServletRequestAwar
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+ List<Advertise> open = advertiseService.queryOpenAdvertise();
|
|
|
|
|
+ if (open.size()>=3 && advertise.getState()==1){
|
|
|
|
|
+ resultjson.put("message", "小程序最多开启三个广告");
|
|
|
|
|
+ resultjson.put("code", 500);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
advertise.setCreateTime(TimeExchange.getTime());
|
|
advertise.setCreateTime(TimeExchange.getTime());
|
|
|
int m = advertiseService.insertAdvertise(advertise);
|
|
int m = advertiseService.insertAdvertise(advertise);
|
|
|
if (m > 0) {
|
|
if (m > 0) {
|
|
@@ -207,6 +215,14 @@ public class advertiseAction extends ActionSupport implements ServletRequestAwar
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+ List<Advertise> open = advertiseService.queryOpenAdvertise();
|
|
|
|
|
+ List<Integer> ids = open.stream().map(Advertise::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (open.size()>=3 && !ids.contains(advertise.getId()) && advertise.getState()==1){
|
|
|
|
|
+ resultjson.put("message", "小程序最多开启三个广告");
|
|
|
|
|
+ resultjson.put("code", 500);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
advertise.setCreateTime(TimeExchange.getTime());
|
|
advertise.setCreateTime(TimeExchange.getTime());
|
|
|
int m = advertiseService.updateAdvertise(advertise);
|
|
int m = advertiseService.updateAdvertise(advertise);
|
|
|
if (m > 0) {
|
|
if (m > 0) {
|
|
@@ -301,5 +317,21 @@ public class advertiseAction extends ActionSupport implements ServletRequestAwar
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String openList(){
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+ List<Advertise> list = advertiseService.queryOpenAdvertise();
|
|
|
|
|
+ if (list==null){
|
|
|
|
|
+ resultJson.put("message", "数据为空");
|
|
|
|
|
+ resultJson.put("code", 205);
|
|
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ resultJson.put("message", "返回成功");
|
|
|
|
|
+ resultJson.put("code", 200);
|
|
|
|
|
+ resultJson.put("data", list);
|
|
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
|
|
+ resultJson.toString());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|