Search in sources :

Example 1 with Dept

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);
}
Also used : R(com.github.liuweijw.commons.base.R) Dept(com.github.liuweijw.business.admin.domain.Dept) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Dept

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);
}
Also used : R(com.github.liuweijw.commons.base.R) Dept(com.github.liuweijw.business.admin.domain.Dept) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) PrePermissions(com.github.liuweijw.business.commons.web.aop.PrePermissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Dept

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");
}
Also used : QDept(com.github.liuweijw.business.admin.domain.QDept) Dept(com.github.liuweijw.business.admin.domain.Dept) ArrayList(java.util.ArrayList) DeptTree(com.github.liuweijw.business.commons.tree.DeptTree)

Example 4 with Dept

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);
}
Also used : QDept(com.github.liuweijw.business.admin.domain.QDept) QDept(com.github.liuweijw.business.admin.domain.QDept) Dept(com.github.liuweijw.business.admin.domain.Dept) DeptTree(com.github.liuweijw.business.commons.tree.DeptTree) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 5 with Dept

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) QDept(com.github.liuweijw.business.admin.domain.QDept) QDept(com.github.liuweijw.business.admin.domain.QDept) Dept(com.github.liuweijw.business.admin.domain.Dept) Sort(org.springframework.data.domain.Sort) Predicate(com.querydsl.core.types.Predicate) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Dept (com.github.liuweijw.business.admin.domain.Dept)5 QDept (com.github.liuweijw.business.admin.domain.QDept)3 DeptTree (com.github.liuweijw.business.commons.tree.DeptTree)2 PrePermissions (com.github.liuweijw.business.commons.web.aop.PrePermissions)2 R (com.github.liuweijw.commons.base.R)2 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Date (java.util.Date)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Predicate (com.querydsl.core.types.Predicate)1 ArrayList (java.util.ArrayList)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1