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