mdf:部门页面
This commit is contained in:
@@ -2,16 +2,21 @@ package org.nl.common.domain.query;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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 lombok.Data;
|
||||||
import org.nl.common.enums.QueryTEnum;
|
import org.nl.common.enums.QueryTEnum;
|
||||||
import org.nl.modules.tools.MapOf;
|
import org.nl.modules.tools.MapOf;
|
||||||
|
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author ZZQ
|
* @author ZZQ
|
||||||
* @Date 2022/12/14 6:33 下午
|
* @Date 2022/12/14 6:33 下午
|
||||||
|
* 泛型必须为数据tb对应do:由mybatis管理
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class BaseQuery<T> {
|
public class BaseQuery<T> {
|
||||||
@@ -32,12 +37,13 @@ public class BaseQuery<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段映射Map:指定字段对应QueryWrapper的查询类型
|
* 字段映射Map:指定字段对应QueryWrapper的查询类型
|
||||||
|
* 字段与数据库字段对应,不支持驼峰
|
||||||
* @see org.nl.common.enums.QueryTEnum
|
* @see org.nl.common.enums.QueryTEnum
|
||||||
* 通过buid构建
|
* 通过buid构建
|
||||||
*/
|
*/
|
||||||
public Map<String, QParam> doP = MapOf.of("blurry", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build()
|
public Map<String, QParam> doP = MapOf.of("blurry", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build()
|
||||||
,"startTime", QParam.builder().k(new String[]{"createTime"}).type(QueryTEnum.LT).build()
|
,"startTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LT).build()
|
||||||
,"endTime", QParam.builder().k(new String[]{"createTime"}).type(QueryTEnum.LE).build()
|
,"endTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LE).build()
|
||||||
,"sort", QParam.builder().k(new String[]{"sort"}).type(QueryTEnum.BY).build()
|
,"sort", QParam.builder().k(new String[]{"sort"}).type(QueryTEnum.BY).build()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,13 +51,18 @@ public class BaseQuery<T> {
|
|||||||
this.paramMapping();
|
this.paramMapping();
|
||||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||||
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
||||||
|
Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments();
|
||||||
|
Map<String, ColumnCache> columnMap = LambdaUtils.getColumnMap((Class<?>) types[0]);
|
||||||
json.forEach((key, vel) -> {
|
json.forEach((key, vel) -> {
|
||||||
if (vel != null && !key.equals("doP")){
|
if (vel != null && !key.equals("doP")){
|
||||||
QParam qParam = doP.get(key);
|
QParam qParam = doP.get(key);
|
||||||
if (qParam != null){
|
if (qParam != null){
|
||||||
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
|
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
|
||||||
}else {
|
}else {
|
||||||
wrapper.eq(key,vel);
|
ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
|
||||||
|
if (columnCache!=null){
|
||||||
|
wrapper.eq(columnCache.getColumn(),vel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import java.util.List;
|
|||||||
public class DeptVo extends BaseDTO implements Serializable {
|
public class DeptVo extends BaseDTO implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
private Long deptId;
|
private String deptId;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public class DeptVo extends BaseDTO implements Serializable {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ApiModelProperty(value = "是否启用")
|
@ApiModelProperty(value = "是否启用")
|
||||||
private String isUsed;
|
private Boolean isUsed;
|
||||||
|
|
||||||
@ApiModelProperty(value = "上级部门")
|
@ApiModelProperty(value = "上级部门")
|
||||||
private Long pid;
|
private Long pid;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.nl.system.service.dept;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.system.service.dept.dao.SysDept;
|
import org.nl.system.service.dept.dao.SysDept;
|
||||||
import org.nl.system.service.dept.dto.DeptQuery;
|
import org.nl.system.service.dept.dto.DeptQuery;
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package org.nl.system.service.dept.dao;
|
package org.nl.system.service.dept.dao;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -52,7 +55,7 @@ public class SysDept implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private String isUsed;
|
private Boolean isUsed;
|
||||||
|
|
||||||
private String createId;
|
private String createId;
|
||||||
|
|
||||||
@@ -71,12 +74,14 @@ public class SysDept implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 创建日期
|
* 创建日期
|
||||||
*/
|
*/
|
||||||
private String createTime;
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
private String updateTime;
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门编号
|
* 部门编号
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package org.nl.system.service.dept.impl;
|
package org.nl.system.service.dept.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -15,7 +19,6 @@ import org.nl.system.service.dept.dto.DeptQuery;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -83,7 +86,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||||||
query.setPidIsNull(true);
|
query.setPidIsNull(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Page page = this.page(pageQuery.build(), query.build());
|
Page page = this.page(pageQuery.build(SysDept.class), query.build());
|
||||||
|
|
||||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||||
if (StringUtils.isNotEmpty(query.getName())){
|
if (StringUtils.isNotEmpty(query.getName())){
|
||||||
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
||||||
|
|||||||
60
nladmin-ui/src/views/system/dept/dept.js
Normal file
60
nladmin-ui/src/views/system/dept/dept.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getDepts(params) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dept',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDeptTree(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/dept/allTree',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDeptSuperior(ids) {
|
||||||
|
const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
|
||||||
|
return request({
|
||||||
|
url: 'api/dept/superior',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDeptvo(params) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dept/vo',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function add(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dept',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function del(ids) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dept',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function edit(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/dept',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { add, edit, del, getDepts, getDeptSuperior, getDeptvo, getDeptTree }
|
||||||
Reference in New Issue
Block a user