提交 3d143c86 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 新增组织机构

上级 a0773f11
package io.dataease.base.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
@Data
public class SysDept implements Serializable {
private Long deptId;
private Long pid;
private Integer subCount;
private String name;
private Integer level;
private Integer deptSort;
private Boolean enabled;
private String createBy;
private String updateBy;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.SysDept;
import io.dataease.base.domain.SysDeptExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysDeptMapper {
long countByExample(SysDeptExample example);
int deleteByExample(SysDeptExample example);
int deleteByPrimaryKey(Long deptId);
int insert(SysDept record);
int insertSelective(SysDept record);
List<SysDept> selectByExample(SysDeptExample example);
SysDept selectByPrimaryKey(Long deptId);
int updateByExampleSelective(@Param("record") SysDept record, @Param("example") SysDeptExample example);
int updateByExample(@Param("record") SysDept record, @Param("example") SysDeptExample example);
int updateByPrimaryKeySelective(SysDept record);
int updateByPrimaryKey(SysDept record);
}
\ No newline at end of file
package io.dataease.controller.sys;
import io.dataease.base.domain.SysDept;
import io.dataease.service.sys.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequiredArgsConstructor
@Api(tags = "系统:部门管理")
@RequestMapping("/api/dept")
public class SysDeptController {
@Resource
private DeptService deptService;
@ApiOperation("查询部门")
@PostMapping("/root")
public List<SysDept> rootData(){
List<SysDept> root = deptService.root();
return root;
}
@ApiOperation("新增部门")
@PostMapping("/create")
public void create(@RequestBody SysDept dept){
deptService.add(dept);
}
}
package io.dataease.controller.sys.request;
public class DeptCreateRequest {
}
package io.dataease.service.sys;
import io.dataease.base.domain.SysDept;
import io.dataease.base.domain.SysDeptExample;
import io.dataease.base.mapper.SysDeptMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class DeptService {
private final static Integer DEPT_ROOT_LEVEL = 0;
@Resource
private SysDeptMapper sysDeptMapper;
public List<SysDept> root(){
SysDeptExample example = new SysDeptExample();
example.createCriteria().andLevelEqualTo(DEPT_ROOT_LEVEL);
example.setOrderByClause("dept_sort");
List<SysDept> sysDepts = sysDeptMapper.selectByExample(example);
return sysDepts;
}
public boolean add(SysDept sysDept){
if (ObjectUtils.isEmpty(sysDept.getLevel())){
sysDept.setLevel(DEPT_ROOT_LEVEL);
}
Date now = new Date();
sysDept.setCreateTime(now);
sysDept.setUpdateTime(now);
sysDept.setCreateBy(null);
sysDept.setUpdateBy(null);
try {
int insert = sysDeptMapper.insert(sysDept);
if (insert == 1){
return true;
}
}catch (Exception e){
return false;
}
return false;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论