Merge remote-tracking branch 'origin/cc_20230520_partner' into cc_20230520_partner
This commit is contained in:
@@ -63,6 +63,8 @@ public class CommonConstants {
|
||||
*/
|
||||
public static final String SQUAREBRACKETSRIGHT = "]";
|
||||
|
||||
public static final String PATH_SPILT = "/";
|
||||
|
||||
/**
|
||||
* rocketmq 消息最大重试次数
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.cool.store.enums;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: DataSourceEnum
|
||||
* @Description:
|
||||
* @date 2023-06-08 15:34
|
||||
*/
|
||||
public enum DataSourceEnum {
|
||||
|
||||
SYNC(0, "同步"),
|
||||
CREATE(1, "创建");
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
DataSourceEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.mapper.EnterpriseUserMapper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -26,16 +27,18 @@ public class EnterpriseUserDAO {
|
||||
return enterpriseUserMapper.getUserInfoById(userId);
|
||||
}
|
||||
|
||||
public void batchInsertOrUpdate(List<EnterpriseUserDO> collect) {
|
||||
public void batchInsertOrUpdate(List<EnterpriseUserDO> insertOrUpdateList) {
|
||||
if(CollectionUtils.isEmpty(insertOrUpdateList)){
|
||||
return;
|
||||
}
|
||||
enterpriseUserMapper.batchInsertOrUpdate(insertOrUpdateList);
|
||||
}
|
||||
|
||||
public void insertEnterpriseUser(EnterpriseUserDO enterpriseUser) {
|
||||
}
|
||||
|
||||
public void updateEnterpriseUser(EnterpriseUserDO enterpriseUser) {
|
||||
}
|
||||
|
||||
public List<String> getMainAdminUserIds() {
|
||||
return null;
|
||||
/**
|
||||
* 删除用户
|
||||
* @param excludeUserIds
|
||||
*/
|
||||
public void deleteUser(List<String> excludeUserIds){
|
||||
enterpriseUserMapper.deleteUser(excludeUserIds);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.dto.buser.UserRoleDTO;
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserRole;
|
||||
import com.cool.store.entity.EnterpriseUserRoleDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.enums.RoleEnum;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import com.cool.store.mapper.EnterpriseUserRoleMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -25,52 +22,18 @@ public class EnterpriseUserRoleDAO {
|
||||
@Resource
|
||||
private EnterpriseUserRoleMapper enterpriseUserRoleMapper;
|
||||
|
||||
public Boolean insertBatchUserRole(List<EnterpriseUserRole> userRole) {
|
||||
return enterpriseUserRoleMapper.insertBatchUserRole(userRole);
|
||||
}
|
||||
|
||||
public List<UserRoleDTO> getUserAndRolesByUserId(List<String> userIdList){
|
||||
if(CollectionUtils.isEmpty(userIdList)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return enterpriseUserRoleMapper.getUserAndRolesByUserId(userIdList);
|
||||
}
|
||||
|
||||
public Boolean checkIsAdmin(String userId) {
|
||||
// 1.取出所有用户角色
|
||||
// 2.匹配是否有管理员角色
|
||||
List<SysRoleDO> sysRoleDOList = enterpriseUserRoleMapper.listRoleByUserId(userId);
|
||||
return ListUtils.emptyIfNull(sysRoleDOList)
|
||||
.stream()
|
||||
.anyMatch(role-> StringUtils.equals(RoleEnum.MASTER.getRoleEnum(),role.getRoleEnum()));
|
||||
}
|
||||
|
||||
public void deleteBatchByPrimaryKey(List<Long> ids){
|
||||
if(CollectionUtils.isEmpty(ids)){
|
||||
return;
|
||||
}
|
||||
enterpriseUserRoleMapper.deleteBatchByPrimaryKey(ids);
|
||||
}
|
||||
|
||||
public List<Long> selectIdsByUserId(String userId){
|
||||
if(StringUtils.isAnyBlank(userId)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return enterpriseUserRoleMapper.selectIdsByUserId(userId);
|
||||
}
|
||||
|
||||
public EnterpriseUserRole selectByUserIdAndRoleId(String userId, String roleId){
|
||||
if(StringUtils.isAnyBlank(userId, roleId)){
|
||||
public Integer batchInsertOrUpdate(List<EnterpriseUserRoleDO> recordList){
|
||||
if(CollectionUtils.isEmpty(recordList)){
|
||||
return null;
|
||||
}
|
||||
return enterpriseUserRoleMapper.selectByUserIdAndRoleId(userId, roleId);
|
||||
return enterpriseUserRoleMapper.batchInsertOrUpdate(recordList);
|
||||
}
|
||||
|
||||
public void save( EnterpriseUserRole entity){
|
||||
if(Objects.isNull(entity)){
|
||||
return;
|
||||
public Integer deleteUserRole(String roleId, DataSourceEnum dataSourceEnum, List<String> userIds){
|
||||
if(StringUtils.isBlank(roleId) || Objects.isNull(dataSourceEnum)){
|
||||
return null;
|
||||
}
|
||||
enterpriseUserRoleMapper.save(entity);
|
||||
return enterpriseUserRoleMapper.deleteUserRole(roleId, dataSourceEnum.getCode(), userIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.entity.LoginRecordDO;
|
||||
import com.cool.store.mapper.LoginRecordMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: LoginRecordDAO
|
||||
* @Description:
|
||||
* @date 2023-05-23 15:48
|
||||
*/
|
||||
@Repository
|
||||
public class LoginRecordDAO {
|
||||
|
||||
@Resource
|
||||
private LoginRecordMapper loginRecordMapper;
|
||||
|
||||
public void addLoginRecord(String userId){
|
||||
LoginRecordDO record = new LoginRecordDO();
|
||||
record.setUserId(userId);
|
||||
record.setCreateTime(System.currentTimeMillis());
|
||||
loginRecordMapper.insertSelective(record);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dto.region.RegionNode;
|
||||
import com.cool.store.dto.region.RegionPathDTO;
|
||||
import com.cool.store.dto.region.RegionSyncDTO;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.enums.RegionTypeEnum;
|
||||
import com.cool.store.mapper.RegionMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
* @FileName: RegionDAO
|
||||
* @Description:
|
||||
* @date 2023-06-07 14:22
|
||||
*/
|
||||
@Repository
|
||||
public class RegionDAO {
|
||||
@@ -27,136 +21,20 @@ public class RegionDAO {
|
||||
@Resource
|
||||
private RegionMapper regionMapper;
|
||||
|
||||
public List<Long> getRegionIdsBySynDingDeptIds(List<String> synDingDeptIds) {
|
||||
if (CollectionUtils.isEmpty(synDingDeptIds)) {
|
||||
return new ArrayList<>();
|
||||
/**
|
||||
* 插入或者更新组织架构
|
||||
* @param insertOrUpdateList
|
||||
* @return
|
||||
*/
|
||||
public Integer batchInsertOrUpdate(List<RegionDO> insertOrUpdateList){
|
||||
if(CollectionUtils.isEmpty(insertOrUpdateList)){
|
||||
return CommonConstants.ZERO;
|
||||
}
|
||||
return regionMapper.selectRegionIdsBySynDingDeptIds(synDingDeptIds);
|
||||
return regionMapper.batchInsertOrUpdate(insertOrUpdateList);
|
||||
}
|
||||
|
||||
public List<RegionDO> getRegionByRegionIds(List<String> regionIds) {
|
||||
if(CollectionUtils.isEmpty(regionIds)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return regionMapper.getRegionByRegionIds(regionIds);
|
||||
public Integer deleteNotExistRegion(List<String> regionIds){
|
||||
return regionMapper.deleteNotExistRegion(regionIds);
|
||||
}
|
||||
|
||||
public RegionDO getUnclassifiedRegionDO() {
|
||||
//先查询是否存在未分组区域
|
||||
RegionDO unclassified = regionMapper.getUnclassifiedRegionDO(CommonConstants.UNGROUPED_DEPT_NAME);
|
||||
if (Objects.isNull(unclassified)) {
|
||||
RegionDO regionDO = new RegionDO();
|
||||
regionDO.setId(CommonConstants.UNGROUPED_DEPT_ID);
|
||||
regionDO.setParentId(CommonConstants.ROOT_DEPT_ID_STR);
|
||||
regionDO.setName(CommonConstants.UNGROUPED_DEPT_NAME);
|
||||
regionDO.setRegionType(RegionTypeEnum.PATH.getType());
|
||||
regionDO.setCreateName(CommonConstants.SYSTEM_USER_ID);
|
||||
regionDO.setCreateTime(Calendar.getInstance().getTimeInMillis());
|
||||
regionDO.setRegionPath("/" + CommonConstants.ROOT_DEPT_ID_STR + "/");
|
||||
regionDO.setUnclassifiedFlag(CommonConstants.ONE);
|
||||
insertRegion(regionDO);
|
||||
regionDO.setRegionId(regionDO.getId().toString());
|
||||
return regionDO;
|
||||
}
|
||||
return unclassified;
|
||||
}
|
||||
|
||||
public Long insertRegion(RegionDO regionDO) {
|
||||
return regionMapper.insertRoot(regionDO);
|
||||
}
|
||||
|
||||
public void batchInsertRegions(List<RegionDO> regionDOList){
|
||||
regionMapper.batchInsertRegionsByDepartments(regionDOList);
|
||||
}
|
||||
|
||||
|
||||
public Map<String,Long> getRegionSynDeptIdAndIdMapping(List<String> syncDeptIds){
|
||||
List<RegionDO> regionDOS = regionMapper.selectRegionBySynDingDeptIds(syncDeptIds);
|
||||
return ListUtils.emptyIfNull(regionDOS)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(RegionDO::getSynDingDeptId, RegionDO::getId, (r, e) -> r));
|
||||
}
|
||||
|
||||
public List<RegionDO> getAllRegion(){
|
||||
return regionMapper.getAllRegion();
|
||||
}
|
||||
|
||||
public List<RegionDO> listStoreRegionByIds(List<Long> regionIds){
|
||||
if(CollectionUtils.isEmpty(regionIds)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return regionMapper.listStoreRegionByIds(regionIds);
|
||||
}
|
||||
|
||||
public List<RegionPathDTO> getRegionPathByList(List<String> regionIds) {
|
||||
List<RegionDO> regionList = regionMapper.getRegionByRegionIds(regionIds);
|
||||
return ListUtils.emptyIfNull(regionList)
|
||||
.stream()
|
||||
.map(data->{
|
||||
RegionPathDTO regionPathDTO =new RegionPathDTO();
|
||||
regionPathDTO.setRegionId(data.getRegionId());
|
||||
regionPathDTO.setRegionPath(data.getFullRegionPath());
|
||||
regionPathDTO.setRegionName(data.getName());
|
||||
regionPathDTO.setStoreNum(data.getStoreNum() == null? 0 : data.getStoreNum());
|
||||
regionPathDTO.setRegionType(data.getRegionType());
|
||||
return regionPathDTO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public RegionDO getByRegionId(Long regionId){
|
||||
if(Objects.isNull(regionId)){
|
||||
return null;
|
||||
}
|
||||
return regionMapper.getByRegionId(regionId);
|
||||
}
|
||||
|
||||
public RegionNode getRegionById(String regionId){
|
||||
return regionMapper.getRegionByRegionId(regionId);
|
||||
}
|
||||
|
||||
public void insertOrUpdate(RegionDO regionDO){
|
||||
regionMapper.insertOrUpdate(regionDO);
|
||||
}
|
||||
|
||||
public List<RegionSyncDTO> getSpecifiedRegionIdAndDeptId(Long parentId){
|
||||
return regionMapper.getSpecifiedRegionIdAndDeptId(parentId);
|
||||
}
|
||||
|
||||
public List<RegionDO> getRegionByDingDeptIds(List<String> dingDeptIds){
|
||||
if(CollectionUtils.isEmpty(dingDeptIds)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return regionMapper.getRegionByDingDeptIds(dingDeptIds);
|
||||
}
|
||||
|
||||
public RegionDO getBySynDingDeptId(String synDingDeptId){
|
||||
if(StringUtils.isAnyBlank(synDingDeptId)){
|
||||
return null;
|
||||
}
|
||||
return regionMapper.getBySynDingDeptId(synDingDeptId);
|
||||
}
|
||||
|
||||
public Long ignoreInsert(RegionDO regionDO) {
|
||||
if(Objects.isNull(regionDO)){
|
||||
return 0L;
|
||||
}
|
||||
return regionMapper.ignoreInsert(regionDO);
|
||||
}
|
||||
|
||||
public Integer updateSyncRegion(RegionDO regionDO){
|
||||
if(Objects.isNull(regionDO)){
|
||||
return 0;
|
||||
}
|
||||
return regionMapper.updateSyncRegion(regionDO);
|
||||
}
|
||||
|
||||
public void removeRegion(List<Long> regionIds) {
|
||||
if (regionIds.contains(CommonConstants.UNGROUPED_DEPT_ID)) {
|
||||
regionIds.remove(CommonConstants.UNGROUPED_DEPT_ID);
|
||||
}
|
||||
if(CollectionUtils.isEmpty(regionIds)) {
|
||||
return;
|
||||
}
|
||||
regionMapper.removeRegions(regionIds);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.dto.dept.SyncTreeNode;
|
||||
import com.cool.store.dto.enterprise.QueryDeptChildDTO;
|
||||
import com.cool.store.entity.SysDepartmentDO;
|
||||
import com.cool.store.mapper.SysDepartmentMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
*/
|
||||
@Repository
|
||||
public class SysDepartmentDAO {
|
||||
|
||||
@Resource
|
||||
private SysDepartmentMapper sysDepartmentMapper;
|
||||
|
||||
public void batchInsertOrUpdate(List<SysDepartmentDO> deptList){
|
||||
if(CollectionUtils.isEmpty(deptList)){
|
||||
return;
|
||||
}
|
||||
sysDepartmentMapper.batchInsertOrUpdate(deptList);
|
||||
}
|
||||
|
||||
public List<QueryDeptChildDTO> getDeptChildListByParentId(String parentId){
|
||||
if(StringUtils.isAnyBlank(parentId)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return sysDepartmentMapper.getDeptChildListByParentId(parentId);
|
||||
}
|
||||
|
||||
public void deleteByNotInIds(List<String> deptIds){
|
||||
if(CollectionUtils.isEmpty(deptIds)){
|
||||
return;
|
||||
}
|
||||
sysDepartmentMapper.deleteByNotInIds(deptIds);
|
||||
}
|
||||
|
||||
public List<SyncTreeNode> getSyncDeptTreeList() {
|
||||
return sysDepartmentMapper.getSyncDeptTreeList();
|
||||
}
|
||||
|
||||
public List<SysDepartmentDO> selectAllDepts(){
|
||||
return sysDepartmentMapper.selectAll();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.enums.RoleEnum;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import com.cool.store.mapper.SysRoleMapper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
* @FileName: SysRoleDAO
|
||||
* @Description:
|
||||
* @date 2023-06-08 11:45
|
||||
*/
|
||||
@Repository
|
||||
public class SysRoleDAO {
|
||||
@@ -18,26 +23,24 @@ public class SysRoleDAO {
|
||||
@Resource
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
|
||||
/**
|
||||
* 获取高优先级的角色
|
||||
* @param enterpriseId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public SysRoleDO getHighestPrioritySysRoleDoByUserId(String userId){
|
||||
if(StringUtils.isAnyBlank(userId)){
|
||||
public Integer batchInsertSelective(List<SysRoleDO> insertOrUpdateList){
|
||||
if(CollectionUtils.isEmpty(insertOrUpdateList)){
|
||||
return null;
|
||||
}
|
||||
return sysRoleMapper.getHighestPrioritySysRoleDoByUserId(userId);
|
||||
return sysRoleMapper.batchInsertSelective(insertOrUpdateList);
|
||||
}
|
||||
|
||||
public Long getRoleIdByRoleEnum(String roleEnum) {
|
||||
|
||||
SysRoleDO roleByRoleEnum = sysRoleMapper.getRoleByRoleEnum(roleEnum);
|
||||
if(roleByRoleEnum==null){
|
||||
return Long.valueOf(RoleEnum.getByCode(roleEnum).getId());
|
||||
public Integer deleteRole(DataSourceEnum dataSourceEnum, List<String> roleIds){
|
||||
if(Objects.isNull(dataSourceEnum) || CollectionUtils.isEmpty(roleIds)){
|
||||
return null;
|
||||
}
|
||||
return roleByRoleEnum.getId();
|
||||
return sysRoleMapper.deleteRole(dataSourceEnum.getCode(), roleIds);
|
||||
}
|
||||
|
||||
public SysRoleDO getHighestPriorityRoleByUserId(String userId) {
|
||||
if(StringUtils.isBlank(userId)){
|
||||
return null;
|
||||
}
|
||||
return sysRoleMapper.getHighestPriorityRoleByUserId(userId);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.entity.UserRegionMappingDO;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import com.cool.store.mapper.UserRegionMappingMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
* @FileName: UserRegionMappingDAO
|
||||
* @Description:
|
||||
* @date 2023-06-08 13:58
|
||||
*/
|
||||
@Repository
|
||||
public class UserRegionMappingDAO {
|
||||
@@ -20,43 +23,18 @@ public class UserRegionMappingDAO {
|
||||
@Resource
|
||||
private UserRegionMappingMapper userRegionMappingMapper;
|
||||
|
||||
|
||||
public void deletedByUserIds(List<String> userIds){
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return;
|
||||
public Integer batchInsertOrUpdateUserRegion(List<UserRegionMappingDO> insertOrUpdateList){
|
||||
if(CollectionUtils.isEmpty(insertOrUpdateList)){
|
||||
return null;
|
||||
}
|
||||
List<String> distinctData = userIds.stream()
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
userRegionMappingMapper.deletedByUserIds(distinctData);
|
||||
return userRegionMappingMapper.batchInsertOrUpdateUserRegion(insertOrUpdateList);
|
||||
}
|
||||
|
||||
public void batchInsertRegionMapping(List<UserRegionMappingDO> userRegionMappingDOS){
|
||||
if (CollectionUtils.isEmpty(userRegionMappingDOS)) {
|
||||
return;
|
||||
public Integer deleteUserRegion(String regionId, DataSourceEnum dataSourceEnum, List<String> excludeUserIds){
|
||||
if(StringUtils.isBlank(regionId) || Objects.isNull(dataSourceEnum)){
|
||||
return null;
|
||||
}
|
||||
List<UserRegionMappingDO> distinctData = userRegionMappingDOS.stream()
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
userRegionMappingMapper.batchInsertRegionMapping(distinctData);
|
||||
}
|
||||
|
||||
|
||||
public List<UserRegionMappingDO> listUserRegionMappingByUserId(List<String> userIds){
|
||||
if(CollectionUtils.isEmpty(userIds)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return userRegionMappingMapper.listUserRegionMappingByUserId(userIds);
|
||||
}
|
||||
|
||||
public void deletedByIds(List<Integer> ids){
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
List<Integer> distinctData = ids.stream()
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
userRegionMappingMapper.deletedByIds(distinctData);
|
||||
return userRegionMappingMapper.deleteUserRegion(regionId, dataSourceEnum.getCode(), excludeUserIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.cool.store.mapper;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-06-06 02:29
|
||||
@@ -14,7 +16,7 @@ public interface EnterpriseUserMapper {
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-06-06 02:29
|
||||
*/
|
||||
int insertSelective(EnterpriseUserDO record);
|
||||
int batchInsertOrUpdate(@Param("recordList") List<EnterpriseUserDO> recordList);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,4 +31,11 @@ public interface EnterpriseUserMapper {
|
||||
* @return
|
||||
*/
|
||||
EnterpriseUserDO getUserInfoById(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
* @param excludeUserIds
|
||||
* @return
|
||||
*/
|
||||
int deleteUser(@Param("excludeUserIds") List<String> excludeUserIds);
|
||||
}
|
||||
@@ -1,50 +1,36 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.buser.UserRoleDTO;
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserRole;
|
||||
import com.cool.store.entity.EnterpriseUserRoleDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
* @date 2023-06-08 10:54
|
||||
*/
|
||||
public interface EnterpriseUserRoleMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 02:59
|
||||
* dateTime:2023-06-08 10:54
|
||||
*/
|
||||
int insertSelective(@Param("record") EnterpriseUserRoleDO record);
|
||||
int batchInsertOrUpdate(@Param("recordList") List<EnterpriseUserRoleDO> recordList);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 02:59
|
||||
* dateTime:2023-06-08 10:54
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") EnterpriseUserRoleDO record);
|
||||
int updateByPrimaryKeySelective(EnterpriseUserRoleDO record);
|
||||
|
||||
/**
|
||||
* 批量插入用户角色
|
||||
* @param enterpriseId
|
||||
* @param userRoles
|
||||
* 删除用户角色
|
||||
* @param roleId
|
||||
* @param type
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
Boolean insertBatchUserRole(@Param("userRoles") List<EnterpriseUserRole> userRoles);
|
||||
|
||||
List<UserRoleDTO> getUserAndRolesByUserId(@Param("userIdList") List<String> userIdList);
|
||||
|
||||
List<SysRoleDO> listRoleByUserId(@Param("userId") String userId);
|
||||
|
||||
void deleteBatchByPrimaryKey(@Param("ids") List<Long> ids);
|
||||
|
||||
List<Long> selectIdsByUserId(@Param("userId") String userId);
|
||||
|
||||
EnterpriseUserRole selectByUserIdAndRoleId(@Param("userId") String userId, @Param("roleId") String roleId);
|
||||
|
||||
void save(@Param("entity") EnterpriseUserRole entity);
|
||||
int deleteUserRole(@Param("roleId") String roleId, @Param("type") Integer type, @Param("userIds") List<String> userIds);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.entity.LoginRecordDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-23 03:46
|
||||
*/
|
||||
public interface LoginRecordMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-23 03:46
|
||||
*/
|
||||
int insertSelective(@Param("record") LoginRecordDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-23 03:46
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") LoginRecordDO record);
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.region.RegionNode;
|
||||
import com.cool.store.dto.region.RegionSyncDTO;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -9,57 +7,28 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
* @date 2023-06-07 02:07
|
||||
*/
|
||||
public interface RegionMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 02:59
|
||||
*/
|
||||
int insertSelective(@Param("record") RegionDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 02:59
|
||||
* dateTime:2023-06-07 02:07
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") RegionDO record);
|
||||
int updateByPrimaryKeySelective(RegionDO record);
|
||||
|
||||
List<Long> selectRegionIdsBySynDingDeptIds(@Param("synDingDeptIds") List<String> synDingDeptIds);
|
||||
|
||||
List<RegionDO> getRegionByRegionIds( @Param("regionIds") List<String> regionIds);
|
||||
|
||||
|
||||
RegionDO getUnclassifiedRegionDO(@Param("name")String name);
|
||||
|
||||
Long insertRoot(@Param("region") RegionDO regionDO);
|
||||
|
||||
Integer batchInsertRegionsByDepartments(@Param("regions") List<RegionDO> regions);
|
||||
|
||||
List<RegionDO> selectRegionBySynDingDeptIds(@Param("synDingDeptIds") List<String> synDingDeptIds);
|
||||
|
||||
List<RegionDO> getAllRegion();
|
||||
|
||||
List<RegionDO> listStoreRegionByIds(@Param("regionIds")List<Long> regionIds);
|
||||
|
||||
RegionDO getByRegionId(@Param("regionId") Long regionId);
|
||||
|
||||
RegionNode getRegionByRegionId(@Param("regionId") String regionId);
|
||||
|
||||
Integer insertOrUpdate(@Param("record") RegionDO regionDO);
|
||||
|
||||
List<RegionSyncDTO> getSpecifiedRegionIdAndDeptId(@Param("parentId") Long parentId);
|
||||
|
||||
List<RegionDO> getRegionByDingDeptIds(@Param("list")List<String> dingDeptIds);
|
||||
|
||||
RegionDO getBySynDingDeptId(@Param("synDingDeptId") String synDingDeptId);
|
||||
|
||||
Long ignoreInsert(@Param("region") RegionDO regionDO);
|
||||
|
||||
Integer updateSyncRegion(@Param("item")RegionDO regionDO);
|
||||
|
||||
Integer removeRegions(@Param("regionIds") List<Long> regionIds);
|
||||
/**
|
||||
* 批量新增或者更新
|
||||
* @param insertOrUpdateList
|
||||
* @return
|
||||
*/
|
||||
int batchInsertOrUpdate(@Param("insertOrUpdateList") List<RegionDO> insertOrUpdateList);
|
||||
|
||||
/**
|
||||
* 删除不存在的区域
|
||||
* @param regionIds
|
||||
* @return
|
||||
*/
|
||||
int deleteNotExistRegion(@Param("regionIds")List<String> regionIds);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.dept.SyncTreeNode;
|
||||
import com.cool.store.dto.enterprise.QueryDeptChildDTO;
|
||||
import com.cool.store.entity.SysDepartmentDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
*/
|
||||
public interface SysDepartmentMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int insertSelective(@Param("record") SysDepartmentDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:00
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysDepartmentDO record);
|
||||
|
||||
void batchInsertOrUpdate(@Param("list") List<SysDepartmentDO> sysDepartmentDOList);
|
||||
|
||||
List<QueryDeptChildDTO> getDeptChildListByParentId(@Param("parentId") String parentId);
|
||||
|
||||
void deleteByNotInIds(@Param("list") List<String> deptIdList);
|
||||
|
||||
List<SyncTreeNode> getSyncDeptTreeList();
|
||||
|
||||
List<SysDepartmentDO> selectAll();
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserRole;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -8,26 +7,30 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
* @date 2023-06-08 10:54
|
||||
*/
|
||||
public interface SysRoleMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:00
|
||||
* dateTime:2023-06-08 10:54
|
||||
*/
|
||||
int insertSelective(@Param("record") SysRoleDO record);
|
||||
int batchInsertSelective(@Param("insertOrUpdateList") List<SysRoleDO> insertOrUpdateList);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:00
|
||||
* dateTime:2023-06-08 10:54
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") SysRoleDO record);
|
||||
int updateByPrimaryKeySelective(SysRoleDO record);
|
||||
|
||||
Integer deleteRole(@Param("roleType")Integer roleType, @Param("roleIds") List<String> roleIds);
|
||||
|
||||
SysRoleDO getHighestPrioritySysRoleDoByUserId(@Param("userId") String userId);
|
||||
|
||||
SysRoleDO getRoleByRoleEnum(@Param("roleEnum") String roleEnum);
|
||||
/**
|
||||
* 获取用户权限
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
SysRoleDO getHighestPriorityRoleByUserId(@Param("userId") String userId);
|
||||
}
|
||||
@@ -7,29 +7,30 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
* @date 2023-06-07 02:07
|
||||
*/
|
||||
public interface UserRegionMappingMapper {
|
||||
/**
|
||||
*
|
||||
* 默认插入方法,只会给有值的字段赋值
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:00
|
||||
* dateTime:2023-06-07 02:07
|
||||
*/
|
||||
int insertSelective(@Param("record") UserRegionMappingDO record);
|
||||
int batchInsertOrUpdateUserRegion(@Param("insertOrUpdateList") List<UserRegionMappingDO> insertOrUpdateList);
|
||||
|
||||
/**
|
||||
*
|
||||
* 默认更新方法,根据主键更新,不会把null值更新到数据库,避免覆盖之前有值的
|
||||
* dateTime:2023-05-19 03:00
|
||||
* dateTime:2023-06-07 02:07
|
||||
*/
|
||||
int updateByPrimaryKeySelective(@Param("record") UserRegionMappingDO record);
|
||||
int updateByPrimaryKeySelective(UserRegionMappingDO record);
|
||||
|
||||
void batchInsertRegionMapping(@Param("userRegionMappingDOS") List<UserRegionMappingDO> userRegionMappingDOS);
|
||||
|
||||
void deletedByUserIds(@Param("userIds") List<String> userIds);
|
||||
|
||||
List<UserRegionMappingDO> listUserRegionMappingByUserId(@Param("userIds") List<String> userIds);
|
||||
|
||||
void deletedByIds(@Param("ids") List<Integer> ids);
|
||||
/**
|
||||
* 删除用户区域
|
||||
* @param regionId
|
||||
* @param type
|
||||
* @param excludeUserIds
|
||||
* @return
|
||||
*/
|
||||
int deleteUserRegion(@Param("regionId") String regionId, @Param("type")Integer type, @Param("excludeUserIds") List<String> excludeUserIds);
|
||||
}
|
||||
@@ -12,10 +12,10 @@
|
||||
<result column="main_admin" jdbcType="BIT" property="mainAdmin"/>
|
||||
<result column="is_admin" jdbcType="BIT" property="isAdmin"/>
|
||||
<result column="unionid" jdbcType="VARCHAR" property="unionid"/>
|
||||
<result column="position" jdbcType="VARCHAR" property="position"/>
|
||||
<result column="avatar" jdbcType="VARCHAR" property="avatar"/>
|
||||
<result column="jobnumber" jdbcType="VARCHAR" property="jobnumber"/>
|
||||
<result column="is_leader" jdbcType="BIT" property="isLeader"/>
|
||||
<result column="leader_dept_ids" jdbcType="VARCHAR" property="leaderDeptIds"/>
|
||||
<result column="face_url" jdbcType="VARCHAR" property="faceUrl"/>
|
||||
<result column="user_status" jdbcType="TINYINT" property="userStatus"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
@@ -27,132 +27,143 @@
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, name, remark, mobile, email, org_email, main_admin, is_admin, unionid,
|
||||
position, avatar, jobnumber, is_leader, face_url, user_status, deleted, create_time,
|
||||
avatar, jobnumber, is_leader, leader_dept_ids, face_url, user_status, deleted, create_time,
|
||||
update_time
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
user_region_ids
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="recordList" item="record" separator=";">
|
||||
insert into enterprise_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">
|
||||
<if test="record.id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
<if test="record.remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="mobile != null">
|
||||
<if test="record.mobile != null">
|
||||
mobile,
|
||||
</if>
|
||||
<if test="email != null">
|
||||
<if test="record.email != null">
|
||||
email,
|
||||
</if>
|
||||
<if test="orgEmail != null">
|
||||
<if test="record.orgEmail != null">
|
||||
org_email,
|
||||
</if>
|
||||
<if test="mainAdmin != null">
|
||||
<if test="record.mainAdmin != null">
|
||||
main_admin,
|
||||
</if>
|
||||
<if test="isAdmin != null">
|
||||
<if test="record.isAdmin != null">
|
||||
is_admin,
|
||||
</if>
|
||||
<if test="unionid != null">
|
||||
<if test="record.unionid != null">
|
||||
unionid,
|
||||
</if>
|
||||
<if test="position != null">
|
||||
position,
|
||||
</if>
|
||||
<if test="avatar != null">
|
||||
<if test="record.avatar != null">
|
||||
avatar,
|
||||
</if>
|
||||
<if test="jobnumber != null">
|
||||
<if test="record.jobnumber != null">
|
||||
jobnumber,
|
||||
</if>
|
||||
<if test="isLeader != null">
|
||||
<if test="record.isLeader != null">
|
||||
is_leader,
|
||||
</if>
|
||||
<if test="faceUrl != null">
|
||||
<if test="record.leaderDeptIds != null">
|
||||
leader_dept_ids,
|
||||
</if>
|
||||
<if test="record.faceUrl != null">
|
||||
face_url,
|
||||
</if>
|
||||
<if test="userStatus != null">
|
||||
<if test="record.userStatus != null">
|
||||
user_status,
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="userRegionIds != null">
|
||||
<if test="record.userRegionIds != null">
|
||||
user_region_ids,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">
|
||||
#{userId},
|
||||
<if test="record.id != null">
|
||||
#{record.id},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name},
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark},
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="mobile != null">
|
||||
#{mobile},
|
||||
<if test="record.remark != null">
|
||||
#{record.remark},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
#{email},
|
||||
<if test="record.mobile != null">
|
||||
#{record.mobile},
|
||||
</if>
|
||||
<if test="orgEmail != null">
|
||||
#{orgEmail},
|
||||
<if test="record.email != null">
|
||||
#{record.email},
|
||||
</if>
|
||||
<if test="mainAdmin != null">
|
||||
#{mainAdmin},
|
||||
<if test="record.orgEmail != null">
|
||||
#{record.orgEmail},
|
||||
</if>
|
||||
<if test="isAdmin != null">
|
||||
#{isAdmin},
|
||||
<if test="record.mainAdmin != null">
|
||||
#{record.mainAdmin},
|
||||
</if>
|
||||
<if test="unionid != null">
|
||||
#{unionid},
|
||||
<if test="record.isAdmin != null">
|
||||
#{record.isAdmin},
|
||||
</if>
|
||||
<if test="position != null">
|
||||
#{position},
|
||||
<if test="record.unionid != null">
|
||||
#{record.unionid},
|
||||
</if>
|
||||
<if test="avatar != null">
|
||||
#{avatar},
|
||||
<if test="record.avatar != null">
|
||||
#{record.avatar},
|
||||
</if>
|
||||
<if test="jobnumber != null">
|
||||
#{jobnumber},
|
||||
<if test="record.jobnumber != null">
|
||||
#{record.jobnumber},
|
||||
</if>
|
||||
<if test="isLeader != null">
|
||||
#{isLeader},
|
||||
<if test="record.isLeader != null">
|
||||
#{record.isLeader},
|
||||
</if>
|
||||
<if test="faceUrl != null">
|
||||
#{faceUrl},
|
||||
<if test="record.leaderDeptIds != null">
|
||||
#{record.leaderDeptIds},
|
||||
</if>
|
||||
<if test="userStatus != null">
|
||||
#{userStatus},
|
||||
<if test="record.faceUrl != null">
|
||||
#{record.faceUrl},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
#{deleted},
|
||||
<if test="record.userStatus != null">
|
||||
#{record.userStatus},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="userRegionIds != null">
|
||||
#{userRegionIds},
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.userRegionIds != null">
|
||||
#{record.userRegionIds},
|
||||
</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE user_id = values(user_id), name = values(name), remark = values(remark), mobile = values(mobile), email = values(email), org_email = values(org_email)
|
||||
, main_admin = values(main_admin), is_admin = values(is_admin), unionid = values(unionid), avatar = values(avatar), jobnumber = values(jobnumber), is_leader = values(is_leader)
|
||||
, leader_dept_ids = values(leader_dept_ids), face_url = values(face_url), user_status = values(user_status), user_region_ids = values(user_region_ids)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update enterprise_user
|
||||
@@ -184,9 +195,6 @@
|
||||
<if test="unionid != null">
|
||||
unionid = #{unionid},
|
||||
</if>
|
||||
<if test="position != null">
|
||||
position = #{position},
|
||||
</if>
|
||||
<if test="avatar != null">
|
||||
avatar = #{avatar},
|
||||
</if>
|
||||
@@ -196,6 +204,9 @@
|
||||
<if test="isLeader != null">
|
||||
is_leader = #{isLeader},
|
||||
</if>
|
||||
<if test="record.leaderDeptIds != null">
|
||||
leader_dept_ids = #{record.leaderDeptIds},
|
||||
</if>
|
||||
<if test="faceUrl != null">
|
||||
face_url = #{faceUrl},
|
||||
</if>
|
||||
@@ -220,10 +231,15 @@
|
||||
|
||||
<select id="getUserInfoById" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>, <include refid="Blob_Column_List"/>
|
||||
<include refid="Base_Column_List"/>,
|
||||
<include refid="Blob_Column_List"/>
|
||||
from
|
||||
enterprise_user
|
||||
where
|
||||
user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<update id="deleteUser">
|
||||
update enterprise_user set deleted = 1 where id in <foreach collection="excludeUserIds" open="(" close=")" separator="," item="userId">#{userId}</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -3,15 +3,17 @@
|
||||
<mapper namespace="com.cool.store.mapper.EnterpriseUserRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.EnterpriseUserRoleDO">
|
||||
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||
<result column="role_id" jdbcType="BIGINT" property="roleId"/>
|
||||
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, role_id, user_id, create_time, update_time
|
||||
id, role_id, user_id, deleted, create_time, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="recordList" separator=";" item="record">
|
||||
insert into enterprise_user_role
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
@@ -20,6 +22,9 @@
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
@@ -34,6 +39,9 @@
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
@@ -41,96 +49,32 @@
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE deleted = values(deleted)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update enterprise_user_role
|
||||
<set>
|
||||
<if test="record.roleId != null">
|
||||
role_id = #{record.roleId},
|
||||
<if test="roleId != null">
|
||||
role_id = #{roleId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
<if test="userId != null">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="insertBatchUserRole">
|
||||
insert ignore into enterprise_user_role
|
||||
(role_id, user_id ,create_time)
|
||||
values
|
||||
<foreach collection="userRoles" item="userRole" separator=",">
|
||||
(#{userRole.roleId}, #{userRole.userId} ,#{userRole.createTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getUserAndRolesByUserId" resultType="com.cool.store.dto.buser.UserRoleDTO">
|
||||
select
|
||||
a.role_id as roleId,
|
||||
a.user_id as userId,
|
||||
b.role_name as roleName,
|
||||
b.role_auth as roleAuth,
|
||||
b.role_enum as roleEnum,
|
||||
b.priority as priority
|
||||
from enterprise_user_role a left join sys_role b on a.role_id=b.id
|
||||
<where>
|
||||
<if test="userIdList != null and userIdList.size>0">
|
||||
<foreach collection="userIdList" item="userId" separator="," open="a.user_id in (" close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</if>
|
||||
AND b.role_name IS NOT NULL
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="listRoleByUserId" resultType="com.cool.store.entity.SysRoleDO">
|
||||
select
|
||||
c.id as id,
|
||||
c.role_name as roleName,
|
||||
c.role_auth as roleAuth,
|
||||
c.source as source,
|
||||
c.role_enum as roleEnum
|
||||
from enterprise_user_role b
|
||||
left join sys_role c on c.id = b.role_id
|
||||
where b.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteBatchByPrimaryKey">
|
||||
delete from enterprise_user_role where id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectIdsByUserId" resultType="java.lang.Long">
|
||||
select id from enterprise_user_role where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectByUserIdAndRoleId" resultMap="BaseResultMap">
|
||||
select * from enterprise_user_role
|
||||
where user_id = #{userId} and role_id = #{roleId}
|
||||
order by id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="save">
|
||||
insert ignore into enterprise_user_role
|
||||
(
|
||||
`role_id`,
|
||||
`user_id`,
|
||||
`create_time`
|
||||
)
|
||||
values
|
||||
(
|
||||
#{entity.roleId},
|
||||
#{entity.userId},
|
||||
#{entity.createTime}
|
||||
)
|
||||
</insert>
|
||||
<update id="deleteUserRole">
|
||||
update enterprise_user_role set deleted = 1 where role_id = #{roleId} and user_id not in <foreach collection="userIds" item="userId" separator="," open="(" close=")">#{userId}</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cool.store.mapper.LoginRecordMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.LoginRecordDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, create_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into login_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update login_record
|
||||
<set>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -5,29 +5,24 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="region_id" jdbcType="VARCHAR" property="regionId"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
||||
<result column="group_id" jdbcType="VARCHAR" property="groupId"/>
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
|
||||
<result column="region_path" jdbcType="VARCHAR" property="regionPath"/>
|
||||
<result column="unclassified_flag" jdbcType="TINYINT" property="unclassifiedFlag"/>
|
||||
<result column="leader_user_id" jdbcType="VARCHAR" property="leaderUserId"/>
|
||||
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
|
||||
<result column="third_dept_id" jdbcType="VARCHAR" property="thirdDeptId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
<result column="create_name" jdbcType="VARCHAR" property="createName"/>
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||
<result column="update_name" jdbcType="VARCHAR" property="updateName"/>
|
||||
<result column="vds_group_corp_id" jdbcType="VARCHAR" property="vdsGroupCorpId"/>
|
||||
<result column="syn_ding_dept_id" jdbcType="VARCHAR" property="synDingDeptId"/>
|
||||
<result column="region_type" jdbcType="VARCHAR" property="regionType"/>
|
||||
<result column="region_path" jdbcType="VARCHAR" property="regionPath"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
<result column="store_num" jdbcType="INTEGER" property="storeNum"/>
|
||||
<result column="store_id" jdbcType="VARCHAR" property="storeId"/>
|
||||
<result column="unclassified_flag" jdbcType="TINYINT" property="unclassifiedFlag"/>
|
||||
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
|
||||
<result column="third_dept_id" jdbcType="VARCHAR" property="thirdDeptId"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, region_id, name, parent_id, group_id, create_time, create_name, update_time,
|
||||
update_name, vds_group_corp_id, syn_ding_dept_id, region_type, region_path, deleted,
|
||||
store_num, store_id, unclassified_flag, order_num, third_dept_id
|
||||
id, region_id, name, parent_id, region_path, unclassified_flag, leader_user_id, order_num,
|
||||
third_dept_id, create_time, create_name, update_time, update_name, deleted
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="insertOrUpdateList" item="record" separator=";">
|
||||
insert into region
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
@@ -39,8 +34,20 @@
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id,
|
||||
<if test="record.regionPath != null">
|
||||
region_path,
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag,
|
||||
</if>
|
||||
<if test="record.leaderUserId != null">
|
||||
leader_user_id,
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num,
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
@@ -54,36 +61,9 @@
|
||||
<if test="record.updateName != null">
|
||||
update_name,
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
vds_group_corp_id,
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
syn_ding_dept_id,
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
region_type,
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
store_num,
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
store_id,
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag,
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num,
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
@@ -95,8 +75,20 @@
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
#{record.groupId},
|
||||
<if test="record.regionPath != null">
|
||||
#{record.regionPath},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
#{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.leaderUserId != null">
|
||||
#{record.leaderUserId},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
#{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
#{record.thirdDeptId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
@@ -110,480 +102,60 @@
|
||||
<if test="record.updateName != null">
|
||||
#{record.updateName},
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
#{record.vdsGroupCorpId},
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
#{record.synDingDeptId},
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
#{record.regionType},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
#{record.regionPath},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
#{record.storeNum},
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
#{record.storeId},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
#{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
#{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
#{record.thirdDeptId},
|
||||
</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE region_id = values(region_id), name = values(name), parent_id = values(parent_id), region_path = values(region_path), leader_user_id = values(leader_user_id), order_num = values(order_num), third_dept_id = values(third_dept_id), update_time = UNIX_TIMESTAMP(), deleted = values(deleted)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update region
|
||||
<set>
|
||||
<if test="record.regionId != null">
|
||||
region_id = #{record.regionId},
|
||||
<if test="regionId != null">
|
||||
region_id = #{regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name = #{record.name},
|
||||
<if test="name != null">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId},
|
||||
<if test="parentId != null">
|
||||
parent_id = #{parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id = #{record.groupId},
|
||||
<if test="regionPath != null">
|
||||
region_path = #{regionPath},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
<if test="unclassifiedFlag != null">
|
||||
unclassified_flag = #{unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name = #{record.createName},
|
||||
<if test="leaderUserId != null">
|
||||
leader_user_id = #{leaderUserId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
<if test="orderNum != null">
|
||||
order_num = #{orderNum},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name = #{record.updateName},
|
||||
<if test="thirdDeptId != null">
|
||||
third_dept_id = #{thirdDeptId},
|
||||
</if>
|
||||
<if test="record.vdsGroupCorpId != null">
|
||||
vds_group_corp_id = #{record.vdsGroupCorpId},
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="record.synDingDeptId != null">
|
||||
syn_ding_dept_id = #{record.synDingDeptId},
|
||||
<if test="createName != null">
|
||||
create_name = #{createName},
|
||||
</if>
|
||||
<if test="record.regionType != null">
|
||||
region_type = #{record.regionType},
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="record.regionPath != null">
|
||||
region_path = #{record.regionPath},
|
||||
<if test="updateName != null">
|
||||
update_name = #{updateName},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted = #{record.deleted},
|
||||
</if>
|
||||
<if test="record.storeNum != null">
|
||||
store_num = #{record.storeNum},
|
||||
</if>
|
||||
<if test="record.storeId != null">
|
||||
store_id = #{record.storeId},
|
||||
</if>
|
||||
<if test="record.unclassifiedFlag != null">
|
||||
unclassified_flag = #{record.unclassifiedFlag},
|
||||
</if>
|
||||
<if test="record.orderNum != null">
|
||||
order_num = #{record.orderNum},
|
||||
</if>
|
||||
<if test="record.thirdDeptId != null">
|
||||
third_dept_id = #{record.thirdDeptId},
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectRegionIdsBySynDingDeptIds" resultType="java.lang.Long">
|
||||
select
|
||||
id
|
||||
from region
|
||||
where
|
||||
deleted = 0 and syn_ding_dept_id in
|
||||
<foreach collection="synDingDeptIds" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getRegionByRegionIds" resultMap="BaseResultMap">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
region_path as regionPath,
|
||||
store_num as storeNum,
|
||||
store_id as storeId,
|
||||
region_type as regionType
|
||||
from region where id in
|
||||
<foreach collection="regionIds" index="index" item="regionId"
|
||||
separator="," open="(" close=")">
|
||||
#{regionId, jdbcType=BIGINT}
|
||||
</foreach>
|
||||
and deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getUnclassifiedRegionDO" resultMap="BaseResultMap">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
vds_group_corp_id as vdsGroupCorpId,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted,
|
||||
region_path as regionPath,
|
||||
store_num as storeNum,
|
||||
unclassified_flag as unclassifiedFlag
|
||||
from region
|
||||
where deleted = 0 and unclassified_flag = 1
|
||||
and (name = #{name} or id = 1) limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertRoot">
|
||||
insert ignore into region
|
||||
(
|
||||
id,
|
||||
region_id,
|
||||
name,
|
||||
parent_id,
|
||||
group_id,
|
||||
create_time,
|
||||
syn_ding_dept_id,
|
||||
create_name,
|
||||
region_type,
|
||||
region_path,
|
||||
store_num,
|
||||
unclassified_flag)
|
||||
values
|
||||
(
|
||||
#{region.id, jdbcType=BIGINT},
|
||||
#{region.regionId, jdbcType=VARCHAR},
|
||||
#{region.name, jdbcType=VARCHAR},
|
||||
#{region.parentId, jdbcType=VARCHAR},
|
||||
#{region.groupId, jdbcType=VARCHAR},
|
||||
#{region.createTime, jdbcType=BIGINT},
|
||||
#{region.synDingDeptId, jdbcType=VARCHAR},
|
||||
#{region.createName, jdbcType=VARCHAR},
|
||||
#{region.regionType, jdbcType=VARCHAR},
|
||||
#{region.regionPath},
|
||||
#{region.storeNum},
|
||||
#{region.unclassifiedFlag}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsertRegionsByDepartments">
|
||||
insert into region
|
||||
(
|
||||
id,
|
||||
name,
|
||||
parent_id,
|
||||
group_id,
|
||||
create_time,
|
||||
syn_ding_dept_id,
|
||||
region_path,
|
||||
region_type,
|
||||
order_num,
|
||||
create_name,
|
||||
store_id
|
||||
)
|
||||
values
|
||||
<foreach collection="regions" item="region" separator=",">
|
||||
(
|
||||
#{region.id},
|
||||
#{region.name},
|
||||
#{region.parentId},
|
||||
#{region.groupId},
|
||||
#{region.createTime},
|
||||
#{region.synDingDeptId},
|
||||
#{region.regionPath},
|
||||
#{region.regionType},
|
||||
#{region.orderNum},
|
||||
#{region.createName},
|
||||
#{region.storeId}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
name=values(name), parent_id=values(parent_id), region_path=values(region_path),region_type=values(region_type),order_num=values(order_num)
|
||||
</insert>
|
||||
|
||||
<select id="selectRegionBySynDingDeptIds" resultMap="BaseResultMap">
|
||||
select
|
||||
id,
|
||||
syn_ding_dept_id
|
||||
from region
|
||||
where deleted = 0 and syn_ding_dept_id in (
|
||||
<foreach collection="synDingDeptIds" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getAllRegion" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
deleted as deleted,
|
||||
third_dept_id as thirdDeptId
|
||||
from region
|
||||
where deleted = 0 and id > 0
|
||||
and region_type != 'store'
|
||||
</select>
|
||||
|
||||
<select id="listStoreRegionByIds" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
region_id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted,
|
||||
region_path as regionPath,
|
||||
store_id as storeId
|
||||
from region
|
||||
where region_type = 'store'
|
||||
and id in (
|
||||
<foreach collection="regionIds" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getByRegionId" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
store_id as storeId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
deleted,
|
||||
store_num as storeNum
|
||||
from region
|
||||
where id = #{regionId}
|
||||
</select>
|
||||
|
||||
<select id="getRegionByRegionId" resultType="com.cool.store.dto.region.RegionNode">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
store_num as storeCount
|
||||
from region where id = #{regionId, jdbcType=BIGINT} and deleted = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdate" useGeneratedKeys="true" keyProperty="record.id">
|
||||
insert into region
|
||||
(
|
||||
id,
|
||||
name,
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
region_type,
|
||||
create_time,
|
||||
syn_ding_dept_id,
|
||||
unclassified_flag,
|
||||
third_dept_id
|
||||
) value
|
||||
(
|
||||
#{record.id, jdbcType=BIGINT},
|
||||
#{record.name, jdbcType=VARCHAR},
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId, jdbcType=BIGINT},
|
||||
</if>
|
||||
#{record.regionType, jdbcType=VARCHAR},
|
||||
#{record.createTime, jdbcType=BIGINT},
|
||||
#{record.synDingDeptId, jdbcType=VARCHAR},
|
||||
#{record.unclassifiedFlag},
|
||||
#{record.thirdDeptId}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE name=values(name), parent_id=values(parent_id), syn_ding_dept_id=values(syn_ding_dept_id),third_dept_id=values(third_dept_id),
|
||||
update_time = values(update_time), region_type = values(region_type), deleted = values(deleted)
|
||||
</insert>
|
||||
|
||||
<select id="getSpecifiedRegionIdAndDeptId" resultType="com.cool.store.dto.region.RegionSyncDTO">
|
||||
select
|
||||
id ,
|
||||
syn_ding_dept_id as synDingDeptId
|
||||
from region
|
||||
where (id > 0 or id = -3) and (deleted = 0 or syn_ding_dept_id is not null)
|
||||
<if test="parentId!=null">
|
||||
and region_path like concat('%/',#{parentId},'/%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getRegionByDingDeptIds" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
region_id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
region_type as regionType,
|
||||
deleted as deleted
|
||||
from region
|
||||
where deleted = 0
|
||||
and syn_ding_dept_id in (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getBySynDingDeptId" resultType="com.cool.store.entity.RegionDO">
|
||||
select
|
||||
id ,
|
||||
id as regionId,
|
||||
name as name ,
|
||||
parent_id as parentId,
|
||||
group_id as groupId,
|
||||
create_time as createTime,
|
||||
create_name as createName,
|
||||
update_time as updateTime,
|
||||
update_name as updateName,
|
||||
syn_ding_dept_id as synDingDeptId,
|
||||
store_id as storeId,
|
||||
region_type as regionType,
|
||||
region_path as regionPath,
|
||||
deleted,
|
||||
store_num as storeNum
|
||||
from region
|
||||
where syn_ding_dept_id = #{synDingDeptId}
|
||||
</select>
|
||||
|
||||
<insert id="ignoreInsert" keyColumn="id" keyProperty="region.id" useGeneratedKeys="true">
|
||||
insert ignore into region
|
||||
(
|
||||
region_id,
|
||||
name,
|
||||
parent_id,
|
||||
group_id,
|
||||
create_time,
|
||||
create_name
|
||||
<if test="region.regionPath !=null and region.regionPath!=''">
|
||||
,region_path
|
||||
</if>
|
||||
<if test="region.regionType !=null and region.regionType!=''">
|
||||
,region_type
|
||||
</if>
|
||||
<if test="region.storeId !=null and region.storeId!=''">
|
||||
,store_id
|
||||
</if>
|
||||
<if test="region.synDingDeptId !=null and region.synDingDeptId!=''">
|
||||
,syn_ding_dept_id
|
||||
</if>
|
||||
,order_num
|
||||
)
|
||||
values
|
||||
(
|
||||
#{region.regionId, jdbcType=VARCHAR},
|
||||
#{region.name, jdbcType=VARCHAR},
|
||||
#{region.parentId, jdbcType=VARCHAR},
|
||||
#{region.groupId, jdbcType=VARCHAR},
|
||||
#{region.createTime, jdbcType=BIGINT},
|
||||
#{region.createName, jdbcType=VARCHAR}
|
||||
<if test="region.regionPath !=null and region.regionPath!=''">
|
||||
,#{region.regionPath}
|
||||
</if>
|
||||
<if test="region.regionType !=null and region.regionType!=''">
|
||||
,#{region.regionType}
|
||||
</if>
|
||||
<if test="region.storeId !=null and region.storeId!=''">
|
||||
,#{region.storeId}
|
||||
</if>
|
||||
<if test="region.synDingDeptId !=null and region.synDingDeptId!=''">
|
||||
,#{region.synDingDeptId}
|
||||
</if>
|
||||
,(SELECT max(order_num)+1 FROM region AS num)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateSyncRegion" >
|
||||
update region
|
||||
set `parent_id` = #{item.parentId},
|
||||
`name` = #{item.name},
|
||||
<if test="item.regionType != null and item.regionType != ''">
|
||||
`region_type` = #{item.regionType},
|
||||
</if>
|
||||
`deleted` = #{item.deleted},
|
||||
`update_time` = #{item.updateTime},
|
||||
<if test="item.storeId != null and item.storeId != ''">
|
||||
store_id = #{item.storeId},
|
||||
</if>
|
||||
`region_path` = #{item.regionPath}
|
||||
where id = #{item.id}
|
||||
</update>
|
||||
|
||||
<update id="removeRegions">
|
||||
update region
|
||||
set
|
||||
deleted = 1,
|
||||
parent_id = -1
|
||||
where id in
|
||||
<foreach collection="regionIds" index="index" item="regionId"
|
||||
separator="," open="(" close=")">
|
||||
#{regionId, jdbcType=BIGINT}
|
||||
</foreach>
|
||||
and id != 1
|
||||
<update id="deleteNotExistRegion">
|
||||
update region set deleted = 1 , update_time = UNIX_TIMESTAMP() where region_id not in <foreach collection="regionIds" separator="," item="regionId" open="(" close=")"> #{regionId}</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,258 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cool.store.mapper.SysDepartmentMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.SysDepartmentDO">
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId"/>
|
||||
<result column="depart_order" jdbcType="INTEGER" property="departOrder"/>
|
||||
<result column="create_dept_group" jdbcType="BIT" property="createDeptGroup"/>
|
||||
<result column="auto_add_user" jdbcType="BIT" property="autoAddUser"/>
|
||||
<result column="dep_Hiding" jdbcType="BIT" property="depHiding"/>
|
||||
<result column="dept_perimits" jdbcType="VARCHAR" property="deptPerimits"/>
|
||||
<result column="user_perimits" jdbcType="VARCHAR" property="userPerimits"/>
|
||||
<result column="outer_dept" jdbcType="BIT" property="outerDept"/>
|
||||
<result column="outer_permit_depts" jdbcType="VARCHAR" property="outerPermitDepts"/>
|
||||
<result column="outer_permit_users" jdbcType="VARCHAR" property="outerPermitUsers"/>
|
||||
<result column="org_dept_owner" jdbcType="VARCHAR" property="orgDeptOwner"/>
|
||||
<result column="dept_manager_userid_list" jdbcType="VARCHAR" property="deptManagerUseridList"/>
|
||||
<result column="user_count" jdbcType="INTEGER" property="userCount"/>
|
||||
<result column="unactive_user_count" jdbcType="INTEGER" property="unactiveUserCount"/>
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.cool.store.entity.SysDepartmentDO">
|
||||
<result column="parent_ids" jdbcType="LONGVARCHAR" property="parentIds"/>
|
||||
<result column="sub_ids" jdbcType="LONGVARCHAR" property="subIds"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, name, parent_id, depart_order, create_dept_group, auto_add_user, dep_Hiding,
|
||||
dept_perimits, user_perimits, outer_dept, outer_permit_depts, outer_permit_users,
|
||||
org_dept_owner, dept_manager_userid_list, user_count, unactive_user_count
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
parent_ids, sub_ids
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_department
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.departOrder != null">
|
||||
depart_order,
|
||||
</if>
|
||||
<if test="record.createDeptGroup != null">
|
||||
create_dept_group,
|
||||
</if>
|
||||
<if test="record.autoAddUser != null">
|
||||
auto_add_user,
|
||||
</if>
|
||||
<if test="record.depHiding != null">
|
||||
dep_Hiding,
|
||||
</if>
|
||||
<if test="record.deptPerimits != null">
|
||||
dept_perimits,
|
||||
</if>
|
||||
<if test="record.userPerimits != null">
|
||||
user_perimits,
|
||||
</if>
|
||||
<if test="record.outerDept != null">
|
||||
outer_dept,
|
||||
</if>
|
||||
<if test="record.outerPermitDepts != null">
|
||||
outer_permit_depts,
|
||||
</if>
|
||||
<if test="record.outerPermitUsers != null">
|
||||
outer_permit_users,
|
||||
</if>
|
||||
<if test="record.orgDeptOwner != null">
|
||||
org_dept_owner,
|
||||
</if>
|
||||
<if test="record.deptManagerUseridList != null">
|
||||
dept_manager_userid_list,
|
||||
</if>
|
||||
<if test="record.userCount != null">
|
||||
user_count,
|
||||
</if>
|
||||
<if test="record.unactiveUserCount != null">
|
||||
unactive_user_count,
|
||||
</if>
|
||||
<if test="record.parentIds != null">
|
||||
parent_ids,
|
||||
</if>
|
||||
<if test="record.subIds != null">
|
||||
sub_ids,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.departOrder != null">
|
||||
#{record.departOrder},
|
||||
</if>
|
||||
<if test="record.createDeptGroup != null">
|
||||
#{record.createDeptGroup},
|
||||
</if>
|
||||
<if test="record.autoAddUser != null">
|
||||
#{record.autoAddUser},
|
||||
</if>
|
||||
<if test="record.depHiding != null">
|
||||
#{record.depHiding},
|
||||
</if>
|
||||
<if test="record.deptPerimits != null">
|
||||
#{record.deptPerimits},
|
||||
</if>
|
||||
<if test="record.userPerimits != null">
|
||||
#{record.userPerimits},
|
||||
</if>
|
||||
<if test="record.outerDept != null">
|
||||
#{record.outerDept},
|
||||
</if>
|
||||
<if test="record.outerPermitDepts != null">
|
||||
#{record.outerPermitDepts},
|
||||
</if>
|
||||
<if test="record.outerPermitUsers != null">
|
||||
#{record.outerPermitUsers},
|
||||
</if>
|
||||
<if test="record.orgDeptOwner != null">
|
||||
#{record.orgDeptOwner},
|
||||
</if>
|
||||
<if test="record.deptManagerUseridList != null">
|
||||
#{record.deptManagerUseridList},
|
||||
</if>
|
||||
<if test="record.userCount != null">
|
||||
#{record.userCount},
|
||||
</if>
|
||||
<if test="record.unactiveUserCount != null">
|
||||
#{record.unactiveUserCount},
|
||||
</if>
|
||||
<if test="record.parentIds != null">
|
||||
#{record.parentIds},
|
||||
</if>
|
||||
<if test="record.subIds != null">
|
||||
#{record.subIds},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_department
|
||||
<set>
|
||||
<if test="record.name != null">
|
||||
name = #{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId},
|
||||
</if>
|
||||
<if test="record.departOrder != null">
|
||||
depart_order = #{record.departOrder},
|
||||
</if>
|
||||
<if test="record.createDeptGroup != null">
|
||||
create_dept_group = #{record.createDeptGroup},
|
||||
</if>
|
||||
<if test="record.autoAddUser != null">
|
||||
auto_add_user = #{record.autoAddUser},
|
||||
</if>
|
||||
<if test="record.depHiding != null">
|
||||
dep_Hiding = #{record.depHiding},
|
||||
</if>
|
||||
<if test="record.deptPerimits != null">
|
||||
dept_perimits = #{record.deptPerimits},
|
||||
</if>
|
||||
<if test="record.userPerimits != null">
|
||||
user_perimits = #{record.userPerimits},
|
||||
</if>
|
||||
<if test="record.outerDept != null">
|
||||
outer_dept = #{record.outerDept},
|
||||
</if>
|
||||
<if test="record.outerPermitDepts != null">
|
||||
outer_permit_depts = #{record.outerPermitDepts},
|
||||
</if>
|
||||
<if test="record.outerPermitUsers != null">
|
||||
outer_permit_users = #{record.outerPermitUsers},
|
||||
</if>
|
||||
<if test="record.orgDeptOwner != null">
|
||||
org_dept_owner = #{record.orgDeptOwner},
|
||||
</if>
|
||||
<if test="record.deptManagerUseridList != null">
|
||||
dept_manager_userid_list = #{record.deptManagerUseridList},
|
||||
</if>
|
||||
<if test="record.userCount != null">
|
||||
user_count = #{record.userCount},
|
||||
</if>
|
||||
<if test="record.unactiveUserCount != null">
|
||||
unactive_user_count = #{record.unactiveUserCount},
|
||||
</if>
|
||||
<if test="record.parentIds != null">
|
||||
parent_ids = #{record.parentIds},
|
||||
</if>
|
||||
<if test="record.subIds != null">
|
||||
sub_ids = #{record.subIds},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
</update>
|
||||
|
||||
<insert id="batchInsertOrUpdate" parameterType="java.util.List">
|
||||
insert into sys_department
|
||||
(
|
||||
id,
|
||||
name,
|
||||
parent_id,
|
||||
depart_order,
|
||||
auto_add_user
|
||||
) values
|
||||
<foreach collection="list" item="it" separator=",">
|
||||
(
|
||||
#{it.id, jdbcType=BIGINT},
|
||||
#{it.name, jdbcType=VARCHAR},
|
||||
#{it.parentId, jdbcType=BIGINT},
|
||||
#{it.departOrder, jdbcType=INTEGER},
|
||||
#{it.autoAddUser, jdbcType=BOOLEAN}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE name=values(name), parent_id=values(parent_id)
|
||||
</insert>
|
||||
|
||||
<select id="getDeptChildListByParentId"
|
||||
resultType="com.cool.store.dto.enterprise.QueryDeptChildDTO">
|
||||
select
|
||||
id,
|
||||
name,
|
||||
depart_order as departOrder,
|
||||
parent_id as parentId
|
||||
from sys_department
|
||||
where parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByNotInIds">
|
||||
delete from sys_department
|
||||
where id not in
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")" >
|
||||
#{item}
|
||||
</foreach>
|
||||
and id != '1'
|
||||
</delete>
|
||||
|
||||
<select id="getSyncDeptTreeList" resultType="com.cool.store.dto.dept.SyncTreeNode">
|
||||
select
|
||||
id,
|
||||
name,
|
||||
parent_id as pid
|
||||
from sys_department
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultType="com.cool.store.entity.SysDepartmentDO">
|
||||
select
|
||||
id,
|
||||
name,
|
||||
parent_id as parentId,
|
||||
depart_order as departOrder
|
||||
from sys_department
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -3,51 +3,38 @@
|
||||
<mapper namespace="com.cool.store.mapper.SysRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.cool.store.entity.SysRoleDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="role_id" jdbcType="VARCHAR" property="roleId"/>
|
||||
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
|
||||
<result column="is_internal" jdbcType="BIT" property="isInternal"/>
|
||||
<result column="role_auth" jdbcType="VARCHAR" property="roleAuth"/>
|
||||
<result column="source" jdbcType="CHAR" property="source"/>
|
||||
<result column="position_type" jdbcType="VARCHAR" property="positionType"/>
|
||||
<result column="app_menu" jdbcType="VARCHAR" property="appMenu"/>
|
||||
<result column="syn_ding_role_id" jdbcType="BIGINT" property="synDingRoleId"/>
|
||||
<result column="priority" jdbcType="INTEGER" property="priority"/>
|
||||
<result column="role_type" jdbcType="TINYINT" property="roleType"/>
|
||||
<result column="third_unique_id" jdbcType="VARCHAR" property="thirdUniqueId"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="role_enum" jdbcType="VARCHAR" property="roleEnum"/>
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
|
||||
<result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
|
||||
<result column="third_unique_id" jdbcType="VARCHAR" property="thirdUniqueId"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, role_name, is_internal, role_auth, source, position_type, app_menu, syn_ding_role_id,
|
||||
priority, create_time, update_time, role_enum, create_user, update_user, third_unique_id
|
||||
id, role_id, role_name, role_type, third_unique_id, deleted, create_time, update_time, create_user,
|
||||
update_user
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
<insert id="batchInsertSelective">
|
||||
<foreach collection="insertOrUpdateList" separator=";" item="record">
|
||||
insert into sys_role
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="record.roleName != null">
|
||||
role_name,
|
||||
</if>
|
||||
<if test="record.isInternal != null">
|
||||
is_internal,
|
||||
<if test="record.roleType != null">
|
||||
role_type,
|
||||
</if>
|
||||
<if test="record.roleAuth != null">
|
||||
role_auth,
|
||||
<if test="record.thirdUniqueId != null">
|
||||
third_unique_id,
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
source,
|
||||
</if>
|
||||
<if test="record.positionType != null">
|
||||
position_type,
|
||||
</if>
|
||||
<if test="record.appMenu != null">
|
||||
app_menu,
|
||||
</if>
|
||||
<if test="record.synDingRoleId != null">
|
||||
syn_ding_role_id,
|
||||
</if>
|
||||
<if test="record.priority != null">
|
||||
priority,
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
@@ -55,43 +42,28 @@
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.roleEnum != null">
|
||||
role_enum,
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
create_user,
|
||||
</if>
|
||||
<if test="record.updateUser != null">
|
||||
update_user,
|
||||
</if>
|
||||
<if test="record.thirdUniqueId != null">
|
||||
third_unique_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
#{record.roleId},
|
||||
</if>
|
||||
<if test="record.roleName != null">
|
||||
#{record.roleName},
|
||||
</if>
|
||||
<if test="record.isInternal != null">
|
||||
#{record.isInternal},
|
||||
<if test="record.roleType != null">
|
||||
#{record.roleType},
|
||||
</if>
|
||||
<if test="record.roleAuth != null">
|
||||
#{record.roleAuth},
|
||||
<if test="record.thirdUniqueId != null">
|
||||
#{record.thirdUniqueId},
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
#{record.source},
|
||||
</if>
|
||||
<if test="record.positionType != null">
|
||||
#{record.positionType},
|
||||
</if>
|
||||
<if test="record.appMenu != null">
|
||||
#{record.appMenu},
|
||||
</if>
|
||||
<if test="record.synDingRoleId != null">
|
||||
#{record.synDingRoleId},
|
||||
</if>
|
||||
<if test="record.priority != null">
|
||||
#{record.priority},
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
@@ -99,102 +71,62 @@
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.roleEnum != null">
|
||||
#{record.roleEnum},
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
#{record.createUser},
|
||||
</if>
|
||||
<if test="record.updateUser != null">
|
||||
#{record.updateUser},
|
||||
</if>
|
||||
<if test="record.thirdUniqueId != null">
|
||||
#{record.thirdUniqueId},
|
||||
</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE role_name = values(role_name), deleted = values(deleted)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_role
|
||||
<set>
|
||||
<if test="record.roleName != null">
|
||||
role_name = #{record.roleName},
|
||||
<if test="roleId != null">
|
||||
role_id = #{roleId},
|
||||
</if>
|
||||
<if test="record.isInternal != null">
|
||||
is_internal = #{record.isInternal},
|
||||
<if test="roleName != null">
|
||||
role_name = #{roleName},
|
||||
</if>
|
||||
<if test="record.roleAuth != null">
|
||||
role_auth = #{record.roleAuth},
|
||||
<if test="roleType != null">
|
||||
role_type = #{roleType},
|
||||
</if>
|
||||
<if test="record.source != null">
|
||||
source = #{record.source},
|
||||
<if test="thirdUniqueId != null">
|
||||
third_unique_id = #{thirdUniqueId},
|
||||
</if>
|
||||
<if test="record.positionType != null">
|
||||
position_type = #{record.positionType},
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
<if test="record.appMenu != null">
|
||||
app_menu = #{record.appMenu},
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="record.synDingRoleId != null">
|
||||
syn_ding_role_id = #{record.synDingRoleId},
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="record.priority != null">
|
||||
priority = #{record.priority},
|
||||
<if test="createUser != null">
|
||||
create_user = #{createUser},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
</if>
|
||||
<if test="record.roleEnum != null">
|
||||
role_enum = #{record.roleEnum},
|
||||
</if>
|
||||
<if test="record.createUser != null">
|
||||
create_user = #{record.createUser},
|
||||
</if>
|
||||
<if test="record.updateUser != null">
|
||||
update_user = #{record.updateUser},
|
||||
</if>
|
||||
<if test="record.thirdUniqueId != null">
|
||||
third_unique_id = #{record.thirdUniqueId},
|
||||
<if test="updateUser != null">
|
||||
update_user = #{updateUser},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getHighestPrioritySysRoleDoByUserId" resultMap="BaseResultMap">
|
||||
select
|
||||
c.id as id,
|
||||
c.role_name as roleName,
|
||||
c.role_auth as roleAuth,
|
||||
c.position_type as positionType,
|
||||
c.app_menu as appMenu,
|
||||
c.role_enum as roleEnum
|
||||
from
|
||||
enterprise_user a
|
||||
left join enterprise_user_role b on a.user_id =b.user_id
|
||||
left join sys_role c on c.id=b.role_id
|
||||
where
|
||||
a.user_id= #{userId} and a.active = true
|
||||
order by
|
||||
c.priority is null, c.priority, position_type desc
|
||||
LIMIT 1
|
||||
</select>
|
||||
<update id="deleteRole">
|
||||
update sys_role set deleted = 1 where role_type = #{roleType} and role_id not in
|
||||
<foreach collection="roleIds" open="(" close=")" separator="," item="roleId">#{roleId}</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getRoleByRoleEnum" resultMap="BaseResultMap">
|
||||
<select id="getHighestPriorityRoleByUserId" resultMap="BaseResultMap">
|
||||
select
|
||||
id as id,
|
||||
role_name as roleName,
|
||||
role_auth as roleAuth,
|
||||
is_internal as isInternal,
|
||||
`source` as source,
|
||||
priority as priority,
|
||||
app_menu as appMenu,
|
||||
position_type as positionType,
|
||||
role_enum as roleEnum
|
||||
r.*
|
||||
from
|
||||
sys_role
|
||||
sys_role r inner join enterprise_user_role e on r.role_id = e.role_id
|
||||
where
|
||||
role_enum = #{roleEnum}
|
||||
e.user_id = #{userId}
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -5,15 +5,18 @@
|
||||
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||
<result column="region_id" jdbcType="VARCHAR" property="regionId"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="type" jdbcType="INTEGER" property="type"/>
|
||||
<result column="deleted" jdbcType="BIT" property="deleted"/>
|
||||
<result column="create_id" jdbcType="VARCHAR" property="createId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
<result column="update_id" jdbcType="VARCHAR" property="updateId"/>
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, region_id, user_id, create_id, create_time, update_id, update_time
|
||||
id, region_id, user_id, type, deleted, create_id, create_time, update_id, update_time
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
<insert id="batchInsertOrUpdateUserRegion">
|
||||
<foreach collection="insertOrUpdateList" item="record" separator=";">
|
||||
insert into user_region_mapping
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
@@ -22,6 +25,12 @@
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
type,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
create_id,
|
||||
</if>
|
||||
@@ -42,6 +51,12 @@
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
#{record.type},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
#{record.createId},
|
||||
</if>
|
||||
@@ -55,78 +70,44 @@
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE type = values(type), deleted = values(deleted)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update user_region_mapping
|
||||
<set>
|
||||
<if test="record.regionId != null">
|
||||
region_id = #{record.regionId},
|
||||
<if test="regionId != null">
|
||||
region_id = #{regionId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId},
|
||||
<if test="userId != null">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="record.createId != null">
|
||||
create_id = #{record.createId},
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime},
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
<if test="record.updateId != null">
|
||||
update_id = #{record.updateId},
|
||||
<if test="createId != null">
|
||||
create_id = #{createId},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime},
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateId != null">
|
||||
update_id = #{updateId},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{record.id}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletedByUserIds">
|
||||
delete from user_region_mapping where user_id in
|
||||
<foreach collection="userIds" open="(" close=")" separator="," item="userId">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchInsertRegionMapping">
|
||||
insert into user_region_mapping
|
||||
(
|
||||
region_id,
|
||||
user_id,
|
||||
create_time,
|
||||
update_time,
|
||||
create_id,
|
||||
update_id
|
||||
)
|
||||
values
|
||||
<foreach collection="userRegionMappingDOS" item="entity" separator=",">
|
||||
(
|
||||
#{entity.regionId},
|
||||
#{entity.userId},
|
||||
#{entity.createTime},
|
||||
#{entity.updateTime},
|
||||
#{entity.createId},
|
||||
#{entity.updateId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="listUserRegionMappingByUserId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from user_region_mapping
|
||||
<if test="userIds !=null and userIds.size >0">
|
||||
where user_id in
|
||||
<foreach collection="userIds" open="(" close=")" separator="," item="userId">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<delete id="deleteUserRegion">
|
||||
update user_region_mapping set deleted = 1 where region_id = #{regionId} and type = #{type}
|
||||
<if test="excludeUserIds != null and excludeUserIds.size() > 0">
|
||||
and user_id not in <foreach collection="excludeUserIds" separator="," open="(" close=")" item="userId" >#{userId}</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<delete id="deletedByIds">
|
||||
delete from user_region_mapping where id in
|
||||
<foreach collection="ids" open="(" close=")" separator="," item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -3,4 +3,4 @@ jdbc.url = jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcoll
|
||||
jdbc.user= coolstore
|
||||
jdbc.password = CSCErYcXniNYm7bT
|
||||
|
||||
table.name = enterprise_user
|
||||
table.name = enterprise_user_role
|
||||
@@ -2,16 +2,20 @@ package com.cool.store.dto.enterprise;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.enums.UserStatusEnum;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -24,12 +28,6 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class EnterpriseUserDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty("分机号")
|
||||
private String tel;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String workPlace;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@@ -39,21 +37,18 @@ public class EnterpriseUserDTO implements Serializable {
|
||||
@ApiModelProperty("钉钉用户id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("手机号码")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("是否已经激活, true表示已激活, false表示未激活")
|
||||
private Boolean active;
|
||||
|
||||
@ApiModelProperty("是否是主管理员,0:否,1:是")
|
||||
private Byte mainAdmin;
|
||||
private Boolean mainAdmin;
|
||||
|
||||
@ApiModelProperty("是否为企业的管理员, true表示是, false表示不是")
|
||||
private Boolean isAdmin;
|
||||
|
||||
@ApiModelProperty("手机号码")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("员工的电子邮箱")
|
||||
private String email;
|
||||
|
||||
@@ -63,18 +58,12 @@ public class EnterpriseUserDTO implements Serializable {
|
||||
@ApiModelProperty("是否号码隐藏, true表示隐藏, false表示不隐藏")
|
||||
private Boolean isHide;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String position;
|
||||
@ApiModelProperty("职务")
|
||||
private String jobTitle;
|
||||
|
||||
@ApiModelProperty("员工的企业邮箱")
|
||||
private String orgEmail;
|
||||
|
||||
@ApiModelProperty("是否为企业的老板, true表示是, false表示不是")
|
||||
private Boolean isBoss;
|
||||
|
||||
@ApiModelProperty("钉钉Id,在钉钉全局范围内标识用户的身份,但用户可以自行修改一次")
|
||||
private String dingid;
|
||||
|
||||
@ApiModelProperty("头像url")
|
||||
private String avatar;
|
||||
|
||||
@@ -84,12 +73,6 @@ public class EnterpriseUserDTO implements Serializable {
|
||||
@ApiModelProperty("是否是部门的主管, true表示是, false表示不是")
|
||||
private Boolean isLeader;
|
||||
|
||||
@ApiModelProperty("扩展属性,可以设置多种属性(但手机上最多只能显示10个扩展属性,具体显示哪些属性,请到OA管理后台->设置->通讯录信息设置和OA管理后台->设置->手机端显示信息设置)性")
|
||||
private String extattr;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private Boolean isEnterprise;
|
||||
|
||||
@ApiModelProperty("用户创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@@ -102,15 +85,6 @@ public class EnterpriseUserDTO implements Serializable {
|
||||
@ApiModelProperty("")
|
||||
private List<String> isLeaderInDepts;
|
||||
|
||||
@ApiModelProperty("用户语言环境:en_us/英语_美国,zh_cn/中文_简体,zh_hk/中文_繁体_HK")
|
||||
private String language;
|
||||
|
||||
@ApiModelProperty("用户来源:默认dingding钉钉,qw企业微信 mobile")
|
||||
private String appType;
|
||||
|
||||
@ApiModelProperty("登录密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String monitoredDepartments;
|
||||
|
||||
@@ -122,53 +96,49 @@ public class EnterpriseUserDTO implements Serializable {
|
||||
@ApiModelProperty("")
|
||||
private List<String> departmentLists;
|
||||
|
||||
/**
|
||||
* 管理范围
|
||||
*/
|
||||
private List<Long> scopeList;
|
||||
|
||||
private List<Long> storeList;
|
||||
|
||||
|
||||
public static EnterpriseUserDO transUserDtoToDo(EnterpriseUserDTO enterpriseUserDTO) {
|
||||
public static List<EnterpriseUserDO> transUserDtoToDo(List<EnterpriseUserDTO> userList, Map<String, String> regionPathMap, Multimap<String, String> leaderDeptMap, Multimap<String, String> roleUserMap) {
|
||||
if(CollectionUtils.isEmpty(userList)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<EnterpriseUserDO> resultList = new ArrayList<>();
|
||||
for (EnterpriseUserDTO user : userList) {
|
||||
EnterpriseUserDO enterpriseUserDO = new EnterpriseUserDO();
|
||||
enterpriseUserDO.setRemark(enterpriseUserDTO.getRemark());
|
||||
enterpriseUserDO.setPosition(enterpriseUserDTO.getPosition());
|
||||
enterpriseUserDO.setMobile(enterpriseUserDTO.getMobile());
|
||||
enterpriseUserDO.setId(UUIDUtils.get32UUID());
|
||||
enterpriseUserDO.setUserId(enterpriseUserDTO.getUserId());
|
||||
enterpriseUserDO.setName(enterpriseUserDTO.getName());
|
||||
enterpriseUserDO.setEmail(enterpriseUserDTO.getEmail());
|
||||
enterpriseUserDO.setOrgEmail(enterpriseUserDTO.getOrgEmail());
|
||||
enterpriseUserDO.setUnionid(enterpriseUserDTO.getUnionid());
|
||||
enterpriseUserDO.setAvatar(enterpriseUserDTO.getAvatar());
|
||||
enterpriseUserDO.setUserId(user.getUserId());
|
||||
enterpriseUserDO.setName(user.getName());
|
||||
enterpriseUserDO.setRemark(user.getRemark());
|
||||
enterpriseUserDO.setMobile(user.getMobile());
|
||||
enterpriseUserDO.setEmail(user.getEmail());
|
||||
enterpriseUserDO.setOrgEmail(user.getOrgEmail());
|
||||
enterpriseUserDO.setMainAdmin(user.getMainAdmin());
|
||||
enterpriseUserDO.setIsAdmin(user.getIsAdmin());
|
||||
enterpriseUserDO.setUnionid(user.getUnionid());
|
||||
enterpriseUserDO.setAvatar(user.getAvatar());
|
||||
enterpriseUserDO.setJobnumber(user.getJobnumber());
|
||||
enterpriseUserDO.setUserStatus(UserStatusEnum.NORMAL.getCode());
|
||||
enterpriseUserDO.setIsLeader(Boolean.FALSE);
|
||||
List<String> departmentLists = user.getDepartmentLists();
|
||||
List<String> regionPaths = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(departmentLists)){
|
||||
for (String departmentId : departmentLists) {
|
||||
regionPaths.add(regionPathMap.get(departmentId));
|
||||
}
|
||||
}
|
||||
Collection<String> deptIds = leaderDeptMap.get(user.getUserId());
|
||||
if(CollectionUtils.isNotEmpty(deptIds)){
|
||||
enterpriseUserDO.setIsLeader(Boolean.TRUE);
|
||||
enterpriseUserDO.setLeaderDeptIds(JSONObject.toJSONString(deptIds));
|
||||
}
|
||||
enterpriseUserDO.setUserRegionIds(JSONObject.toJSONString(regionPaths));
|
||||
enterpriseUserDO.setDeleted(Boolean.FALSE);
|
||||
enterpriseUserDO.setCreateTime(new Date());
|
||||
enterpriseUserDO.setJobnumber(enterpriseUserDTO.getJobnumber());
|
||||
return enterpriseUserDO;
|
||||
if(StringUtils.isNotBlank(user.getJobTitle())){
|
||||
roleUserMap.put(user.getJobTitle(), user.getUserId());
|
||||
}
|
||||
|
||||
|
||||
public static EnterpriseUserDO convertEnterpriseUserDTO2EnterpriseUserDO(EnterpriseUserDTO dto){
|
||||
if(dto == null){
|
||||
return null;
|
||||
resultList.add(enterpriseUserDO);
|
||||
}
|
||||
EnterpriseUserDO enterpriseUserDO = new EnterpriseUserDO();
|
||||
enterpriseUserDO.setName(dto.getName());
|
||||
enterpriseUserDO.setId(dto.getId());
|
||||
enterpriseUserDO.setUserId(dto.getUserId());
|
||||
enterpriseUserDO.setRemark(dto.getRemark());
|
||||
enterpriseUserDO.setMobile(dto.getMobile());
|
||||
enterpriseUserDO.setEmail(dto.getEmail());
|
||||
enterpriseUserDO.setOrgEmail(dto.getOrgEmail());
|
||||
enterpriseUserDO.setIsAdmin(dto.getIsAdmin());
|
||||
enterpriseUserDO.setUnionid(dto.getUnionid());
|
||||
enterpriseUserDO.setPosition(dto.getPosition());
|
||||
enterpriseUserDO.setAvatar(dto.getAvatar());
|
||||
enterpriseUserDO.setIsLeader(dto.getIsLeader());
|
||||
enterpriseUserDO.setCreateTime(dto.getCreateTime());
|
||||
enterpriseUserDO.setJobnumber(dto.getJobnumber());
|
||||
return enterpriseUserDO;
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.cool.store.dto.enterprise;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,7 +87,7 @@ public class SysDepartmentDTO {
|
||||
/**
|
||||
* 部门的主管列表,取值为由主管的userid组成的字符串,不同的userid使用|符号进行分割
|
||||
*/
|
||||
private String deptManagerUseridList;
|
||||
private List<String> deptManagerUseridList;
|
||||
|
||||
|
||||
/**
|
||||
@@ -105,6 +110,8 @@ public class SysDepartmentDTO {
|
||||
*/
|
||||
private String subIds;
|
||||
|
||||
private String leaderUserId;
|
||||
|
||||
|
||||
public SysDepartmentDTO() {
|
||||
|
||||
@@ -182,4 +189,42 @@ public class SysDepartmentDTO {
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
public static List<RegionDO> convertRegionDO(List<SysDepartmentDTO> departmentList, Multimap<String, String> leaderDeptMap){
|
||||
if(CollectionUtils.isEmpty(departmentList)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Map<String, String> parentMap = departmentList.stream().collect(Collectors.toMap(SysDepartmentDTO::getId, SysDepartmentDTO::getParentId));
|
||||
List<RegionDO> resultList = new ArrayList<>();
|
||||
for (SysDepartmentDTO dept : departmentList) {
|
||||
RegionDO region = new RegionDO();
|
||||
region.setRegionId(dept.getId());
|
||||
region.setName(dept.getName());
|
||||
region.setParentId(dept.getParentId());
|
||||
region.setUnclassifiedFlag(CommonConstants.ZERO);
|
||||
region.setLeaderUserId(dept.getLeaderUserId());
|
||||
region.setOrderNum(dept.getDepartOrder());
|
||||
region.setThirdDeptId(dept.getId());
|
||||
region.setCreateTime(System.currentTimeMillis());
|
||||
region.setUpdateTime(System.currentTimeMillis());
|
||||
List<String> pathIds = new ArrayList<>();
|
||||
pathIds.add(region.getRegionId());
|
||||
String parentId = parentMap.get(region.getRegionId());
|
||||
while (Objects.nonNull(parentId)){
|
||||
pathIds.add(parentId);
|
||||
parentId = parentMap.get(parentId);
|
||||
}
|
||||
Collections.reverse(pathIds);
|
||||
String regionPath = CommonConstants.PATH_SPILT + String.join(CommonConstants.PATH_SPILT, pathIds) + CommonConstants.PATH_SPILT;
|
||||
region.setRegionPath(regionPath);
|
||||
region.setDeleted(Boolean.TRUE);
|
||||
if(CollectionUtils.isNotEmpty(dept.getDeptManagerUseridList())){
|
||||
for (String leader : dept.getDeptManagerUseridList()) {
|
||||
leaderDeptMap.put(leader, dept.getId());
|
||||
}
|
||||
}
|
||||
resultList.add(region);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.cool.store.dto.region;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* @author byd
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RegionDTO {
|
||||
/**
|
||||
* 自增ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
|
||||
/**
|
||||
* dinging部门id
|
||||
*/
|
||||
private String synDingDeptId;
|
||||
|
||||
/**
|
||||
* 是否删除标记
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
/**
|
||||
* 区域门店数量
|
||||
*/
|
||||
private Integer storeNum;
|
||||
|
||||
/**
|
||||
* 区域门店范围是否
|
||||
*/
|
||||
private Boolean storeRange = false;
|
||||
|
||||
/**
|
||||
* 门店地址 非DO
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 门店经度 非DO
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
|
||||
/**
|
||||
* 纬度 非DO
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
/**
|
||||
* 门店编号 非DO
|
||||
*/
|
||||
private String storeCode;
|
||||
|
||||
|
||||
/**
|
||||
* 大区名称
|
||||
*/
|
||||
private String zoneName;
|
||||
|
||||
/**
|
||||
* brand 主品牌
|
||||
*/
|
||||
private String brand;
|
||||
|
||||
/**
|
||||
* 管理分区
|
||||
*/
|
||||
private String mangerCity;
|
||||
|
||||
/**
|
||||
* 经营城市
|
||||
*/
|
||||
private String bizCity;
|
||||
|
||||
/**
|
||||
* 省区
|
||||
*/
|
||||
private String provinceName;
|
||||
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.cool.store.dto.region;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName RegionNode
|
||||
* @Description 用一句话描述什么
|
||||
*/
|
||||
@Data
|
||||
public class RegionNode {
|
||||
/**
|
||||
* 自增ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 区域ID
|
||||
*/
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long createTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Long updateTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateName;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<RegionNode> children;
|
||||
|
||||
/**
|
||||
* 是否有区域权限
|
||||
*/
|
||||
private Boolean isAuth;
|
||||
|
||||
/**
|
||||
* 门店数量
|
||||
*/
|
||||
private Long storeCount;
|
||||
|
||||
/**
|
||||
* dinging部门id
|
||||
*/
|
||||
private String synDingDeptId;
|
||||
|
||||
/**
|
||||
* root path store
|
||||
*/
|
||||
private String regionType;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String regionPath;
|
||||
|
||||
private String fullRegionPath;
|
||||
|
||||
public String getFullRegionPath() {
|
||||
if(id != null && id == 1L){
|
||||
return "/1/";
|
||||
}
|
||||
if (StringUtils.isNotBlank(regionPath)) {
|
||||
return regionPath + id + "/";
|
||||
} else {
|
||||
return "/" + id + "/";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.cool.store.dto.region;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 邵凌志
|
||||
* @date 2020/12/22 13:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RegionPathDTO {
|
||||
|
||||
private String regionId;
|
||||
|
||||
private String regionPath;
|
||||
|
||||
private Integer storeNum;
|
||||
|
||||
private String regionName;
|
||||
|
||||
private String regionType;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.cool.store.dto.region;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* describe:
|
||||
*
|
||||
* @author zhouyiping
|
||||
* @date 2021/05/31
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class RegionStoreNumMsgDTO {
|
||||
private String eid;
|
||||
private List<Long> regionIdList;
|
||||
public RegionStoreNumMsgDTO(){}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.cool.store.dto.region;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 邵凌志
|
||||
* @date 2020/12/22 13:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RegionSyncDTO {
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 区域钉钉id
|
||||
*/
|
||||
private String synDingDeptId;
|
||||
}
|
||||
@@ -48,9 +48,6 @@ public class EnterpriseUserDO implements Serializable {
|
||||
@ApiModelProperty("在当前isv全局范围内唯一标识一个用户的身份,用户无法修改")
|
||||
private String unionid;
|
||||
|
||||
@ApiModelProperty("")
|
||||
private String position;
|
||||
|
||||
@ApiModelProperty("头像url")
|
||||
private String avatar;
|
||||
|
||||
@@ -60,6 +57,9 @@ public class EnterpriseUserDO implements Serializable {
|
||||
@ApiModelProperty("是否是部门的主管, true表示是, false表示不是")
|
||||
private Boolean isLeader;
|
||||
|
||||
@ApiModelProperty("管理的部门列表")
|
||||
private String leaderDeptIds;
|
||||
|
||||
@ApiModelProperty("人脸照片url")
|
||||
private String faceUrl;
|
||||
|
||||
|
||||
@@ -1,36 +1,60 @@
|
||||
package com.cool.store.entity;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
* @date 2023-06-08 10:54
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EnterpriseUserRoleDO implements Serializable {
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private Long roleId;
|
||||
private String roleId;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("删除标识")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
public static List<EnterpriseUserRoleDO> convertDO(String roleId, List<String> userIds){
|
||||
if(CollectionUtils.isEmpty(userIds)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<EnterpriseUserRoleDO> resultList = new ArrayList<>();
|
||||
for (String userId : userIds) {
|
||||
EnterpriseUserRoleDO userRole = new EnterpriseUserRoleDO();
|
||||
userRole.setRoleId(roleId);
|
||||
userRole.setUserId(userId);
|
||||
userRole.setDeleted(Boolean.FALSE);
|
||||
userRole.setCreateTime(new Date());
|
||||
userRole.setUpdateTime(new Date());
|
||||
resultList.add(userRole);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.cool.store.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-23 03:46
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginRecordDO implements Serializable {
|
||||
@ApiModelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
}
|
||||
@@ -6,19 +6,17 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 02:59
|
||||
* @date 2023-06-07 02:07
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RegionDO implements Serializable {
|
||||
|
||||
@ApiModelProperty("自增ID")
|
||||
private Long id;
|
||||
|
||||
@@ -31,8 +29,20 @@ public class RegionDO implements Serializable {
|
||||
@ApiModelProperty("父区域id")
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty("阿里云分组id")
|
||||
private String groupId;
|
||||
@ApiModelProperty("区域路径")
|
||||
private String regionPath;
|
||||
|
||||
@ApiModelProperty("未分组标志 0 分组 1 未分组")
|
||||
private Integer unclassifiedFlag;
|
||||
|
||||
@ApiModelProperty("部门负责人")
|
||||
private String leaderUserId;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer orderNum;
|
||||
|
||||
@ApiModelProperty("第三方唯一id")
|
||||
private String thirdDeptId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
@@ -46,67 +56,6 @@ public class RegionDO implements Serializable {
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateName;
|
||||
|
||||
@ApiModelProperty("vds分组id")
|
||||
private String vdsGroupCorpId;
|
||||
|
||||
@ApiModelProperty("dinging部门id")
|
||||
private String synDingDeptId;
|
||||
|
||||
@ApiModelProperty("区域类型 root 根目录 path 区域 store 门店")
|
||||
private String regionType;
|
||||
|
||||
@ApiModelProperty("区域路径")
|
||||
private String regionPath;
|
||||
|
||||
@ApiModelProperty("删除标记")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("门店数量")
|
||||
private Integer storeNum;
|
||||
|
||||
@ApiModelProperty("门店ID")
|
||||
private String storeId;
|
||||
|
||||
@ApiModelProperty("未分组标志 0 分组 1 未分组")
|
||||
private Integer unclassifiedFlag;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer orderNum;
|
||||
|
||||
@ApiModelProperty("第三方唯一id")
|
||||
private String thirdDeptId;
|
||||
|
||||
private Boolean storeRange = false;
|
||||
|
||||
/**
|
||||
* 门店地址 非DO
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 门店经度 非DO
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
|
||||
/**
|
||||
* 纬度 非DO
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
/**
|
||||
* 门店编号 非DO
|
||||
*/
|
||||
private String storeCode;
|
||||
|
||||
public String getFullRegionPath() {
|
||||
if(id != null && id == 1L){
|
||||
return "/1/";
|
||||
}
|
||||
if (StringUtils.isNotBlank(regionPath)) {
|
||||
return regionPath + id + "/";
|
||||
} else {
|
||||
return "/" + id + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.cool.store.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.Serializable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysDepartmentDO implements Serializable {
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("parent_id")
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty("在父部门中的次序值")
|
||||
private Integer departOrder;
|
||||
|
||||
@ApiModelProperty("是否同步创建一个关联此部门的企业群, true表示是, false表示不是")
|
||||
private Boolean createDeptGroup;
|
||||
|
||||
@ApiModelProperty("当群已经创建后,是否有新人加入部门会自动加入该群, true表示是, false表示不是")
|
||||
private Boolean autoAddUser;
|
||||
|
||||
@ApiModelProperty("是否隐藏部门, true表示隐藏, false表示显示")
|
||||
private Boolean depHiding;
|
||||
|
||||
@ApiModelProperty("可以查看指定隐藏部门的其他部门列表,如果部门隐藏,则此值生效,取值为其他的部门id组成的的字符串,使用|符号进行分割")
|
||||
private String deptPerimits;
|
||||
|
||||
@ApiModelProperty("可以查看指定隐藏部门的其他人员列表,如果部门隐藏,则此值生效,取值为其他的人员userid组成的的字符串,使用|符号进行分割")
|
||||
private String userPerimits;
|
||||
|
||||
@ApiModelProperty("是否本部门的员工仅可见员工自己, 为true时,本部门员工默认只能看到员工自己")
|
||||
private Boolean outerDept;
|
||||
|
||||
@ApiModelProperty("本部门的员工仅可见员工自己为true时,可以配置额外可见部门,值为部门id组成的的字符串,使用|符号进行分割")
|
||||
private String outerPermitDepts;
|
||||
|
||||
@ApiModelProperty("本部门的员工仅可见员工自己为true时,可以配置额外可见人员,值为userid组成的的字符串,使用| 符号进行分割")
|
||||
private String outerPermitUsers;
|
||||
|
||||
@ApiModelProperty("企业群群主")
|
||||
private String orgDeptOwner;
|
||||
|
||||
@ApiModelProperty("部门的主管列表,取值为由主管的userid组成的字符串,不同的userid使用|符号进行分割")
|
||||
private String deptManagerUseridList;
|
||||
|
||||
@ApiModelProperty("部门下总人数(包括子部门)")
|
||||
private Integer userCount;
|
||||
|
||||
@ApiModelProperty("部门下未激活总人数(包括子部门)")
|
||||
private Integer unactiveUserCount;
|
||||
|
||||
@ApiModelProperty("部门所有父级部门id, 不包括自己, 以/分隔")
|
||||
private String parentIds;
|
||||
|
||||
@ApiModelProperty("部门所有子部门id,以英文逗号分隔")
|
||||
private String subIds;
|
||||
|
||||
/**
|
||||
* 是否是叶子节点
|
||||
*/
|
||||
private Boolean isLeaf;
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.cool.store.entity;
|
||||
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@@ -11,40 +14,30 @@ import lombok.NoArgsConstructor;
|
||||
/**
|
||||
*
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
* @date 2023-06-08 10:54
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysRoleDO implements Serializable {
|
||||
|
||||
@ApiModelProperty("自增id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("")
|
||||
@ApiModelProperty("角色id")
|
||||
private String roleId;
|
||||
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("是否预制")
|
||||
private Boolean isInternal;
|
||||
@ApiModelProperty("角色类型 0-同步 1-自建")
|
||||
private Integer roleType;
|
||||
|
||||
@ApiModelProperty("角色权限范围all(全企业数据)include_subordinate(所在组织架构包含下级) not_include_subordinate(所在的组织架构不包含下级) personal (仅自己的数据) ")
|
||||
private String roleAuth;
|
||||
@ApiModelProperty("第三方唯一id")
|
||||
private String thirdUniqueId;
|
||||
|
||||
@ApiModelProperty("岗位来源:(create:自建岗位, sync:从钉钉同步的角色,sync_position从钉钉同步的职位, ehr 从第三方ehr同步的)")
|
||||
private String source;
|
||||
|
||||
@ApiModelProperty("职位类型:store_outside-店外,store_inside-店内")
|
||||
private String positionType;
|
||||
|
||||
@ApiModelProperty("移动端菜单")
|
||||
private String appMenu;
|
||||
|
||||
@ApiModelProperty("钉钉角色id")
|
||||
private Long synDingRoleId;
|
||||
|
||||
@ApiModelProperty("角色排序 1.管理员 1-99.门店职位 100+.钉钉角色")
|
||||
private Integer priority;
|
||||
@ApiModelProperty("删除标识")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
@@ -52,15 +45,20 @@ public class SysRoleDO implements Serializable {
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("角色枚举用于判定逻辑")
|
||||
private String roleEnum;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createUser;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateUser;
|
||||
|
||||
@ApiModelProperty("第三方唯一id")
|
||||
private String thirdUniqueId;
|
||||
public static SysRoleDO convertSyncDO(String roleName){
|
||||
SysRoleDO role = new SysRoleDO();
|
||||
role.setRoleId(MD5.create().digestHex(roleName));
|
||||
role.setRoleName(roleName);
|
||||
role.setRoleType(DataSourceEnum.SYNC.getCode());
|
||||
role.setDeleted(Boolean.FALSE);
|
||||
role.setCreateTime(new Date());
|
||||
role.setUpdateTime(new Date());
|
||||
return role;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,30 @@
|
||||
package com.cool.store.entity;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserDTO;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangchenbiao
|
||||
* @date 2023-05-19 03:00
|
||||
* @date 2023-06-07 02:07
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserRegionMappingDO implements Serializable {
|
||||
|
||||
@ApiModelProperty("主键")
|
||||
private Integer id;
|
||||
|
||||
@@ -27,6 +34,12 @@ public class UserRegionMappingDO implements Serializable {
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("删除标识")
|
||||
private Boolean deleted;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createId;
|
||||
|
||||
@@ -38,4 +51,22 @@ public class UserRegionMappingDO implements Serializable {
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
public static List<UserRegionMappingDO> convertSyncDO(String regionId, List<EnterpriseUserDTO> departmentUsers){
|
||||
if(CollectionUtils.isEmpty(departmentUsers)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<UserRegionMappingDO> resultList = new ArrayList<>();
|
||||
for (EnterpriseUserDTO departmentUser : departmentUsers) {
|
||||
UserRegionMappingDO userRegion = new UserRegionMappingDO();
|
||||
userRegion.setRegionId(regionId);
|
||||
userRegion.setUserId(departmentUser.getUserId());
|
||||
userRegion.setType(DataSourceEnum.SYNC.getCode());
|
||||
userRegion.setCreateTime(System.currentTimeMillis());
|
||||
userRegion.setUpdateTime(System.currentTimeMillis());
|
||||
userRegion.setDeleted(Boolean.FALSE);
|
||||
resultList.add(userRegion);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.cool.store.context;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class CurrentUser {
|
||||
|
||||
|
||||
@@ -14,21 +14,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface EnterpriseUserService {
|
||||
|
||||
void updateUserRegionPathList(List<String> userIds);
|
||||
|
||||
List<EnterpriseUserPageVO> listUser(String userName, String deptId,
|
||||
String orderBy, String orderRule,
|
||||
Long roleId, Integer userStatus, Integer pageNum, Integer pageSize, String jobNumber, String regionId, Boolean hasPage);
|
||||
|
||||
List<String> initUserRole(List<EnterpriseUserPageVO> enterpriseUserList);
|
||||
|
||||
/**
|
||||
* 更新用户的部门全路径
|
||||
* @param user
|
||||
* @param deptIdMap
|
||||
*/
|
||||
void updateUserDeptPath(EnterpriseUserRequest user, Map<String, String> deptIdMap);
|
||||
|
||||
EnterpriseUserDO getUserInfoByUserId(String userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ public interface LoginService {
|
||||
|
||||
|
||||
|
||||
Object feiShuLogin(String userId, String corpId, Boolean needRefreshToken , String appType, String avatar);
|
||||
Object feiShuLogin(String userId, Boolean needRefreshToken, String avatar);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.entity.RegionDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: RegionService
|
||||
@@ -12,8 +8,4 @@ import java.util.List;
|
||||
*/
|
||||
public interface RegionService {
|
||||
|
||||
void saveRegionAndStore(RegionDO regionDO, String userId);
|
||||
|
||||
void removeRegions(List<Long> regionIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.enterprise.*;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import com.cool.store.http.ISVHttpRequest;
|
||||
import com.cool.store.service.EnterpriseSyncService;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
@@ -20,12 +29,107 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EnterpriseSyncServiceImpl implements EnterpriseSyncService {
|
||||
|
||||
@Resource
|
||||
private ISVHttpRequest isvHttpRequest;
|
||||
@Resource
|
||||
private RegionDAO regionDAO;
|
||||
@Resource
|
||||
private EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
private EnterpriseUserRoleDAO enterpriseUserRoleDAO;
|
||||
@Resource
|
||||
private SysRoleDAO sysRoleDAO;
|
||||
@Resource
|
||||
private UserRegionMappingDAO userRegionMappingDAO;
|
||||
|
||||
@Override
|
||||
public void syncAll() {
|
||||
//同步部门
|
||||
List<SysDepartmentDTO> departments = isvHttpRequest.getSubDepartments(CommonConstants.ROOT_DEPT_ID_STR, true);
|
||||
//获取企业信息
|
||||
AuthInfoDTO authInfo = isvHttpRequest.getAuthInfo();
|
||||
Multimap<String, String> leaderDeptMap = ArrayListMultimap.create();
|
||||
//组织架构中增加根节点,处理部门上下级关系
|
||||
List<RegionDO> regionList = SysDepartmentDTO.convertRegionDO(departments, leaderDeptMap);
|
||||
List<String> regionIds = regionList.stream().map(RegionDO::getRegionId).distinct().collect(Collectors.toList());
|
||||
//添加根节点
|
||||
regionList.add(getRootRegion(authInfo));
|
||||
//批量插入
|
||||
regionDAO.batchInsertOrUpdate(regionList);
|
||||
//删除不存在的区域
|
||||
regionDAO.deleteNotExistRegion(regionIds);
|
||||
Multimap<String, String> roleUserMap = ArrayListMultimap.create();
|
||||
//同步用户及部门
|
||||
syncUserAndUserRegion(regionList, roleUserMap, leaderDeptMap);
|
||||
//处理用户角色 删除多余的角色
|
||||
if(!roleUserMap.isEmpty()){
|
||||
List<SysRoleDO> insertOrUpdateList = new ArrayList<>();
|
||||
List<EnterpriseUserRoleDO> userRoleInsertOrUpdateList = new ArrayList<>();
|
||||
List<String> roleIds = new ArrayList<>();
|
||||
for (String roleName : roleUserMap.keys()) {
|
||||
SysRoleDO sysRole = SysRoleDO.convertSyncDO(roleName);
|
||||
roleIds.add(sysRole.getRoleId());
|
||||
Collection<String> userIds = roleUserMap.get(roleName);
|
||||
insertOrUpdateList.add(sysRole);
|
||||
userRoleInsertOrUpdateList.addAll(EnterpriseUserRoleDO.convertDO(sysRole.getRoleId(), new ArrayList<>(userIds)));
|
||||
//删除角色下不存在的用户
|
||||
enterpriseUserRoleDAO.deleteUserRole(sysRole.getRoleId(), DataSourceEnum.SYNC, new ArrayList<>(userIds));
|
||||
}
|
||||
sysRoleDAO.batchInsertSelective(insertOrUpdateList);
|
||||
enterpriseUserRoleDAO.batchInsertOrUpdate(userRoleInsertOrUpdateList);
|
||||
//删除不存在的角色?
|
||||
sysRoleDAO.deleteRole(DataSourceEnum.SYNC, roleIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void syncUserAndUserRegion(List<RegionDO> regionList, Multimap<String, String> roleUserMap, Multimap<String, String> leaderDeptMap){
|
||||
Map<String, String> regionPathMap = regionList.stream().collect(Collectors.toMap(RegionDO::getRegionId, RegionDO::getRegionPath));
|
||||
List<EnterpriseUserDO> userList = new ArrayList<>();
|
||||
List<UserRegionMappingDO> userRegionList = new ArrayList<>();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
//按部门获取用户
|
||||
for (RegionDO region : regionList) {
|
||||
List<EnterpriseUserDTO> departmentUsers = isvHttpRequest.getDepartmentUsers(region.getRegionId());
|
||||
List<String> deptUserIds = ListUtils.emptyIfNull(departmentUsers).stream().map(EnterpriseUserDTO::getUserId).collect(Collectors.toList());
|
||||
userRegionMappingDAO.deleteUserRegion(region.getRegionId(), DataSourceEnum.SYNC, deptUserIds);
|
||||
if(CollectionUtils.isEmpty(departmentUsers)){
|
||||
continue;
|
||||
}
|
||||
userIds.addAll(deptUserIds);
|
||||
userRegionList.addAll(UserRegionMappingDO.convertSyncDO(region.getRegionId(), departmentUsers));
|
||||
//系统内的角色 获取飞书的职务 一个人只能一个职务
|
||||
List<EnterpriseUserDO> deptUserList = EnterpriseUserDTO.transUserDtoToDo(departmentUsers, regionPathMap, leaderDeptMap, roleUserMap);
|
||||
userList.addAll(deptUserList);
|
||||
if(userList.size() > CommonConstants.DEAL_RECORD_MAX_SIZE){
|
||||
enterpriseUserDAO.batchInsertOrUpdate(userList);
|
||||
userList.clear();
|
||||
}
|
||||
if(userRegionList.size() > CommonConstants.DEAL_RECORD_MAX_SIZE){
|
||||
userRegionMappingDAO.batchInsertOrUpdateUserRegion(userRegionList);
|
||||
userRegionList.clear();
|
||||
}
|
||||
}
|
||||
enterpriseUserDAO.batchInsertOrUpdate(userList);
|
||||
userRegionMappingDAO.batchInsertOrUpdateUserRegion(userRegionList);
|
||||
//删除不存在的用户
|
||||
enterpriseUserDAO.deleteUser(userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取跟部门
|
||||
* @param authInfo
|
||||
* @return
|
||||
*/
|
||||
private RegionDO getRootRegion(AuthInfoDTO authInfo){
|
||||
RegionDO rootRegion = new RegionDO();
|
||||
rootRegion.setName(authInfo.getAuthCorpInfo().getCorpName());
|
||||
rootRegion.setRegionId(CommonConstants.ROOT_DEPT_ID_STR);
|
||||
rootRegion.setParentId(CommonConstants.ZERO_STR);
|
||||
rootRegion.setThirdDeptId(CommonConstants.ROOT_DEPT_ID_STR);
|
||||
rootRegion.setOrderNum(CommonConstants.ZERO);
|
||||
rootRegion.setRegionPath(CommonConstants.PATH_SPILT + rootRegion.getRegionId() + CommonConstants.PATH_SPILT);
|
||||
return rootRegion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.context.CurrentUser;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.buser.UserRoleDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.request.EnterpriseUserRequest;
|
||||
import com.cool.store.service.EnterpriseUserService;
|
||||
import com.cool.store.vo.buser.EnterpriseUserPageVO;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
@@ -29,153 +17,12 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class EnterpriseUserServiceImpl implements EnterpriseUserService {
|
||||
|
||||
@Resource
|
||||
private UserRegionMappingDAO userRegionMappingDAO;
|
||||
@Resource
|
||||
private RegionDAO regionDAO;
|
||||
|
||||
@Resource
|
||||
private EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
private EnterpriseUserRoleDAO enterpriseUserRoleDAO;
|
||||
|
||||
@Override
|
||||
public void updateUserRegionPathList(List<String> userIds) {
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
//查询该人员的最新部门情况 同步到enterpriseUser 表usereginIds表中
|
||||
List<UserRegionMappingDO> userRegionMappingDOS = userRegionMappingDAO.listUserRegionMappingByUserId(userIds);
|
||||
Map<String, List<UserRegionMappingDO>> userRegionMappingMap = ListUtils.emptyIfNull(userRegionMappingDOS)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(UserRegionMappingDO::getUserId));
|
||||
List<String> regionIds = userRegionMappingDOS.stream()
|
||||
.map(UserRegionMappingDO::getRegionId).distinct().collect(Collectors.toList());
|
||||
List<RegionDO> regionDOS = regionDAO.getRegionByRegionIds(regionIds);
|
||||
Map<String, RegionDO> regionMap = regionDOS.stream()
|
||||
.collect(Collectors.toMap(RegionDO::getRegionId, data -> data));
|
||||
|
||||
List<EnterpriseUserDO> enterpriseUserList= new ArrayList<>();
|
||||
for (String userId:userIds) {
|
||||
EnterpriseUserDO enterpriseUserDO = new EnterpriseUserDO();
|
||||
enterpriseUserDO.setUserId(userId);
|
||||
String regionPathString = "";
|
||||
List<RegionDO> regionDOList = new ArrayList<>();
|
||||
//如果没有对应部门 默认未null 正常情况下不会出现userRegionId不为null的情况
|
||||
enterpriseUserDO.setUserRegionIds(null);
|
||||
List<UserRegionMappingDO> userRegionMappingList = userRegionMappingMap.get(userId);
|
||||
|
||||
//异常情况下处理
|
||||
if (CollectionUtils.isEmpty(userRegionMappingList)){
|
||||
log.info("getUserRegionPathListStr exception 该人员没有任何部门");
|
||||
//查询未分组
|
||||
RegionDO unclassifiedRegionDO = regionDAO.getUnclassifiedRegionDO();
|
||||
//将人添加到未分组中
|
||||
addUserRegionMappingDO(userId,unclassifiedRegionDO.getRegionId(),new CurrentUser());
|
||||
regionDOList.add(unclassifiedRegionDO);
|
||||
}
|
||||
|
||||
ListUtils.emptyIfNull(userRegionMappingList)
|
||||
.stream()
|
||||
.forEach(userRegionMappingDO -> {
|
||||
RegionDO regionDO = regionMap.get(userRegionMappingDO.getRegionId());
|
||||
if (Objects.nonNull(regionDO)){
|
||||
regionDOList.add(regionDO);
|
||||
}
|
||||
});
|
||||
|
||||
regionPathString = regionDOList.stream()
|
||||
.map(e -> e.getFullRegionPath()).collect(Collectors.joining(CommonConstants.COMMA));
|
||||
if (StringUtils.isNotBlank(regionPathString)){
|
||||
enterpriseUserDO.setUserRegionIds(CommonConstants.SQUAREBRACKETSLEFT+ regionPathString+ CommonConstants.SQUAREBRACKETSRIGHT);
|
||||
}
|
||||
enterpriseUserList.add(enterpriseUserDO);
|
||||
}
|
||||
//enterpriseUserDAO.batchUpdateDiffUserDiffRegionIds(enterpriseUserList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnterpriseUserPageVO> listUser(String userName, String deptId,
|
||||
String orderBy, String orderRule,
|
||||
Long roleId, Integer userStatus, Integer pageNum, Integer pageSize, String jobNumber, String regionId, Boolean hasPage) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addUserRegionMappingDO(String userId,String regionId,CurrentUser currentUser){
|
||||
UserRegionMappingDO userRegionMappingDO = new UserRegionMappingDO();
|
||||
userRegionMappingDO.setUserId(userId);
|
||||
userRegionMappingDO.setRegionId(regionId);
|
||||
userRegionMappingDO.setCreateId(currentUser.getUserId());
|
||||
userRegionMappingDO.setUpdateId(currentUser.getUserId());
|
||||
userRegionMappingDO.setCreateTime(System.currentTimeMillis());
|
||||
userRegionMappingDO.setUpdateTime(System.currentTimeMillis());
|
||||
//将用户添加到未分组
|
||||
userRegionMappingDAO.batchInsertRegionMapping(Arrays.asList(userRegionMappingDO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> initUserRole(List<EnterpriseUserPageVO> enterpriseUserList) {
|
||||
List<String> userIdList = ListUtils.emptyIfNull(enterpriseUserList)
|
||||
.stream()
|
||||
.map(EnterpriseUserPageVO::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if(CollectionUtils.isNotEmpty(userIdList)){
|
||||
List<UserRoleDTO> userRoleDTOS = enterpriseUserRoleDAO.getUserAndRolesByUserId(userIdList);
|
||||
//封装 userId-userRole map,以表示一个用户对应几个角色
|
||||
Map<String, List<Long>> userRoleDtoMap = new HashMap<>();
|
||||
userRoleDTOS.forEach(roleDto -> {
|
||||
List<Long> check = userRoleDtoMap.get(roleDto.getUserId());
|
||||
if (check == null) {
|
||||
List<Long> roleDtoList = new ArrayList<>();
|
||||
roleDtoList.add(roleDto.getRoleId());
|
||||
userRoleDtoMap.put(roleDto.getUserId(), roleDtoList);
|
||||
} else {
|
||||
check.add(roleDto.getRoleId());
|
||||
userRoleDtoMap.put(roleDto.getUserId(), check);
|
||||
}
|
||||
});
|
||||
//获得角色id -角色名称的map
|
||||
Map<Long, String> roleNameMap = ListUtils.emptyIfNull(userRoleDTOS)
|
||||
.stream()
|
||||
.filter(data -> StringUtils.isNotBlank(data.getRoleName()))
|
||||
.collect(Collectors.toMap(UserRoleDTO::getRoleId, UserRoleDTO::getRoleName, (a, b) -> a));
|
||||
enterpriseUserList.forEach(user -> {
|
||||
List<Long> roleIdList = userRoleDtoMap.get(user.getUserId());
|
||||
if (roleIdList != null && roleIdList.size() != 0) {
|
||||
String roleName = roleIdList.stream()
|
||||
.filter(data -> roleNameMap.get(data) != null)
|
||||
.map(role -> roleNameMap.get(role))
|
||||
.collect(Collectors.joining(","));
|
||||
user.setRoleName(roleName);
|
||||
}
|
||||
});
|
||||
}
|
||||
return userIdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserDeptPath(EnterpriseUserRequest user, Map<String, String> deptIdMap) {
|
||||
List<String> departmentLists = user.getDepartmentLists();
|
||||
//logger.info("设置用户部门全路径 start department:{},user:{},id:{}",department,user.getUnionid(),user.getId());
|
||||
if (CollectionUtils.isNotEmpty(departmentLists)) {
|
||||
//logger.info("into if else department ");
|
||||
List<String> deptList = Lists.newArrayList();
|
||||
departmentLists.forEach(deptId -> {
|
||||
List<String> tmpList = Lists.newArrayList(deptId);
|
||||
String parentId;
|
||||
while ((parentId = deptIdMap.get(deptId)) != null && (!parentId.equals(deptId))) {
|
||||
tmpList.add(parentId);
|
||||
deptId = parentId;
|
||||
}
|
||||
String collect = Lists.reverse(tmpList).stream().map(String::valueOf).collect(Collectors.joining("/"));
|
||||
String data = collect.startsWith("/") ? collect : "/" + collect;
|
||||
data = data.endsWith("/") ? data : data + "/";
|
||||
deptList.add(data);
|
||||
});
|
||||
user.setDepartments("[" + String.join(",", deptList) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterpriseUserDO getUserInfoByUserId(String userId) {
|
||||
|
||||
@@ -37,20 +37,17 @@ public class LoginServiceImpl implements LoginService {
|
||||
@Resource
|
||||
private SysRoleDAO sysRoleDAO;
|
||||
@Resource
|
||||
private LoginRecordDAO loginRecordDAO;
|
||||
@Resource
|
||||
private RedisUtilPool redisUtilPool;
|
||||
@Resource
|
||||
private EnterpriseUserRoleDAO enterpriseUserRoleDAO;
|
||||
|
||||
@Override
|
||||
public Object feiShuLogin(String userId, String corpId, Boolean needRefreshToken, String appType, String avatar) {
|
||||
log.info("isvLogin, corpId={}, userId={}, appType={}", corpId, userId, appType);
|
||||
public Object feiShuLogin(String userId, Boolean needRefreshToken, String avatar) {
|
||||
log.info("isvLogin, corpId={}, userId={}", userId);
|
||||
DataSourceContext.clearDataSourceType();
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
throw new ServiceException(ErrorCodeEnum.USER_NOT_EXIST);
|
||||
}
|
||||
if (StringUtils.isEmpty(corpId)) {
|
||||
throw new ServiceException(ErrorCodeEnum.ENTERPRISE_NOT_EXIST);
|
||||
}
|
||||
CurrentUser currentUser = new CurrentUser();
|
||||
RefreshUser refreshUser = new RefreshUser();
|
||||
// 查企业用户
|
||||
@@ -58,7 +55,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
if(enterpriseUser == null){
|
||||
throw new ServiceException(ErrorCodeEnum.NOT_AUTH);
|
||||
}
|
||||
SysRoleDO sysRole = sysRoleDAO.getHighestPrioritySysRoleDoByUserId(userId);
|
||||
SysRoleDO sysRole = sysRoleDAO.getHighestPriorityRoleByUserId(userId);
|
||||
if(Objects.isNull(sysRole)){
|
||||
log.info("当前用户没角色:{}", userId);
|
||||
throw new ServiceException(ErrorCodeEnum.NOT_AUTH);
|
||||
@@ -77,7 +74,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
currentUser.setUserId(enterpriseUser.getUserId());
|
||||
currentUser.setIsAdmin(enterpriseUser.getIsAdmin());
|
||||
//设置当前登录人使用的企业相关信息
|
||||
currentUser.setRoleAuth(sysRole.getRoleAuth());
|
||||
//currentUser.setRoleAuth(sysRole.getRoleAuth());
|
||||
currentUser.setSysRoleDO(sysRole);
|
||||
//生成令牌
|
||||
RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
|
||||
@@ -85,7 +82,6 @@ public class LoginServiceImpl implements LoginService {
|
||||
String refreshToken = randomNumberGenerator.nextBytes().toHex();
|
||||
currentUser.setName(enterpriseUser.getName());
|
||||
currentUser.setAccessToken(token);
|
||||
currentUser.setAppType(appType);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("action_token", token);
|
||||
jsonObject.put("user", currentUser);
|
||||
@@ -94,7 +90,6 @@ public class LoginServiceImpl implements LoginService {
|
||||
redisUtilPool.setString(currentUser.getUserId(), token);
|
||||
redisUtilPool.setString(CommonConstants.REFRESH_TOKEN_KEY+":"+refreshToken,JSON.toJSONString(refreshUser), CommonConstants.REFRESH_TOKEN_EXPIRE);
|
||||
jsonObject.put("refresh_token",refreshToken);
|
||||
loginRecordDAO.addLoginRecord(currentUser.getUserId());
|
||||
log.info("[" + enterpriseUser.getName() + "; action_token:"+ token + "; userId:" + currentUser.getUserId() +"]登入系统成功");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.dao.RegionDAO;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.enums.RegionTypeEnum;
|
||||
import com.cool.store.mq.producer.SimpleMessageService;
|
||||
import com.cool.store.service.RegionService;
|
||||
import com.cool.store.utils.RedisConstantUtil;
|
||||
import com.cool.store.utils.RedisUtil;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
@@ -28,38 +22,7 @@ public class RegionServiceImpl implements RegionService {
|
||||
@Resource
|
||||
private RedisConstantUtil redisConstantUtil;
|
||||
@Resource
|
||||
private RegionDAO regionDAO;
|
||||
@Resource
|
||||
private SimpleMessageService simpleMessageService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void saveRegionAndStore(RegionDO regionDO, String userId) {
|
||||
String storeId = null;
|
||||
if(regionDO.getStoreRange()){
|
||||
storeId = UUIDUtils.get32UUID();
|
||||
}
|
||||
regionDO.setStoreId(storeId);
|
||||
regionDO.setRegionType(RegionTypeEnum.PATH.getType());
|
||||
RegionDO oldRegion = regionDAO.getBySynDingDeptId(regionDO.getSynDingDeptId());
|
||||
boolean isAdd = oldRegion == null;
|
||||
if (isAdd) {
|
||||
if(regionDO.getStoreRange()){
|
||||
regionDO.setStoreId(storeId);
|
||||
regionDO.setRegionType(RegionTypeEnum.STORE.getType());
|
||||
}
|
||||
regionDAO.ignoreInsert(regionDO);
|
||||
} else {
|
||||
if(regionDO.getStoreRange()){
|
||||
regionDO.setRegionType(RegionTypeEnum.STORE.getType());
|
||||
}
|
||||
regionDAO.updateSyncRegion(regionDO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRegions(List<Long> regionIds) {
|
||||
regionDAO.removeRegion(regionIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,25 +28,5 @@ public class EnterpriseUserController {
|
||||
@Resource
|
||||
public EnterpriseUserService enterpriseUserService;
|
||||
|
||||
@GetMapping(path = "/dept/userList")
|
||||
public ResponseResult<PageInfo<EnterpriseUserPageVO>> getUserList(@RequestParam(name = "user_name", required = false) String userName,
|
||||
@RequestParam(name = "dept_id", required = false) String deptId,
|
||||
@RequestParam(name = "role_id", required = false) Long roleId,
|
||||
@RequestParam(name = "order_by", required = false) String orderBy,
|
||||
@RequestParam(name = "order_rule", required = false, defaultValue = "asc") String orderRule,
|
||||
@RequestParam(name = "user_status", required = false) Integer userStatus,
|
||||
@RequestParam(name = "page_num", required = false, defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "page_size", required = false, defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(name = "job_number", required = false) String jobNumber,
|
||||
@RequestParam(name = "region_id", required = false) String regionId,
|
||||
@RequestParam(name = "has_page", required = false,defaultValue = "true") Boolean hasPage) {
|
||||
DataSourceHelper.changeToMy();
|
||||
List<EnterpriseUserPageVO> deptUserList = enterpriseUserService.listUser(userName, deptId, orderBy, orderRule, roleId, userStatus, pageNum, pageSize, jobNumber,regionId,hasPage);
|
||||
if(CollectionUtils.isNotEmpty(deptUserList)){
|
||||
return ResponseResult.success(new PageInfo<>(deptUserList));
|
||||
}else {
|
||||
return ResponseResult.success(new PageInfo<>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,18 +37,15 @@ public class LoginController {
|
||||
public Object feiShuLogin(@RequestBody FeiShuLoginDTO param) {
|
||||
log.info("feiShuLogin data={}", JSONObject.toJSONString(param));
|
||||
String code = param.getCode();
|
||||
String appId = param.getAppId();
|
||||
String userId = "", corpId = "", appType = AppTypeEnum.FEI_SHU.getValue();
|
||||
try {
|
||||
String value = "code=" + code + "&appType=" + appType + "&appId=" + appId;
|
||||
String value = "code=" + code;
|
||||
UserIdInfoDTO userInfo = isvHttpRequest.getUserIdByCode(value);
|
||||
if(Objects.isNull(userInfo)){
|
||||
throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR);
|
||||
}
|
||||
log.info("userInfo:{}", JSONObject.toJSONString(userInfo));
|
||||
userId = userInfo.getOpenId();
|
||||
corpId = userInfo.getCorpId();
|
||||
return loginService.feiShuLogin(userId, corpId, Boolean.TRUE, appType, StringUtils.EMPTY);
|
||||
String userId = userInfo.getOpenId();
|
||||
return loginService.feiShuLogin(userId, Boolean.TRUE, StringUtils.EMPTY);
|
||||
} catch (ServiceException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR);
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.cool.store.request.AllocationInvestmentManagerRequest;
|
||||
import com.cool.store.request.City;
|
||||
import com.cool.store.request.TestRequest;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.EnterpriseSyncService;
|
||||
import com.cool.store.service.EnterpriseUserService;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -39,6 +40,9 @@ public class TestController {
|
||||
private ISVHttpRequest isvHttpRequest;
|
||||
@Resource
|
||||
HyOpenAreaInfoMapper hyOpenAreaInfoMapper;
|
||||
@Resource
|
||||
private EnterpriseSyncService enterpriseSyncService;
|
||||
|
||||
|
||||
@GetMapping("/sendMq")
|
||||
public ResponseResult sendMq(){
|
||||
@@ -156,4 +160,10 @@ public class TestController {
|
||||
return ResponseResult.success(isvHttpRequest.getSubDepartments(parentId, fetchChild));
|
||||
}
|
||||
|
||||
@GetMapping("syncAll")
|
||||
public ResponseResult syncAll(){
|
||||
enterpriseSyncService.syncAll();
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user