【system】【org】【position】更新模块实体和数据库对应

pull/3/head
fengshuonan 2020-12-20 15:45:19 +08:00
parent 92941bb331
commit adb9b4096b
8 changed files with 83 additions and 116 deletions

View File

@ -24,25 +24,25 @@ public class SysOrganizationRequest extends BaseRequest {
*
*/
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class, detail.class, updateStatus.class})
private Long id;
private Long orgId;
/**
* id
*/
@NotNull(message = "父id不能为空", groups = {add.class, edit.class})
private Long pid;
private Long orgParentId;
/**
* ids
*/
@NotBlank(message = "父ids不能为空", groups = {add.class, edit.class})
private String pids;
private String orgPids;
/**
*
*/
@NotBlank(message = "组织名称不能为空", groups = {add.class, edit.class})
private String name;
private String orgName;
/**
*
@ -52,19 +52,19 @@ public class SysOrganizationRequest extends BaseRequest {
message = "组织编码存在重复请检查code参数",
groups = {add.class, edit.class},
tableName = "sys_organization",
columnName = "code")
private String code;
columnName = "org_code")
private String orgCode;
/**
*
*/
@NotNull(message = "排序不能为空", groups = {add.class, edit.class})
private BigDecimal sort;
private BigDecimal orgSort;
/**
* 1-2-
* 1-2-
*/
@NotNull(message = "状态1-启用2-禁用)不能为空", groups = {updateStatus.class})
@NotNull(message = "状态不能为空", groups = {updateStatus.class})
@StatusValue(groups = updateStatus.class)
private Integer statusFlag;

View File

@ -24,35 +24,35 @@ public class SysPositionRequest extends BaseRequest {
*
*/
@NotNull(message = "主键不能为空", groups = {edit.class, detail.class, delete.class})
private Long id;
private Long positionId;
/**
*
*/
@NotBlank(message = "职位名称不能为空", groups = {add.class, edit.class})
private String name;
private String positionName;
/**
*
*/
@NotBlank(message = "职位编码不能为空", groups = {add.class, edit.class})
@TableUniqueValue(
message = "职位编码存在重复请检查code参数",
message = "职位编码存在重复",
groups = {add.class, edit.class},
tableName = "sys_position",
columnName = "code")
private String code;
columnName = "position_code")
private String positionCode;
/**
*
*/
@NotNull(message = "排序不能为空", groups = {add.class, edit.class})
private BigDecimal sort;
private BigDecimal positionSort;
/**
* 1-2-
* 1-2-
*/
@NotNull(message = "状态1-启用2-禁用)不能为空", groups = {updateStatus.class})
@NotNull(message = "状态不能为空", groups = {updateStatus.class})
@StatusValue(groups = updateStatus.class)
private Integer statusFlag;

View File

@ -1,9 +1,9 @@
package cn.stylefeng.roses.kernel.system.modular.organization.entity;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -23,41 +23,41 @@ public class SysOrganization extends BaseEntity {
/**
*
*/
@TableId("id")
private Long id;
@TableId("org_id")
private Long orgId;
/**
* idid0
* idid0
*/
@TableField("pid")
private Long pid;
@TableField("org_parent_id")
private Long orgParentId;
/**
* ids
*/
@TableField("pids")
private String pids;
@TableField("org_pids")
private String orgPids;
/**
*
*/
@TableField("name")
private String name;
@TableField("org_name")
private String orgName;
/**
*
*/
@TableField("code")
private String code;
@TableField("org_code")
private String orgCode;
/**
*
*/
@TableField("sort")
private BigDecimal sort;
@TableField("org_sort")
private BigDecimal orgSort;
/**
* 1-2-
* 1-2-
*/
@TableField("status_flag")
private Integer statusFlag;

View File

@ -1,9 +1,9 @@
package cn.stylefeng.roses.kernel.system.modular.organization.entity;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -23,29 +23,29 @@ public class SysPosition extends BaseEntity {
/**
*
*/
@TableId("id")
private Long id;
@TableId("position_id")
private Long positionId;
/**
*
*/
@TableField("name")
private String name;
@TableField("position_name")
private String positionName;
/**
*
*/
@TableField("code")
private String code;
@TableField("position_code")
private String positionCode;
/**
*
*/
@TableField("sort")
private BigDecimal sort;
@TableField("position_sort")
private BigDecimal positionSort;
/**
* 1-2-
* 1-2-
*/
@TableField("status_flag")
private Integer statusFlag;
@ -57,7 +57,7 @@ public class SysPosition extends BaseEntity {
private String remark;
/**
* Y-N-
* Y-N-
*/
@TableField("del_flag")
private String delFlag;

View File

@ -2,21 +2,4 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.organization.mapper.SysOrganizationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.system.modular.organization.entity.SysOrganization">
<id column="id" property="id" />
<result column="pid" property="pid" />
<result column="pids" property="pids" />
<result column="name" property="name" />
<result column="code" property="code" />
<result column="sort" property="sort" />
<result column="status_flag" property="statusFlag" />
<result column="remark" property="remark" />
<result column="del_flag" property="delFlag" />
<result column="create_time" property="createTime" />
<result column="create_user" property="createUser" />
<result column="update_time" property="updateTime" />
<result column="update_user" property="updateUser" />
</resultMap>
</mapper>

View File

@ -2,19 +2,4 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.organization.mapper.SysPositionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.system.modular.organization.entity.SysPosition">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="code" property="code" />
<result column="sort" property="sort" />
<result column="status_flag" property="statusFlag" />
<result column="remark" property="remark" />
<result column="del_flag" property="delFlag" />
<result column="create_time" property="createTime" />
<result column="create_user" property="createUser" />
<result column="update_time" property="updateTime" />
<result column="update_user" property="updateUser" />
</resultMap>
</mapper>

View File

@ -61,7 +61,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
public void add(SysOrganizationRequest sysOrganizationRequest) {
// 获取父id
Long pid = sysOrganizationRequest.getPid();
Long pid = sysOrganizationRequest.getOrgParentId();
// 校验数据范围
if (DataScopeUtil.validateDataScopeByOrganizationId(pid)) {
@ -85,7 +85,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
public void edit(SysOrganizationRequest sysOrganizationRequest) {
SysOrganization sysOrganization = this.querySysOrganization(sysOrganizationRequest);
Long id = sysOrganization.getId();
Long id = sysOrganization.getOrgId();
// 校验数据范围
if (DataScopeUtil.validateDataScopeByOrganizationId(id)) {
@ -110,7 +110,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
public void delete(SysOrganizationRequest sysOrganizationRequest) {
SysOrganization sysOrganization = this.querySysOrganization(sysOrganizationRequest);
Long organizationId = sysOrganization.getId();
Long organizationId = sysOrganization.getOrgId();
// 校验数据范围
if (DataScopeUtil.validateDataScopeByOrganizationId(organizationId)) {
@ -128,7 +128,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
Set<Long> childIdList = DbOperatorContext.me().findSubListByParentId("sys_organization", "pids", "id", organizationId);
childIdList.add(organizationId);
LambdaUpdateWrapper<SysOrganization> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(SysOrganization::getId, childIdList)
updateWrapper.in(SysOrganization::getOrgId, childIdList)
.set(SysOrganization::getDelFlag, YesOrNotEnum.Y.getCode());
this.update(updateWrapper);
@ -143,7 +143,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
public void updateStatus(SysOrganizationRequest sysOrganizationRequest) {
LambdaUpdateWrapper<SysOrganization> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SysOrganization::getId, sysOrganizationRequest.getId());
updateWrapper.eq(SysOrganization::getOrgId, sysOrganizationRequest.getOrgId());
updateWrapper.set(SysOrganization::getStatusFlag, sysOrganizationRequest.getStatusFlag());
this.update(updateWrapper);
@ -206,23 +206,23 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
Set<Long> allLevelParentIdsByOrganizations = this.findAllLevelParentIdsByOrganizations(dataScope);
// 拼接查询条件
queryWrapper.in(SysOrganization::getId, allLevelParentIdsByOrganizations);
queryWrapper.in(SysOrganization::getOrgId, allLevelParentIdsByOrganizations);
}
// 只查询未删除的
queryWrapper.eq(SysOrganization::getDelFlag, YesOrNotEnum.N.getCode());
// 根据排序升序排列,序号越小越在前
queryWrapper.orderByAsc(SysOrganization::getSort);
queryWrapper.orderByAsc(SysOrganization::getOrgSort);
// 组装节点
List<SysOrganization> list = this.list(queryWrapper);
for (SysOrganization sysOrganization : list) {
DefaultTreeNode orgTreeNode = new DefaultTreeNode();
orgTreeNode.setId(String.valueOf(sysOrganization.getId()));
orgTreeNode.setPId(String.valueOf(sysOrganization.getPid()));
orgTreeNode.setName(sysOrganization.getName());
orgTreeNode.setSort(sysOrganization.getSort());
orgTreeNode.setId(String.valueOf(sysOrganization.getOrgId()));
orgTreeNode.setPId(String.valueOf(sysOrganization.getOrgParentId()));
orgTreeNode.setName(sysOrganization.getOrgName());
orgTreeNode.setSort(sysOrganization.getOrgSort());
treeNodeList.add(orgTreeNode);
}
@ -238,8 +238,8 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
// 查询出这些节点的pids字段
LambdaQueryWrapper<SysOrganization> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SysOrganization::getId, organizationIds);
queryWrapper.select(SysOrganization::getPids);
queryWrapper.in(SysOrganization::getOrgId, organizationIds);
queryWrapper.select(SysOrganization::getOrgPids);
List<SysOrganization> organizationList = this.list(queryWrapper);
if (organizationList == null || organizationList.isEmpty()) {
@ -250,7 +250,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
for (SysOrganization sysOrganization : organizationList) {
// 获取pids值
String pids = sysOrganization.getPids();
String pids = sysOrganization.getOrgPids();
// 去掉所有的左中括号
String cutLeft = StrUtil.removeAll(pids, SystemConstants.PID_LEFT_DIVIDE_SYMBOL);
@ -281,21 +281,21 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
if (ObjectUtil.isNotNull(sysOrganizationRequest)) {
// 拼接机构名称查询条件
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getName())) {
queryWrapper.like(SysOrganization::getName, sysOrganizationRequest.getName());
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getOrgName())) {
queryWrapper.like(SysOrganization::getOrgName, sysOrganizationRequest.getOrgName());
}
// 拼接机构id查询条件
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getId())) {
queryWrapper.eq(SysOrganization::getId, sysOrganizationRequest.getId());
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getOrgId())) {
queryWrapper.eq(SysOrganization::getOrgId, sysOrganizationRequest.getOrgId());
}
// 拼接父机构id查询条件
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getPid())) {
if (ObjectUtil.isNotEmpty(sysOrganizationRequest.getOrgParentId())) {
queryWrapper
.eq(SysOrganization::getId, sysOrganizationRequest.getPid())
.eq(SysOrganization::getOrgId, sysOrganizationRequest.getOrgParentId())
.or()
.like(SysOrganization::getPids, sysOrganizationRequest.getPid());
.like(SysOrganization::getOrgPids, sysOrganizationRequest.getOrgParentId());
}
}
@ -303,7 +303,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
queryWrapper.eq(SysOrganization::getDelFlag, YesOrNotEnum.N.getCode());
// 根据排序升序排列,序号越小越在前
queryWrapper.orderByAsc(SysOrganization::getSort);
queryWrapper.orderByAsc(SysOrganization::getOrgSort);
return queryWrapper;
}
@ -316,7 +316,7 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
* @date 2020/11/04 11:05
*/
private SysOrganization querySysOrganization(SysOrganizationRequest sysOrganizationRequest) {
SysOrganization sysorganization = this.getById(sysOrganizationRequest.getId());
SysOrganization sysorganization = this.getById(sysOrganizationRequest.getOrgId());
if (ObjectUtil.isEmpty(sysorganization)) {
throw new SystemModularException(OrganizationExceptionEnum.CANT_FIND_ORG);
}
@ -332,16 +332,16 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
private void fillParentIds(SysOrganization sysOrganization) {
// 如果是一级节点一级节点的pid是0
if (sysOrganization.getPid().equals(SystemConstants.DEFAULT_PARENT_ID)) {
if (sysOrganization.getOrgParentId().equals(SystemConstants.DEFAULT_PARENT_ID)) {
// 设置一级节点的pid为[0],
sysOrganization.setPids(SystemConstants.PID_LEFT_DIVIDE_SYMBOL + SystemConstants.DEFAULT_PARENT_ID + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
sysOrganization.setOrgPids(SystemConstants.PID_LEFT_DIVIDE_SYMBOL + SystemConstants.DEFAULT_PARENT_ID + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
} else {
// 获取父组织机构
SysOrganization parentSysOrganization = this.getById(sysOrganization.getPid());
SysOrganization parentSysOrganization = this.getById(sysOrganization.getOrgParentId());
// 设置本节点的父ids为 (上一个节点的pids + (上级节点的id) )
sysOrganization.setPids(
parentSysOrganization.getPids() + SystemConstants.PID_LEFT_DIVIDE_SYMBOL + parentSysOrganization.getId() + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
sysOrganization.setOrgPids(
parentSysOrganization.getOrgPids() + SystemConstants.PID_LEFT_DIVIDE_SYMBOL + parentSysOrganization.getOrgId() + SystemConstants.PID_RIGHT_DIVIDE_SYMBOL + ",");
}
}

View File

@ -69,7 +69,7 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPo
// 该职位下是否有员工
// 职位有绑定员工,不能删除
Boolean userOrgFlag = userOrgServiceApi.getUserOrgFlag(null, sysPosition.getId());
Boolean userOrgFlag = userOrgServiceApi.getUserOrgFlag(null, sysPosition.getPositionId());
if (userOrgFlag) {
throw new SystemModularException(PositionExceptionEnum.CANT_DELETE_POSITION);
}
@ -83,7 +83,7 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPo
@Override
public void updateStatus(SysPositionRequest sysPositionRequest) {
LambdaUpdateWrapper<SysPosition> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SysPosition::getId, sysPositionRequest.getId());
updateWrapper.eq(SysPosition::getPositionId, sysPositionRequest.getPositionId());
updateWrapper.set(SysPosition::getStatusFlag, sysPositionRequest.getStatusFlag());
this.update(updateWrapper);
@ -113,14 +113,14 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPo
// 拼接查询条件
LambdaQueryWrapper<SysPosition> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SysPosition::getId, positionIds);
queryWrapper.select(SysPosition::getName);
queryWrapper.in(SysPosition::getPositionId, positionIds);
queryWrapper.select(SysPosition::getPositionName);
// 查询结果
List<SysPosition> sysPositions = this.list(queryWrapper);
// 把name组装起来
return sysPositions.stream().map(SysPosition::getName).collect(Collectors.toList());
return sysPositions.stream().map(SysPosition::getPositionName).collect(Collectors.toList());
}
/**
@ -134,22 +134,21 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPo
if (ObjectUtil.isNotNull(sysPositionRequest)) {
// 拼接职位名称条件
if (ObjectUtil.isNotEmpty(sysPositionRequest.getName())) {
queryWrapper.like(SysPosition::getName, sysPositionRequest.getName());
if (ObjectUtil.isNotEmpty(sysPositionRequest.getPositionName())) {
queryWrapper.like(SysPosition::getPositionName, sysPositionRequest.getPositionName());
}
// 拼接职位编码条件
if (ObjectUtil.isNotEmpty(sysPositionRequest.getCode())) {
queryWrapper.eq(SysPosition::getCode, sysPositionRequest.getCode());
if (ObjectUtil.isNotEmpty(sysPositionRequest.getPositionCode())) {
queryWrapper.eq(SysPosition::getPositionCode, sysPositionRequest.getPositionCode());
}
}
// 查询未删除状态的
queryWrapper.eq(SysPosition::getDelFlag, YesOrNotEnum.N.getCode());
// 根据排序升序排列,序号越小越在前
queryWrapper.orderByAsc(SysPosition::getSort);
queryWrapper.orderByAsc(SysPosition::getPositionSort);
return queryWrapper;
}
@ -161,9 +160,9 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPo
* @date 2020/11/18 22:59
*/
private SysPosition querySysPosition(SysPositionRequest sysPositionRequest) {
SysPosition sysposition = this.getById(sysPositionRequest.getId());
SysPosition sysposition = this.getById(sysPositionRequest.getPositionId());
if (ObjectUtil.isEmpty(sysposition)) {
String userTip = StrUtil.format(PositionExceptionEnum.CANT_FIND_POSITION.getUserTip(), sysposition.getId());
String userTip = StrUtil.format(PositionExceptionEnum.CANT_FIND_POSITION.getUserTip(), sysposition.getPositionId());
throw new SystemModularException(PositionExceptionEnum.CANT_FIND_POSITION, userTip);
}
return sysposition;