|
@@ -44,31 +44,33 @@ public class ADIndexController {
|
|
|
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 根据广告id获取广告
|
|
|
*/
|
|
|
@GetMapping(value = "/getAdById.htm", produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public String getAdById(String id) {
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
// return JsonMessage.error("id为null");
|
|
|
return "id为null";
|
|
|
}
|
|
|
TAd ad = aDService.getById(id);
|
|
|
ArrayList<AdVo> list = new ArrayList<>();
|
|
|
- AdVo adVo = new AdVo();
|
|
|
- adVo.setAdType(String.valueOf(ad.getAdType()));
|
|
|
- adVo.setLocationType(String.valueOf(ad.getLocationType()));
|
|
|
- adVo.setName(ad.getName());
|
|
|
- adVo.setOrder(ad.getOrders());
|
|
|
- adVo.setUrl(ad.getUrl());
|
|
|
- adVo.setEquipmentType(ad.getEquipmentType());
|
|
|
- adVo.setCreateDate(ad.getCreateDate());
|
|
|
- adVo.setId(ad.getId());
|
|
|
- adVo.setMediaPreview(ad.getMediaPreview());
|
|
|
- adVo.setDuration(ad.getDuration());
|
|
|
- adVo.setScreenType(ad.getScreenType());
|
|
|
- list.add(adVo);
|
|
|
+ AdVo adVo = new AdVo();
|
|
|
+ adVo.setAdType(String.valueOf(ad.getAdType()));
|
|
|
+ adVo.setLocationType(String.valueOf(ad.getLocationType()));
|
|
|
+ adVo.setName(ad.getName());
|
|
|
+ adVo.setOrder(ad.getOrders());
|
|
|
+ adVo.setUrl(ad.getUrl());
|
|
|
+ adVo.setEquipmentType(ad.getEquipmentType());
|
|
|
+ adVo.setCreateDate(ad.getCreateDate());
|
|
|
+ adVo.setId(ad.getId());
|
|
|
+ adVo.setMediaPreview(ad.getMediaPreview());
|
|
|
+ adVo.setDuration(ad.getDuration());
|
|
|
+ adVo.setScreenType(ad.getScreenType());
|
|
|
+ adVo.setPlayTimeStatus(ad.getPlayTimeStatus());
|
|
|
+ list.add(adVo);
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("code", 0);
|
|
@@ -82,20 +84,20 @@ public class ADIndexController {
|
|
|
*/
|
|
|
@GetMapping(value = "/getAd.htm", produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public String getAdNew(String clientId,String equimentType) {
|
|
|
+ public String getAdNew(String clientId, String equimentType) {
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TEquipment::getClientId,clientId);
|
|
|
+ query.eq(TEquipment::getClientId, clientId);
|
|
|
List<TEquipment> equipmentList = equipmentService.list(query);
|
|
|
TEquipment equipment = equipmentList.get(0);
|
|
|
String adminId = String.valueOf(equipment.getAdminId());
|
|
|
//1,获取
|
|
|
LambdaQueryWrapper<TAd> query1 = Wrappers.lambdaQuery();
|
|
|
- query1.eq(TAd::getType,"0");
|
|
|
- query1.eq(TAd::getEquipmentType,equimentType);
|
|
|
+ query1.eq(TAd::getType, "0");
|
|
|
+ query1.eq(TAd::getEquipmentType, equimentType);
|
|
|
List<TAd> ads = aDService.list(query1);
|
|
|
ArrayList<AdVo> list = new ArrayList<>();
|
|
|
for (TAd ad : ads) {
|
|
|
- if(adminId.equals(ad.getAdminId())||ad.getAdminId()==null){
|
|
|
+ if (adminId.equals(ad.getAdminId()) || ad.getAdminId() == null) {
|
|
|
AdVo adVo = new AdVo();
|
|
|
adVo.setAdType(String.valueOf(ad.getAdType()));
|
|
|
adVo.setLocationType(String.valueOf(ad.getLocationType()));
|
|
@@ -107,6 +109,7 @@ public class ADIndexController {
|
|
|
adVo.setMediaPreview(ad.getMediaPreview());
|
|
|
adVo.setDuration(ad.getDuration());
|
|
|
adVo.setScreenType(ad.getScreenType());
|
|
|
+ adVo.setPlayTimeStatus(ad.getPlayTimeStatus());
|
|
|
list.add(adVo);
|
|
|
}
|
|
|
|
|
@@ -117,38 +120,40 @@ public class ADIndexController {
|
|
|
jsonObject.put("errmsg", "");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设备获取广告
|
|
|
*/
|
|
|
@GetMapping(value = "/getAdByEquipment.htm", produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public String getAdByEquipment(String clientId,String equimentType) {
|
|
|
+ public String getAdByEquipment(String clientId, String equimentType) {
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TEquipment::getClientId,clientId);
|
|
|
+ query.eq(TEquipment::getClientId, clientId);
|
|
|
List<TEquipment> equipmentList = equipmentService.list(query);
|
|
|
TEquipment equipment = equipmentList.get(0);
|
|
|
String adminId = String.valueOf(equipment.getAdminId());
|
|
|
//1,获取
|
|
|
LambdaQueryWrapper<TAd> query1 = Wrappers.lambdaQuery();
|
|
|
- query1.eq(TAd::getType,"0");
|
|
|
- query1.eq(TAd::getEquipmentType,equimentType);
|
|
|
- query1.eq(TAd::getAdminId,adminId);
|
|
|
+ query1.eq(TAd::getType, "0");
|
|
|
+ query1.eq(TAd::getEquipmentType, equimentType);
|
|
|
+ query1.eq(TAd::getAdminId, adminId);
|
|
|
List<TAd> ads = aDService.list(query1);
|
|
|
ArrayList<AdVo> list = new ArrayList<>();
|
|
|
for (TAd ad : ads) {
|
|
|
- if(adminId.equals(ad.getAdminId())||ad.getAdminId()==null){
|
|
|
- AdVo adVo = new AdVo();
|
|
|
- adVo.setAdType(String.valueOf(ad.getAdType()));
|
|
|
- adVo.setLocationType(String.valueOf(ad.getLocationType()));
|
|
|
- adVo.setName(ad.getName());
|
|
|
- adVo.setOrder(ad.getOrders());
|
|
|
- adVo.setUrl(ad.getUrl());
|
|
|
- adVo.setCreateDate(ad.getCreateDate());
|
|
|
- adVo.setId(ad.getId());
|
|
|
- adVo.setMediaPreview(ad.getMediaPreview());
|
|
|
- adVo.setDuration(ad.getDuration());
|
|
|
- adVo.setScreenType(ad.getScreenType());
|
|
|
- list.add(adVo);
|
|
|
+ if (adminId.equals(ad.getAdminId()) || ad.getAdminId() == null) {
|
|
|
+ AdVo adVo = new AdVo();
|
|
|
+ adVo.setAdType(String.valueOf(ad.getAdType()));
|
|
|
+ adVo.setLocationType(String.valueOf(ad.getLocationType()));
|
|
|
+ adVo.setName(ad.getName());
|
|
|
+ adVo.setOrder(ad.getOrders());
|
|
|
+ adVo.setUrl(ad.getUrl());
|
|
|
+ adVo.setCreateDate(ad.getCreateDate());
|
|
|
+ adVo.setId(ad.getId());
|
|
|
+ adVo.setMediaPreview(ad.getMediaPreview());
|
|
|
+ adVo.setDuration(ad.getDuration());
|
|
|
+ adVo.setScreenType(ad.getScreenType());
|
|
|
+ adVo.setPlayTimeStatus(ad.getPlayTimeStatus());
|
|
|
+ list.add(adVo);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -158,6 +163,7 @@ public class ADIndexController {
|
|
|
jsonObject.put("errmsg", "");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取时间规则
|
|
|
*
|
|
@@ -172,22 +178,23 @@ public class ADIndexController {
|
|
|
// return JsonMessage.error("该规则不存在");
|
|
|
return "该规则不存在";
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(timeRule.getType())||timeRule.getType().equals("0")){
|
|
|
+ if (StringUtils.isEmpty(timeRule.getType()) || timeRule.getType().equals("0")) {
|
|
|
//旧规则
|
|
|
String rule = null;
|
|
|
List<TimeRuleVo> timeRuleVos = JSON.parseArray(timeRule.getRule(), TimeRuleVo.class);
|
|
|
- for(TimeRuleVo timeRuleVo:timeRuleVos){
|
|
|
+ for (TimeRuleVo timeRuleVo : timeRuleVos) {
|
|
|
List<String> ads = timeRuleVo.getAd();
|
|
|
rule = ads.toString();
|
|
|
break;
|
|
|
}
|
|
|
return rule;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//新规则
|
|
|
String rule = timeRule.getRule();
|
|
|
return rule;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取时间规则 ByClientId
|
|
|
*
|
|
@@ -197,40 +204,41 @@ public class ADIndexController {
|
|
|
@GetMapping(value = "/getTimeRuleByClientId.htm", produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public String getTimeRuleByClientId(String clientId) {
|
|
|
- if(StringUtils.isEmpty(clientId)){
|
|
|
+ if (StringUtils.isEmpty(clientId)) {
|
|
|
return "编号为空";
|
|
|
}
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TEquipment::getClientId,clientId);
|
|
|
+ query.eq(TEquipment::getClientId, clientId);
|
|
|
List<TEquipment> equipmentList = equipmentService.list(query);
|
|
|
- if(equipmentList.size()>0){
|
|
|
+ if (equipmentList.size() > 0) {
|
|
|
TEquipment equipment = equipmentList.get(0);
|
|
|
- if(equipment.getTimeRuleId()!=null){
|
|
|
+ if (equipment.getTimeRuleId() != null) {
|
|
|
TTimeRule timeRule = timeRuleService.getById(equipment.getTimeRuleId());
|
|
|
if (timeRule == null) {
|
|
|
// return JsonMessage.error("该规则不存在");
|
|
|
return "该规则不存在";
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(timeRule.getType())||timeRule.getType().equals("0")){
|
|
|
+ if (StringUtils.isEmpty(timeRule.getType()) || timeRule.getType().equals("0")) {
|
|
|
//旧规则
|
|
|
String rule = null;
|
|
|
List<TimeRuleVo> timeRuleVos = JSON.parseArray(timeRule.getRule(), TimeRuleVo.class);
|
|
|
- for(TimeRuleVo timeRuleVo:timeRuleVos){
|
|
|
+ for (TimeRuleVo timeRuleVo : timeRuleVos) {
|
|
|
List<String> ads = timeRuleVo.getAd();
|
|
|
rule = ads.toString();
|
|
|
break;
|
|
|
}
|
|
|
return rule;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//新规则
|
|
|
String rule = timeRule.getRule();
|
|
|
return rule;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
return "该规则不存在";
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设备下载广告失败则更新设备的推送广告时间
|
|
|
*
|
|
@@ -240,7 +248,7 @@ public class ADIndexController {
|
|
|
@ResponseBody
|
|
|
public String updatePushTimeUpdate(String clientId, String pushUpdateTime) {
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TEquipment::getClientId,clientId);
|
|
|
+ query.eq(TEquipment::getClientId, clientId);
|
|
|
List<TEquipment> equipmentList = equipmentService.list(query);
|
|
|
TEquipment equipment = equipmentList.get(0);
|
|
|
if (equipment == null) {
|
|
@@ -261,9 +269,8 @@ public class ADIndexController {
|
|
|
// return JsonMessage.success("修改成功");
|
|
|
return "修改成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
- *
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
@@ -273,15 +280,14 @@ public class ADIndexController {
|
|
|
Boolean hasKey = redisTemplate.hasKey(str);
|
|
|
return JsonMessage.success(hasKey);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
- *
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping(value = "/checkRedis2.htm", produces = "application/json;charset=UTF-8")
|
|
|
@ResponseBody
|
|
|
- public JsonMessage checkRedis2(String key,String hashkey) {
|
|
|
+ public JsonMessage checkRedis2(String key, String hashkey) {
|
|
|
Object o = redisTemplate.boundHashOps(key).get(hashkey);
|
|
|
return JsonMessage.success(o);
|
|
|
}
|