|
@@ -2,12 +2,16 @@ package com.zanxiang.game.module.manage.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.zanxiang.erp.security.annotation.PreAuthorize;
|
|
|
+import com.zanxiang.game.module.manage.pojo.enums.AccountTypeEnum;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.AgentAddParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.AgentListParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.AgentVO;
|
|
|
import com.zanxiang.game.module.manage.service.IAgentService;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.Agent;
|
|
|
+import com.zanxiang.module.util.exception.BaseException;
|
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -36,6 +40,25 @@ public class AgentController {
|
|
|
@PreAuthorize(permissionKey = "sdk:agent:add")
|
|
|
@PostMapping
|
|
|
public ResultVO<Boolean> add(AgentAddParam dto) {
|
|
|
+ dto.setAgentName(dto.getAgentName().trim());
|
|
|
+ AccountTypeEnum accountType = AccountTypeEnum.getByValue(dto.getAccountType());
|
|
|
+ if (accountType == null) {
|
|
|
+ throw new BaseException("错误的账号类型:" + dto.getAccountType());
|
|
|
+ }
|
|
|
+ if (accountType == AccountTypeEnum.TENCENT) {
|
|
|
+ if (dto.getUserActionSetId() == null) {
|
|
|
+ throw new BaseException("腾讯广告账号必须选回传的数据源");
|
|
|
+ }
|
|
|
+ } else if (accountType == AccountTypeEnum.BYTE) {
|
|
|
+ if (StringUtils.isBlank(dto.getReportToken()) || StringUtils.isBlank(dto.getReportUrl())) {
|
|
|
+ throw new BaseException("头条广告账号必须填入回传的 token 和 url");
|
|
|
+ }
|
|
|
+ dto.setReportToken(dto.getReportToken().trim());
|
|
|
+ dto.setReportUrl(dto.getReportUrl());
|
|
|
+ }
|
|
|
+ if (dto.getPutStatus() == null) {
|
|
|
+ dto.setPutStatus(Agent.PUT_STATUS_ING);
|
|
|
+ }
|
|
|
return ResultVO.ok(agentService.add(dto));
|
|
|
}
|
|
|
|