package com.tuoheng.admin.controller; | package com.tuoheng.admin.controller; | ||||
import com.alibaba.fastjson.JSON; | |||||
import com.tuoheng.admin.request.dept.AddDeptRequest; | import com.tuoheng.admin.request.dept.AddDeptRequest; | ||||
import com.tuoheng.admin.request.dept.EditDeptRequest; | import com.tuoheng.admin.request.dept.EditDeptRequest; | ||||
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest; | |||||
import com.tuoheng.admin.service.dept.IDeptService; | import com.tuoheng.admin.service.dept.IDeptService; | ||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import java.util.Map; | |||||
/** | /** | ||||
* 部门前端控制器 | * 部门前端控制器 | ||||
* | * | ||||
private IDeptService deptService; | private IDeptService deptService; | ||||
/** | /** | ||||
* 查询部门列表 | |||||
* 查询部门树形列表 | |||||
*/ | */ | ||||
@GetMapping("/list/tree") | @GetMapping("/list/tree") | ||||
public JsonResult getListTree() { | public JsonResult getListTree() { | ||||
return deptService.getListTree(); | return deptService.getListTree(); | ||||
} | } | ||||
/** | |||||
* 根据id查询子部门列表 | |||||
*/ | |||||
@GetMapping("/child/page/list/{id}") | |||||
public JsonResult getChildList(@RequestBody QueryDeptChildPageListRequest queryDeptChildPageListRequest) { | |||||
log.info("进入获取子部门分页列表列表接口, id:{}", queryDeptChildPageListRequest.getId()); | |||||
return deptService.getChildPageList(queryDeptChildPageListRequest); | |||||
} | |||||
/** | /** | ||||
* 获取部门详细信息 | * 获取部门详细信息 | ||||
*/ | */ | ||||
* 修改部门 | * 修改部门 | ||||
*/ | */ | ||||
@PutMapping | @PutMapping | ||||
public JsonResult update(@RequestBody EditDeptRequest oldEditDeptRequest, @RequestBody EditDeptRequest newEditDeptRequest) { | |||||
public JsonResult update(@RequestBody Map<String, Object> param) { | |||||
log.info("进入修改部门接口"); | log.info("进入修改部门接口"); | ||||
EditDeptRequest oldEditDeptRequest = JSON.parseObject(JSON.toJSONString(param.get("oldEditDeptRequest")), EditDeptRequest.class); | |||||
EditDeptRequest newEditDeptRequest = JSON.parseObject(JSON.toJSONString(param.get("newEditDeptRequest")), EditDeptRequest.class); | |||||
return deptService.update(oldEditDeptRequest, newEditDeptRequest); | return deptService.update(oldEditDeptRequest, newEditDeptRequest); | ||||
} | } | ||||
return roadInformationService.getListInfo(query); | return roadInformationService.getListInfo(query); | ||||
} | } | ||||
/** | |||||
* 根据部门id获取该部门下公路信息列表 | |||||
* @param deptId | |||||
* @return | |||||
*/ | |||||
@GetMapping("/list/by/dept/{deptId}") | |||||
public JsonResult getListByDeptId(@PathVariable("deptId") String deptId){ | |||||
return roadInformationService.getListByDeptId(deptId); | |||||
} | |||||
/** | /** | ||||
* 公路新增 | * 公路新增 | ||||
* @param entity | * @param entity |
return sectionService.getListInfo(query); | return sectionService.getListInfo(query); | ||||
} | } | ||||
/** | |||||
* 根据部门id获取该部门下路段信息列表 | |||||
* @param deptId | |||||
* @return | |||||
*/ | |||||
@GetMapping("/list/by/dept/{deptId}") | |||||
public JsonResult getListByDeptId(@PathVariable("deptId") String deptId){ | |||||
return sectionService.getListByDeptId(deptId); | |||||
} | |||||
/** | /** | ||||
* 根据id获取路段详情 | * 根据id获取路段详情 | ||||
* @param sectionId | * @param sectionId |
package com.tuoheng.admin.enums.dept; | |||||
/** | |||||
* 获取子部门列表返回码 | |||||
* 模块代码:20(部门管理) | |||||
* 接口代码:06 (获取子部门列表) | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-22 | |||||
*/ | |||||
public enum QueryDeptChildListCodeEnum { | |||||
DEPT_LIST_IS_FAILED(1200600, "获取子部门列表失败"), | |||||
DEPT_ID_IS_NULL(1200601, "部门id为空"), | |||||
DEPT_IS_NOT_EXIST(1200602, "部门不存在"), | |||||
DEPT_LIST_IS_NULL(1200603, "子部门列表为空"); | |||||
/** | |||||
* 错误码 | |||||
*/ | |||||
private int code; | |||||
/** | |||||
* 错误信息 | |||||
*/ | |||||
private String msg; | |||||
QueryDeptChildListCodeEnum(int code, String msg){ | |||||
this.code = code; | |||||
this.msg = msg; | |||||
} | |||||
public int getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(int code) { | |||||
this.code = code; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
public void setMsg(String msg) { | |||||
this.msg = msg; | |||||
} | |||||
} |
* @team tuoheng | * @team tuoheng | ||||
* @date 2022-11-20 | * @date 2022-11-20 | ||||
*/ | */ | ||||
public enum DeptInfoCodeEnum { | |||||
public enum QueryDeptInfoCodeEnum { | |||||
// 部门列表为空 | |||||
DEPT_ID_IS_NULL(1200201, "部门id为空"), | DEPT_ID_IS_NULL(1200201, "部门id为空"), | ||||
DEPT_IS_NOT_EXIST(1200202, "部门不存在"); | DEPT_IS_NOT_EXIST(1200202, "部门不存在"); | ||||
*/ | */ | ||||
private String msg; | private String msg; | ||||
DeptInfoCodeEnum(int code, String msg){ | |||||
QueryDeptInfoCodeEnum(int code, String msg){ | |||||
this.code = code; | this.code = code; | ||||
this.msg = msg; | this.msg = msg; | ||||
} | } |
* @team tuoheng | * @team tuoheng | ||||
* @date 2022-11-20 | * @date 2022-11-20 | ||||
*/ | */ | ||||
public enum DeptTreeCodeListEnum { | |||||
public enum QueryDeptTreeListCodeEnum { | |||||
DEPT_LIST_NULL(1200101, "部门列表为空"); | |||||
DEPT_LIST_IS_NULL(1200101, "部门列表为空"); | |||||
/** | /** | ||||
* 错误码 | * 错误码 | ||||
*/ | */ | ||||
private String msg; | private String msg; | ||||
DeptTreeCodeListEnum(int code, String msg){ | |||||
QueryDeptTreeListCodeEnum(int code, String msg){ | |||||
this.code = code; | this.code = code; | ||||
this.msg = msg; | this.msg = msg; | ||||
} | } |
package com.tuoheng.admin.enums.road; | |||||
/** | |||||
* 根据部门id获取该部门下公路列表返回码 | |||||
* 模块代码:21(公路管理) | |||||
* 接口代码:03 (根据部门id获取该部门下公路列表) | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-20 | |||||
*/ | |||||
public enum QueryRoadListByDeptIdCodeEnum { | |||||
QUERY_IS_FAILED(1210300, "获取数据失败"), | |||||
DEPT_ID_IS_NULL(1210301, "部门id为空"), | |||||
DEPT_IS_NOT_EXIST(1210302, "部门不存在"), | |||||
ROAD_LIST_IS_NULL(1210303, "公路列表为空"); | |||||
/** | |||||
* 错误码 | |||||
*/ | |||||
private int code; | |||||
/** | |||||
* 错误信息 | |||||
*/ | |||||
private String msg; | |||||
QueryRoadListByDeptIdCodeEnum(int code, String msg){ | |||||
this.code = code; | |||||
this.msg = msg; | |||||
} | |||||
public int getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(int code) { | |||||
this.code = code; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
public void setMsg(String msg) { | |||||
this.msg = msg; | |||||
} | |||||
} |
package com.tuoheng.admin.enums.section; | |||||
/** | |||||
* 根据部门id获取该部门下公路列表返回码 | |||||
* 模块代码:22(路段管理) | |||||
* 接口代码:03 (根据部门id获取该部门下公路列表) | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-20 | |||||
*/ | |||||
public enum QuerySectionListByDeptIdCodeEnum { | |||||
QUERY_IS_FAILED(1220300, "获取数据失败"), | |||||
DEPT_ID_IS_NULL(1220201, "部门id为空"), | |||||
DEPT_IS_NOT_EXIST(1220202, "部门不存在"), | |||||
SECTION_LIST_IS_NULL(1220203, "路段列表为空");; | |||||
/** | |||||
* 错误码 | |||||
*/ | |||||
private int code; | |||||
/** | |||||
* 错误信息 | |||||
*/ | |||||
private String msg; | |||||
QuerySectionListByDeptIdCodeEnum(int code, String msg){ | |||||
this.code = code; | |||||
this.msg = msg; | |||||
} | |||||
public int getCode() { | |||||
return code; | |||||
} | |||||
public void setCode(int code) { | |||||
this.code = code; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
public void setMsg(String msg) { | |||||
this.msg = msg; | |||||
} | |||||
} |
*/ | */ | ||||
public interface DeptMapper extends BaseMapper<Dept> { | public interface DeptMapper extends BaseMapper<Dept> { | ||||
List<String> selectAllChildListById(String id); | |||||
/** | /** | ||||
* 修改部门 | * 修改部门 | ||||
* | * |
*/ | */ | ||||
private List<RoadSectionDto> roadSectionDtoList; | private List<RoadSectionDto> roadSectionDtoList; | ||||
} | } |
package com.tuoheng.admin.request.dept; | |||||
import com.tuoheng.admin.dto.RoadSectionDto; | |||||
import com.tuoheng.common.core.common.BaseQuery; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotBlank; | |||||
import java.util.List; | |||||
/** | |||||
* 根据部门id查询子部门列表请求参数 | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-22 | |||||
*/ | |||||
@Data | |||||
public class QueryDeptChildPageListRequest extends BaseQuery { | |||||
private static final long serialVersionUID = 1L; | |||||
/** | |||||
* 部门id | |||||
*/ | |||||
private String id; | |||||
} |
JsonResult getListInfo(SectionQuery query); | JsonResult getListInfo(SectionQuery query); | ||||
JsonResult getListByDeptId(String deptId); | |||||
JsonResult editInfo(Section entity); | JsonResult editInfo(Section entity); | ||||
JsonResult getSectionInfo(String sectionId); | JsonResult getSectionInfo(String sectionId); |
JsonResult getListInfo(RoadInformationQuery query); | JsonResult getListInfo(RoadInformationQuery query); | ||||
JsonResult getListByDeptId(String deptId); | |||||
JsonResult editInfo(RoadInformation entity); | JsonResult editInfo(RoadInformation entity); | ||||
// JsonResult deleteRoadByIds(String[] ids); | // JsonResult deleteRoadByIds(String[] ids); |
import com.tuoheng.admin.mapper.DeptMapper; | import com.tuoheng.admin.mapper.DeptMapper; | ||||
import com.tuoheng.admin.request.dept.AddDeptRequest; | import com.tuoheng.admin.request.dept.AddDeptRequest; | ||||
import com.tuoheng.admin.request.dept.EditDeptRequest; | import com.tuoheng.admin.request.dept.EditDeptRequest; | ||||
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest; | |||||
import com.tuoheng.admin.service.dept.add.AddDeptService; | import com.tuoheng.admin.service.dept.add.AddDeptService; | ||||
import com.tuoheng.admin.service.dept.delete.DeleteDeptService; | import com.tuoheng.admin.service.dept.delete.DeleteDeptService; | ||||
import com.tuoheng.admin.service.dept.query.QueryChildListService; | |||||
import com.tuoheng.admin.service.dept.query.QueryDeptInfoService; | import com.tuoheng.admin.service.dept.query.QueryDeptInfoService; | ||||
import com.tuoheng.admin.service.dept.query.QueryListTreeService; | import com.tuoheng.admin.service.dept.query.QueryListTreeService; | ||||
import com.tuoheng.admin.service.dept.update.UpdateDeptService; | import com.tuoheng.admin.service.dept.update.UpdateDeptService; | ||||
@Autowired | @Autowired | ||||
private QueryListTreeService queryListTreeService; | private QueryListTreeService queryListTreeService; | ||||
@Autowired | |||||
private QueryChildListService queryChildListService; | |||||
@Autowired | @Autowired | ||||
private QueryDeptInfoService queryDeptInfoService; | private QueryDeptInfoService queryDeptInfoService; | ||||
private DeleteDeptService deleteDeptService; | private DeleteDeptService deleteDeptService; | ||||
/** | /** | ||||
* 查询部门列表 | |||||
* 查询部门树形列表 | |||||
* | * | ||||
* @return 部门 | * @return 部门 | ||||
*/ | */ | ||||
return queryListTreeService.getListTree(); | return queryListTreeService.getListTree(); | ||||
} | } | ||||
/** | |||||
* 根据id查询子部门列表 | |||||
* | |||||
* @return 部门 | |||||
*/ | |||||
@Override | |||||
public JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest) { | |||||
return queryChildListService.getChildPageList(queryDeptChildPageListRequest); | |||||
} | |||||
/** | /** | ||||
* 查询部门 | * 查询部门 | ||||
* | * |
import com.tuoheng.admin.entity.Dept; | import com.tuoheng.admin.entity.Dept; | ||||
import com.tuoheng.admin.request.dept.AddDeptRequest; | import com.tuoheng.admin.request.dept.AddDeptRequest; | ||||
import com.tuoheng.admin.request.dept.EditDeptRequest; | import com.tuoheng.admin.request.dept.EditDeptRequest; | ||||
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest; | |||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
import java.util.List; | import java.util.List; | ||||
JsonResult getDeptInfo(String id); | JsonResult getDeptInfo(String id); | ||||
/** | /** | ||||
* 查询部门列表 | |||||
* 查询部门树形列表 | |||||
* | * | ||||
* @return 部门集合 | * @return 部门集合 | ||||
*/ | */ | ||||
JsonResult getListTree(); | JsonResult getListTree(); | ||||
/** | |||||
* 根据id查询子部门列表 | |||||
* | |||||
* @return 部门集合 | |||||
*/ | |||||
JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest); | |||||
/** | /** | ||||
* 新增部门 | * 新增部门 | ||||
* | * |
package com.tuoheng.admin.service.dept.query; | |||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||||
import com.tuoheng.admin.entity.Dept; | |||||
import com.tuoheng.admin.enums.dept.QueryDeptChildListCodeEnum; | |||||
import com.tuoheng.admin.mapper.DeptMapper; | |||||
import com.tuoheng.admin.request.dept.QueryDeptChildPageListRequest; | |||||
import com.tuoheng.admin.utils.ShiroUtils; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.common.core.utils.StringUtils; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | |||||
* 根据id查询子部门列表业务层处理 | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-22 | |||||
*/ | |||||
@Slf4j | |||||
@Service | |||||
public class QueryChildListService { | |||||
@Autowired | |||||
private DeptMapper deptMapper; | |||||
/** | |||||
* 获取部门树形列表 | |||||
* | |||||
* @return | |||||
*/ | |||||
public JsonResult getChildPageList(QueryDeptChildPageListRequest queryDeptChildPageListRequest) { | |||||
log.info("进入查询子部门列表业务"); | |||||
String tenantId = ShiroUtils.getTenantId(); | |||||
String deptId = queryDeptChildPageListRequest.getId(); | |||||
JsonResult result = this.check(tenantId, deptId); | |||||
if (0 != result.getCode()) { | |||||
log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg()); | |||||
return result; | |||||
} | |||||
// 查询所有有效的子部门数据 | |||||
IPage<Dept> page = new Page<>(queryDeptChildPageListRequest.getPage(), queryDeptChildPageListRequest.getLimit()); | |||||
IPage<Dept> pageData = deptMapper.selectPage(page, Wrappers.<Dept>lambdaQuery() | |||||
.eq(Dept::getMark, 1) | |||||
.eq(Dept::getTenantId, tenantId) | |||||
.orderByDesc(Dept::getCreateTime)); | |||||
List<Dept> deptList = pageData.getRecords(); | |||||
List<Dept> list = new ArrayList<>(); | |||||
for (Dept record : deptList) { | |||||
list.add(record); | |||||
} | |||||
pageData.setRecords(list); | |||||
if (CollectionUtil.isEmpty(deptList)) { | |||||
log.info("获取子部门列表为空"); | |||||
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_LIST_IS_NULL.getCode(), QueryDeptChildListCodeEnum.DEPT_LIST_IS_NULL.getMsg()); | |||||
} | |||||
return JsonResult.success(pageData); | |||||
} | |||||
/** | |||||
* 检查参数 | |||||
* @param tenantId | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
private JsonResult check(String tenantId, String id) { | |||||
// 判断id是否为空 | |||||
if (StringUtils.isEmpty(id)) { | |||||
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryDeptChildListCodeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
// 判断部门是否存在 | |||||
Integer count = deptMapper.selectCount(new LambdaQueryWrapper<Dept>() | |||||
.eq(Dept::getTenantId, tenantId) | |||||
.eq(Dept::getId, id) | |||||
.eq(Dept::getMark, 1)); | |||||
if (count <= 0) { | |||||
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryDeptChildListCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||||
} | |||||
return JsonResult.success(); | |||||
} | |||||
} |
import com.tuoheng.admin.conver.DeptConverMapper; | import com.tuoheng.admin.conver.DeptConverMapper; | ||||
import com.tuoheng.admin.dto.RoadSectionDto; | import com.tuoheng.admin.dto.RoadSectionDto; | ||||
import com.tuoheng.admin.entity.*; | import com.tuoheng.admin.entity.*; | ||||
import com.tuoheng.admin.enums.dept.DeptInfoCodeEnum; | |||||
import com.tuoheng.admin.enums.dept.QueryDeptInfoCodeEnum; | |||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
import com.tuoheng.admin.utils.ShiroUtils; | import com.tuoheng.admin.utils.ShiroUtils; | ||||
import com.tuoheng.admin.vo.DeptInfoVo; | import com.tuoheng.admin.vo.DeptInfoVo; | ||||
*/ | */ | ||||
private JsonResult check(String tenantId, String id) { | private JsonResult check(String tenantId, String id) { | ||||
if (StringUtils.isEmpty(id)) { | if (StringUtils.isEmpty(id)) { | ||||
return JsonResult.error(DeptInfoCodeEnum.DEPT_ID_IS_NULL.getCode(), DeptInfoCodeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
return JsonResult.error(QueryDeptInfoCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryDeptInfoCodeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | } | ||||
// 判断部门是否存在 | // 判断部门是否存在 | ||||
.eq(Dept::getId, id) | .eq(Dept::getId, id) | ||||
.eq(Dept::getMark, 1)); | .eq(Dept::getMark, 1)); | ||||
if (null == dept) { | if (null == dept) { | ||||
return JsonResult.error(DeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getCode(), DeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||||
return JsonResult.error(QueryDeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryDeptInfoCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||||
} | } | ||||
return JsonResult.success(dept); | return JsonResult.success(dept); | ||||
} | } |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.tuoheng.admin.conver.DeptConverMapper; | import com.tuoheng.admin.conver.DeptConverMapper; | ||||
import com.tuoheng.admin.entity.Dept; | import com.tuoheng.admin.entity.Dept; | ||||
import com.tuoheng.admin.enums.dept.DeptTreeCodeListEnum; | |||||
import com.tuoheng.admin.enums.dept.QueryDeptTreeListCodeEnum; | |||||
import com.tuoheng.admin.mapper.DeptMapper; | import com.tuoheng.admin.mapper.DeptMapper; | ||||
import com.tuoheng.admin.vo.DeptTreeVo; | import com.tuoheng.admin.vo.DeptTreeVo; | ||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
if (CollectionUtil.isEmpty(deptList)) { | if (CollectionUtil.isEmpty(deptList)) { | ||||
log.info("获取部门列表为空"); | log.info("获取部门列表为空"); | ||||
return JsonResult.error(DeptTreeCodeListEnum.DEPT_LIST_NULL.getCode(), DeptTreeCodeListEnum.DEPT_LIST_NULL.getMsg()); | |||||
return JsonResult.error(QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getCode(), QueryDeptTreeListCodeEnum.DEPT_LIST_IS_NULL.getMsg()); | |||||
} | } | ||||
List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList); | List<DeptTreeVo> deptTreeVoListTmp = DeptConverMapper.INSTANCE.deptListToDeptVoList(deptList); | ||||
deptTreeVoList.add(deptTreeVo); | deptTreeVoList.add(deptTreeVo); | ||||
} else { | } else { | ||||
DeptTreeVo parent = deptVoMap.get(child.getPid()); | DeptTreeVo parent = deptVoMap.get(child.getPid()); | ||||
deptTreeVo.setPName(parent.getName()); | |||||
parent.getChildren().add(child); | parent.getChildren().add(child); | ||||
} | } | ||||
} | } |
import com.tuoheng.admin.mapper.SectionMapper; | import com.tuoheng.admin.mapper.SectionMapper; | ||||
import com.tuoheng.admin.query.RoadInformationQuery; | import com.tuoheng.admin.query.RoadInformationQuery; | ||||
import com.tuoheng.admin.service.RoadInformationService; | import com.tuoheng.admin.service.RoadInformationService; | ||||
import com.tuoheng.admin.service.road.query.QueryRoadListByDeptIdService; | |||||
import com.tuoheng.common.core.common.BaseServiceImpl; | import com.tuoheng.common.core.common.BaseServiceImpl; | ||||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | import com.tuoheng.common.core.enums.ServiceExceptionEnum; | ||||
import com.tuoheng.common.core.utils.DateUtils; | import com.tuoheng.common.core.utils.DateUtils; | ||||
@Autowired | @Autowired | ||||
private SectionMapper sectionMapper; | private SectionMapper sectionMapper; | ||||
@Autowired | |||||
private QueryRoadListByDeptIdService queryRoadListByDeptIdService; | |||||
@Override | @Override | ||||
public JsonResult queryPage(RoadInformationQuery query) { | public JsonResult queryPage(RoadInformationQuery query) { | ||||
if (query.getLimit() == null && query.getPage() == null) { | if (query.getLimit() == null && query.getPage() == null) { | ||||
return JsonResult.success(list); | return JsonResult.success(list); | ||||
} | } | ||||
/** | |||||
* 根据部门id获取该部门下公路列表 | |||||
* @param deptId | |||||
* @return | |||||
*/ | |||||
@Override | |||||
public JsonResult getListByDeptId(String deptId) { | |||||
return queryRoadListByDeptIdService.getRoadList(deptId); | |||||
} | |||||
@Override | @Override | ||||
public JsonResult editInfo(RoadInformation entity) { | public JsonResult editInfo(RoadInformation entity) { | ||||
// User user = (User) ThreadLocalUtil.get(); | // User user = (User) ThreadLocalUtil.get(); |
import com.tuoheng.admin.mapper.SectionMapper; | import com.tuoheng.admin.mapper.SectionMapper; | ||||
import com.tuoheng.admin.query.SectionQuery; | import com.tuoheng.admin.query.SectionQuery; | ||||
import com.tuoheng.admin.service.ISectionService; | import com.tuoheng.admin.service.ISectionService; | ||||
import com.tuoheng.admin.service.section.query.QuerySectionListByDeptIdService; | |||||
import com.tuoheng.admin.vo.SectionInfoVo; | import com.tuoheng.admin.vo.SectionInfoVo; | ||||
import com.tuoheng.common.core.common.BaseServiceImpl; | import com.tuoheng.common.core.common.BaseServiceImpl; | ||||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | import com.tuoheng.common.core.enums.ServiceExceptionEnum; | ||||
@Autowired | @Autowired | ||||
private SectionDeptMapper sectionDeptMapper; | private SectionDeptMapper sectionDeptMapper; | ||||
@Autowired | |||||
private QuerySectionListByDeptIdService querySectionListByDeptIdService; | |||||
@Override | @Override | ||||
public JsonResult queryPage(SectionQuery query) { | public JsonResult queryPage(SectionQuery query) { | ||||
return JsonResult.success(list); | return JsonResult.success(list); | ||||
} | } | ||||
/** | |||||
* 根据部门id获取该部门下路段信息列表 | |||||
* @param deptId | |||||
* @return | |||||
*/ | |||||
@Override | |||||
public JsonResult getListByDeptId(String deptId) { | |||||
return querySectionListByDeptIdService.getRoadList(deptId); | |||||
} | |||||
@Override | @Override | ||||
public JsonResult editInfo(Section entity) { | public JsonResult editInfo(Section entity) { | ||||
// User user = (User) ThreadLocalUtil.get(); | // User user = (User) ThreadLocalUtil.get(); |
package com.tuoheng.admin.service.road.query; | |||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.tuoheng.admin.entity.Dept; | |||||
import com.tuoheng.admin.entity.RoadDept; | |||||
import com.tuoheng.admin.entity.RoadInformation; | |||||
import com.tuoheng.admin.enums.dept.QueryDeptChildListCodeEnum; | |||||
import com.tuoheng.admin.enums.road.QueryRoadListByDeptIdCodeEnum; | |||||
import com.tuoheng.admin.mapper.DeptMapper; | |||||
import com.tuoheng.admin.mapper.RoadDeptMapper; | |||||
import com.tuoheng.admin.mapper.RoadInformationMapper; | |||||
import com.tuoheng.admin.utils.ShiroUtils; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.common.core.utils.StringUtils; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 根据部门Id查询公路列表业务层处理 | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-22 | |||||
*/ | |||||
@Slf4j | |||||
@Service | |||||
public class QueryRoadListByDeptIdService { | |||||
@Autowired | |||||
private DeptMapper deptMapper; | |||||
@Autowired | |||||
private RoadInformationMapper roadInformationMapper; | |||||
@Autowired | |||||
private RoadDeptMapper roadDeptMapper; | |||||
public JsonResult getRoadList(String deptId) { | |||||
log.info("进入根据部门Id查询公路列表业务"); | |||||
String tenantId = ShiroUtils.getTenantId(); | |||||
// 校验 | |||||
JsonResult result = this.check(tenantId, deptId); | |||||
if (0 != result.getCode()) { | |||||
log.info("根据部门Id查询公路列表业务:校验失败:{}", result.getMsg()); | |||||
return result; | |||||
} | |||||
// 获取该部门下公路列表 | |||||
List<RoadInformation> roadInformationList = this.getRoadInformationList(tenantId, deptId); | |||||
if (CollectionUtil.isEmpty(roadInformationList)) { | |||||
log.info("根据部门Id查询公路列表业务:公路信息为空"); | |||||
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.ROAD_LIST_IS_NULL.getCode(), QueryRoadListByDeptIdCodeEnum.ROAD_LIST_IS_NULL.getMsg()); | |||||
} | |||||
return JsonResult.success(roadInformationList); | |||||
} | |||||
/** | |||||
* 检查参数 | |||||
* | |||||
* @param tenantId | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
private JsonResult check(String tenantId, String id) { | |||||
if (StringUtils.isEmpty(id)) { | |||||
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getCode(), QueryRoadListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
// 判断部门是否存在 | |||||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||||
.eq(Dept::getTenantId, tenantId) | |||||
.eq(Dept::getId, id) | |||||
.eq(Dept::getMark, 1)); | |||||
if (null == dept) { | |||||
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QueryRoadListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||||
} | |||||
return JsonResult.success(dept); | |||||
} | |||||
/** | |||||
* 查询该部门下公路信息列表 | |||||
* | |||||
* @param tenantId | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
private List<RoadInformation> getRoadInformationList(String tenantId, String id) { | |||||
List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>() | |||||
.eq(RoadDept::getTenantId, tenantId) | |||||
.eq(RoadDept::getDeptId, id)); | |||||
if (CollectionUtil.isEmpty(roadDeptList)) { | |||||
return null; | |||||
} | |||||
List<String> roadIdList = roadDeptList.stream().map(o -> o.getRoadId()).collect(Collectors.toList()); | |||||
Map<String, Object> map = new HashMap<>(); | |||||
map.put("tenantId", tenantId); | |||||
map.put("roadIdList", roadIdList); | |||||
List<RoadInformation> roadInformationList = roadInformationMapper.getListByMap(map); | |||||
return roadInformationList; | |||||
} | |||||
} |
package com.tuoheng.admin.service.section.query; | |||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.tuoheng.admin.conver.DeptConverMapper; | |||||
import com.tuoheng.admin.dto.RoadSectionDto; | |||||
import com.tuoheng.admin.entity.*; | |||||
import com.tuoheng.admin.enums.road.QueryRoadListByDeptIdCodeEnum; | |||||
import com.tuoheng.admin.enums.section.QuerySectionListByDeptIdCodeEnum; | |||||
import com.tuoheng.admin.mapper.*; | |||||
import com.tuoheng.admin.utils.ShiroUtils; | |||||
import com.tuoheng.admin.vo.DeptInfoVo; | |||||
import com.tuoheng.common.core.utils.JsonResult; | |||||
import com.tuoheng.common.core.utils.StringUtils; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 根据部门Id查询路段列表业务层处理 | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2022-11-22 | |||||
*/ | |||||
@Slf4j | |||||
@Service | |||||
public class QuerySectionListByDeptIdService { | |||||
@Autowired | |||||
private DeptMapper deptMapper; | |||||
@Autowired | |||||
private RoadInformationMapper roadInformationMapper; | |||||
@Autowired | |||||
private SectionMapper sectionMapper; | |||||
@Autowired | |||||
private RoadDeptMapper roadDeptMapper; | |||||
@Autowired | |||||
private SectionDeptMapper sectionDeptMapper; | |||||
public JsonResult getRoadList(String id) { | |||||
log.info("进入根据部门Id查询路段列表业务"); | |||||
String tenantId = ShiroUtils.getTenantId(); | |||||
// 校验 | |||||
JsonResult result = this.check(tenantId, id); | |||||
if (0 != result.getCode()) { | |||||
log.info("根据部门Id查询路段列表业务:校验失败:{}", result.getMsg()); | |||||
return result; | |||||
} | |||||
// 获取该部门下路段列表 | |||||
List<Section> sectionList = this.getSectionList(tenantId, id); | |||||
if (CollectionUtil.isEmpty(sectionList)) { | |||||
log.info("根据部门Id查询路段列表业务:路段信息为空"); | |||||
return JsonResult.error(QuerySectionListByDeptIdCodeEnum.SECTION_LIST_IS_NULL.getCode(), QuerySectionListByDeptIdCodeEnum.SECTION_LIST_IS_NULL.getMsg()); | |||||
} | |||||
return JsonResult.success(sectionList); | |||||
} | |||||
/** | |||||
* 检查参数 | |||||
* | |||||
* @param tenantId | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
private JsonResult check(String tenantId, String id) { | |||||
if (StringUtils.isEmpty(id)) { | |||||
return JsonResult.error(QuerySectionListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getCode(), QuerySectionListByDeptIdCodeEnum.DEPT_ID_IS_NULL.getMsg()); | |||||
} | |||||
// 判断部门是否存在 | |||||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||||
.eq(Dept::getTenantId, tenantId) | |||||
.eq(Dept::getId, id) | |||||
.eq(Dept::getMark, 1)); | |||||
if (null == dept) { | |||||
return JsonResult.error(QuerySectionListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getCode(), QuerySectionListByDeptIdCodeEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||||
} | |||||
return JsonResult.success(dept); | |||||
} | |||||
/** | |||||
* 查询该部门下路段信息列表 | |||||
* | |||||
* @param tenantId | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
private List<Section> getSectionList(String tenantId, String id) { | |||||
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(new LambdaQueryWrapper<SectionDept>() | |||||
.eq(SectionDept::getTenantId, tenantId) | |||||
.eq(SectionDept::getDeptId, id)); | |||||
if (CollectionUtil.isEmpty(sectionDeptList)) { | |||||
return null; | |||||
} | |||||
List<String> sectionIdList = sectionDeptList.stream().map(o -> o.getSectionId()).collect(Collectors.toList()); | |||||
Map<String, Object> map = new HashMap<>(); | |||||
map.put("tenantId", tenantId); | |||||
map.put("sectionIdList", sectionIdList); | |||||
List<Section> sectionList = sectionMapper.getListByMap(map); | |||||
return sectionList; | |||||
} | |||||
} |
*/ | */ | ||||
private String pid; | private String pid; | ||||
/** | |||||
* 上级部门名称 | |||||
*/ | |||||
private String pname; | |||||
/** | /** | ||||
* 子部门 | * 子部门 | ||||
*/ | */ |
id, tenant_id, name, code, fullname, type, pid, sort, note, create_user, create_time, update_user, update_time, mark | id, tenant_id, name, code, fullname, type, pid, sort, note, create_user, create_time, update_user, update_time, mark | ||||
</sql> | </sql> | ||||
<select id="selectAllChildListById" parameterType="String" resultType="java.lang.String"> | |||||
SELECT id | |||||
FROM( | |||||
SELECT @ids AS p_ids, (SELECT @ids := GROUP_CONCAT(id) FROM th_dept WHERE FIND_IN_SET(pid, CONVERT(@ids USING utf8) COLLATE utf8_unicode_ci)) AS c_ids, @l := @l+1 AS LEVEL | |||||
FROM th_dept, (SELECT @ids := #{id}, @l := 0 ) b | |||||
WHERE @ids IS NOT NULL | |||||
) u1 | |||||
JOIN th_dept u2 ON FIND_IN_SET(u2.id, CONVERT(u1.p_ids USING utf8) COLLATE utf8_unicode_ci) | |||||
</select> | |||||
<update id="update" parameterType="com.tuoheng.admin.entity.Dept"> | <update id="update" parameterType="com.tuoheng.admin.entity.Dept"> | ||||
update th_dept | update th_dept | ||||
<trim prefix="SET" suffixOverrides=","> | <trim prefix="SET" suffixOverrides=","> |