Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
godchao 2019-08-06 15:45:08 +08:00
commit 0583e09c47
6 changed files with 76 additions and 9 deletions

View File

@ -165,8 +165,8 @@ public class DepartmentController extends BaseCrudRestController {
/*
* 根据组织ID获取部门kv list
* */
@GetMapping("/getDepartment/{orgId}")
public JsonResult getDepartment(@PathVariable Long orgId, HttpServletRequest request){
@GetMapping("/getDepartmentKV/{orgId}")
public JsonResult getDepartmentKV(@PathVariable Long orgId, HttpServletRequest request){
Wrapper wrapper = null;
//获取部门KV
wrapper = new QueryWrapper<Department>()
@ -178,6 +178,21 @@ public class DepartmentController extends BaseCrudRestController {
return new JsonResult(deptKvList);
}
/*
* 根据组织ID获取部门list
* */
@GetMapping("/getDepartmentList/{orgId}")
public JsonResult getDepartmentList(@PathVariable Long orgId, HttpServletRequest request) throws Exception {
// 构建分页
Pagination pagination = buildPagination(request);
Wrapper wrapper = new QueryWrapper<Department>()
.lambda()
.eq(Department::getOrgId, orgId);
List<DepartmentVO> voList = departmentService.getViewObjectList(wrapper, pagination, DepartmentVO.class);
return new JsonResult(voList);
}
@Override
protected BaseService getService() {
return departmentService;

View File

@ -6,6 +6,7 @@ import com.diboot.core.binding.RelationsBinder;
import com.diboot.core.controller.BaseCrudRestController;
import com.diboot.core.service.BaseService;
import com.diboot.core.service.DictionaryService;
import com.diboot.core.util.V;
import com.diboot.core.vo.JsonResult;
import com.diboot.core.vo.KeyValue;
import com.diboot.core.vo.Pagination;
@ -38,12 +39,11 @@ public class OrganizationController extends BaseCrudRestController {
@GetMapping("/list")
public JsonResult getVOList(HttpServletRequest request) throws Exception{
QueryWrapper<Organization> queryWrapper = buildQuery(request);
queryWrapper.lambda().eq(Organization::getParentId, 0);
// 构建分页
Pagination pagination = buildPagination(request);
// 查询当前页的Entity主表数据
List<Organization> entityList = organizationService.getEntityList(queryWrapper, pagination);
//筛选出在列表页展示的字段
List<OrganizationVO> voList = RelationsBinder.convertAndBind(entityList, OrganizationVO.class);
List<OrganizationVO> voList = organizationService.getOrganizatioList(queryWrapper, pagination);
// 返回结果
return new JsonResult(Status.OK, voList).bindPagination(pagination);
}
@ -85,10 +85,11 @@ public class OrganizationController extends BaseCrudRestController {
@GetMapping("/attachMore")
public JsonResult attachMore(HttpServletRequest request, ModelMap modelMap){
Wrapper wrapper = null;
//获取组织机构KV
//获取组织机构KV
wrapper = new QueryWrapper<Organization>()
.lambda()
.select(Organization::getName, Organization::getId);
.select(Organization::getName, Organization::getId)
.eq(Organization::getParentId, 0);
List<KeyValue> orgKvList = organizationService.getKeyValueList(wrapper);
modelMap.put("orgKvList", orgKvList);
@ -99,6 +100,25 @@ public class OrganizationController extends BaseCrudRestController {
return new JsonResult(modelMap);
}
@GetMapping("/getOrgTree")
public JsonResult getOrgTree() throws Exception{
QueryWrapper<Organization> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(Organization::getParentId, 0);
List<Organization> orgList = organizationService.getEntityList(queryWrapper);
List<OrganizationVO> voList = RelationsBinder.convertAndBind(orgList, OrganizationVO.class);
if(V.notEmpty(voList)){
for(OrganizationVO vo : voList){
queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(Organization::getParentId, vo.getId());
List<Organization> childList = organizationService.getEntityList(queryWrapper);
List<OrganizationVO> childvVoList = RelationsBinder.convertAndBind(childList, OrganizationVO.class);
vo.setChildren(childvVoList);
}
}
return new JsonResult(orgList);
}
@Override
protected BaseService getService() {
return organizationService;

View File

@ -116,8 +116,8 @@ public class PositionController extends BaseCrudRestController {
/*
* 根据部门ID获取职位kv list
* */
@GetMapping("/getPosition/{deptId}")
public JsonResult getPosition(@PathVariable Long deptId, HttpServletRequest request){
@GetMapping("/getPositionKV/{deptId}")
public JsonResult getPositionKV(@PathVariable Long deptId, HttpServletRequest request){
Wrapper wrapper = null;
List<Long> positionIdList = new ArrayList<>();
wrapper = new LambdaQueryWrapper<PositionDepartment>()

View File

@ -1,7 +1,12 @@
package com.diboot.example.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.diboot.core.service.BaseService;
import com.diboot.core.vo.Pagination;
import com.diboot.example.entity.Organization;
import com.diboot.example.vo.OrganizationVO;
import java.util.List;
/**
* 单位相关Service
@ -11,4 +16,6 @@ import com.diboot.example.entity.Organization;
*/
public interface OrganizationService extends BaseService<Organization> {
List<OrganizationVO> getOrganizatioList(Wrapper wrapper, Pagination pagination);
}

View File

@ -1,12 +1,20 @@
package com.diboot.example.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diboot.core.binding.RelationsBinder;
import com.diboot.core.service.impl.BaseServiceImpl;
import com.diboot.core.util.V;
import com.diboot.core.vo.Pagination;
import com.diboot.example.entity.Organization;
import com.diboot.example.mapper.OrganizationMapper;
import com.diboot.example.service.OrganizationService;
import com.diboot.example.vo.OrganizationVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 单位相关Service实现
* @author Mazhicheng
@ -17,4 +25,17 @@ import org.springframework.stereotype.Service;
@Slf4j
public class OrganizationServiceImpl extends BaseServiceImpl<OrganizationMapper, Organization> implements OrganizationService {
@Override
public List<OrganizationVO> getOrganizatioList(Wrapper wrapper, Pagination pagination) {
List<OrganizationVO> voList = super.getViewObjectList(wrapper, pagination, OrganizationVO.class);
if(V.notEmpty(voList)){
for(OrganizationVO vo : voList){
wrapper = new LambdaQueryWrapper<Organization>().eq(Organization::getParentId, vo.getId());
List<Organization> orgList = super.getEntityList(wrapper);
List<OrganizationVO> orgVoList = RelationsBinder.convertAndBind(orgList, OrganizationVO.class);
vo.setChildren(orgVoList);
}
}
return voList;
}
}

View File

@ -5,6 +5,8 @@ import com.diboot.core.binding.annotation.BindField;
import com.diboot.example.entity.Organization;
import lombok.Data;
import java.util.List;
/**
* @author wangyongliang
* @version v2.0
@ -22,4 +24,6 @@ public class OrganizationVO extends Organization {
@BindDict(type = "INDUSTRY", field = "industry")
private String industryLabel;
private List<OrganizationVO> children;
}