|
|
@@ -34,6 +34,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -54,6 +55,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
@RequiredArgsConstructor
|
|
|
public class AdPlanConfController {
|
|
|
|
|
|
+ private final RedisTemplate<String, String> redisTemplate;
|
|
|
private final AdPlanConfService adPlanConfService;
|
|
|
private final AdPlanService adPlanService;
|
|
|
private final AdPlanDailyReportService adPlanDailyReportService;
|
|
|
@@ -70,6 +72,11 @@ public class AdPlanConfController {
|
|
|
if (adPlanConf == null) {
|
|
|
return Result.fail("广告计划配置不存在");
|
|
|
}
|
|
|
+ String lockKey = "ad_plan_conf_suspend_all_lock_" + confId;
|
|
|
+ Boolean isLocked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 1, TimeUnit.MINUTES);
|
|
|
+ if (!isLocked) {
|
|
|
+ return Result.fail("请勿重复操作");
|
|
|
+ }
|
|
|
adPlanConfService.gdtSuspendByConf(adPlanConf);
|
|
|
adPlanConfService.lambdaUpdate()
|
|
|
.eq(AdPlanConf::getId, confId)
|
|
|
@@ -87,6 +94,11 @@ public class AdPlanConfController {
|
|
|
if (adPlanConf == null) {
|
|
|
return Result.fail("广告计划配置不存在");
|
|
|
}
|
|
|
+ String lockKey = "ad_plan_conf_suspend_selected_lock_" + confId;
|
|
|
+ Boolean isLocked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 1, TimeUnit.MINUTES);
|
|
|
+ if (!isLocked) {
|
|
|
+ return Result.fail("请勿重复操作");
|
|
|
+ }
|
|
|
adPlanConfService.gdtSuspendByPlanIds(adPlanConf, planIds);
|
|
|
adPlanConfService.lambdaUpdate()
|
|
|
.eq(AdPlanConf::getId, confId)
|
|
|
@@ -101,6 +113,11 @@ public class AdPlanConfController {
|
|
|
if (adPlanConf == null) {
|
|
|
return Result.fail("广告计划配置不存在");
|
|
|
}
|
|
|
+ String lockKey = "ad_plan_conf_delete_all_lock_" + confId;
|
|
|
+ Boolean isLocked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 1, TimeUnit.MINUTES);
|
|
|
+ if (!isLocked) {
|
|
|
+ return Result.fail("请勿重复操作");
|
|
|
+ }
|
|
|
adPlanConfService.gdtDeleteByConf(adPlanConf);
|
|
|
adPlanConfService.lambdaUpdate()
|
|
|
.eq(AdPlanConf::getId, confId)
|
|
|
@@ -118,6 +135,11 @@ public class AdPlanConfController {
|
|
|
if (adPlanConf == null) {
|
|
|
return Result.fail("广告计划配置不存在");
|
|
|
}
|
|
|
+ String lockKey = "ad_plan_conf_delete_selected_lock_" + confId;
|
|
|
+ Boolean isLocked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 1, TimeUnit.MINUTES);
|
|
|
+ if (!isLocked) {
|
|
|
+ return Result.fail("请勿重复操作");
|
|
|
+ }
|
|
|
adPlanConfService.gdtDeleteByPlanIds(adPlanConf, planIds);
|
|
|
adPlanConfService.lambdaUpdate()
|
|
|
.eq(AdPlanConf::getId, confId)
|
|
|
@@ -298,6 +320,12 @@ public class AdPlanConfController {
|
|
|
|
|
|
@GetMapping("/syncSystemStatus/{id}")
|
|
|
public Result<Void> syncSystemStatus(@PathVariable Long id, @AuthUser SysUser sysUser) {
|
|
|
+ //redis锁 1分钟
|
|
|
+ String lockKey = "ad_plan_conf_sync_system_status_lock_" + id;
|
|
|
+ Boolean isLocked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 1, TimeUnit.MINUTES);
|
|
|
+ if (!isLocked) {
|
|
|
+ return Result.fail("请勿重复操作");
|
|
|
+ }
|
|
|
adPlanService.syncAdPlanStatus(id);
|
|
|
adPlanCreativeService.syncAdPlanCreativeStatus(id);
|
|
|
adPlanDailyReportService.syncDailyReport(id);
|