| | |
| | | package com.zy.crm.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | import com.core.common.Cools; |
| | | import com.zy.crm.common.model.enums.RoleType; |
| | | import com.zy.crm.system.entity.Role; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.mapper.RoleMapper; |
| | | import com.zy.crm.system.service.RoleService; |
| | | import com.zy.crm.system.service.UserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Service("roleService") |
| | | public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService { |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Override |
| | | public List<User> getUserByRoleCode(Long hostId, Long deptId, Long userId) { |
| | | Role role = this.selectById(userService.selectById(userId).getRoleId()); |
| | | if (Cools.isEmpty(role) || Cools.isEmpty(role.getCode())) { |
| | | return new ArrayList<>(); |
| | | } |
| | | switch (role.getCode()) { |
| | | case "boss": |
| | | case "manager": |
| | | return userService.getUserByDept(hostId, deptId); |
| | | case "salesman": |
| | | User user = userService.selectById(userId); |
| | | if (deptId.equals(user.getDeptId())) { |
| | | return Collections.singletonList(user); |
| | | } else { |
| | | return new ArrayList<>(); |
| | | } |
| | | default: |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean judgeLeader(Long roleId) { |
| | | Role role = this.selectById(roleId); |
| | | return (role.getCode().equals(RoleType.boss.toString()) || role.getCode().equals(RoleType.manager.toString())); |
| | | } |
| | | |
| | | } |