更新用户和组织管理功能,优化查询条件,新增供应商用户VO类,调整分页查询逻辑,确保公司层级信息的正确传递。
This commit is contained in:
@ -52,7 +52,6 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="getUserById" resultType="com.coscoshipping.ebtp.system.login.entity.BaseUserSelectVo" >
|
<select id="getUserById" resultType="com.coscoshipping.ebtp.system.login.entity.BaseUserSelectVo" >
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT
|
DISTINCT
|
||||||
@ -85,7 +84,6 @@
|
|||||||
and ou.orgnid = #{orgnId}
|
and ou.orgnid = #{orgnId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="getUserByObject" resultType="com.coscoshipping.ebtp.system.login.entity.BaseUserSelectVo" >
|
<select id="getUserByObject" resultType="com.coscoshipping.ebtp.system.login.entity.BaseUserSelectVo" >
|
||||||
SELECT
|
SELECT
|
||||||
u.user_id,
|
u.user_id,
|
||||||
@ -108,9 +106,6 @@
|
|||||||
AND ur.role_id = r.role_id
|
AND ur.role_id = r.role_id
|
||||||
and u.user_id = ou.user_id
|
and u.user_id = ou.user_id
|
||||||
and r.role_id in (2,4)
|
and r.role_id in (2,4)
|
||||||
<!-- <if test="vo.phone!=null and vo.phone !=''">-->
|
|
||||||
<!-- and u.phone = #{phone}-->
|
|
||||||
<!-- </if>-->
|
|
||||||
<if test="vo.idcard!=null and vo.idcard !='' ">
|
<if test="vo.idcard!=null and vo.idcard !='' ">
|
||||||
and u.idcard = #{vo.idcard}
|
and u.idcard = #{vo.idcard}
|
||||||
</if>
|
</if>
|
||||||
@ -124,11 +119,12 @@
|
|||||||
r.role_scope AS roleScope
|
r.role_scope AS roleScope
|
||||||
FROM
|
FROM
|
||||||
sys_user u,
|
sys_user u,
|
||||||
sys_user_role ou,
|
sys_user_role ou,
|
||||||
sys_role r
|
sys_role r
|
||||||
WHERE
|
WHERE
|
||||||
u.user_id = ou.user_id
|
u.user_id = ou.user_id
|
||||||
AND ou.role_id = r.role_id
|
AND ou.role_id = r.role_id
|
||||||
|
AND r.role_scope = 'EBTP'
|
||||||
AND u.user_id = #{userId}
|
AND u.user_id = #{userId}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
@ -145,8 +141,9 @@
|
|||||||
sys_role r
|
sys_role r
|
||||||
WHERE
|
WHERE
|
||||||
u.user_id = ou.user_id
|
u.user_id = ou.user_id
|
||||||
AND ou.role_id = r.role_id
|
AND ou.role_id = r.role_id
|
||||||
AND u.user_id = #{userId}
|
AND r.role_scope = 'SUP'
|
||||||
|
AND u.user_id = #{userId}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -162,8 +159,9 @@
|
|||||||
sys_role r
|
sys_role r
|
||||||
WHERE
|
WHERE
|
||||||
u.user_id = ou.user_id
|
u.user_id = ou.user_id
|
||||||
AND ou.role_id = r.role_id
|
AND ou.role_id = r.role_id
|
||||||
AND u.user_id = #{userId}
|
AND r.role_scope = 'EXPE'
|
||||||
|
AND u.user_id = #{userId}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -141,7 +141,6 @@ public class BaseUserServiceImpl extends BaseServiceImpl<BaseUserMapper, SysUser
|
|||||||
byte[] decode = RSA.decryptByPrivateKey(RSA.decryptBASE64(password), privateKey);
|
byte[] decode = RSA.decryptByPrivateKey(RSA.decryptBASE64(password), privateKey);
|
||||||
|
|
||||||
String pw = new String(decode);
|
String pw = new String(decode);
|
||||||
// String pw = password;
|
|
||||||
|
|
||||||
if (!Md5Util.encode(pw).equals(user.getPassword())) {
|
if (!Md5Util.encode(pw).equals(user.getPassword())) {
|
||||||
// 记录登录失败日志
|
// 记录登录失败日志
|
||||||
|
@ -46,6 +46,12 @@ public class SysOrg extends BaseEntity implements Serializable {
|
|||||||
@ApiModelProperty(value = "组织类型(Org:表示公司;Dept:表示部门)")
|
@ApiModelProperty(value = "组织类型(Org:表示公司;Dept:表示部门)")
|
||||||
private String orgCategory;
|
private String orgCategory;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "公司层级代码")
|
||||||
|
private String companyLevelCode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "公司层级描述")
|
||||||
|
private String companyLevelText;
|
||||||
|
|
||||||
@ApiModelProperty(value = "部门或者团队领导名称")
|
@ApiModelProperty(value = "部门或者团队领导名称")
|
||||||
private String leaderName;
|
private String leaderName;
|
||||||
|
|
||||||
|
@ -172,17 +172,32 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgMapper, SysOrg> imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByVo(SysOrgVO vo) {
|
public Boolean insertByVo(SysOrgVO vo) {
|
||||||
|
// 无上级机构情况下默认赋予根节点
|
||||||
|
String upOrgId = vo.getUpOrgId();
|
||||||
|
if (StringUtils.isEmpty(upOrgId)) {
|
||||||
|
vo.setUpOrgId(CommonUtil.ROOT_NODE);
|
||||||
|
}
|
||||||
|
|
||||||
vo.setOrgId(PropertyUtils.getSnowflakeId()).setCreateDate(LocalDateTime.now());
|
vo.setOrgId(PropertyUtils.getSnowflakeId()).setCreateDate(LocalDateTime.now());
|
||||||
|
|
||||||
|
// 添加全路径与全路径名称,同时设置公司相关信息
|
||||||
SysOrg full = this.buildOrgFullPath(vo);
|
SysOrg full = this.buildOrgFullPath(vo);
|
||||||
vo.setOrgFullId(full.getOrgFullId()).setOrgFullName(full.getOrgFullName());
|
vo.setOrgFullId(full.getOrgFullId()).setOrgFullName(full.getOrgFullName());
|
||||||
|
|
||||||
|
// 设置所属公司编码和名称
|
||||||
|
if (full.getCuCompanyNumber() != null) {
|
||||||
|
vo.setCuCompanyNumber(full.getCuCompanyNumber());
|
||||||
|
vo.setCuCompanyName(full.getCuCompanyName());
|
||||||
|
}
|
||||||
|
|
||||||
validEntityBeforeSave(vo, false);
|
validEntityBeforeSave(vo, false);
|
||||||
boolean result = baseMapper.insert(vo) > 0;
|
boolean result = baseMapper.insert(vo) > 0;
|
||||||
|
|
||||||
// 新增成功后刷新缓存
|
// 新增成功后刷新缓存
|
||||||
if (result) {
|
if (result) {
|
||||||
orgCacheManager.refreshCache();
|
orgCacheManager.refreshCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,15 +206,22 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgMapper, SysOrg> imp
|
|||||||
validEntityBeforeSave(vo, true);
|
validEntityBeforeSave(vo, true);
|
||||||
SysOrg full = this.buildOrgFullPath(vo);
|
SysOrg full = this.buildOrgFullPath(vo);
|
||||||
vo.setOrgFullId(full.getOrgFullId()).setOrgFullName(full.getOrgFullName());
|
vo.setOrgFullId(full.getOrgFullId()).setOrgFullName(full.getOrgFullName());
|
||||||
|
|
||||||
|
// 设置所属公司编码和名称
|
||||||
|
if (full.getCuCompanyNumber() != null) {
|
||||||
|
vo.setCuCompanyNumber(full.getCuCompanyNumber());
|
||||||
|
vo.setCuCompanyName(full.getCuCompanyName());
|
||||||
|
}
|
||||||
|
|
||||||
// 删除机构与人员关联
|
// 删除机构与人员关联
|
||||||
// roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, vo.getRoleId()));
|
// roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, vo.getRoleId()));
|
||||||
boolean result = baseMapper.updateById(vo) > 0;
|
boolean result = baseMapper.updateById(vo) > 0;
|
||||||
|
|
||||||
// 更新成功后刷新缓存
|
// 更新成功后刷新缓存
|
||||||
if (result) {
|
if (result) {
|
||||||
orgCacheManager.refreshCache();
|
orgCacheManager.refreshCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,12 +234,12 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgMapper, SysOrg> imp
|
|||||||
// 删除机构与人员关联
|
// 删除机构与人员关联
|
||||||
// roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
|
// roleMenuService.remove(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
|
||||||
boolean result = this.removeById(orgId);
|
boolean result = this.removeById(orgId);
|
||||||
|
|
||||||
// 删除成功后刷新缓存
|
// 删除成功后刷新缓存
|
||||||
if (result) {
|
if (result) {
|
||||||
orgCacheManager.refreshCache();
|
orgCacheManager.refreshCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,17 +259,29 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgMapper, SysOrg> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
/**
|
||||||
|
* 构建组织全路径并查找最近的上级公司组织
|
||||||
|
* @param nowOrg 当前组织
|
||||||
|
* @return 包含全路径信息和公司组织信息的对象
|
||||||
|
*/
|
||||||
public SysOrg buildOrgFullPath(SysOrg nowOrg) {
|
public SysOrg buildOrgFullPath(SysOrg nowOrg) {
|
||||||
String upOrgId = StringUtils.isBlank(nowOrg.getUpOrgId()) ? CommonUtil.ROOT_NODE : nowOrg.getUpOrgId();
|
String upOrgId = StringUtils.isBlank(nowOrg.getUpOrgId()) ? CommonUtil.ROOT_NODE : nowOrg.getUpOrgId();
|
||||||
List<String> idPath = new ArrayList<>();
|
List<String> idPath = new ArrayList<>();
|
||||||
List<String> namePath = new ArrayList<>();
|
List<String> namePath = new ArrayList<>();
|
||||||
idPath.add(0, nowOrg.getOrgId());
|
idPath.add(0, nowOrg.getOrgId());
|
||||||
namePath.add(0, nowOrg.getOrgName());
|
namePath.add(0, nowOrg.getOrgName());
|
||||||
|
|
||||||
SysOrg currentOrg = baseMapper.selectById(upOrgId);
|
SysOrg currentOrg = baseMapper.selectById(upOrgId);
|
||||||
|
SysOrg companyOrg = null; // 用于存储找到的公司组织
|
||||||
|
|
||||||
while (currentOrg != null) {
|
while (currentOrg != null) {
|
||||||
idPath.add(0, currentOrg.getOrgId());
|
idPath.add(0, currentOrg.getOrgId());
|
||||||
namePath.add(0, currentOrg.getOrgName());
|
namePath.add(0, currentOrg.getOrgName());
|
||||||
|
|
||||||
|
// 如果还没有找到公司组织,且当前组织的orgCategory是"Org",则记录
|
||||||
|
if (companyOrg == null && "Org".equals(currentOrg.getOrgCategory())) {
|
||||||
|
companyOrg = currentOrg;
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(currentOrg.getUpOrgId()) || currentOrg.getUpOrgId().equals(CommonUtil.ROOT_NODE)) {
|
if (StringUtils.isBlank(currentOrg.getUpOrgId()) || currentOrg.getUpOrgId().equals(CommonUtil.ROOT_NODE)) {
|
||||||
break;
|
break;
|
||||||
@ -257,11 +291,19 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgMapper, SysOrg> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
String orgFullId = String.join(",", idPath);
|
String orgFullId = String.join(",", idPath);
|
||||||
String orgFullName = String.join("--", namePath);
|
String orgFullName = String.join(",", namePath);
|
||||||
|
|
||||||
return new SysOrg().setOrgId(idPath.get(idPath.size() - 1))
|
SysOrg result = new SysOrg().setOrgId(idPath.get(idPath.size() - 1))
|
||||||
.setOrgFullId(orgFullId)
|
.setOrgFullId(orgFullId)
|
||||||
.setOrgFullName(orgFullName);
|
.setOrgFullName(orgFullName);
|
||||||
|
|
||||||
|
// 如果找到了公司组织,设置公司相关信息
|
||||||
|
if (companyOrg != null) {
|
||||||
|
result.setCuCompanyNumber(companyOrg.getOrgId());
|
||||||
|
result.setCuCompanyName(companyOrg.getOrgName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.coscoshipping.ebtp.system.user.controller;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
||||||
|
import com.coscoshipping.ebtp.system.user.entity.vo.SysSupplierUserVO;
|
||||||
import com.coscoshipping.ebtp.system.user.service.SysSupplierUserService;
|
import com.coscoshipping.ebtp.system.user.service.SysSupplierUserService;
|
||||||
import com.coscoshipping.ebtp.system.user.vo.SupplierRegistrationVO;
|
import com.coscoshipping.ebtp.system.user.vo.SupplierRegistrationVO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -51,13 +52,13 @@ public class SysSupplierUserController {
|
|||||||
/**
|
/**
|
||||||
* 供应商用户分页查询
|
* 供应商用户分页查询
|
||||||
*
|
*
|
||||||
* @param sysSupplierUser 查询条件
|
* @param sysSupplierUserVO 查询条件
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
@ApiOperation("供应商用户分页查询")
|
@ApiOperation("供应商用户分页查询")
|
||||||
@PostMapping("/getPage")
|
@PostMapping("/getPage")
|
||||||
public BaseResponse<IPage<SysSupplierUser>> getPage(@ApiParam(value = "查询条件", required = true) @RequestBody SysSupplierUser sysSupplierUser) {
|
public BaseResponse<IPage<SysSupplierUser>> getPage(@ApiParam(value = "查询条件", required = true) @RequestBody SysSupplierUserVO sysSupplierUserVO) {
|
||||||
return BaseResponse.success(sysSupplierUserService.getPage(sysSupplierUser));
|
return BaseResponse.success(sysSupplierUserService.getPage(sysSupplierUserVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.coscoshipping.ebtp.system.user.entity.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.base.entity.BasePageRequest;
|
||||||
|
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体类 SysSupplierUserVO-供应商用户表VO
|
||||||
|
*
|
||||||
|
* @author yss
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName(autoResultMap = true)
|
||||||
|
@ApiModel("供应商用户信息VO类")
|
||||||
|
public class SysSupplierUserVO extends SysSupplierUser implements Serializable {
|
||||||
|
/**
|
||||||
|
* 分页数据
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "分页对象信息")
|
||||||
|
private BasePageRequest basePageRequest;
|
||||||
|
}
|
@ -3,6 +3,7 @@ package com.coscoshipping.ebtp.system.user.service;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||||
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
||||||
|
import com.coscoshipping.ebtp.system.user.entity.vo.SysSupplierUserVO;
|
||||||
import com.coscoshipping.ebtp.system.user.vo.SupplierRegistrationVO;
|
import com.coscoshipping.ebtp.system.user.vo.SupplierRegistrationVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,10 +15,10 @@ public interface SysSupplierUserService extends IBaseService<SysSupplierUser> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 供应商用户分页查询
|
* 供应商用户分页查询
|
||||||
* @param sysSupplierUser 供应商用户信息
|
* @param sysSupplierUserVO 供应商用户VO信息
|
||||||
* @return 返回结果
|
* @return 返回结果
|
||||||
*/
|
*/
|
||||||
IPage<SysSupplierUser> getPage(SysSupplierUser sysSupplierUser);
|
IPage<SysSupplierUser> getPage(SysSupplierUserVO sysSupplierUserVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增供应商用户
|
* 新增供应商用户
|
||||||
|
@ -9,6 +9,7 @@ import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
|||||||
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
|
import com.chinaunicom.mall.ebtp.common.util.PropertyUtils;
|
||||||
|
|
||||||
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
import com.coscoshipping.ebtp.system.user.entity.SysSupplierUser;
|
||||||
|
import com.coscoshipping.ebtp.system.user.entity.vo.SysSupplierUserVO;
|
||||||
import com.coscoshipping.ebtp.system.user.service.SysSupplierUserService;
|
import com.coscoshipping.ebtp.system.user.service.SysSupplierUserService;
|
||||||
import com.coscoshipping.ebtp.system.user.dao.SysSupplierUserMapper;
|
import com.coscoshipping.ebtp.system.user.dao.SysSupplierUserMapper;
|
||||||
import com.coscoshipping.ebtp.system.user.util.AccountGeneratorUtil;
|
import com.coscoshipping.ebtp.system.user.util.AccountGeneratorUtil;
|
||||||
@ -47,12 +48,13 @@ public class SysSupplierUserServiceImpl extends BaseServiceImpl<SysSupplierUserM
|
|||||||
private SysUserRoleService sysUserRoleService;
|
private SysUserRoleService sysUserRoleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<SysSupplierUser> getPage(SysSupplierUser sysSupplierUser) {
|
public IPage<SysSupplierUser> getPage(SysSupplierUserVO sysSupplierUserVO) {
|
||||||
LambdaQueryWrapper<SysSupplierUser> query = buildQueryWrapper(sysSupplierUser);
|
LambdaQueryWrapper<SysSupplierUser> query = buildQueryWrapper(sysSupplierUserVO);
|
||||||
|
// 从VO中获取分页请求,如果没有则创建默认的
|
||||||
// 如果没有分页请求,创建一个默认的
|
BasePageRequest basePageRequest = sysSupplierUserVO.getBasePageRequest();
|
||||||
BasePageRequest basePageRequest = new BasePageRequest();
|
if (basePageRequest == null) {
|
||||||
|
basePageRequest = new BasePageRequest();
|
||||||
|
}
|
||||||
// 查询
|
// 查询
|
||||||
IPage<SysSupplierUser> result = new Page<>(basePageRequest.getPageNo(), basePageRequest.getPageSize());
|
IPage<SysSupplierUser> result = new Page<>(basePageRequest.getPageNo(), basePageRequest.getPageSize());
|
||||||
result = this.page(result, query);
|
result = this.page(result, query);
|
||||||
|
Reference in New Issue
Block a user