use of com.github.liuweijw.business.admin.domain.Dept in project fw-cloud-framework by liuweijw.
the class DeptController method upd.
@ApiOperation(value = "修改", notes = "部门信息")
@ApiImplicitParam(name = "dept", value = "", required = true, dataType = "Dept")
@RequestMapping(value = "/upd", method = RequestMethod.POST)
@PrePermissions(value = Functional.UPD)
public R<Boolean> upd(HttpServletRequest request, @RequestBody Dept dept) {
if (null == dept)
return new R<Boolean>().failure("部门信息不能为空");
if (null == dept.getDeptId())
return new R<Boolean>().failure("部门信息不存在");
if (StringHelper.isBlank(dept.getDeptName()))
return new R<Boolean>().failure("部门名称不能为空");
Dept dbDept = deptService.findById(dept.getDeptId());
if (null == dbDept)
return new R<Boolean>().failure("部门不存在");
dbDept.setUpdateTime(new Date());
dbDept.setStatu(dept.getStatu());
dbDept.setDeptName(dept.getDeptName());
dbDept.setPos(null != dept.getPos() ? dept.getPos() : dbDept.getPos());
Dept exDept = deptService.saveOrUpdate(dbDept);
return new R<Boolean>().data(null != exDept);
}
use of com.github.liuweijw.business.admin.domain.Dept in project fw-cloud-framework by liuweijw.
the class DeptController method add.
@ApiOperation(value = "新增", notes = "部门信息")
@ApiImplicitParam(name = "dept", value = "", required = true, dataType = "Dept")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@PrePermissions(value = Functional.ADD)
public R<Boolean> add(HttpServletRequest request, @RequestBody Dept dept) {
if (null == dept)
return new R<Boolean>().failure("部门信息不能为空");
if (null == dept.getPid() || dept.getPid() < 0)
return new R<Boolean>().failure("上级部门不能为空");
if (StringHelper.isBlank(dept.getDeptName()))
return new R<Boolean>().failure("部门名称不能为空");
dept.setDeptId(null);
dept.setPos(null != dept.getPos() ? dept.getPos() : 0);
dept.setCreateTime(new Date());
dept.setUpdateTime(new Date());
dept.setStatu(0);
Dept dbDept = deptService.saveOrUpdate(dept);
return new R<Boolean>().data(null != dbDept);
}
use of com.github.liuweijw.business.admin.domain.Dept in project fw-cloud-framework by liuweijw.
the class DeptServiceImpl method getDeptTree.
private List<DeptTree> getDeptTree(List<Dept> list, int rootId) {
List<DeptTree> treeList = new ArrayList<DeptTree>();
for (Dept dept : list) {
// 排除父节点和自己节点相同的数据
if (dept.getPid().intValue() == dept.getDeptId().intValue())
continue;
DeptTree node = new DeptTree();
node.setId(dept.getDeptId() + "");
node.setPid(dept.getPid() + "");
node.setName(dept.getDeptName());
node.setPos(dept.getPos());
treeList.add(node);
}
return TreeUtil.build(treeList, "0");
}
use of com.github.liuweijw.business.admin.domain.Dept in project fw-cloud-framework by liuweijw.
the class DeptServiceImpl method getDeptTreeList.
@Override
@Cacheable(key = "'dept_tree_list'", unless = "#result eq null")
public List<DeptTree> getDeptTreeList() {
QDept dept = QDept.dept;
List<Dept> list = this.queryFactory.selectFrom(dept).where(dept.statu.eq(0)).fetch();
if (null == list || list.size() == 0)
return new ArrayList<DeptTree>();
return getDeptTree(list, 0);
}
use of com.github.liuweijw.business.admin.domain.Dept in project fw-cloud-framework by liuweijw.
the class DeptServiceImpl method findAll.
@Override
@Cacheable(key = "'page_dept_' + #p0.currentPage + '_' + #p0.pageSize + '_' + #p1.type + '_' + #p1.label")
public PageBean<Dept> findAll(PageParams pageParams, Dept dept) {
QDept qDept = QDept.dept;
Predicate qNamePredicate = null;
if (null != dept) {
if (StringHelper.isNotBlank(dept.getDeptName())) {
qNamePredicate = qDept.deptName.like("%" + dept.getDeptName().trim() + "%");
}
}
Predicate predicate = qDept.deptId.goe(0).and(qNamePredicate);
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "deptId"));
PageRequest pageRequest = PageUtils.of(pageParams, sort);
Page<Dept> pageList = deptRepository.findAll(predicate, pageRequest);
return PageUtils.of(pageList);
}
Aggregations