|
@@ -1,5 +1,6 @@
|
|
|
-package cn.com.ctop.kuaishou.modules.ai.controller;
|
|
|
+package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
|
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
import cn.com.ctop.common.module.utils.QueryGenerator;
|
|
@@ -13,7 +14,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.modules.system.service.ISysRoleService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -33,7 +37,8 @@ import java.util.*;
|
|
|
public class AiKuaishouAdvertiserStrategyController {
|
|
|
@Autowired
|
|
|
private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService sysRoleService;
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -51,6 +56,11 @@ public class AiKuaishouAdvertiserStrategyController {
|
|
|
HttpServletRequest req) {
|
|
|
Result<IPage<AiKuaishouAdvertiserStrategy>> result = new Result<>();
|
|
|
QueryWrapper<AiKuaishouAdvertiserStrategy> queryWrapper = QueryGenerator.initQueryWrapper(aiKuaishouAdvertiserStrategy, req.getParameterMap());
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
|
|
|
+ if(!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)){
|
|
|
+ queryWrapper.eq("user_id", user.getId());
|
|
|
+ }
|
|
|
Page<AiKuaishouAdvertiserStrategy> page = new Page<>(pageNo, pageSize);
|
|
|
queryWrapper.orderByDesc("id");
|
|
|
IPage<AiKuaishouAdvertiserStrategy> pageList = aiKuaishouAdvertiserStrategyService.page(page, queryWrapper);
|
|
@@ -86,6 +96,16 @@ public class AiKuaishouAdvertiserStrategyController {
|
|
|
public Result<AiKuaishouAdvertiserStrategy> add(@RequestBody AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy) {
|
|
|
Result<AiKuaishouAdvertiserStrategy> result = new Result<>();
|
|
|
try {
|
|
|
+ Long accountId = aiKuaishouAdvertiserStrategy.getAccountId();
|
|
|
+ AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(accountId);
|
|
|
+ if(null!=getEntity){
|
|
|
+ result.error500("该账户配置信息已经被创建");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ UserAllocation allocation = allocationService.getByAccountId(accountId);
|
|
|
+ if(null!=allocation){
|
|
|
+ aiKuaishouAdvertiserStrategy.setUserId(allocation.getUserId());
|
|
|
+ }
|
|
|
Integer singleAppId = aiKuaishouAdvertiserStrategy.getSingleAppid();
|
|
|
if (null != singleAppId && singleAppId == 1) {
|
|
|
Integer appId = Integer.parseInt(JSONArray.parseArray(aiKuaishouAdvertiserStrategy.getAppIdArray()).getString(0));
|