forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-10 abb0d631ffed8b67b0a78205ba127b46a4cb546b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package cn.huge.module.bytogz.service;
 
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.ctrole.constant.ByRoleBaseEnum;
import cn.huge.module.ctuser.dao.mapper.CtUseroleMapper;
import cn.huge.module.ctuser.domain.po.CtUser;
import cn.huge.module.ctuser.domain.po.CtUserole;
import cn.huge.module.ctuser.service.CtUserService;
import cn.huge.module.ctuser.service.CtUseroleService;
import cn.huge.module.cust.constant.RoleBaseEnum;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * @title: 白云数据割接为广州数据的业务逻辑处理
 * @Description 白云数据割接为广州数据的业务逻辑处理
 * @company hugeinfo
 * @author liyj
 * @Time 2024-08-19 20:04:19
 * @version 1.0.0
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class ByToGzService{
 
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
 
    @Autowired
    private CtUseroleService ctUseroleService;
    @Autowired
    private CtUserService ctUserService;
 
    /**
     * 用户角色更新-白云角色映射为广州角色
     */
    public void upBytoGzUserole(){
        try{
            List<CtUserole> ctUseroleList = ctUseroleService.list();
            for (CtUserole ctUserole: ctUseroleList){
                if (ctUserole.getRoleCode().equals(ByRoleBaseEnum.ROLE_5)
                        || ctUserole.getRoleCode().equals(ByRoleBaseEnum.ROLE_7)
                                || ctUserole.getRoleCode().equals(ByRoleBaseEnum.ROLE_8)){
                    ctUseroleService.removeById(ctUserole.getId());
                }else {
                    RoleBaseEnum roleBaseEnum = ByRoleBaseEnum.getGzRole(ctUserole.getRoleCode());
                    ctUserole.setRoleId(roleBaseEnum.getIndex());
                    ctUserole.setRoleCode(roleBaseEnum.getIndex());
                    ctUserole.setRoleName(roleBaseEnum.getDes());
                    ctUseroleService.updateById(ctUserole);
                }
            }
        }catch (Exception e){
            log.error("[ByToGzService.upBytoGzUserole]调用失败,异常信息:"+e, e);
            throw new ServiceException("ByToGzService.upBytoGzUserole", e);
        }
    }
}