提交 896937a2 作者: 典文龙

修改权限校验

上级 c78a70c7
......@@ -3,7 +3,9 @@ package com.yaoyaozw.customer.dto;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: Dwl
......@@ -19,4 +21,23 @@ public class DistributeDTO {
private AuthInfoVO sourceAuth;
private List<AuthInfoVO> targetAuthList;
private List<String> typeList;
public List<String> getAccountId() {
if (!this.targetAuthList.isEmpty()) {
return targetAuthList.stream().map(AuthInfoVO::getAccountId).collect(Collectors.toList());
}
return null;
}
public List<AuthInfoVO> filterInfo(List<Long> channelIds) {
if (!this.targetAuthList.isEmpty()) {
return this.getTargetAuthList().stream().filter(item -> channelIds.contains(Long.valueOf(item.getAccountId()))).collect(Collectors.toList());
}
return new ArrayList<>();
}
public List<Long> getAuthIds() {
return this.getTargetAuthList().stream().map(AuthInfoVO::getId).collect(Collectors.toList());
}
}
package com.yaoyaozw.customer.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.Id;
import java.io.Serializable;
import java.util.Date;
/**
* @Author: Dwl
* @Date: 2024/05/30/11:14
* @ClassName: MaterialMenuConfigService
* @Version: V3.2.0
* @Description:
*/
@Data
@TableName("material_menu_config")
public class MaterialMenuConfig implements Serializable {
/**
*
*/
@Id
@TableId(value = "id", type = IdType.ID_WORKER)
private Long id;
/**
* 公众号id
*/
@TableField("auth_id")
private Long authId;
/**
* appId
*/
@TableField(exist = false)
private String appId;
/**
* 配置名称
*/
@TableField("config_name")
private String configName;
/**
* 0-文本 1-图片 2-图文
*/
@TableField("type")
private Integer type;
/**
* 推广标题
*/
@TableField("extend_title")
private String extendTitle;
/**
* 图片地址
*/
@TableField("img_url")
private String imgUrl;
/**
* 文本内容【文本类型存H5代码】
*/
@TableField("content")
private String content;
/**
* 图文链接地址
*/
@TableField("referral")
private String referral;
/**
* 图片在公众号后台的地址
*/
@TableField("media_id")
private String mediaId;
/**
* 启用状态 0-启用 1-禁用
*/
@TableField("status")
private Integer status;
/**
* 逻辑删除
*/
@TableField(value = "is_deleted", fill = FieldFill.INSERT)
@TableLogic
private Integer isDeleted;
/**
* 创建时间
*/
@TableField(value = "gmt_create", fill = FieldFill.INSERT)
private Date gmtCreate;
/**
* 创建人
*/
@TableField(value = "gmt_create_user", fill = FieldFill.INSERT)
private String gmtCreateUser;
/**
* 修改时间
*/
@TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;
/**
* 修改人
*/
@TableField(value = "gmt_modified_user", fill = FieldFill.INSERT_UPDATE)
private String gmtModifiedUser;
public String getContent() {
if (StringUtils.isBlank(this.content)) {
return null;
}
return content;
}
}
package com.yaoyaozw.customer.feigns;
import com.yaoyaozw.customer.annotations.AccountOperateControl;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.dto.MenuMainCopyDTO;
import com.yaoyaozw.customer.enums.AccountParamType;
import com.yaoyaozw.customer.enums.AccountTableColumnType;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
......@@ -19,4 +24,7 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface MenuFeignClient {
@PostMapping("/copy")
public BaseResult copy(@RequestBody @Validated MenuMainCopyDTO menuMainCopyDTO);
@GetMapping("/removeMenu")
@AccountOperateControl(paramType = AccountParamType.ACCOUNT_PRIMARY, paramName = "appId", columnType = AccountTableColumnType.APP_ID)
public BaseResult removeMenu(@RequestParam Long id, @RequestParam String appId);
}
......@@ -14,12 +14,4 @@ public interface AuthorizerTokenMapper extends BaseMapper<AuthorizerToken> {
AuthorizerToken findByAppid(@Param("appid") String appid);
List<AuthorizerToken> findByAppidIn(@Param("appidList") Set<String> appidList);
/**
* 查看权限等级
*
* @param userId
* @return
*/
Integer getUserRoleLevel(@Param("userId") Long userId);
}
package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.MaterialMenuConfig;
import org.springframework.stereotype.Repository;
/**
* @Author: Dwl
* @Date: 2024/05/30/11:16
* @ClassName: MaterialMenuConfigMapper
* @Version: V3.2.0
* @Description:
*/
@DS("material")
@Repository
public interface MaterialMenuConfigMapper extends BaseMapper<MaterialMenuConfig> {
}
package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.entity.MaterialMenuConfig;
import java.util.List;
/**
* @Author: Dwl
* @Date: 2024/05/30/11:14
* @ClassName: MaterialMenuConfigService
* @Version: V3.2.0
* @Description:
*/
public interface MaterialMenuConfigService extends IService<MaterialMenuConfig> {
/**
* 删除目标公众号配置
*
* @param authIds
*/
void removeById(List<Long> authIds);
}
......@@ -328,7 +328,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
List<AuthInfoVO> authList = super.baseMapper.getAuthList(keyword, keywordList, storeType, appId);
if (ObjectUtil.isNotNull(appId)) {
/*if (ObjectUtil.isNotNull(appId)) {
Long userId = tokenManager.getUserIdFromToken();
Integer userRoleLevel = authorizerTokenMapper.getUserRoleLevel(userId);
if (userRoleLevel <= 3) {
......@@ -341,7 +341,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
authList = authList.stream().filter(item -> appIdList.contains(item.getAppId())).collect(Collectors.toList());
}
}
}
}*/
Map<Object, Object> entries = redisTemplate.opsForHash().entries(STORE_NAME_REDIS_KEY);
if (CollectionUtil.isNotEmpty(entries)) {
Map<String, String> map = new HashMap<>(entries.size());
......
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
......@@ -14,20 +16,20 @@ import com.yaoyaozw.customer.dto.keyword.CustomerKeywordCopyDTO;
import com.yaoyaozw.customer.entity.AccountDistributeRecord;
import com.yaoyaozw.customer.feigns.MenuFeignClient;
import com.yaoyaozw.customer.mapper.AccountDistributeLogMapper;
import com.yaoyaozw.customer.service.CustomerFollowReplyService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.service.CustomerKeywordService;
import com.yaoyaozw.customer.service.DistributeService;
import com.yaoyaozw.customer.mapper.AuthorizerTokenMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.*;
import com.yaoyaozw.customer.vo.AccountDistributeLogVO;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.kanban.AccountSetupVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Author: Dwl
......@@ -53,6 +55,12 @@ public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMappe
@Autowired
private TokenManager tokenManager;
@Autowired
private AuthorizerTokenMapper authorizerTokenMapper;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private MaterialMenuConfigService materialMenuConfigService;
@Override
......@@ -61,8 +69,33 @@ public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMappe
List<AccountDistributeRecord> distributeLogList = new ArrayList<>();
log.info("开始执行复用任务....");
AuthInfoVO sourceAuth = distributeDTO.getSourceAuth();
List<Long> channelIds = new ArrayList<>();
List<String> nickNameList = new ArrayList<>();
if (ObjectUtil.isNotNull(sourceAuth.getAppId())) {
List<AccountSetupVO> accountSetupVOList = kanbanCommonMapper.getRole(userId, distributeDTO.getAccountId());
if (accountSetupVOList.isEmpty()) {
return new BaseResult().error("暂无权限");
}
channelIds = accountSetupVOList.stream().map(AccountSetupVO::getChannelId).collect(Collectors.toList());
nickNameList = accountSetupVOList.stream().map(AccountSetupVO::getNickName).collect(Collectors.toList());
}
myExecutorDistribute(channelIds, distributeDTO, userId, distributeLogList, sourceAuth);
return new BaseResult().success(JSONUtil.toJsonStr(nickNameList) + ":复用进行中, 请等待");
}
@Async("myExecutor")
public void myExecutorDistribute(List<Long> channelIds, DistributeDTO distributeDTO, Long userId, List<AccountDistributeRecord> distributeLogList, AuthInfoVO sourceAuth) {
List<String> targetAppList = distributeDTO.getTargetAppList();
List<AuthInfoVO> targetAuthList = distributeDTO.getTargetAuthList();
//获取到当天再投的进行复用
List<AuthInfoVO> targetAuthList = distributeDTO.filterInfo(channelIds);
for (AuthInfoVO authInfoVO : targetAuthList) {
menuFeignClient.removeMenu(authInfoVO.getId(), authInfoVO.getAppId());
}
//删除目标公众号配置
List<Long> authIds = distributeDTO.getAuthIds();
materialMenuConfigService.removeById(authIds);
List<String> targetApp = targetAuthList.stream().map(AuthInfoVO::getAppId).collect(Collectors.toList());
List<Long> idList = targetAuthList.stream().map(AuthInfoVO::getId).collect(Collectors.toList());
List<String> typeList = distributeDTO.getTypeList();
......@@ -103,15 +136,13 @@ public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMappe
log.error("Distribution reuse exception:{}", e.getMessage(), e);
}
idList.forEach(c -> {
AccountDistributeRecord distributeLog = new AccountDistributeRecord();
distributeLog.saveDistribute(sourceAuth.getId(), c, typeList, userId);
distributeLogList.add(distributeLog);
});
this.saveBatch(distributeLogList);
return new BaseResult().success("复用进行中, 请等待");
super.saveBatch(distributeLogList);
}
@Override
......
package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.MaterialMenuConfig;
import com.yaoyaozw.customer.mapper.MaterialMenuConfigMapper;
import com.yaoyaozw.customer.service.MaterialMenuConfigService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: Dwl
* @Date: 2024/05/30/11:14
* @ClassName: MaterialMenuConfigServiceImpl
* @Version: V3.2.0
* @Description:
*/
@Service
public class MaterialMenuConfigServiceImpl extends ServiceImpl<MaterialMenuConfigMapper, MaterialMenuConfig> implements MaterialMenuConfigService {
@Override
public void removeById(List<Long> authIds) {
this.baseMapper.deleteBatchIds(authIds);
}
}
......@@ -11,7 +11,8 @@ import lombok.Data;
*/
@Data
public class AccountSetupVO {
private Long id;
private String appId;
private Long accountId;
private Long channelId;
private String nickName;
}
......@@ -30,12 +30,4 @@
</foreach>
</select>
<select id="getUserRoleLevel" resultType="java.lang.Integer">
select max(role.role_level)
from acl_user_role aur
left join acl_role role
on aur.role_id = role.id
where aur.user_id = #{userId}
</select>
</mapper>
......@@ -59,15 +59,20 @@
where is_deleted = 0 and pct_type = 'PROFIT_PCT'
</select>
<select id="getRole" resultType="com.yaoyaozw.customer.vo.kanban.AccountSetupVO">
SELECT ae.nick_name,
SELECT
ae.id,
ae.app_id,
acs.account_id,
acs.sales_user
FROM account_entity ae
LEFT JOIN account_cost_setup acs ON acs.account_id = ae.id
WHERE acs.cost_date = CURRENT_DATE
ae.nick_name,
ae.channel_id
FROM
account_entity ae
LEFT JOIN account_cost_setup acs on acs.account_id=ae.id
WHERE
acs.is_deleted=0
AND ae.is_deleted=0
AND acs.cost_date = CURRENT_DATE
AND acs.sales_user = #{userId}
AND acs.app_id in
AND ae.channel_id IN
<foreach collection="appIds" item="appId" open="(" close=")" separator=",">
#{appId}
</foreach>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论