add: 用户、组织
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -39,7 +39,7 @@
|
||||
<joda.time.version>2.9.9</joda.time.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
<fastjson.version>1.2.72</fastjson.version>
|
||||
<hutool.version>4.1.1</hutool.version>
|
||||
<hutool.version>5.8.22</hutool.version>
|
||||
<lombok.version>1.18.4</lombok.version>
|
||||
|
||||
</properties>
|
||||
@@ -54,6 +54,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
|
||||
33
src/main/java/com/boge/common/base/BaseDTO.java
Normal file
33
src/main/java/com/boge/common/base/BaseDTO.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.boge.common.base;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019年10月24日20:48:53
|
||||
*/
|
||||
@Data
|
||||
public class BaseDTO implements Serializable {
|
||||
|
||||
private String create_name;
|
||||
|
||||
private String create_id;
|
||||
|
||||
private String update_name;
|
||||
|
||||
private String update_id;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
}
|
||||
53
src/main/java/com/boge/common/base/BaseMapper.java
Normal file
53
src/main/java/com/boge/common/base/BaseMapper.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.boge.common.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-23
|
||||
*/
|
||||
public interface BaseMapper<D, E> {
|
||||
|
||||
/**
|
||||
* DTO转Entity
|
||||
* @param dto /
|
||||
* @return /
|
||||
*/
|
||||
E toEntity(D dto);
|
||||
|
||||
/**
|
||||
* Entity转DTO
|
||||
* @param entity /
|
||||
* @return /
|
||||
*/
|
||||
D toDto(E entity);
|
||||
|
||||
/**
|
||||
* DTO集合转Entity集合
|
||||
* @param dtoList /
|
||||
* @return /
|
||||
*/
|
||||
List <E> toEntity(List<D> dtoList);
|
||||
|
||||
/**
|
||||
* Entity集合转DTO集合
|
||||
* @param entityList /
|
||||
* @return /
|
||||
*/
|
||||
List <D> toDto(List<E> entityList);
|
||||
}
|
||||
78
src/main/java/com/boge/common/base/TableDataInfo.java
Normal file
78
src/main/java/com/boge/common/base/TableDataInfo.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.boge.common.base;
|
||||
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表格分页数据对象
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class TableDataInfo<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private long totalElements;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<T> content;
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public TableDataInfo(List<T> list, long total) {
|
||||
this.content = list;
|
||||
this.totalElements = total;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> build(IPage<T> page) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setContent(page.getRecords());
|
||||
rspData.setTotalElements(page.getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> build(List<T> list) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setContent(list);
|
||||
rspData.setTotalElements(list.size());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> build() {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setMsg("查询成功");
|
||||
return rspData;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/com/boge/common/query/BaseQuery.java
Normal file
73
src/main/java/com/boge/common/query/BaseQuery.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.boge.common.query;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;
|
||||
import lombok.Data;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 泛型必须为数据tb对应do:由mybatis管理
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 6:33 下午
|
||||
*/
|
||||
@Data
|
||||
public class BaseQuery<T> {
|
||||
/**
|
||||
* 模糊查询
|
||||
*/
|
||||
private String blurry;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_used;
|
||||
/**
|
||||
* 创建时间范围查询
|
||||
*/
|
||||
private String start_time;
|
||||
private String end_time;
|
||||
|
||||
|
||||
/**
|
||||
* 字段映射Map:指定字段对应QueryWrapper的查询类型
|
||||
* 字段与数据库字段对应,不支持驼峰
|
||||
* 通过buid构建
|
||||
*/
|
||||
public Map<String, QParam> doP = MapOf.of("blurry", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build()
|
||||
,"startTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LT).build()
|
||||
,"endTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LE).build()
|
||||
,"sort", QParam.builder().k(new String[]{"sort"}).type(QueryTEnum.BY).build()
|
||||
);
|
||||
|
||||
public QueryWrapper<T> build(){
|
||||
this.paramMapping();
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
||||
Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments();
|
||||
Map<String, ColumnCache> columnMap = LambdaUtils.getColumnMap((Class<?>) types[0]);
|
||||
|
||||
String dopStr = "doP";
|
||||
json.forEach((key, vel) -> {
|
||||
if (vel != null && !key.equals(dopStr)){
|
||||
QParam qParam = doP.get(key);
|
||||
if (qParam != null){
|
||||
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
|
||||
}else {
|
||||
ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
|
||||
if (columnCache!=null){
|
||||
wrapper.eq(columnCache.getColumn(),vel);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public void paramMapping(){};
|
||||
}
|
||||
21
src/main/java/com/boge/common/query/LConsumer.java
Normal file
21
src/main/java/com/boge/common/query/LConsumer.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.boge.common.query;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 8:40 下午
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface LConsumer<X,Y,Z> {
|
||||
|
||||
/**
|
||||
* 切面
|
||||
* @param x 、
|
||||
* @param y 、
|
||||
* @param z 、
|
||||
*/
|
||||
void accept(X x,Y y,Z z);
|
||||
|
||||
}
|
||||
21
src/main/java/com/boge/common/query/MapOf.java
Normal file
21
src/main/java/com/boge/common/query/MapOf.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.boge.common.query;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/11/29 2:55 下午
|
||||
*/
|
||||
public class MapOf implements Serializable {
|
||||
|
||||
public static <K> HashMap of(K... key){
|
||||
HashMap map = new HashMap<>();
|
||||
for (int i = 0; i < (key.length & ~1); i=i+2) {
|
||||
map.put(key[i],key[i+1]);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
115
src/main/java/com/boge/common/query/PageQuery.java
Normal file
115
src/main/java/com/boge/common/query/PageQuery.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package com.boge.common.query;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 分页参数
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-11-16
|
||||
*/
|
||||
@Data
|
||||
public class PageQuery implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer page;
|
||||
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
private String sort;
|
||||
|
||||
/**
|
||||
* 排序的方向desc或者asc
|
||||
*/
|
||||
private Boolean isAsc;
|
||||
|
||||
/**
|
||||
* 当前记录起始索引 默认值
|
||||
*/
|
||||
public static final int DEFAULT_PAGE_NUM = 1;
|
||||
|
||||
/**
|
||||
* 每页显示记录数 默认值 默认查全部
|
||||
*/
|
||||
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
|
||||
|
||||
public <T> Page<T> build() {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
}
|
||||
Page<T> page = new Page<>(pageNum, pageSize);
|
||||
if (StringUtils.isNotEmpty(sort)){
|
||||
String[] split = sort.split(",");
|
||||
for (int i = 0; i < (split.length & ~1); i=i+2) {
|
||||
String col = split[i];
|
||||
OrderItem item = new OrderItem();
|
||||
item.setColumn(col);
|
||||
item.setAsc(split[i+1].toLowerCase(Locale.ROOT).equals("asc"));
|
||||
page.addOrder(item);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public <R,T> Page<T> build(Class<R> r) {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
}
|
||||
Page<T> page = new Page<>(pageNum, pageSize);
|
||||
if (StringUtils.isNotEmpty(sort)){
|
||||
String[] split = sort.split(",");
|
||||
for (int i = 0; i < (split.length & ~1); i=i+2) {
|
||||
String col = split[i];
|
||||
if ("id".equals(col)){
|
||||
String mId = mappingId(r);
|
||||
col = StringUtils.isNotEmpty(mId)?mId:col;
|
||||
}
|
||||
OrderItem item = new OrderItem();
|
||||
item.setColumn(col);
|
||||
item.setAsc(split[i+1].toLowerCase(Locale.ROOT).equals("asc"));
|
||||
page.addOrder(item);
|
||||
}
|
||||
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
private <R> String mappingId(R r){
|
||||
if (r instanceof Class){
|
||||
Field[] fields = ((Class) r).getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
TableId[] byType = field.getAnnotationsByType(TableId.class);
|
||||
if (byType !=null && byType.length>0){
|
||||
TableId tableId = byType[0];
|
||||
return tableId.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/boge/common/query/QParam.java
Normal file
18
src/main/java/com/boge/common/query/QParam.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.boge.common.query;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/15 1:41 下午
|
||||
*/
|
||||
@Builder
|
||||
public class QParam {
|
||||
public String[] k;
|
||||
public QueryTEnum type;
|
||||
}
|
||||
35
src/main/java/com/boge/common/query/QueryTEnum.java
Normal file
35
src/main/java/com/boge/common/query/QueryTEnum.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.boge.common.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 8:26 下午
|
||||
*/
|
||||
@Getter
|
||||
public enum QueryTEnum {
|
||||
//
|
||||
EQ((q, k, v) -> { q.eq(k[0],v); }),
|
||||
IN((q, key, o) -> { if (o instanceof Collection){ q.in(key[0],(Collection) o); } }),
|
||||
LK((q, keys, o) -> { for (String key : keys) { q.like(key,o); } }),
|
||||
LE((q, k, v) -> { q.le(k[0],v); }),
|
||||
BY((q, k, v) -> { q.orderByDesc(k[0],v); }),
|
||||
NO((q, k, v) -> { q.isNull(k[0]); }),
|
||||
LT((q, k, v) -> { q.lt(k[0],v); }),
|
||||
OREQ((q, k, v) -> { if (StringUtils.isBlank((String)v)){ q.isNull(k[0]); }else { q.eq(k[0],v); } });
|
||||
|
||||
private LConsumer<QueryWrapper,String[], Object> doP;
|
||||
|
||||
QueryTEnum(LConsumer<QueryWrapper,String[], Object> doP) {
|
||||
this.doP = doP;
|
||||
}
|
||||
|
||||
public static void build(QueryTEnum type, QueryWrapper q, String[] k , Object v){
|
||||
type.getDoP().accept(q,k,v);
|
||||
}
|
||||
}
|
||||
33
src/main/java/com/boge/common/utils/CopyUtil.java
Normal file
33
src/main/java/com/boge/common/utils/CopyUtil.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.boge.common.utils;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CopyUtil {
|
||||
public static <F, T> List<T> copyList(final Collection<F> sources, final Class<T> clazz) {
|
||||
if (sources == null) {
|
||||
return new ArrayList(0);
|
||||
} else {
|
||||
List<T> list = new ArrayList(sources.size());
|
||||
Iterator var3 = sources.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Object source = var3.next();
|
||||
|
||||
try {
|
||||
T dest = clazz.newInstance();
|
||||
BeanUtils.copyProperties(source, dest);
|
||||
list.add(dest);
|
||||
} catch (Throwable var6) {
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.boge.modules.dept.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.boge.common.base.TableDataInfo;
|
||||
import com.boge.common.exception.RRException;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.modules.dept.dao.SysDept;
|
||||
import com.boge.modules.dept.dto.DeptQuery;
|
||||
import com.boge.modules.dept.service.ISysDeptService;
|
||||
import com.boge.modules.dept.util.PageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@RestController
|
||||
|
||||
@RequestMapping("/api/dept")
|
||||
public class DeptController {
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> query(DeptQuery query) throws Exception {
|
||||
List<SysDept> list = deptService.list(query.build());
|
||||
return new ResponseEntity<>(PageUtil.toPage(list, list.size()),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/vo")
|
||||
public ResponseEntity queryvo(DeptQuery query, PageQuery pageQuery) throws Exception {
|
||||
Page deptPage = deptService.queryVo(query, pageQuery);
|
||||
return new ResponseEntity((TableDataInfo.build(deptPage)),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/allTree")
|
||||
public ResponseEntity<Object> allTree(DeptQuery query) {
|
||||
return new ResponseEntity<>(deptService.buildTree(query),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/superior")
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)){
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
return new ResponseEntity<>(deptService.getSuperior(ids),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysDept resources){
|
||||
deptService.createDept(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysDept dept){
|
||||
if (dept.getPid() != null && dept.getDept_id().equals(dept.getPid())) {
|
||||
throw new RRException("ID不能为空");
|
||||
}
|
||||
deptService.updateDept(dept);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> deptIds){
|
||||
if (CollectionUtils.isEmpty(deptIds)){
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
deptService.delateDept(deptIds);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
107
src/main/java/com/boge/modules/dept/dao/SysDept.java
Normal file
107
src/main/java/com/boge/modules/dept/dao/SysDept.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.boge.modules.dept.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_dept")
|
||||
public class SysDept implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "dept_id", type = IdType.NONE)
|
||||
private String dept_id;
|
||||
|
||||
/**
|
||||
* 上级部门
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 子部门数目
|
||||
*/
|
||||
private Integer sub_count;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 中文名称
|
||||
*/
|
||||
private String zh_name;
|
||||
/**
|
||||
* 英文名称
|
||||
*/
|
||||
private String en_name;
|
||||
|
||||
/**
|
||||
* 印尼名称
|
||||
*/
|
||||
private String in_name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer dept_sort;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Boolean is_used;
|
||||
|
||||
private String create_id;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
/**
|
||||
* 部门编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
|
||||
|
||||
}
|
||||
35
src/main/java/com/boge/modules/dept/dao/SysUserDept.java
Normal file
35
src/main/java/com/boge/modules/dept/dao/SysUserDept.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.boge.modules.dept.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_user_dept")
|
||||
public class SysUserDept implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户标识
|
||||
*/
|
||||
private Long user_id;
|
||||
|
||||
/**
|
||||
* 部门标识
|
||||
*/
|
||||
private Long dept_id;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.boge.modules.dept.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.boge.modules.dept.dao.SysDept;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
* 保存依赖关系
|
||||
* @param UserId
|
||||
* @param deptId
|
||||
*/
|
||||
void saveDeptRelation(@Param("user") String UserId,@Param("depts") Collection<String> deptId);
|
||||
void delDeptRelation(@Param("user") String UserId);
|
||||
|
||||
List<Map> getDeptRelation(@Param("deptIds") Collection<String> deptIds);
|
||||
|
||||
/**
|
||||
* 跟新sub_count字段
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
int updateSubCount(String deptId);
|
||||
|
||||
/**
|
||||
* 返回字符串列表 split = ,
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
String findAllChild(String pid);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.boge.modules.dept.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.boge.modules.dept.dao.SysUserDept;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserDeptMapper extends BaseMapper<SysUserDept> {
|
||||
|
||||
}
|
||||
31
src/main/java/com/boge/modules/dept/dto/DeptQuery.java
Normal file
31
src/main/java/com/boge/modules/dept/dto/DeptQuery.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.boge.modules.dept.dto;
|
||||
|
||||
import com.boge.common.query.BaseQuery;
|
||||
import com.boge.common.query.QParam;
|
||||
import com.boge.common.query.QueryTEnum;
|
||||
import com.boge.modules.dept.dao.SysDept;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class DeptQuery extends BaseQuery<SysDept> {
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private String name;
|
||||
|
||||
private String code;
|
||||
|
||||
private Long pid;
|
||||
|
||||
private Boolean pid_is_null;
|
||||
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
super.doP.put("pid_is_null", QParam.builder().k(new String[]{"pid"}).type(QueryTEnum.NO).build());
|
||||
super.doP.put("deptIds", QParam.builder().k(new String[]{"dept_id"}).type(QueryTEnum.IN).build());
|
||||
}
|
||||
}
|
||||
44
src/main/java/com/boge/modules/dept/dto/DeptTree.java
Normal file
44
src/main/java/com/boge/modules/dept/dto/DeptTree.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.boge.modules.dept.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeptTree implements Serializable {
|
||||
|
||||
private String dept_id;
|
||||
|
||||
private String pid;
|
||||
|
||||
private String name;
|
||||
private String in_name;
|
||||
private String en_name;
|
||||
private String zh_name;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<DeptTree> children;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.boge.modules.dept.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.modules.dept.dao.SysDept;
|
||||
import com.boge.modules.dept.dto.DeptQuery;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface ISysDeptService extends IService<SysDept> {
|
||||
/**
|
||||
* 条件查询
|
||||
* @param query
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
Page queryVo(DeptQuery query, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 条件查询树结构
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> buildTree(DeptQuery query);
|
||||
|
||||
/**
|
||||
* 查询当前部门id的上级id
|
||||
* @param deptIds
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getSuperior(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 保存用户部门关系
|
||||
* @param UserId
|
||||
* @param deptIds
|
||||
*/
|
||||
void saveUserDeptRelation(String UserId, Collection<String> deptIds);
|
||||
void delUserDeptRelation(String user);
|
||||
|
||||
/**
|
||||
* 更新部门:同时更新节点
|
||||
* @param dept
|
||||
*/
|
||||
void updateDept(SysDept dept);
|
||||
|
||||
/**
|
||||
* 删除部门及子部门
|
||||
* @param deptIds
|
||||
*/
|
||||
void delateDept(Set<String> deptIds);
|
||||
|
||||
void createDept(SysDept dept);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.boge.modules.dept.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.boge.modules.dept.dao.SysUserDept;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface ISysUserDeptService extends IService<SysUserDept> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.boge.modules.dept.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.boge.common.exception.RRException;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.common.utils.CopyUtil;
|
||||
import com.boge.common.utils.ShiroUtils;
|
||||
import com.boge.modules.dept.dao.SysDept;
|
||||
import com.boge.modules.dept.dao.mapper.SysDeptMapper;
|
||||
import com.boge.modules.dept.dto.DeptQuery;
|
||||
import com.boge.modules.dept.dto.DeptTree;
|
||||
import com.boge.modules.dept.service.ISysDeptService;
|
||||
import com.boge.modules.dept.vo.DeptVo;
|
||||
import com.boge.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {
|
||||
|
||||
@Autowired
|
||||
private SysDeptMapper sysDeptMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> buildTree(DeptQuery query) {
|
||||
List<SysDept> list = this.list(query.build());
|
||||
List<DeptTree> deptTrees = CopyUtil.copyList(list, DeptTree.class);
|
||||
return this.buildTree(deptTrees);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSuperior(List<Long> deptIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildTree(List<DeptTree> deptDtos) {
|
||||
List<DeptTree> trees= new ArrayList<>();
|
||||
Set<DeptTree> depts = new LinkedHashSet<>();
|
||||
List<String> deptNames = deptDtos.stream().map(DeptTree::getName).collect(Collectors.toList());
|
||||
boolean isChild;
|
||||
for (DeptTree deptDTO : deptDtos) {
|
||||
isChild = false;
|
||||
if (deptDTO.getPid() == null) {
|
||||
trees.add(deptDTO);
|
||||
}
|
||||
for (DeptTree it : deptDtos) {
|
||||
if (it.getPid() != null && deptDTO.getDept_id().equals(it.getPid())) {
|
||||
isChild = true;
|
||||
if (deptDTO.getChildren() == null) {
|
||||
deptDTO.setChildren(new ArrayList<>());
|
||||
}
|
||||
deptDTO.getChildren().add(it);
|
||||
}
|
||||
}
|
||||
if (isChild) {
|
||||
depts.add(deptDTO);
|
||||
} else if (deptDTO.getPid() != null && !deptNames.contains(this.getById(deptDTO.getPid()).getName())) {
|
||||
depts.add(deptDTO);
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("totalElements", deptDtos.size());
|
||||
map.put("content", CollectionUtil.isEmpty(trees) ? deptDtos : trees);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page queryVo(DeptQuery query, PageQuery pageQuery) {
|
||||
if (query.getPid_is_null() == null){
|
||||
if (query.getPid() == null){
|
||||
query.setPid_is_null(true);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIs_used()!=null){
|
||||
query.setPid_is_null(null);
|
||||
}
|
||||
}
|
||||
Page page = this.page(pageQuery.build(SysDept.class), query.build());
|
||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIs_used()!=null){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHas_children(false) );
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveUserDeptRelation(String userId, Collection<String> deptIds) {
|
||||
if (StringUtils.isEmpty(userId) || CollectionUtils.isEmpty(deptIds)){
|
||||
return;
|
||||
}
|
||||
sysDeptMapper.saveDeptRelation(userId,deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delUserDeptRelation(String user) {
|
||||
sysDeptMapper.delDeptRelation(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDept(SysDept dept) {
|
||||
if (dept == null ||StringUtils.isEmpty(dept.getDept_id())){
|
||||
return;
|
||||
}
|
||||
this.updateById(dept);
|
||||
//删除节点信息
|
||||
sysDeptMapper.updateSubCount(dept.getDept_id());
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){
|
||||
sysDeptMapper.updateSubCount(dept.getPid());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delateDept(Set<String> deptIds) {
|
||||
if (CollectionUtils.isEmpty(deptIds)){
|
||||
return;
|
||||
}
|
||||
verification(deptIds);
|
||||
Set<String> depts = new HashSet<>();
|
||||
Set<String> pids = new HashSet<>();
|
||||
List<SysDept> deptList = sysDeptMapper.selectList(new QueryWrapper<SysDept>().in("dept_id", deptIds));
|
||||
for (String deptId : deptIds) {
|
||||
depts.add(deptId);
|
||||
String allChild = sysDeptMapper.findAllChild(deptId);
|
||||
if (StringUtils.isNotEmpty(allChild)){
|
||||
String[] split = allChild.split(",");
|
||||
depts.addAll(Arrays.asList(split));
|
||||
}
|
||||
}
|
||||
this.remove(new QueryWrapper<SysDept>().in("dept_id", depts));
|
||||
deptList.forEach(dept -> {
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){sysDeptMapper.updateSubCount(dept.getPid());}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void verification(Set<String> depeIds) {
|
||||
if (!CollectionUtils.isEmpty(depeIds)){
|
||||
List<Map> deptRelation = sysDeptMapper.getDeptRelation(depeIds);
|
||||
if (!CollectionUtils.isEmpty(deptRelation)){
|
||||
throw new RRException("部门为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createDept(SysDept dept) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
|
||||
dept.setCreate_id(String.valueOf(userEntity.getUserId()));
|
||||
dept.setCreate_name(userEntity.getUsername());
|
||||
dept.setCreate_time(new Date());
|
||||
this.save(dept);
|
||||
// 清理缓存
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){
|
||||
sysDeptMapper.updateSubCount(dept.getPid());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.boge.modules.dept.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.boge.modules.dept.dao.SysUserDept;
|
||||
import com.boge.modules.dept.dao.mapper.SysUserDeptMapper;
|
||||
import com.boge.modules.dept.service.ISysUserDeptService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Service
|
||||
public class SysUserDeptServiceImpl extends ServiceImpl<SysUserDeptMapper, SysUserDept> implements ISysUserDeptService {
|
||||
|
||||
}
|
||||
70
src/main/java/com/boge/modules/dept/util/PageUtil.java
Normal file
70
src/main/java/com/boge/modules/dept/util/PageUtil.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.boge.modules.dept.util;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分页工具
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-10
|
||||
*/
|
||||
public class PageUtil extends cn.hutool.core.util.PageUtil {
|
||||
|
||||
/**
|
||||
* List 分页
|
||||
*/
|
||||
public static List toPage(int page, int size , List list) {
|
||||
int fromIndex = page * size;
|
||||
int toIndex = page * size + size;
|
||||
if(fromIndex > list.size()){
|
||||
return new ArrayList();
|
||||
} else if(toIndex >= list.size()) {
|
||||
return list.subList(fromIndex,list.size());
|
||||
} else {
|
||||
return list.subList(fromIndex,toIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page 数据处理,预防redis反序列化报错
|
||||
*/
|
||||
public static Map<String,Object> toPage(Page page) {
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",page.getContent());
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
public static Map<String,Object> toPage(Object object, Object totalElements) {
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",object);
|
||||
map.put("totalElements",totalElements);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
83
src/main/java/com/boge/modules/dept/vo/DeptVo.java
Normal file
83
src/main/java/com/boge/modules/dept/vo/DeptVo.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.boge.modules.dept.vo;
|
||||
|
||||
|
||||
import com.boge.common.base.BaseDTO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeptVo extends BaseDTO implements Serializable {
|
||||
|
||||
|
||||
private String dept_id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
|
||||
|
||||
|
||||
private Integer dept_sort;
|
||||
|
||||
|
||||
@NotBlank
|
||||
|
||||
private String name;
|
||||
@NotBlank
|
||||
|
||||
private String zh_name;
|
||||
@NotBlank
|
||||
|
||||
private String en_name;
|
||||
@NotBlank
|
||||
|
||||
private String in_name;
|
||||
|
||||
@NotNull
|
||||
|
||||
private Boolean is_used;
|
||||
|
||||
|
||||
private Long pid;
|
||||
|
||||
|
||||
private Integer sub_count = 0;
|
||||
/**
|
||||
* 前端显示
|
||||
*/
|
||||
private Boolean has_children =Boolean.FALSE;
|
||||
|
||||
private List<DeptVo> children;
|
||||
|
||||
public void setSub_count(Integer sub_count) {
|
||||
this.sub_count = sub_count;
|
||||
if (sub_count >0){
|
||||
this.has_children =Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.boge.modules.dict.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.boge.common.base.TableDataInfo;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.modules.dict.dao.Dict;
|
||||
import com.boge.modules.dict.dto.DictQuery;
|
||||
import com.boge.modules.dict.service.ISysDictService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/dict")
|
||||
public class SysDictController {
|
||||
|
||||
@Autowired
|
||||
private ISysDictService dictService;
|
||||
|
||||
|
||||
@GetMapping
|
||||
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery pageable){
|
||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAll(whereJson,pageable)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/all")
|
||||
public ResponseEntity<Object> queryAll(){
|
||||
return new ResponseEntity<>(dictService.queryAll(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> create(@RequestBody Dict dict){
|
||||
dictService.create(dict);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> updateDict(@Validated @RequestBody Dict dto){
|
||||
dictService.updateDict(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
|
||||
dictService.deleteBatchByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/dictDetail")
|
||||
public ResponseEntity<Object> queryDetails(@RequestParam Map criteria, PageQuery pageable){
|
||||
DictQuery dictQuery = JSONObject.parseObject(JSONObject.toJSONString(criteria), DictQuery.class);
|
||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAllDetail(dictQuery,pageable)),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/dictDetail/map")
|
||||
public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName){
|
||||
String[] names = dictName.split("[,,]");
|
||||
Map<String, List<Dict>> dictMap = new HashMap<>(16);
|
||||
for (String name : names) {
|
||||
dictMap.put(name, dictService.getDictByName(name));
|
||||
}
|
||||
return new ResponseEntity<>(dictMap, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/dictDetail")
|
||||
public ResponseEntity<Object> createDetail(@RequestBody Dict resources){
|
||||
dictService.createDetail(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/dictDetail")
|
||||
public ResponseEntity<Object> updateDetail(@RequestBody Dict resources){
|
||||
dictService.updateDetail(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/dictDetail/{id}")
|
||||
public ResponseEntity<Object> deleteDetail(@PathVariable String id){
|
||||
dictService.deleteDetail(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
107
src/main/java/com/boge/modules/dict/dao/Dict.java
Normal file
107
src/main/java/com/boge/modules/dict/dao/Dict.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.boge.modules.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_dict")
|
||||
public class Dict implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典标识
|
||||
*/
|
||||
@TableId(value = "dict_id")
|
||||
private String dict_id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private BigDecimal dict_sort;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dict_type;
|
||||
|
||||
/**
|
||||
* 参数1
|
||||
*/
|
||||
private String para1;
|
||||
|
||||
/**
|
||||
* 参数2
|
||||
*/
|
||||
private String para2;
|
||||
|
||||
/**
|
||||
* 参数3
|
||||
*/
|
||||
private String para3;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_id;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.boge.modules.dict.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.boge.modules.dict.dao.Dict;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDictMapper extends BaseMapper<Dict> {
|
||||
|
||||
}
|
||||
19
src/main/java/com/boge/modules/dict/dto/DictQuery.java
Normal file
19
src/main/java/com/boge/modules/dict/dto/DictQuery.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.boge.modules.dict.dto;
|
||||
|
||||
import com.boge.common.query.BaseQuery;
|
||||
import com.boge.modules.dict.dao.Dict;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2022/12/15
|
||||
*/
|
||||
@Data
|
||||
public class DictQuery extends BaseQuery<Dict> {
|
||||
private String code;
|
||||
|
||||
private String dict_name;
|
||||
private String dict_id;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.boge.modules.dict.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.modules.dict.dao.Dict;
|
||||
import com.boge.modules.dict.dto.DictQuery;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
public interface ISysDictService extends IService<Dict> {
|
||||
|
||||
/**
|
||||
* 分页查找
|
||||
* @param whereJson
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
IPage<Dict> queryAll(Map whereJson, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param dict
|
||||
*/
|
||||
void create(Dict dict);
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @param dto
|
||||
*/
|
||||
void updateDict(Dict dto);
|
||||
|
||||
/**
|
||||
* 通过id批量删除字典
|
||||
* @param ids
|
||||
*/
|
||||
void deleteBatchByIds(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 分页查询获取字典明细
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
IPage<Dict> queryAllDetail(DictQuery criteria, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 获取字典明细
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
List<Dict> getDictByName(String name);
|
||||
|
||||
/**
|
||||
* 添加字典明细
|
||||
* @param resources
|
||||
*/
|
||||
void createDetail(Dict resources);
|
||||
|
||||
/**
|
||||
* 更新字典明细
|
||||
* @param resources
|
||||
*/
|
||||
void updateDetail(Dict resources);
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @param id
|
||||
*/
|
||||
void deleteDetail(String id);
|
||||
|
||||
/**
|
||||
* 查询所有字典信息
|
||||
* @return
|
||||
*/
|
||||
List<Dict> queryAll();
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.boge.modules.dict.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.boge.common.exception.RRException;
|
||||
import com.boge.common.query.PageQuery;
|
||||
import com.boge.common.utils.ShiroUtils;
|
||||
import com.boge.modules.dict.dao.Dict;
|
||||
import com.boge.modules.dict.dao.mapper.SysDictMapper;
|
||||
import com.boge.modules.dict.dto.DictQuery;
|
||||
import com.boge.modules.dict.service.ISysDictService;
|
||||
import com.boge.modules.sys.entity.SysUserEntity;
|
||||
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;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Service("ISysDictService")
|
||||
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> implements ISysDictService {
|
||||
@Autowired
|
||||
private SysDictMapper sysDictMapper;
|
||||
|
||||
@Override
|
||||
public IPage<Dict> queryAll(Map whereJson, PageQuery page) {
|
||||
String blurry = null;
|
||||
if (ObjectUtil.isNotNull(whereJson.get("blurry"))) blurry = whereJson.get("blurry").toString();
|
||||
IPage<Dict> pages = this.page(new Page<>(page.getPage() + 1, page.getSize()), new QueryWrapper<Dict>()
|
||||
.select("MAX(dict_id) AS dict_id, code, name")
|
||||
.lambda()
|
||||
.like(ObjectUtil.isNotNull(blurry), Dict::getCode, blurry)
|
||||
.or(ObjectUtil.isNotNull(blurry))
|
||||
.like(ObjectUtil.isNotNull(blurry), Dict::getName, blurry)
|
||||
.orderBy(true, true, Dict::getCode)
|
||||
.groupBy(Dict::getCode, Dict::getName));
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Dict dict) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
String date = DateUtil.now();
|
||||
List<Dict> oldDict = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>()
|
||||
.eq(ObjectUtil.isNotNull(dict.getCode()), Dict::getCode, dict.getCode()));
|
||||
if (ObjectUtil.isNotNull(oldDict))
|
||||
throw new RRException("无标签");
|
||||
dict.setDict_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dict.setCreate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setCreate_name(userEntity.getUsername());
|
||||
dict.setCreate_time(date);
|
||||
dict.setUpdate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setUpdate_name(userEntity.getUsername());
|
||||
dict.setUpdate_time(date);
|
||||
sysDictMapper.insert(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDict(Dict dto) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
||||
if (ObjectUtil.isNull(dict)) {
|
||||
throw new RRException("无标签");
|
||||
}
|
||||
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dto.getCode()));
|
||||
if (ObjectUtil.isNotNull(dictList) && !dto.getCode().equals(dict.getCode()))
|
||||
throw new RRException("无标签");
|
||||
String currentUserId = String.valueOf(userEntity.getUserId());
|
||||
String currentNickName = userEntity.getNickname();
|
||||
// 根据code获取所有字典
|
||||
List<Dict> dicts = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dict.getCode()));
|
||||
dicts.forEach(di -> {
|
||||
di.setCode(dto.getCode());
|
||||
di.setName(dto.getName());
|
||||
di.setUpdate_id(currentUserId);
|
||||
di.setUpdate_name(currentNickName);
|
||||
di.setUpdate_time(DateUtil.now());
|
||||
sysDictMapper.updateById(di);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteBatchByIds(Set<String> ids) {
|
||||
// 查找code删除
|
||||
ids.forEach(id -> {
|
||||
String code = sysDictMapper.selectById(id).getCode();
|
||||
sysDictMapper.delete(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, code));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Dict> queryAllDetail(DictQuery criteria, PageQuery page) {
|
||||
LambdaQueryWrapper<Dict> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq(Dict::getCode, criteria.getCode())
|
||||
.isNotNull(Dict::getLabel)
|
||||
.ne(Dict::getLabel, "")
|
||||
.orderBy(true, true, Dict::getDict_sort);
|
||||
IPage<Dict> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
sysDictMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> getDictByName(String name) {
|
||||
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, name)
|
||||
.isNotNull(Dict::getLabel)
|
||||
.ne(Dict::getLabel, ""));
|
||||
return dictList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createDetail(Dict dict) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
// 校验是否已经有标签
|
||||
Dict one = sysDictMapper.selectOne(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, dict.getLabel())
|
||||
.eq(Dict::getCode, dict.getCode()));
|
||||
if (ObjectUtil.isNotNull(one))
|
||||
throw new RRException("无标签");
|
||||
// 判断是否有空的值
|
||||
List<Dict> selectOne = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dict.getCode()));
|
||||
Dict dic = selectOne.get(0);
|
||||
if (ObjectUtil.isNull(dic.getLabel())) {
|
||||
// 空就赋值
|
||||
dic.setCode(dict.getCode());
|
||||
dic.setLabel(dict.getLabel());
|
||||
dic.setValue(dict.getValue());
|
||||
dic.setDict_sort(dict.getDict_sort());
|
||||
dic.setDict_type(dict.getDict_type());
|
||||
dic.setPara1(dict.getPara1());
|
||||
dic.setPara2(dict.getPara2());
|
||||
dic.setPara3(dict.getPara3());
|
||||
sysDictMapper.updateById(dic);
|
||||
return;
|
||||
}
|
||||
// 插入新的数据
|
||||
dict.setDict_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
dict.setCode(dic.getCode());
|
||||
dict.setName(dic.getName());
|
||||
dict.setCreate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setCreate_name(userEntity.getUsername());
|
||||
dict.setCreate_time(DateUtil.now());
|
||||
dict.setUpdate_id(String.valueOf(userEntity.getUserId()));
|
||||
dict.setUpdate_name(userEntity.getUsername());
|
||||
dict.setUpdate_time(DateUtil.now());
|
||||
sysDictMapper.insert(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDetail(Dict resources) {
|
||||
SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
||||
Dict dict = sysDictMapper.selectById(resources.getDict_id());
|
||||
if (ObjectUtil.isNull(dict)) {
|
||||
throw new RRException("无标签");
|
||||
}
|
||||
// 校验是否已经有标签
|
||||
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getLabel, resources.getLabel())
|
||||
.eq(Dict::getCode, resources.getCode()));
|
||||
if (ObjectUtil.isNotNull(dictList) && !resources.getLabel().equals(dict.getLabel())) {
|
||||
throw new RRException("无标签");
|
||||
}
|
||||
resources.setUpdate_id(String.valueOf(userEntity.getUserId()));
|
||||
resources.setUpdate_name(userEntity.getUsername());
|
||||
resources.setUpdate_time(DateUtil.now());
|
||||
sysDictMapper.updateById(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDetail(String id) {
|
||||
sysDictMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> queryAll() {
|
||||
return sysDictMapper.selectList(new QueryWrapper<Dict>()
|
||||
.select("MAX(dict_id) AS dictId, code, name")
|
||||
.lambda()
|
||||
.groupBy(Dict::getCode, Dict::getName));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class FlwDeployController {
|
||||
|
||||
|
||||
/**
|
||||
* 根据Id查询流程定义信息
|
||||
* 发起流程
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -55,7 +55,7 @@ public class FlwInstanceController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的发起
|
||||
* 我的完成
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
|
||||
40
src/main/resources/mapper/dept/SysDeptMapper.xml
Normal file
40
src/main/resources/mapper/dept/SysDeptMapper.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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.boge.modules.dept.dao.mapper.SysDeptMapper">
|
||||
|
||||
<insert id="saveDeptRelation">
|
||||
replace into sys_user_dept values
|
||||
<foreach collection="depts" item="dept" separator=",">
|
||||
(#{user},#{dept})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="delDeptRelation">
|
||||
delete from sys_user_dept where user_id = #{user}
|
||||
</delete>
|
||||
|
||||
<update id="updateSubCount">
|
||||
update sys_dept set sub_count =
|
||||
(select m.count from (select count(*) count from sys_dept where pid = #{pid}) as m)
|
||||
where dept_id = #{pid}
|
||||
</update>
|
||||
<select id="findAllChild" resultType="java.lang.String">
|
||||
SELECT
|
||||
max(t3.childId) as deptIds
|
||||
from
|
||||
(
|
||||
select *,
|
||||
if( find_in_set(t1.pid, @p) > 0,@p := concat(@p,',',id),0 ) as childId
|
||||
from
|
||||
(select dept_id as id, pid from sys_dept t order by id) t1,
|
||||
(select @p := #{pid}) t2
|
||||
) t3
|
||||
where childId != '0'
|
||||
</select>
|
||||
<select id="getDeptRelation" resultType="java.util.Map">
|
||||
select * from sys_user_dept where dept_id in (
|
||||
<foreach collection="deptIds" separator="," item="dept">
|
||||
#{dept}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
</mapper>
|
||||
5
src/main/resources/mapper/dept/SysUserDeptMapper.xml
Normal file
5
src/main/resources/mapper/dept/SysUserDeptMapper.xml
Normal file
@@ -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.boge.modules.dept.dao.mapper.SysUserDeptMapper">
|
||||
|
||||
</mapper>
|
||||
5
src/main/resources/mapper/dict/SysDictMapper.xml
Normal file
5
src/main/resources/mapper/dict/SysDictMapper.xml
Normal file
@@ -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.boge.modules.dict.dao.mapper.SysDictMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user