pom.xml
@@ -10,7 +10,7 @@ <version>2.8.1.RELEASE</version> <properties> <bladex.project.id>blade-jfpts</bladex.project.id> <bladex.project.id>qfqk</bladex.project.id> <bladex.project.version>2.8.1.RELEASE</bladex.project.version> <java.version>1.8</java.version> src/main/java/org/springblade/modules/jurisdiction/controller/JurisdictionController.java
New file @@ -0,0 +1,161 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.swagger.annotations.*; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.cache.utils.CacheUtil; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.BladeUser; import org.springblade.core.tenant.annotation.NonDS; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.service.JurisdictionService; import org.springblade.modules.jurisdiction.vo.JurisdictionVO; import org.springblade.modules.jurisdiction.wrapper.JurisdictionWrapper; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; import java.util.List; import java.util.Map; import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; /** * 控制器 * * @author Chill */ @NonDS @RestController @AllArgsConstructor @RequestMapping("/jurisdiction") @Api(value = "部门", tags = "部门") public class JurisdictionController extends BladeController { private final JurisdictionService jurisdictionService; /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入dept") public R<JurisdictionVO> detail(Jurisdiction jurisdiction) { Jurisdiction detail = jurisdictionService.getOne(Condition.getQueryWrapper(jurisdiction)); return R.data(JurisdictionWrapper.build().entityVO(detail)); } /** * 列表 */ @GetMapping("/list") @ApiImplicitParams({ @ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "fullName", value = "部门全称", paramType = "query", dataType = "string") }) @ApiOperationSupport(order = 2) @ApiOperation(value = "列表", notes = "传入dept") public R<List<JurisdictionVO>> list(@ApiIgnore @RequestParam Map<String, Object> dept, BladeUser bladeUser) { QueryWrapper<Jurisdiction> queryWrapper = Condition.getQueryWrapper(dept, Jurisdiction.class); List<Jurisdiction> list = jurisdictionService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Jurisdiction::getTenantId, bladeUser.getTenantId()) : queryWrapper); return R.data(JurisdictionWrapper.build().listNodeVO(list)); } /** * 懒加载列表 */ @GetMapping("/lazy-list") @ApiImplicitParams({ @ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "fullName", value = "部门全称", paramType = "query", dataType = "string") }) @ApiOperationSupport(order = 3) @ApiOperation(value = "懒加载列表", notes = "传入dept") public R<List<JurisdictionVO>> lazyList(@ApiIgnore @RequestParam Map<String, Object> dept, Long parentId, BladeUser bladeUser) { List<JurisdictionVO> list = jurisdictionService.lazyList(bladeUser.getTenantId(), parentId, dept); return R.data(JurisdictionWrapper.build().listNodeLazyVO(list)); } /** * 获取部门树形结构 */ @GetMapping("/tree") @ApiOperationSupport(order = 4) @ApiOperation(value = "树形结构", notes = "树形结构") public R<List<JurisdictionVO>> tree(String tenantId, BladeUser bladeUser) { List<JurisdictionVO> tree = jurisdictionService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId())); return R.data(tree); } /** * 懒加载获取部门树形结构 */ @GetMapping("/lazy-tree") @ApiOperationSupport(order = 5) @ApiOperation(value = "懒加载树形结构", notes = "树形结构") public R<List<JurisdictionVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser) { List<JurisdictionVO> tree = jurisdictionService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId); return R.data(tree); } /** * 懒加载获取部门树形结构 */ @GetMapping("/lazy-trees") @ApiOperation(value = "懒加载树形结构", notes = "树形结构") public R<List<JurisdictionVO>> lazyTrees() { List<JurisdictionVO> tree = jurisdictionService.lazyTrees(); return R.data(tree); } /** * 新增或修改 */ @PostMapping("/submit") @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入dept") public R submit(@Valid @RequestBody Jurisdiction jurisdiction) { if (jurisdictionService.submit(jurisdiction)) { CacheUtil.clear(SYS_CACHE); // 返回懒加载树更新节点所需字段 Kv kv = Kv.create().set("id", String.valueOf(jurisdiction.getId())).set("tenantId", jurisdiction.getTenantId()); return R.data(kv); } return R.fail("操作失败"); } /** * 删除 */ @PostMapping("/remove") @ApiOperationSupport(order = 7) @ApiOperation(value = "删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { CacheUtil.clear(SYS_CACHE); return R.status(jurisdictionService.removeDept(ids)); } } src/main/java/org/springblade/modules/jurisdiction/dto/JurisdictionDTO.java
New file @@ -0,0 +1,33 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.dto; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.modules.jurisdiction.entity.Jurisdiction; /** * 数据传输对象实体类 * * @author Chill */ @Data @EqualsAndHashCode(callSuper = true) public class JurisdictionDTO extends Jurisdiction { private static final long serialVersionUID = 1L; } src/main/java/org/springblade/modules/jurisdiction/entity/Jurisdiction.java
New file @@ -0,0 +1,96 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; /** * 实体类 * * @author Chill */ @Data @TableName("sys_jurisdiction") @ApiModel(value = "jurisdiction对象", description = "jurisdiction对象") public class Jurisdiction implements Serializable { private static final long serialVersionUID = 1L; /** * 主键 */ @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty(value = "主键") @TableId(value = "id", type = IdType.ASSIGN_ID) private Long id; /** * 租户ID */ @ApiModelProperty(value = "租户ID") private String tenantId; /** * 父主键 */ @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty(value = "父主键") private Long parentId; /** * 机构全称 */ @ApiModelProperty(value = "机构全称") private String fullName; /** * 机构名 */ @ApiModelProperty(value = "机构名") private String deptName; /** * 祖级机构主键 */ @ApiModelProperty(value = "祖级机构主键") private String ancestors; /** * 备注 */ @ApiModelProperty(value = "备注") private String remark; /** * 是否已删除 */ @TableLogic @ApiModelProperty(value = "是否已删除") private Integer isDeleted; } src/main/java/org/springblade/modules/jurisdiction/mapper/JurisdictionMapper.java
New file @@ -0,0 +1,75 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.vo.JurisdictionVO; import java.util.List; import java.util.Map; /** * Mapper 接口 * * @author Chill */ public interface JurisdictionMapper extends BaseMapper<Jurisdiction> { /** * 懒加载部门列表 * * @param tenantId * @param parentId * @param param * @return */ List<JurisdictionVO> lazyList(String tenantId, Long parentId, Map<String, Object> param); /** * 获取树形节点 * * @param tenantId * @return */ List<JurisdictionVO> tree(String tenantId); /** * 懒加载获取树形节点 * * @param tenantId * @param parentId * @return */ List<JurisdictionVO> lazyTree(String tenantId, Long parentId); /** * 懒加载获取树形节点 * * @return */ List<JurisdictionVO> lazyTrees(); /** * 获取部门名 * * @param ids * @return */ List<String> getDeptNames(Long[] ids); } src/main/java/org/springblade/modules/jurisdiction/mapper/JurisdictionMapper.xml
New file @@ -0,0 +1,113 @@ <?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="org.springblade.modules.jurisdiction.mapper.JurisdictionMapper"> <!-- 通用查询映射结果 --> <resultMap id="deptResultMap" type="org.springblade.modules.jurisdiction.entity.Jurisdiction"> <id column="id" property="id"/> <result column="parent_id" property="parentId"/> <result column="dept_name" property="deptName"/> <result column="full_name" property="fullName"/> <result column="ancestors" property="ancestors"/> <result column="remark" property="remark"/> <result column="is_deleted" property="isDeleted"/> </resultMap> <resultMap id="deptVOResultMap" type="org.springblade.modules.jurisdiction.vo.JurisdictionVO"> <id column="id" property="id"/> <result column="parent_id" property="parentId"/> <result column="dept_name" property="deptName"/> <result column="full_name" property="fullName"/> <result column="ancestors" property="ancestors"/> <result column="remark" property="remark"/> <result column="is_deleted" property="isDeleted"/> <result column="has_children" property="hasChildren"/> </resultMap> <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> <id column="id" property="id"/> <result column="parent_id" property="parentId"/> <result column="title" property="title"/> <result column="value" property="value"/> <result column="key" property="key"/> <result column="has_children" property="hasChildren"/> </resultMap> <select id="lazyList" resultMap="deptVOResultMap"> SELECT dept.* , ( SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM sys_jurisdiction WHERE parent_id = dept.id and is_deleted = 0 ) AS "has_children" FROM sys_jurisdiction dept WHERE dept.is_deleted = 0 <if test="param1!=null and param1!=''"> and dept.tenant_id = #{param1} </if> <if test="param2!=null"> and dept.parent_id = #{param2} </if> <if test="param3.deptName!=null and param3.deptName!=''"> and dept.dept_name like concat(concat('%', #{param3.deptName}),'%') </if> <if test="param3.fullName!=null and param3.fullName!=''"> and dept.full_name like concat(concat('%', #{param3.fullName}),'%') </if> </select> <select id="tree" resultMap="treeNodeResultMap"> select id, parent_id, dept_name as title, id as "value", id as "key" from sys_jurisdiction where is_deleted = 0 <if test="_parameter!=null and _parameter!=''"> and tenant_id = #{_parameter} </if> </select> <select id="lazyTree" resultMap="treeNodeResultMap" > SELECT dept.id, dept.parent_id, dept.dept_name AS title, dept.id AS "value", dept.id AS "key", ( SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM sys_jurisdiction WHERE parent_id = dept.id and is_deleted = 0 ) AS "has_children" FROM sys_jurisdiction dept WHERE dept.is_deleted = 0 <if test="param1!=null and param1!=''"> and dept.tenant_id = #{param1} </if> </select> <select id="lazyTrees" resultMap="treeNodeResultMap" > SELECT dept.id, dept.parent_id, dept.dept_name AS title, dept.id AS "value", dept.id AS "key", ( SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM sys_jurisdiction WHERE parent_id = dept.id and is_deleted = 0 ) AS "has_children" FROM sys_jurisdiction dept WHERE dept.is_deleted = 0 </select> </mapper> src/main/java/org/springblade/modules/jurisdiction/service/JurisdictionService.java
New file @@ -0,0 +1,82 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.service; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.vo.JurisdictionVO; import java.util.List; import java.util.Map; /** * 服务类 * * @author Chill */ public interface JurisdictionService extends IService<Jurisdiction> { /** * 懒加载部门列表 * * @param tenantId * @param parentId * @param param * @return */ List<JurisdictionVO> lazyList(String tenantId, Long parentId, Map<String, Object> param); /** * 树形结构 * * @param tenantId * @return */ List<JurisdictionVO> tree(String tenantId); /** * 懒加载树形结构 * * @param tenantId * @param parentId * @return */ List<JurisdictionVO> lazyTree(String tenantId, Long parentId); /** * 懒加载获取树形节点 * * @return */ List<JurisdictionVO> lazyTrees(); /** * 删除部门 * * @param ids * @return */ boolean removeDept(String ids); /** * 提交 * * @param * @return */ boolean submit(Jurisdiction jurisdiction); } src/main/java/org/springblade/modules/jurisdiction/service/impl/JurisdictionServiceImpl.java
New file @@ -0,0 +1,112 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.mapper.JurisdictionMapper; import org.springblade.modules.jurisdiction.service.JurisdictionService; import org.springblade.modules.jurisdiction.vo.JurisdictionVO; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; /** * 服务实现类 * * @author Chill */ @Service public class JurisdictionServiceImpl extends ServiceImpl<JurisdictionMapper, Jurisdiction> implements JurisdictionService { private static final String TENANT_ID = "tenantId"; private static final String PARENT_ID = "parentId"; @Override public List<JurisdictionVO> lazyList(String tenantId, Long parentId, Map<String, Object> param) { // 设置租户ID if (AuthUtil.isAdministrator()) { tenantId = StringPool.EMPTY; } String paramTenantId = Func.toStr(param.get(TENANT_ID)); if (Func.isNotEmpty(paramTenantId) && AuthUtil.isAdministrator()) { tenantId = paramTenantId; } // 判断点击搜索但是没有查询条件的情况 if (Func.isEmpty(param.get(PARENT_ID)) && param.size() == 1) { parentId = 0L; } // 判断点击搜索带有查询条件的情况 if (Func.isEmpty(param.get(PARENT_ID)) && param.size() > 1 && Func.toLong(parentId) == 0L) { parentId = null; } return baseMapper.lazyList(tenantId, parentId, param); } @Override public List<JurisdictionVO> tree(String tenantId) { return ForestNodeMerger.merge(baseMapper.tree(tenantId)); } @Override public List<JurisdictionVO> lazyTree(String tenantId, Long parentId) { if (AuthUtil.isAdministrator()) { tenantId = StringPool.EMPTY; } return ForestNodeMerger.merge(baseMapper.lazyTree(tenantId, parentId)); } @Override public List<JurisdictionVO> lazyTrees() { return ForestNodeMerger.merge(baseMapper.lazyTrees()); } @Override public boolean removeDept(String ids) { return removeByIds(Func.toLongList(ids)); } @Override public boolean submit(Jurisdiction dept) { if (Func.isEmpty(dept.getParentId())) { dept.setTenantId(AuthUtil.getTenantId()); dept.setParentId(BladeConstant.TOP_PARENT_ID); dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID)); } if (dept.getParentId() > 0) { Jurisdiction parent = getById(dept.getParentId()); if (Func.toLong(dept.getParentId()) == Func.toLong(dept.getId())) { throw new ServiceException("父节点不可选择自身!"); } dept.setTenantId(parent.getTenantId()); String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId(); dept.setAncestors(ancestors); } dept.setIsDeleted(BladeConstant.DB_NOT_DELETED); return saveOrUpdate(dept); } } src/main/java/org/springblade/modules/jurisdiction/vo/JurisdictionVO.java
New file @@ -0,0 +1,80 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.vo; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tool.node.INode; import org.springblade.modules.system.entity.Dept; import java.util.ArrayList; import java.util.List; /** * 视图实体类 * * @author Chill */ @Data @EqualsAndHashCode(callSuper = true) @ApiModel(value = "DeptVO对象", description = "DeptVO对象") public class JurisdictionVO extends Dept implements INode<JurisdictionVO> { private static final long serialVersionUID = 1L; /** * 主键ID */ @JsonSerialize(using = ToStringSerializer.class) private Long id; /** * 父节点ID */ @JsonSerialize(using = ToStringSerializer.class) private Long parentId; /** * 子孙节点 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List<JurisdictionVO> children; /** * 是否有子孙节点 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private Boolean hasChildren; @Override public List<JurisdictionVO> getChildren() { if (this.children == null) { this.children = new ArrayList<>(); } return this.children; } /** * 上级机构 */ private String parentName; } src/main/java/org/springblade/modules/jurisdiction/wrapper/JurisdictionWrapper.java
New file @@ -0,0 +1,71 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.jurisdiction.wrapper; import org.springblade.common.cache.DictCache; import org.springblade.common.cache.SysCache; import org.springblade.common.enums.DictEnum; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.vo.JurisdictionVO; import org.springblade.modules.system.entity.Dept; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * 包装类,返回视图层所需的字段 * * @author Chill */ public class JurisdictionWrapper extends BaseEntityWrapper<Jurisdiction, JurisdictionVO> { public static JurisdictionWrapper build() { return new JurisdictionWrapper(); } @Override public JurisdictionVO entityVO(Jurisdiction jurisdiction) { JurisdictionVO jurisdictionVO = Objects.requireNonNull(BeanUtil.copy(jurisdiction, JurisdictionVO.class)); if (Func.equals(jurisdiction.getParentId(), BladeConstant.TOP_PARENT_ID)) { jurisdictionVO.setParentName(BladeConstant.TOP_PARENT_NAME); } else { Dept parent = SysCache.getDept(jurisdiction.getParentId()); jurisdictionVO.setParentName(parent.getDeptName()); } return jurisdictionVO; } public List<JurisdictionVO> listNodeVO(List<Jurisdiction> list) { List<JurisdictionVO> collect = list.stream().map(dept -> { JurisdictionVO deptVO = BeanUtil.copy(dept, JurisdictionVO.class); return deptVO; }).collect(Collectors.toList()); return ForestNodeMerger.merge(collect); } public List<JurisdictionVO> listNodeLazyVO(List<JurisdictionVO> list) { List<JurisdictionVO> collect = list.stream().peek(dept -> { String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()); }).collect(Collectors.toList()); return ForestNodeMerger.merge(collect); } } src/main/java/org/springblade/modules/system/entity/User.java
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; @@ -104,4 +105,10 @@ private String examination_mx; /** * 辖区id */ @ApiModelProperty(value = "辖区id") private String jurisdiction; } src/main/java/org/springblade/modules/zc/controller/ZcController.java
@@ -151,6 +151,7 @@ user.setPhone(zc.getPhone()); user.setDeptId(zc.getDeptid()); user.setRoleId(zc.getParentId()); user.setJurisdiction(zc.getJurisdiction()); user.setExamination_type("0"); user.setExamination_mx("正常"); iUserService.saveOrUpdate(user); src/main/java/org/springblade/modules/zc/entity/Zc.java
@@ -77,8 +77,22 @@ */ @ApiModelProperty(value = "审核状态") private String type; /** * 部门id */ @ApiModelProperty(value = "部门id") private String deptid; /** * 角色id */ @ApiModelProperty(value = "角色id") private String parentId; /** * 辖区id */ @ApiModelProperty(value = "辖区id") private String jurisdiction; } src/main/java/org/springblade/modules/zc/mapper/ZcMapper.xml
@@ -13,7 +13,8 @@ <result column="zctime" property="zctime"/> <result column="type" property="type"/> <result column="deptid" property="deptid"/> <result column="parentId" property="parentId"/> <result column="parent_id" property="parentId"/> <result column="jurisdiction" property="jurisdiction"/> </resultMap>