提交 1d76bfbd 作者: 典文龙

修改权限校验

上级 5f656c63
...@@ -40,4 +40,8 @@ public class DistributeDTO { ...@@ -40,4 +40,8 @@ public class DistributeDTO {
public List<Long> getAuthIds() { public List<Long> getAuthIds() {
return this.getTargetAuthList().stream().map(AuthInfoVO::getId).collect(Collectors.toList()); return this.getTargetAuthList().stream().map(AuthInfoVO::getId).collect(Collectors.toList());
} }
public Integer getTargetAuthListSize() {
return this.targetAuthList.size();
}
} }
...@@ -5,7 +5,7 @@ import lombok.Data; ...@@ -5,7 +5,7 @@ import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
...@@ -36,8 +36,7 @@ public class MenuMainCopyDTO implements Serializable { ...@@ -36,8 +36,7 @@ public class MenuMainCopyDTO implements Serializable {
this.authId = authId; this.authId = authId;
this.openImmediately = 1; this.openImmediately = 1;
this.targetAuthList = targetAuthList; this.targetAuthList = targetAuthList;
this.sourceMenuSortList = Collections.singletonList(1); this.sourceMenuSortList = Arrays.asList(1, 2, 3);
} }
} }
package com.yaoyaozw.customer.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.springframework.data.annotation.Id;
import java.io.Serializable;
import java.util.Date;
/**
* @author darker
* @date 2022/11/10 15:48
*/
@Data
@TableName("material_menu_main")
public class MaterialMenuMain implements Serializable {
/**
* 主键
*/
@TableId(value = "id", type = IdType.ID_WORKER)
@Id
private Long id;
/**
* 公众号id
*/
@TableField("auth_id")
private Long authId;
/**
* 公众号appId
*/
@TableField("app_id")
private String appId;
/**
* 上级菜单id
*/
@TableField("pid")
private Long pid;
/**
* 手机系统 1-安卓 2-ios
*/
@TableField("mobile_os")
private Integer mobileOs;
/**
* 菜单标识
*/
@TableField("menu_key")
private String menuKey;
/**
* 菜单标识
*/
@TableField("wechat_menu_id")
private String wechatMenuId;
/**
* 菜单名称
*/
@TableField("name")
private String name;
/**
* 菜单点击类型(跳转\弹出)
*/
@TableField("click_type")
private Integer clickType;
/**
* 跳转链接类型 0-自定义 1-常用链接
*/
@TableField("url_type")
private Integer urlType;
/**
* 跳转值(书城常用链接的取值)
*/
@TableField("skip_value")
private String skipValue;
/**
* 跳转地址
*/
@TableField("skip_url")
private String skipUrl;
/**
* 资源配置主键id
*/
@TableField("config_id")
private String configId;
/**
* 状态
*/
@TableField("status")
private Integer status;
/**
* 菜单等级
*/
@TableField("level")
private Integer level;
/**
* 菜单排序
*/
@TableField("sort")
private Integer sort;
/**
* 备注
*/
@TableField("remarks")
private String remarks;
/**
* 创建时间
*/
@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 void clearDictConfig() {
this.clickType = null;
this.urlType = null;
this.skipValue = null;
this.skipUrl = null;
this.configId = null;
}
}
...@@ -63,5 +63,5 @@ public interface KanbanCommonMapper { ...@@ -63,5 +63,5 @@ public interface KanbanCommonMapper {
*/ */
List<AuthInfoVO> getAllStoreList(); List<AuthInfoVO> getAllStoreList();
List<AccountSetupVO> getRole(@Param("userId") Long userId, @Param("appIds") List<String> appIds); List<AccountSetupVO> getRole(@Param("userId") Long userId, @Param("accountIds") List<String> accountIds);
} }
package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.MaterialMenuMain;
import org.springframework.stereotype.Repository;
/**
* @Author: Dwl
* @Date: 2024/05/31/22:34
* @ClassName: MaterialMenuMainVoMapper
* @Version: V3.2.0
* @Description:
*/
@DS("material")
@Repository
public interface MaterialMenuMainVoMapper extends BaseMapper<MaterialMenuMain> {
}
package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.entity.MaterialMenuMain;
import java.util.List;
/**
* @Author: Dwl
* @Date: 2024/05/31/22:31
* @ClassName: MaterialMenuMainService
* @Version: V3.2.0
* @Description:
*/
public interface MaterialMenuMainService extends IService<MaterialMenuMain> {
List<MaterialMenuMain> getMaterialMenuMainVoInfo(List<String> appIds);
}
package com.yaoyaozw.customer.service;
import com.yaoyaozw.customer.dto.DistributeDTO;
import com.yaoyaozw.customer.entity.AccountDistributeRecord;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import org.springframework.scheduling.annotation.Async;
import java.util.List;
/**
* @Author: Dwl
* @Date: 2024/05/31/22:45
* @ClassName: MyExecutorDistributeService
* @Version: V3.2.0
* @Description:
*/
public interface MyExecutorDistributeService {
@Async("myExecutor")
void myExecutorDistribute(DistributeDTO distributeDTO, Long userId, List<AccountDistributeRecord> distributeLogList, AuthInfoVO sourceAuth);
}
package com.yaoyaozw.customer.service.impl; package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -10,13 +9,8 @@ import com.yaoyaozw.customer.common.GenericsResult; ...@@ -10,13 +9,8 @@ import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.components.TokenManager; import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.dto.ConditionDTO; import com.yaoyaozw.customer.dto.ConditionDTO;
import com.yaoyaozw.customer.dto.DistributeDTO; import com.yaoyaozw.customer.dto.DistributeDTO;
import com.yaoyaozw.customer.dto.MenuMainCopyDTO;
import com.yaoyaozw.customer.dto.follow.FollowReplyCopyDTO;
import com.yaoyaozw.customer.dto.keyword.CustomerKeywordCopyDTO;
import com.yaoyaozw.customer.entity.AccountDistributeRecord; import com.yaoyaozw.customer.entity.AccountDistributeRecord;
import com.yaoyaozw.customer.feigns.MenuFeignClient;
import com.yaoyaozw.customer.mapper.AccountDistributeLogMapper; import com.yaoyaozw.customer.mapper.AccountDistributeLogMapper;
import com.yaoyaozw.customer.mapper.AuthorizerTokenMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper; import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.*; import com.yaoyaozw.customer.service.*;
import com.yaoyaozw.customer.vo.AccountDistributeLogVO; import com.yaoyaozw.customer.vo.AccountDistributeLogVO;
...@@ -24,12 +18,10 @@ import com.yaoyaozw.customer.vo.AuthInfoVO; ...@@ -24,12 +18,10 @@ import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.kanban.AccountSetupVO; import com.yaoyaozw.customer.vo.kanban.AccountSetupVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Author: Dwl * @Author: Dwl
...@@ -42,25 +34,11 @@ import java.util.stream.Collectors; ...@@ -42,25 +34,11 @@ import java.util.stream.Collectors;
@Service @Service
public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMapper, AccountDistributeRecord> implements DistributeService { public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMapper, AccountDistributeRecord> implements DistributeService {
@Autowired @Autowired
private CustomerGraphicsDelayService customerGraphicsDelayService;
@Autowired
private CustomerKeywordService keywordService;
@Autowired
private CustomerFollowReplyService followReplyService;
@Autowired
private MenuFeignClient menuFeignClient;
@Autowired
private TokenManager tokenManager; private TokenManager tokenManager;
@Autowired @Autowired
private AuthorizerTokenMapper authorizerTokenMapper;
@Autowired
private KanbanCommonMapper kanbanCommonMapper; private KanbanCommonMapper kanbanCommonMapper;
@Autowired @Autowired
private MaterialMenuConfigService materialMenuConfigService; private MyExecutorDistributeService myExecutorDistributeService;
@Override @Override
...@@ -69,105 +47,17 @@ public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMappe ...@@ -69,105 +47,17 @@ public class DistributeServiceImpl extends ServiceImpl<AccountDistributeLogMappe
List<AccountDistributeRecord> distributeLogList = new ArrayList<>(); List<AccountDistributeRecord> distributeLogList = new ArrayList<>();
log.info("开始执行复用任务...."); log.info("开始执行复用任务....");
AuthInfoVO sourceAuth = distributeDTO.getSourceAuth(); AuthInfoVO sourceAuth = distributeDTO.getSourceAuth();
List<Long> channelIds = new ArrayList<>(); Integer targetAuthListSize = distributeDTO.getTargetAuthListSize();
List<String> nickNameList = new ArrayList<>();
if (ObjectUtil.isNotNull(sourceAuth.getAppId())) { if (ObjectUtil.isNotNull(sourceAuth.getAppId())) {
List<AccountSetupVO> accountSetupVOList = kanbanCommonMapper.getRole(userId, distributeDTO.getAccountId()); List<AccountSetupVO> accountSetupVOList = kanbanCommonMapper.getRole(userId, distributeDTO.getAccountId());
if (accountSetupVOList.isEmpty()) { int size = accountSetupVOList.size();
if (targetAuthListSize != size) {
return new BaseResult().error("暂无权限"); 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); myExecutorDistributeService.myExecutorDistribute(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.filterInfo(channelIds);
try {
if (!targetAppList.isEmpty()) {
for (AuthInfoVO authInfoVO : targetAuthList) {
menuFeignClient.removeMenu(authInfoVO.getId(), authInfoVO.getAppId());
}
}
} catch (Exception e) {
log.error("Failed to delete menu configuration: {}", e.getMessage(), e);
}
//删除目标公众号配置
try {
List<Long> authIds = distributeDTO.getAuthIds();
materialMenuConfigService.removeById(authIds);
} catch (Exception e) {
log.error("Failed to delete the target public account configuration :{}", e.getMessage(), e);
}
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();
try {
for (String type : typeList) {
switch (type) {
case "1":
//关回复用
try {
FollowReplyCopyDTO followReplyCopyDTO = new FollowReplyCopyDTO(sourceAuth, targetAuthList);
followReplyService.copy(followReplyCopyDTO);
} catch (Exception e) {
log.error("Off reply failed: {}", e.getMessage(), e);
}
break;
case "2":
//关键词复用
try {
CustomerKeywordCopyDTO customerKeywordCopyDTO = new CustomerKeywordCopyDTO();
customerKeywordCopyDTO.replace(sourceAuth, targetAuthList, targetAppList);
keywordService.copy(customerKeywordCopyDTO);
} catch (Exception e) {
log.error("Keyword reuse failure: {}", e.getMessage(), e);
}
break;
case "3":
//延时客服复用
try {
customerGraphicsDelayService.copy(sourceAuth.getAppId(), "", "", null, targetApp);
} catch (Exception e) {
log.error("Delayed customer service reuse failure: {}", e.getMessage(), e);
}
break;
case "4":
//菜单管理复用
try {
MenuMainCopyDTO menuMainCopyDTO = new MenuMainCopyDTO();
menuMainCopyDTO.addList(sourceAuth.getId(), idList);
menuFeignClient.copy(menuMainCopyDTO);
} catch (Exception e) {
log.error("Menu management reuse failure: {}", e.getMessage(), e);
}
break;
default:
break;
}
}
} catch (Exception e) {
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);
});
super.saveBatch(distributeLogList); return new BaseResult().success("复用进行中, 请等待");
} }
@Override @Override
......
package com.yaoyaozw.customer.service.impl; package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.MaterialMenuConfig; import com.yaoyaozw.customer.entity.MaterialMenuConfig;
import com.yaoyaozw.customer.mapper.MaterialMenuConfigMapper; import com.yaoyaozw.customer.mapper.MaterialMenuConfigMapper;
...@@ -19,6 +20,7 @@ import java.util.List; ...@@ -19,6 +20,7 @@ import java.util.List;
public class MaterialMenuConfigServiceImpl extends ServiceImpl<MaterialMenuConfigMapper, MaterialMenuConfig> implements MaterialMenuConfigService { public class MaterialMenuConfigServiceImpl extends ServiceImpl<MaterialMenuConfigMapper, MaterialMenuConfig> implements MaterialMenuConfigService {
@Override @Override
public void removeById(List<Long> authIds) { public void removeById(List<Long> authIds) {
this.baseMapper.deleteBatchIds(authIds); LambdaQueryWrapper<MaterialMenuConfig> queryWrapper = new LambdaQueryWrapper<MaterialMenuConfig>().in(MaterialMenuConfig::getAuthId, authIds);
this.baseMapper.delete(queryWrapper);
} }
} }
package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.MaterialMenuMain;
import com.yaoyaozw.customer.mapper.MaterialMenuMainVoMapper;
import com.yaoyaozw.customer.service.MaterialMenuMainService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: Dwl
* @Date: 2024/05/31/22:31
* @ClassName: MaterialMenuMainServiceImpl
* @Version: V3.2.0
* @Description:
*/
@Service
public class MaterialMenuMainServiceImpl extends ServiceImpl<MaterialMenuMainVoMapper, MaterialMenuMain> implements MaterialMenuMainService {
@Override
public List<MaterialMenuMain> getMaterialMenuMainVoInfo(List<String> appIds) {
LambdaQueryWrapper<MaterialMenuMain> queryWrapper = new LambdaQueryWrapper<MaterialMenuMain>().in(MaterialMenuMain::getAppId, appIds);
return this.baseMapper.selectList(queryWrapper);
}
}
package com.yaoyaozw.customer.service.impl;
import com.yaoyaozw.customer.dto.DistributeDTO;
import com.yaoyaozw.customer.dto.MenuMainCopyDTO;
import com.yaoyaozw.customer.dto.follow.FollowReplyCopyDTO;
import com.yaoyaozw.customer.dto.keyword.CustomerKeywordCopyDTO;
import com.yaoyaozw.customer.entity.AccountDistributeRecord;
import com.yaoyaozw.customer.entity.MaterialMenuMain;
import com.yaoyaozw.customer.feigns.MenuFeignClient;
import com.yaoyaozw.customer.service.*;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: Dwl
* @Date: 2024/05/31/22:45
* @ClassName: MyExecutorDistributeServiceImpl
* @Version: V3.2.0
* @Description:
*/
@Slf4j
@Service
public class MyExecutorDistributeServiceImpl implements MyExecutorDistributeService {
@Autowired
private CustomerGraphicsDelayService customerGraphicsDelayService;
@Autowired
private CustomerKeywordService keywordService;
@Autowired
private CustomerFollowReplyService followReplyService;
@Autowired
private MenuFeignClient menuFeignClient;
@Autowired
private MaterialMenuConfigService materialMenuConfigService;
@Autowired
private MaterialMenuMainService materialMenuMainService;
@Autowired
private DistributeService distributeService;
@Override
public void myExecutorDistribute(DistributeDTO distributeDTO, Long userId, List<AccountDistributeRecord> distributeLogList, AuthInfoVO sourceAuth) {
List<String> targetAppList = distributeDTO.getTargetAppList();
//获取到当天再投的进行复用
List<AuthInfoVO> targetAuthList = distributeDTO.getTargetAuthList();
//删除目标公众号配置
try {
List<Long> authIds = distributeDTO.getAuthIds();
materialMenuConfigService.removeById(authIds);
} catch (Exception e) {
log.error("Failed to delete the target public account configuration :{}", e.getMessage(), e);
}
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();
try {
for (String type : typeList) {
switch (type) {
case "1":
//关回复用
try {
FollowReplyCopyDTO followReplyCopyDTO = new FollowReplyCopyDTO(sourceAuth, targetAuthList);
followReplyService.copy(followReplyCopyDTO);
} catch (Exception e) {
log.error("Off reply failed: {}", e.getMessage(), e);
}
break;
case "2":
//关键词复用
try {
CustomerKeywordCopyDTO customerKeywordCopyDTO = new CustomerKeywordCopyDTO();
customerKeywordCopyDTO.replace(sourceAuth, targetAuthList, targetAppList);
keywordService.copy(customerKeywordCopyDTO);
} catch (Exception e) {
log.error("Keyword reuse failure: {}", e.getMessage(), e);
}
break;
case "3":
//延时客服复用
try {
customerGraphicsDelayService.copy(sourceAuth.getAppId(), "", "", null, targetApp);
} catch (Exception e) {
log.error("Delayed customer service reuse failure: {}", e.getMessage(), e);
}
break;
case "4":
//菜单管理复用
try {
try {
List<String> appIds = targetAuthList.stream().map(AuthInfoVO::getAppId).collect(Collectors.toList());
List<MaterialMenuMain> materialMenuMainList = materialMenuMainService.getMaterialMenuMainVoInfo(appIds);
if (!materialMenuMainList.isEmpty()) {
for (MaterialMenuMain menuMain : materialMenuMainList) {
String appId = String.valueOf(menuMain.getAppId());
menuFeignClient.removeMenu(menuMain.getId(), appId);
}
}
} catch (Exception e) {
log.error("Failed to delete menu configuration: {}", e.getMessage(), e);
}
MenuMainCopyDTO menuMainCopyDTO = new MenuMainCopyDTO();
menuMainCopyDTO.addList(sourceAuth.getId(), idList);
menuFeignClient.copy(menuMainCopyDTO);
} catch (Exception e) {
log.error("Menu management reuse failure: {}", e.getMessage(), e);
}
break;
default:
break;
}
}
} catch (Exception e) {
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);
});
distributeService.saveBatch(distributeLogList);
}
}
...@@ -73,8 +73,8 @@ ...@@ -73,8 +73,8 @@
AND acs.cost_date = CURRENT_DATE AND acs.cost_date = CURRENT_DATE
AND acs.sales_user = #{userId} AND acs.sales_user = #{userId}
AND ae.channel_id IN AND ae.channel_id IN
<foreach collection="appIds" item="appId" open="(" close=")" separator=","> <foreach collection="accountIds" item="accountId" open="(" close=")" separator=",">
#{appId} #{accountId}
</foreach> </foreach>
</select> </select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论