fix:用户,部门
This commit is contained in:
@@ -16,20 +16,20 @@ import java.util.Date;
|
||||
@Data
|
||||
public class BaseDTO implements Serializable {
|
||||
|
||||
private String create_name;
|
||||
private String createName;
|
||||
|
||||
private Long create_id;
|
||||
private Long createId;
|
||||
|
||||
private String update_optname;
|
||||
private String updateOptname;
|
||||
|
||||
private Long update_optid;
|
||||
private Long updateOptid;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
private Date createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -37,15 +37,15 @@ import java.util.List;
|
||||
public class DeptVo extends BaseDTO implements Serializable {
|
||||
|
||||
|
||||
private Long dept_id;
|
||||
private Long deptId;
|
||||
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
private String extId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer dept_sort;
|
||||
private Integer deptSort;
|
||||
|
||||
|
||||
@NotBlank
|
||||
@@ -54,22 +54,21 @@ public class DeptVo extends BaseDTO implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private String is_used;
|
||||
private String isUsed;
|
||||
|
||||
@ApiModelProperty(value = "上级部门")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||
private Integer sub_count = 0;
|
||||
private Integer subCount = 0;
|
||||
//前端显示
|
||||
private Boolean hasChildren =Boolean.FALSE;
|
||||
|
||||
|
||||
private List<DeptVo> children;
|
||||
|
||||
public void setSub_count(Integer sub_count) {
|
||||
this.sub_count = sub_count;
|
||||
if (sub_count>0){
|
||||
public void setSubCount(Integer subCount) {
|
||||
this.subCount = subCount;
|
||||
if (subCount>0){
|
||||
this.hasChildren=Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,10 @@ import java.util.Objects;
|
||||
@Setter
|
||||
public class DeptTree implements Serializable {
|
||||
|
||||
private Long Dept_id;
|
||||
private Long deptId;
|
||||
|
||||
private Long pid;
|
||||
|
||||
private String name;
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<DeptTree> children;
|
||||
|
||||
@@ -130,10 +130,10 @@ public class DeptServiceImpl implements DeptService {
|
||||
CurrentUser user = SecurityUtils.getCurrentUser();
|
||||
dept.setSub_count(0);
|
||||
dept.setCode(UUID.randomUUID().toString());
|
||||
dept.setCreate_time(new Date());
|
||||
dept.setUpdate_time(new Date());
|
||||
dept.setCreate_id(user.getId());
|
||||
dept.setCreate_name(user.getUsername());
|
||||
dept.setCreateTime(new Date());
|
||||
dept.setUpdateTime(new Date());
|
||||
dept.setCreateId(user.getId());
|
||||
dept.setCreateName(user.getUsername());
|
||||
WQLObject.getWQLObject("sys_dept").insert(JSONObject.parseObject(JSON.toJSONString(dept)));
|
||||
|
||||
// 清理缓存
|
||||
@@ -215,7 +215,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
trees.add(deptDTO);
|
||||
}
|
||||
for (DeptTree it : deptDtos) {
|
||||
if (it.getPid() != null && deptDTO.getDept_id().equals(it.getPid())) {
|
||||
if (it.getPid() != null && deptDTO.getDeptId().equals(it.getPid())) {
|
||||
isChild = true;
|
||||
if (deptDTO.getChildren() == null) {
|
||||
deptDTO.setChildren(new ArrayList<>());
|
||||
|
||||
@@ -17,10 +17,16 @@ package org.nl.system.controller.dept;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.modules.system.domain.vo.DeptVo;
|
||||
import org.nl.modules.system.util.CopyUtil;
|
||||
import org.nl.system.service.dept.ISysDeptService;
|
||||
import org.nl.system.service.dept.dao.SysDept;
|
||||
import org.nl.system.service.dept.dto.DeptQuery;
|
||||
@@ -53,9 +59,9 @@ public class DeptController {
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping("/vo")
|
||||
public ResponseEntity<Object> queryvo(DeptQuery query) throws Exception {
|
||||
List<SysDept> sysDepts = deptService.queryVo(query);
|
||||
return new ResponseEntity<>(PageUtil.toPage(sysDepts, sysDepts.size()),HttpStatus.OK);
|
||||
public ResponseEntity queryvo(DeptQuery query, PageQuery pageQuery) throws Exception {
|
||||
Page deptPage = deptService.queryVo(query, pageQuery);
|
||||
return new ResponseEntity((TableDataInfo.build(deptPage)),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.config.RsaProperties;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
@@ -65,7 +66,7 @@ public class UserController {
|
||||
// @SaCheckPermission("user:list")
|
||||
public ResponseEntity<Object> query(UserQuery query, PageQuery page){
|
||||
Page<SysUser> pageable = userService.page(page.build(), query.build());
|
||||
return new ResponseEntity<>(null,HttpStatus.OK);
|
||||
return new ResponseEntity<>(TableDataInfo.build(pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增用户")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.nl.system.service.dept;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.dept.dao.SysDept;
|
||||
import org.nl.system.service.dept.dto.DeptQuery;
|
||||
|
||||
@@ -19,9 +21,10 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
/**
|
||||
* 条件查询
|
||||
* @param query
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
List<SysDept> queryVo(DeptQuery query);
|
||||
Page queryVo(DeptQuery query, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 条件查询树结构
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DeptQuery extends BaseQuery<SysDept> {
|
||||
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
super.doP.put("pidIsNull", QParam.builder().k(new String[]{"pid"}).type(QueryTEnum.LK).build());
|
||||
super.doP.put("pidIsNull", QParam.builder().k(new String[]{"pid"}).type(QueryTEnum.NO).build());
|
||||
super.doP.put("deptIds", QParam.builder().k(new String[]{"deptId"}).type(QueryTEnum.IN).build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.nl.system.service.dept.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.modules.system.domain.Dept;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.system.domain.vo.DeptVo;
|
||||
import org.nl.modules.system.service.dto.DeptTree;
|
||||
import org.nl.modules.system.util.CopyUtil;
|
||||
@@ -52,7 +51,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
trees.add(deptDTO);
|
||||
}
|
||||
for (DeptTree it : deptDtos) {
|
||||
if (it.getPid() != null && deptDTO.getDept_id().equals(it.getPid())) {
|
||||
if (it.getPid() != null && deptDTO.getDeptId().equals(it.getPid())) {
|
||||
isChild = true;
|
||||
if (deptDTO.getChildren() == null) {
|
||||
deptDTO.setChildren(new ArrayList<>());
|
||||
@@ -66,7 +65,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
depts.add(deptDTO);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("totalElements", deptDtos.size());
|
||||
map.put("content", CollectionUtil.isEmpty(trees) ? deptDtos : trees);
|
||||
@@ -74,24 +72,17 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDept> queryVo(DeptQuery query) {
|
||||
Boolean hasChild = false;
|
||||
public Page queryVo(DeptQuery query, PageQuery pageQuery) {
|
||||
if (query.getPidIsNull() == null){
|
||||
if (query.getPid() == null){
|
||||
query.setPidIsNull(true);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(query.getName())||!query.getIsUsed()){
|
||||
query.setPidIsNull(null);
|
||||
hasChild=true;
|
||||
}
|
||||
}
|
||||
List<SysDept> list = this.list(query.build());
|
||||
List<DeptVo> deptVos = CopyUtil.copyList(list, DeptVo.class);
|
||||
if (hasChild){
|
||||
deptVos.forEach(a->{
|
||||
a.setHasChildren(false);
|
||||
});
|
||||
Page page = this.page(pageQuery.build(), query.build());
|
||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||
if (StringUtils.isNotEmpty(query.getName())){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
||||
}
|
||||
return list;
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.system.service.user.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,5 +17,7 @@ import java.util.List;
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
List<SysUser> selectAl();
|
||||
@Select("select * from sys_user")
|
||||
List<SysUser> selectAl2();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +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="org.nl.system.service.user.dao.mapper.SysUserMapper">
|
||||
<select id="selectAl" resultType="org.nl.system.service.user.dao.SysUser">
|
||||
select * from sys_user
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user