fetch:通过name查询角色
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
* 服务类
|
* 服务类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author zyl
|
* @author zxy
|
||||||
* @since 2021-06-22
|
* @since 2021-06-22
|
||||||
*/
|
*/
|
||||||
public interface ITsInstitutionService extends IService<TsInstitution> {
|
public interface ITsInstitutionService extends IService<TsInstitution> {
|
||||||
|
|||||||
+1
@@ -51,6 +51,7 @@ public class TsInstitutionServiceImpl extends ServiceImpl<TsInstitutionDao, TsIn
|
|||||||
private List<TsInstitution> recursionGetInstitution(TsInstitution tsInstitution){
|
private List<TsInstitution> recursionGetInstitution(TsInstitution tsInstitution){
|
||||||
QueryWrapper<TsInstitution> institutionQueryWrapper=new QueryWrapper<>();
|
QueryWrapper<TsInstitution> institutionQueryWrapper=new QueryWrapper<>();
|
||||||
institutionQueryWrapper.eq("parent_id",tsInstitution.getId());
|
institutionQueryWrapper.eq("parent_id",tsInstitution.getId());
|
||||||
|
institutionQueryWrapper.eq("level",tsInstitution.getLevel()+1);
|
||||||
List<TsInstitution> tsInstitutions=tsInstitutionDao.selectList(institutionQueryWrapper);
|
List<TsInstitution> tsInstitutions=tsInstitutionDao.selectList(institutionQueryWrapper);
|
||||||
for(TsInstitution tsInstitutionNode:tsInstitutions){
|
for(TsInstitution tsInstitutionNode:tsInstitutions){
|
||||||
tsInstitutionNode.setChildren(recursionGetInstitution(tsInstitutionNode));
|
tsInstitutionNode.setChildren(recursionGetInstitution(tsInstitutionNode));
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.adc.da.slrs.sarRole.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.adc.da.http.ResponseMessage;
|
||||||
|
import com.adc.da.http.Result;
|
||||||
|
import com.adc.da.slrs.sarRole.service.ITsRoleService;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zxy
|
||||||
|
* @since 2021-06-22
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "|角色管理|")
|
||||||
|
@RequestMapping("/sarRole/role")
|
||||||
|
public class TsRoleController extends BaseController<TsRole> {
|
||||||
|
@Autowired
|
||||||
|
private ITsRoleService tsRoleService;
|
||||||
|
|
||||||
|
@ApiOperation("查询所有角色")
|
||||||
|
@GetMapping
|
||||||
|
public ResponseMessage<List<TsRole>> getAll(){
|
||||||
|
List<TsRole> tsRoles=tsRoleService.getAll();
|
||||||
|
return Result.success(tsRoles);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("根据角色名筛选角色")
|
||||||
|
@GetMapping("/name")
|
||||||
|
public ResponseMessage<List<TsRole>> getByName(String name){
|
||||||
|
List<TsRole> tsRoles=tsRoleService.getByName(name);
|
||||||
|
return Result.success(tsRoles);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.adc.da.slrs.sarRole.dao;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-22
|
||||||
|
*/
|
||||||
|
public interface TsRoleDao extends BaseMapper<TsRole> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
package com.adc.da.slrs.sarRole.entity;
|
||||||
|
|
||||||
|
import com.adc.da.base.entity.BaseEntity;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="TsRole对象", description="")
|
||||||
|
public class TsRole extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
@TableId("ID")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色名称")
|
||||||
|
@TableField("NAME")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色类型")
|
||||||
|
@TableField("ROLE_TYPE")
|
||||||
|
private String roleType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色状态")
|
||||||
|
@TableField("USE_FLAG")
|
||||||
|
private BigDecimal useFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否默认")
|
||||||
|
@TableField("IS_DEFAULT")
|
||||||
|
private BigDecimal isDefault;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色描述")
|
||||||
|
@TableField("REMARKS")
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
@TableField("EXT_INFO")
|
||||||
|
private String extInfo;
|
||||||
|
|
||||||
|
@TableField("OPER_USER")
|
||||||
|
private String operUser;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否有效")
|
||||||
|
@TableField("VALID_FLAG")
|
||||||
|
private BigDecimal validFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@TableField("CREATION_TIME")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Timestamp creationTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
@TableField("MODIFY_TIME")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Timestamp modifyTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上级节点id")
|
||||||
|
@TableField("PARENT_ID")
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色层级")
|
||||||
|
@TableField("role_level")
|
||||||
|
private Integer roleLevel;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "对应部门id")
|
||||||
|
@TableField("DY_ORG_ID")
|
||||||
|
private String dyOrgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "对应部门名称")
|
||||||
|
@TableField("DY_ORG_NAME")
|
||||||
|
private String dyOrgName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "子角色")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<TsRole> children;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.adc.da.slrs.sarRole.service;
|
||||||
|
|
||||||
|
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-22
|
||||||
|
*/
|
||||||
|
public interface ITsRoleService extends IService<TsRole> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有角色
|
||||||
|
* @return List<TsRole>
|
||||||
|
*/
|
||||||
|
List<TsRole> getAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过名字查询角色
|
||||||
|
* @param name:角色名
|
||||||
|
* @return List<TsRole>
|
||||||
|
*/
|
||||||
|
List<TsRole> getByName(String name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.adc.da.slrs.sarRole.service.impl;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||||
|
import com.adc.da.slrs.sarRole.dao.TsRoleDao;
|
||||||
|
import com.adc.da.slrs.sarRole.service.ITsRoleService;
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-22
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements ITsRoleService {
|
||||||
|
@Autowired
|
||||||
|
private TsRoleDao tsRoleDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有角色
|
||||||
|
* @return List<TsRole>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TsRole> getAll() {
|
||||||
|
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
|
||||||
|
tsRoleQueryWrapper.eq("role_level",1);
|
||||||
|
List<TsRole> rootRole=tsRoleDao.selectList(tsRoleQueryWrapper);
|
||||||
|
for(TsRole tsRole:rootRole){
|
||||||
|
tsRole.setChildren(recursionGetRole(tsRole));
|
||||||
|
}
|
||||||
|
return rootRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归查询子角色
|
||||||
|
* @param tsRole:父角色
|
||||||
|
* @return List<TsRole>
|
||||||
|
*/
|
||||||
|
private List<TsRole> recursionGetRole(TsRole tsRole){
|
||||||
|
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
|
||||||
|
tsRoleQueryWrapper.eq("parent_id",tsRole.getId());
|
||||||
|
tsRoleQueryWrapper.eq("role_level",tsRole.getRoleLevel()+1);
|
||||||
|
List<TsRole> tsRoles=tsRoleDao.selectList(tsRoleQueryWrapper);
|
||||||
|
for(TsRole tsRoleNode:tsRoles){
|
||||||
|
tsRoleNode.setChildren(recursionGetRole(tsRoleNode));
|
||||||
|
}
|
||||||
|
return tsRoles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过名字查询角色
|
||||||
|
* @param name:角色名
|
||||||
|
* @return List<TsRole>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TsRole> getByName(String name) {
|
||||||
|
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
|
||||||
|
tsRoleQueryWrapper.like("name","%"+name+"%");
|
||||||
|
return tsRoleDao.selectList(tsRoleQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ import javax.validation.constraints.NotNull;
|
|||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author zyl
|
* @author zxy
|
||||||
* @since 2021-06-22
|
* @since 2021-06-22
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?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.sarRole.dao.TsRoleDao">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user