|
|
@@ -14,7 +14,6 @@ import com.moka.gdtauto.entity.AdPlan;
|
|
|
import com.moka.gdtauto.entity.AdPlanCreative;
|
|
|
import com.moka.gdtauto.service.SysUserService;
|
|
|
|
|
|
-
|
|
|
import com.moka.gdtauto.mapper.AccountGroupAccountRelationshipMapper;
|
|
|
import com.moka.gdtauto.service.AccountGroupService;
|
|
|
import com.moka.gdtauto.service.AdPlanConfService;
|
|
|
@@ -63,8 +62,8 @@ public class AdPlanConfController {
|
|
|
.eq(AccountGroupAccountRelationship::getGroupId, request.getAccountGroupId()));
|
|
|
|
|
|
List<AdPlan> plans = buildPlans(request, accountGroup, relationships);
|
|
|
-
|
|
|
- return Result.success(plans,"重新创建广告计划配置成功");
|
|
|
+
|
|
|
+ return Result.success(plans, "重新创建广告计划配置成功");
|
|
|
} catch (Exception e) {
|
|
|
log.error("重新创建广告计划配置失败", e);
|
|
|
return Result.fail("重新创建广告计划配置失败: " + e.getMessage());
|
|
|
@@ -79,11 +78,11 @@ public class AdPlanConfController {
|
|
|
String creativeFileNames = request.getCreativeFileNames();
|
|
|
String[] creativeUrlArray = creativeFileUrls.split(",");
|
|
|
String[] creativeNameArray = creativeFileNames != null ? creativeFileNames.split(",") : new String[0];
|
|
|
- List<AdPlan> plans = new ArrayList<>();
|
|
|
- int i = 0;
|
|
|
+ List<AdPlan> plans = new ArrayList<>();
|
|
|
+ int i = 0;
|
|
|
for (AccountGroupAccountRelationship relationship : relationships) {
|
|
|
Long accountId = relationship.getAccountId();
|
|
|
-
|
|
|
+
|
|
|
String targets = request.getTargets();
|
|
|
String sites = request.getSites();
|
|
|
|
|
|
@@ -110,9 +109,10 @@ public class AdPlanConfController {
|
|
|
adPlan.setAdCreatives(adPlanCreatives);
|
|
|
int j = 0;
|
|
|
for (String creativeUrl : creativeUrlArray) {
|
|
|
- String fileName = (j < creativeNameArray.length && creativeNameArray[j] != null && !creativeNameArray[j].isEmpty())
|
|
|
- ? creativeNameArray[j]
|
|
|
- : creativeUrl.substring(creativeUrl.lastIndexOf("/") + 1);
|
|
|
+ String fileName = (j < creativeNameArray.length && creativeNameArray[j] != null
|
|
|
+ && !creativeNameArray[j].isEmpty())
|
|
|
+ ? creativeNameArray[j]
|
|
|
+ : creativeUrl.substring(creativeUrl.lastIndexOf("/") + 1);
|
|
|
String creativeName = accountGroupName.trim() + "-" + dateTime + "-" + j + "-" + fileName;
|
|
|
AdPlanCreative adPlanCreative = new AdPlanCreative();
|
|
|
adPlanCreative.setCreativeFileUrl(creativeUrl);
|
|
|
@@ -137,36 +137,35 @@ public class AdPlanConfController {
|
|
|
public Result<AdPlanConf> generatePlan(
|
|
|
@RequestBody UpdateAdPlanConfRequest request,
|
|
|
@AuthUser SysUser sysUser) {
|
|
|
-
|
|
|
+
|
|
|
SysUser user = sysUserService.getById(sysUser.getId());
|
|
|
LocalDateTime userTokenExpiresAt = user.getUserTokenExpiresAt();
|
|
|
- if (userTokenExpiresAt == null || userTokenExpiresAt.isBefore(LocalDateTime.now())) {
|
|
|
+ if (userTokenExpiresAt == null || userTokenExpiresAt.isBefore(LocalDateTime.now())) {
|
|
|
return Result.fail("实名认证已过期");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
AccountGroup accountGroup = accountGroupService.getById(request.getAccountGroupId());
|
|
|
List<AccountGroupAccountRelationship> relationships = relationshipMapper.selectList(
|
|
|
new LambdaQueryWrapper<AccountGroupAccountRelationship>()
|
|
|
.eq(AccountGroupAccountRelationship::getGroupId, request.getAccountGroupId()));
|
|
|
- Long confId = request.getId();
|
|
|
+ Long confId = request.getId();
|
|
|
AdPlanConf adPlanConf = new AdPlanConf();
|
|
|
if (confId == null) {
|
|
|
BeanUtils.copyProperties(request, adPlanConf);
|
|
|
adPlanConf.setUserId(sysUser.getId());
|
|
|
adPlanConf.setJobNumber(sysUser.getJobNumber());
|
|
|
+ adPlanConf.setCreator(sysUser.getName());
|
|
|
confId = adPlanConfService.createAdPlanConf(adPlanConf);
|
|
|
} else {
|
|
|
BeanUtils.copyProperties(request, adPlanConf);
|
|
|
- adPlanConf.setUserId(sysUser.getId());
|
|
|
- adPlanConf.setJobNumber(sysUser.getJobNumber());
|
|
|
adPlanConfService.updateAdPlanConf(adPlanConf);
|
|
|
}
|
|
|
List<AdPlan> plans = buildPlans(request, accountGroup, relationships);
|
|
|
-
|
|
|
+
|
|
|
adPlanConfService.generatePlan(plans);
|
|
|
|
|
|
- //异步对接腾讯接口
|
|
|
+ // 异步对接腾讯接口
|
|
|
adPlanConfService.asyncTencentInterface(plans);
|
|
|
|
|
|
return Result.success(adPlanConf, "创建广告计划成功;异步执行接口对接中");
|
|
|
@@ -176,18 +175,16 @@ public class AdPlanConfController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@GetMapping("/reGeneratePlan/{id}")
|
|
|
public Result<Void> reGeneratePlan(@PathVariable Long id, @AuthUser SysUser sysUser) {
|
|
|
SysUser user = sysUserService.getById(sysUser.getId());
|
|
|
LocalDateTime userTokenExpiresAt = user.getUserTokenExpiresAt();
|
|
|
- if (userTokenExpiresAt == null || userTokenExpiresAt.isBefore(LocalDateTime.now())) {
|
|
|
+ if (userTokenExpiresAt == null || userTokenExpiresAt.isBefore(LocalDateTime.now())) {
|
|
|
return Result.fail("实名认证已过期");
|
|
|
}
|
|
|
adPlanConfService.asyncReGeneratePlan(id);
|
|
|
return Result.success("重新生成广告计划执行中");
|
|
|
}
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 创建广告计划配置
|
|
|
@@ -202,7 +199,8 @@ public class AdPlanConfController {
|
|
|
BeanUtils.copyProperties(request, adPlanConf);
|
|
|
adPlanConf.setUserId(sysUser.getId());
|
|
|
adPlanConf.setJobNumber(sysUser.getJobNumber());
|
|
|
-
|
|
|
+ adPlanConf.setCreator(sysUser.getName());
|
|
|
+
|
|
|
Long confId = adPlanConfService.createAdPlanConf(adPlanConf);
|
|
|
return Result.success(confId, "创建广告计划配置成功");
|
|
|
} catch (Exception e) {
|
|
|
@@ -222,9 +220,6 @@ public class AdPlanConfController {
|
|
|
try {
|
|
|
AdPlanConf adPlanConf = new AdPlanConf();
|
|
|
BeanUtils.copyProperties(request, adPlanConf);
|
|
|
- adPlanConf.setUserId(sysUser.getId());
|
|
|
- adPlanConf.setJobNumber(sysUser.getJobNumber());
|
|
|
-
|
|
|
boolean success = adPlanConfService.updateAdPlanConf(adPlanConf);
|
|
|
if (success) {
|
|
|
return Result.success("更新广告计划配置成功");
|
|
|
@@ -243,8 +238,7 @@ public class AdPlanConfController {
|
|
|
@Operation(summary = "删除广告计划配置", description = "删除指定的广告计划配置")
|
|
|
@DeleteMapping("/{confId}")
|
|
|
public Result<Void> deleteAdPlanConf(
|
|
|
- @Parameter(description = "配置ID", required = true)
|
|
|
- @PathVariable Long confId,
|
|
|
+ @Parameter(description = "配置ID", required = true) @PathVariable Long confId,
|
|
|
@AuthUser SysUser sysUser) {
|
|
|
try {
|
|
|
boolean success = adPlanConfService.deleteAdPlanConf(confId, sysUser.getId());
|
|
|
@@ -265,10 +259,8 @@ public class AdPlanConfController {
|
|
|
@Operation(summary = "获取广告计划配置列表", description = "分页获取当前用户的所有广告计划配置")
|
|
|
@GetMapping("/list")
|
|
|
public Result<Page<AdPlanConf>> getAdPlanConfs(
|
|
|
- @Parameter(description = "页码", example = "1")
|
|
|
- @RequestParam(defaultValue = "1") Integer pageNum,
|
|
|
- @Parameter(description = "每页大小", example = "10")
|
|
|
- @RequestParam(defaultValue = "10") Integer pageSize,
|
|
|
+ @Parameter(description = "页码", example = "1") @RequestParam(defaultValue = "1") Integer pageNum,
|
|
|
+ @Parameter(description = "每页大小", example = "10") @RequestParam(defaultValue = "10") Integer pageSize,
|
|
|
@AuthUser SysUser sysUser) {
|
|
|
try {
|
|
|
Page<AdPlanConf> page = adPlanConfService.getUserAdPlanConfs(
|
|
|
@@ -286,8 +278,7 @@ public class AdPlanConfController {
|
|
|
@Operation(summary = "获取广告计划配置详情", description = "根据ID获取广告计划配置详细信息")
|
|
|
@GetMapping("/{confId}")
|
|
|
public Result<AdPlanConf> getAdPlanConf(
|
|
|
- @Parameter(description = "配置ID", required = true)
|
|
|
- @PathVariable Long confId,
|
|
|
+ @Parameter(description = "配置ID", required = true) @PathVariable Long confId,
|
|
|
@AuthUser SysUser sysUser) {
|
|
|
try {
|
|
|
AdPlanConf adPlanConf = adPlanConfService.getAdPlanConfById(confId, sysUser.getId());
|