岗位管理
This commit is contained in:
@@ -36,3 +36,4 @@ target
|
||||
*logs/
|
||||
.metadata
|
||||
|
||||
adc-da-main/src/main/resources/application-zxy.properties
|
||||
@@ -22,11 +22,11 @@ public class CodeGen {
|
||||
|
||||
// x.x.x.x:3306/xxxx --MYSQL
|
||||
// 192.168.10.140:1521:foton_slrs_test
|
||||
private static final String DB_IP="192.168.10.47:3306/foton_slrs_test";
|
||||
private static final String DB_IP="localhost:3306/foton_slrs_test";
|
||||
|
||||
private static final String DB_USER="root";
|
||||
|
||||
private static final String DB_PWD="root";
|
||||
private static final String DB_PWD="Zxy20010202";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
# 数据库配置
|
||||
#=============================================
|
||||
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url = jdbc:mysql://101.36.227.22:33050/foton_slrs_test?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
|
||||
spring.datasource.url = jdbc:mysql://localhost:3306/foton_slrs_test?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
|
||||
spring.datasource.username = root
|
||||
spring.datasource.password = 1q2w3e4r
|
||||
spring.datasource.password = Zxy20010202
|
||||
|
||||
#==============================================
|
||||
# 应用设置
|
||||
|
||||
@@ -91,6 +91,7 @@ spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
|
||||
# =======================================
|
||||
mybatis-plus.config-location=classpath:mybatis/mybatis-config.xml
|
||||
mybatis-plus.mapper-locations=classpath*:mybatis/mapper/**/*.xml
|
||||
mybatis-plus.type-aliases-package=com.adc.da.**.entity
|
||||
|
||||
# ========================================
|
||||
# activiti 配置信息
|
||||
|
||||
+4
-1
@@ -11,7 +11,10 @@
|
||||
|
||||
<artifactId>adc-da-slrs</artifactId>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId></groupId>
|
||||
<artifactId></artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.adc</groupId>
|
||||
<artifactId>adc-da-base</artifactId>
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.adc.da.slrs.sarPosition.controller;
|
||||
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPositionRoleVO;
|
||||
import com.adc.da.slrs.sarPosition.service.ITsPositionService;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPosition;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author zyl
|
||||
* @since 2021-06-23
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "|岗位管理|")
|
||||
@RequestMapping("/sarPosition/position")
|
||||
public class TsPositionController extends BaseController<TsPosition> {
|
||||
@Autowired
|
||||
private ITsPositionService tsPositionService;
|
||||
|
||||
/**
|
||||
* 查询岗位(可通过name筛选)
|
||||
* @param tsPosition:筛选信息
|
||||
*/
|
||||
@ApiOperation("查询岗位")
|
||||
@GetMapping
|
||||
public ResponseMessage<List<TsPosition>> getPosition(TsPosition tsPosition){
|
||||
List<TsPosition> positions=tsPositionService.getPosition(tsPosition);
|
||||
return Result.success(positions);
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@PostMapping
|
||||
public ResponseMessage<Object> addPosition(@Validated(TsPosition.insert.class) TsPosition tsPosition){
|
||||
return tsPositionService.addPosition(tsPosition);
|
||||
}
|
||||
|
||||
@ApiOperation("配置角色")
|
||||
@PostMapping("/role")
|
||||
public ResponseMessage<Object> setRole(@Valid @RequestBody TsPositionRoleVO tsPositionRoleVO){
|
||||
return tsPositionService.setRole(tsPositionRoleVO);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@GetMapping("/role")
|
||||
public ResponseMessage<List<TsRole>> getRole(@RequestParam String positionId){
|
||||
List<TsRole> roles=tsPositionService.getRole(positionId);
|
||||
return Result.success(roles);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.adc.da.slrs.sarPosition.dao;
|
||||
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPosition;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zyl
|
||||
* @since 2021-06-23
|
||||
*/
|
||||
public interface TsPositionDao extends BaseMapper<TsPosition> {
|
||||
|
||||
@Select("select role_id from ts_position_role where position_id=#{positionId}")
|
||||
List<String> getRoleId(String positionId);
|
||||
|
||||
@Insert("insert into ts_position_role (position_id,role_id) values (#{positionId},#{roleId})")
|
||||
void insertRole(String positionId, String roleId);
|
||||
|
||||
@Delete("delete from ts_position_role where position_id=#{positionId} and role_id=#{roleId}")
|
||||
void deleteRole(String positionId, String roleId);
|
||||
|
||||
List<TsRole> getRole(String positionId);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.adc.da.slrs.sarPosition.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author zyl
|
||||
* @since 2021-06-23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="TsPosition对象", description="")
|
||||
public class TsPosition extends BaseEntity {
|
||||
public interface insert{
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp operateTime;
|
||||
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private String operator;
|
||||
|
||||
@NotNull(message = "name不能为空",groups = {insert.class})
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "创建部门ID")
|
||||
private String createDeptId;
|
||||
|
||||
@ApiModelProperty(value = "创建人ID")
|
||||
private String createById;
|
||||
|
||||
@ApiModelProperty(value = "类型(1为导入,2为新建)")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
@TableId(value = "id",type = IdType.UUID)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp createTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.adc.da.slrs.sarPosition.entity;
|
||||
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TsPositionRoleVO {
|
||||
@NotNull(message = "positionId不能为空")
|
||||
private String positionId;
|
||||
@NotNull(message = "roleIds不能为空")
|
||||
private List<String> roleIds;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.adc.da.slrs.sarPosition.service;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPosition;
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPositionRoleVO;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zyl
|
||||
* @since 2021-06-23
|
||||
*/
|
||||
public interface ITsPositionService extends IService<TsPosition> {
|
||||
|
||||
/**
|
||||
* 查询岗位
|
||||
* @param tsPosition:查询信息
|
||||
* @return List<TsPosition>
|
||||
*/
|
||||
List<TsPosition> getPosition(TsPosition tsPosition);
|
||||
|
||||
/**
|
||||
* 配置角色
|
||||
* @param tsPositionRoleVO:角色ID
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> setRole(TsPositionRoleVO tsPositionRoleVO);
|
||||
|
||||
/**
|
||||
* 查询角色
|
||||
* @param positionId :岗位ID
|
||||
* @return List<TsRole>
|
||||
*/
|
||||
List<TsRole> getRole(String positionId);
|
||||
|
||||
/**
|
||||
* 添加岗位
|
||||
* @param tsPosition:岗位信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> addPosition(TsPosition tsPosition);
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package com.adc.da.slrs.sarPosition.service.impl;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPosition;
|
||||
import com.adc.da.slrs.sarPosition.dao.TsPositionDao;
|
||||
import com.adc.da.slrs.sarPosition.entity.TsPositionRoleVO;
|
||||
import com.adc.da.slrs.sarPosition.service.ITsPositionService;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import com.adc.da.utils.util.ListUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zyl
|
||||
* @since 2021-06-23
|
||||
*/
|
||||
@Service
|
||||
public class TsPositionServiceImpl extends ServiceImpl<TsPositionDao, TsPosition> implements ITsPositionService {
|
||||
@Autowired
|
||||
private TsPositionDao tsPositionDao;
|
||||
|
||||
/**
|
||||
* 查询岗位
|
||||
* @param tsPosition:查询信息
|
||||
* @return List<TsPosition>
|
||||
*/
|
||||
@Override
|
||||
public List<TsPosition> getPosition(TsPosition tsPosition) {
|
||||
QueryWrapper<TsPosition> positionQueryWrapper=new QueryWrapper<>();
|
||||
if(tsPosition.getName()!=null){
|
||||
positionQueryWrapper.like("name","%"+tsPosition.getName()+"%");
|
||||
}
|
||||
return tsPositionDao.selectList(positionQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置角色
|
||||
* @param tsPositionRoleVO:角色ID
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseMessage<Object> setRole(TsPositionRoleVO tsPositionRoleVO) {
|
||||
List<String> oldRoleIds=tsPositionDao.getRoleId(tsPositionRoleVO.getPositionId());
|
||||
Map<String,List<String>> updateRoleIds= ListUtil.difList(tsPositionRoleVO.getRoleIds(),oldRoleIds);
|
||||
List<String> insertIds=updateRoleIds.get("insert");
|
||||
List<String> deleteIds=updateRoleIds.get("delete");
|
||||
for(String id:insertIds){
|
||||
tsPositionDao.insertRole(tsPositionRoleVO.getPositionId(),id);
|
||||
}
|
||||
for(String id:deleteIds){
|
||||
tsPositionDao.deleteRole(tsPositionRoleVO.getPositionId(),id);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色
|
||||
* @param positionId :岗位ID
|
||||
* @return List<TsRole>
|
||||
*/
|
||||
@Override
|
||||
public List<TsRole> getRole(String positionId) {
|
||||
return tsPositionDao.getRole(positionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加岗位
|
||||
* @param tsPosition:岗位信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
@Override
|
||||
public ResponseMessage<Object> addPosition(TsPosition tsPosition) {
|
||||
QueryWrapper<TsPosition> positionQueryWrapper=new QueryWrapper<>();
|
||||
positionQueryWrapper.eq("name",tsPosition.getName());
|
||||
List<TsPosition> tsPositions=tsPositionDao.selectList(positionQueryWrapper);
|
||||
if(tsPositions!=null&&tsPositions.size()>0){
|
||||
return Result.error("该岗位已存在");
|
||||
}
|
||||
tsPositionDao.insert(tsPosition);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,15 @@ package com.adc.da.slrs.sarRole.controller;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.login.util.UserUtils;
|
||||
import com.adc.da.slrs.sarRole.service.ITsRoleService;
|
||||
import com.adc.da.sys.entity.UserEO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -48,7 +47,19 @@ public class TsRoleController extends BaseController<TsRole> {
|
||||
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping
|
||||
public ResponseMessage<List<TsRole>> addRole(@Validated(TsRole.insert.class) TsRole tsRole){
|
||||
return null;
|
||||
public ResponseMessage<Object> addRole(@Validated(TsRole.insert.class) TsRole tsRole){
|
||||
//设置操作人
|
||||
UserEO userEO=UserUtils.getUser();
|
||||
tsRole.setOperator(userEO.getUname());
|
||||
return tsRoleService.addRole(tsRole);
|
||||
}
|
||||
|
||||
@ApiOperation("编辑角色")
|
||||
@PutMapping
|
||||
public ResponseMessage<Object> updateRole(@Validated(TsRole.update.class) TsRole tsRole){
|
||||
//设置操作人
|
||||
UserEO userEO=UserUtils.getUser();
|
||||
tsRole.setOperator(userEO.getUname());
|
||||
return tsRoleService.updateRole(tsRole);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.adc.da.slrs.sarRole.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
@@ -35,11 +37,14 @@ import javax.validation.constraints.NotNull;
|
||||
public class TsRole extends BaseEntity {
|
||||
public interface insert{
|
||||
}
|
||||
public interface update{
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "id不能为空",groups = {update.class})
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId("ID")
|
||||
@TableId(value = "ID",type = IdType.UUID)
|
||||
private String id;
|
||||
|
||||
@NotNull(message = "name不能为空",groups = {insert.class})
|
||||
@@ -99,8 +104,8 @@ public class TsRole extends BaseEntity {
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty(value = "角色层级")
|
||||
@TableField("role_level")
|
||||
private Integer roleLevel;
|
||||
@TableField("ROLE_HIERARCHY")
|
||||
private Integer roleHierarchy;
|
||||
|
||||
@ApiModelProperty(value = "对应部门id")
|
||||
@TableField("DY_ORG_ID")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.slrs.sarRole.service;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -27,4 +28,18 @@ public interface ITsRoleService extends IService<TsRole> {
|
||||
* @return List<TsRole>
|
||||
*/
|
||||
List<TsRole> getByName(String name);
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
* @param tsRole :角色信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> addRole(TsRole tsRole);
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
* @param tsRole:角色信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> updateRole(TsRole tsRole);
|
||||
}
|
||||
|
||||
+45
-2
@@ -1,5 +1,7 @@
|
||||
package com.adc.da.slrs.sarRole.service.impl;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||
import com.adc.da.slrs.sarRole.dao.TsRoleDao;
|
||||
import com.adc.da.slrs.sarRole.service.ITsRoleService;
|
||||
@@ -30,7 +32,7 @@ public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements
|
||||
@Override
|
||||
public List<TsRole> getAll() {
|
||||
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
|
||||
tsRoleQueryWrapper.eq("role_level",1);
|
||||
tsRoleQueryWrapper.eq("ROLE_HIERARCHY",1);
|
||||
List<TsRole> rootRole=tsRoleDao.selectList(tsRoleQueryWrapper);
|
||||
for(TsRole tsRole:rootRole){
|
||||
tsRole.setChildren(recursionGetRole(tsRole));
|
||||
@@ -46,7 +48,7 @@ public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements
|
||||
private List<TsRole> recursionGetRole(TsRole tsRole){
|
||||
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
|
||||
tsRoleQueryWrapper.eq("parent_id",tsRole.getId());
|
||||
tsRoleQueryWrapper.eq("role_level",tsRole.getRoleLevel()+1);
|
||||
tsRoleQueryWrapper.eq("ROLE_HIERARCHY",tsRole.getRoleHierarchy()+1);
|
||||
List<TsRole> tsRoles=tsRoleDao.selectList(tsRoleQueryWrapper);
|
||||
for(TsRole tsRoleNode:tsRoles){
|
||||
tsRoleNode.setChildren(recursionGetRole(tsRoleNode));
|
||||
@@ -66,5 +68,46 @@ public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements
|
||||
return tsRoleDao.selectList(tsRoleQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
* @param tsRole :角色信息
|
||||
* @return TsRole
|
||||
*/
|
||||
@Override
|
||||
public ResponseMessage<Object> addRole(TsRole tsRole) {
|
||||
//判断是否是顶级角色
|
||||
if(tsRole.getParentId()==null){
|
||||
tsRole.setRoleHierarchy(1);
|
||||
}else {
|
||||
QueryWrapper<TsRole> parentQueryWrapper=new QueryWrapper<>();
|
||||
parentQueryWrapper.eq("id",tsRole.getParentId());
|
||||
TsRole parentRole=tsRoleDao.selectOne(parentQueryWrapper);
|
||||
if(parentRole==null){
|
||||
return Result.error("父角色不存在");
|
||||
}
|
||||
tsRole.setRoleHierarchy(parentRole.getRoleHierarchy()+1);
|
||||
}
|
||||
tsRoleDao.insert(tsRole);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
* @param tsRole:角色信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
@Override
|
||||
public ResponseMessage<Object> updateRole(TsRole tsRole) {
|
||||
TsRole oldRole=tsRoleDao.selectById(tsRole.getParentId());
|
||||
if(oldRole==null){
|
||||
return Result.error("该角色不存在");
|
||||
}
|
||||
//不允许修改父节点
|
||||
tsRole.setRoleHierarchy(null);
|
||||
tsRole.setParentId(null);
|
||||
tsRoleDao.updateById(tsRole);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.adc.da.utils.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* List操作
|
||||
* @author zxy
|
||||
*/
|
||||
public class ListUtil {
|
||||
|
||||
/**
|
||||
* 获得targetList和referList中不同的元素
|
||||
* @param targetList:目标List
|
||||
* @param referList:参照List
|
||||
*/
|
||||
public static Map<String,List<String>> difList(List<String> targetList, List<String> referList){
|
||||
targetList.sort(String::compareTo);
|
||||
referList.sort(String::compareTo);
|
||||
//targetList多的节点
|
||||
List<String> insertList=new ArrayList<>();
|
||||
//referList多的节点
|
||||
List<String> deleteList=new ArrayList<>();
|
||||
//最后一个相等的节点
|
||||
int endEqual=-1;
|
||||
//referList第一个与当前targetList节点不相等的节点坐标
|
||||
int index=0;
|
||||
for(String node:targetList){
|
||||
//判断referList是否已遍历完成
|
||||
if(index<referList.size()){
|
||||
//判断是否相等
|
||||
if(node.equals(referList.get(index))){
|
||||
endEqual=index;
|
||||
index++;
|
||||
}else {
|
||||
//循环referList,寻找是否有与当前targetList节点相等的节点
|
||||
int i=index;
|
||||
for(i++;i<referList.size();i++){
|
||||
//找到相等节点,则相等之前的(endEqual之后)所有节点都是targetList所没有的节点
|
||||
if(node.equals(referList.get(i))){
|
||||
for(int j=endEqual+1;j<i;j++){
|
||||
deleteList.add(referList.get(j));
|
||||
}
|
||||
endEqual=i;
|
||||
index=i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//没找到相等节点,则该targetList节点在referList中不存在
|
||||
if(i==referList.size()){
|
||||
insertList.add(node);
|
||||
i=index;
|
||||
}
|
||||
}
|
||||
//遍历完成直接插入insertList
|
||||
}else {
|
||||
insertList.add(node);
|
||||
}
|
||||
}
|
||||
//referList中未遍历到的节点,直接插入deleteList
|
||||
if(index<referList.size()){
|
||||
for(;index<referList.size();index++){
|
||||
deleteList.add(referList.get(index));
|
||||
}
|
||||
}
|
||||
Map<String,List<String>> result=new HashMap<>();
|
||||
result.put("insert",insertList);
|
||||
result.put("delete",deleteList);
|
||||
System.out.println(insertList);
|
||||
System.out.println(deleteList);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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.adc.da.slrs.sarPosition.dao.TsPositionDao">
|
||||
<select id="getRole" resultType="TsRole">
|
||||
select * from ts_role r
|
||||
left join ts_position_role ps
|
||||
on r.id=ps.role_id
|
||||
where ps.position_id=#{positionId}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user