大调整
This commit is contained in:
@@ -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);
|
||||
return userRegionMappingMapper.deleteUserRegion(regionId, dataSourceEnum.getCode(), excludeUserIds);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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 into enterprise_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="mobile != null">
|
||||
mobile,
|
||||
</if>
|
||||
<if test="email != null">
|
||||
email,
|
||||
</if>
|
||||
<if test="orgEmail != null">
|
||||
org_email,
|
||||
</if>
|
||||
<if test="mainAdmin != null">
|
||||
main_admin,
|
||||
</if>
|
||||
<if test="isAdmin != null">
|
||||
is_admin,
|
||||
</if>
|
||||
<if test="unionid != null">
|
||||
unionid,
|
||||
</if>
|
||||
<if test="position != null">
|
||||
position,
|
||||
</if>
|
||||
<if test="avatar != null">
|
||||
avatar,
|
||||
</if>
|
||||
<if test="jobnumber != null">
|
||||
jobnumber,
|
||||
</if>
|
||||
<if test="isLeader != null">
|
||||
is_leader,
|
||||
</if>
|
||||
<if test="faceUrl != null">
|
||||
face_url,
|
||||
</if>
|
||||
<if test="userStatus != null">
|
||||
user_status,
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="userRegionIds != null">
|
||||
user_region_ids,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">
|
||||
#{userId},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="mobile != null">
|
||||
#{mobile},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
#{email},
|
||||
</if>
|
||||
<if test="orgEmail != null">
|
||||
#{orgEmail},
|
||||
</if>
|
||||
<if test="mainAdmin != null">
|
||||
#{mainAdmin},
|
||||
</if>
|
||||
<if test="isAdmin != null">
|
||||
#{isAdmin},
|
||||
</if>
|
||||
<if test="unionid != null">
|
||||
#{unionid},
|
||||
</if>
|
||||
<if test="position != null">
|
||||
#{position},
|
||||
</if>
|
||||
<if test="avatar != null">
|
||||
#{avatar},
|
||||
</if>
|
||||
<if test="jobnumber != null">
|
||||
#{jobnumber},
|
||||
</if>
|
||||
<if test="isLeader != null">
|
||||
#{isLeader},
|
||||
</if>
|
||||
<if test="faceUrl != null">
|
||||
#{faceUrl},
|
||||
</if>
|
||||
<if test="userStatus != null">
|
||||
#{userStatus},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
#{deleted},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="userRegionIds != null">
|
||||
#{userRegionIds},
|
||||
</if>
|
||||
</trim>
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="recordList" item="record" separator=";">
|
||||
insert into enterprise_user
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
remark,
|
||||
</if>
|
||||
<if test="record.mobile != null">
|
||||
mobile,
|
||||
</if>
|
||||
<if test="record.email != null">
|
||||
email,
|
||||
</if>
|
||||
<if test="record.orgEmail != null">
|
||||
org_email,
|
||||
</if>
|
||||
<if test="record.mainAdmin != null">
|
||||
main_admin,
|
||||
</if>
|
||||
<if test="record.isAdmin != null">
|
||||
is_admin,
|
||||
</if>
|
||||
<if test="record.unionid != null">
|
||||
unionid,
|
||||
</if>
|
||||
<if test="record.avatar != null">
|
||||
avatar,
|
||||
</if>
|
||||
<if test="record.jobnumber != null">
|
||||
jobnumber,
|
||||
</if>
|
||||
<if test="record.isLeader != null">
|
||||
is_leader,
|
||||
</if>
|
||||
<if test="record.leaderDeptIds != null">
|
||||
leader_dept_ids,
|
||||
</if>
|
||||
<if test="record.faceUrl != null">
|
||||
face_url,
|
||||
</if>
|
||||
<if test="record.userStatus != null">
|
||||
user_status,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.userRegionIds != null">
|
||||
user_region_ids,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.id != null">
|
||||
#{record.id},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.remark != null">
|
||||
#{record.remark},
|
||||
</if>
|
||||
<if test="record.mobile != null">
|
||||
#{record.mobile},
|
||||
</if>
|
||||
<if test="record.email != null">
|
||||
#{record.email},
|
||||
</if>
|
||||
<if test="record.orgEmail != null">
|
||||
#{record.orgEmail},
|
||||
</if>
|
||||
<if test="record.mainAdmin != null">
|
||||
#{record.mainAdmin},
|
||||
</if>
|
||||
<if test="record.isAdmin != null">
|
||||
#{record.isAdmin},
|
||||
</if>
|
||||
<if test="record.unionid != null">
|
||||
#{record.unionid},
|
||||
</if>
|
||||
<if test="record.avatar != null">
|
||||
#{record.avatar},
|
||||
</if>
|
||||
<if test="record.jobnumber != null">
|
||||
#{record.jobnumber},
|
||||
</if>
|
||||
<if test="record.isLeader != null">
|
||||
#{record.isLeader},
|
||||
</if>
|
||||
<if test="record.leaderDeptIds != null">
|
||||
#{record.leaderDeptIds},
|
||||
</if>
|
||||
<if test="record.faceUrl != null">
|
||||
#{record.faceUrl},
|
||||
</if>
|
||||
<if test="record.userStatus != null">
|
||||
#{record.userStatus},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<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,134 +3,78 @@
|
||||
<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 into enterprise_user_role
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="recordList" separator=";" item="record">
|
||||
insert into enterprise_user_role
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.roleId != null">
|
||||
#{record.roleId},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
#{record.userId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
</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,585 +5,157 @@
|
||||
<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 into region
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
region_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
group_id,
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<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">
|
||||
#{record.regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<if test="record.groupId != null">
|
||||
#{record.groupId},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
#{record.createTime},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
#{record.createName},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<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>
|
||||
<insert id="batchInsertOrUpdate">
|
||||
<foreach collection="insertOrUpdateList" item="record" separator=";">
|
||||
insert into region
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
region_id,
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<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,
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
create_name,
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
update_name,
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
deleted,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.regionId != null">
|
||||
#{record.regionId},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
#{record.name},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
#{record.parentId},
|
||||
</if>
|
||||
<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},
|
||||
</if>
|
||||
<if test="record.createName != null">
|
||||
#{record.createName},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
#{record.updateTime},
|
||||
</if>
|
||||
<if test="record.updateName != null">
|
||||
#{record.updateName},
|
||||
</if>
|
||||
<if test="record.deleted != null">
|
||||
#{record.deleted},
|
||||
</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,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
|
||||
Reference in New Issue
Block a user