职位管理& 区域管理

This commit is contained in:
luolm 2025-02-06 22:43:55 +08:00
parent 66963b748f
commit 13d6882c76
6 changed files with 20 additions and 15 deletions

View File

@ -44,7 +44,6 @@ public class BaseAreaController extends ControllerBase {
* @return
*/
@PostMapping("getList")
@MethodInfoMark(value = "获取区域列表" ,menuName = "区域管理")
public ApiResult<PageData<TBaseAreaVO>> getList(@RequestBody BaseAreaQuery query){
//
return adminBaseAreaService.getList(query);

View File

@ -3,6 +3,7 @@ package com.nflg.mobilebroken.admin.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.mobilebroken.admin.pojo.dto.PositionDetailDTO;
@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -51,7 +53,7 @@ public class PositionController extends ControllerBase {
* @return
*/
@PostMapping("getList")
@MethodInfoMark(value = "获取职位列表", menuName = "职位管理")
public ApiResult<PageData<TBasePosition>> getList(@RequestBody PositionQuery query) {
Page<TBasePosition> result = positionService.getList(new Page<>(query.getPage(), query.getPageSize()), query);
@ -65,16 +67,19 @@ public class PositionController extends ControllerBase {
* @return
*/
@GetMapping("getPositionDetail")
@MethodInfoMark(value = "获取职位明细", menuName = "职位管理")
public ApiResult<PositionDetailVO> getPositionDetail(@RequestParam("id") Integer id) {
TBasePosition ent = positionService.getById(id);
VUtils.trueThrow(null == ent).throwMessage(STATE.ParamErr, "职位不存在");
PositionDetailVO result = Convert.convert(PositionDetailVO.class, ent);
List<Language> allLanguage = languageService.lambdaQuery().eq(Language::getEnable, true).list();
Map<String, String> positionLanguageMp=new HashMap<>();
if(StrUtil.isNotBlank(ent.getPositionLanguage())) {
List<PositionLanguageVO> positionLanguage = JSON.parseArray(ent.getPositionLanguage(), PositionLanguageVO.class);
Map<String, String> positionLanguageMp = positionLanguage.stream()
positionLanguageMp = positionLanguage.stream()
.collect(Collectors.toMap(PositionLanguageVO::getCode, PositionLanguageVO::getLanguageValue));
}
List<PositionLanguageVO> positionLanguageResult = Convert.toList(PositionLanguageVO.class, allLanguage);
for (PositionLanguageVO lan : positionLanguageResult) {
if (positionLanguageMp.containsKey(lan.getCode())) {
@ -119,11 +124,12 @@ public class PositionController extends ControllerBase {
public ApiResult<Boolean> update(@Valid @RequestBody PositionDetailDTO positionDetailDto) {
VUtils.trueThrow(positionDetailDto.getId()<=0).throwMessage(STATE.ParamErr,"编辑时ID不能等于0");
TBasePosition ent = Convert.convert(TBasePosition.class, positionDetailDto);
ent.setPositionCode(null);
ent.setPositionLanguage(JSON.toJSONString(positionDetailDto.getLanguage()));
ent.setDataModifyUserNo(AdminUserUtil.getUserNo());
ent.setDataModifyUserName(AdminUserUtil.getUserName());
ent.setDataModifyTime(LocalDateTime.now());
positionService.save(ent);
positionService.updateById(ent);
return ApiResult.success(true);
}

View File

@ -31,10 +31,10 @@ public class AdminBaseAreaService {
public ApiResult<PageData<TBaseAreaVO>> getList(@RequestBody BaseAreaQuery query){
Page<TBaseAreaVO> result = baseAreaService.getList(new Page<>(query.getPage(),query.getPageSize()), query);
List<TBaseAreaVO> dataResult = Convert.toList(TBaseAreaVO.class, result);
List<TBaseAreaVO> dataResult = Convert.toList(TBaseAreaVO.class, result.getRecords());
if(StrUtil.isNotBlank(query.getAreaCodeOrName())){
List<TBaseAreaVO> allAreaList = Convert.toList(TBaseAreaVO.class,baseAreaService.lambdaQuery().eq(TBaseArea::getAreaState,1).list()) ;
Map<Long, TBaseAreaVO> collect = allAreaList.stream().collect(Collectors.toMap(TBaseAreaVO::getRowId, Function.identity()));
Map<Long, TBaseAreaVO> collect = allAreaList.stream().collect(Collectors.toMap(TBaseAreaVO::getId, Function.identity()));
List<TBaseAreaVO> allParents=new ArrayList<>();
for (TBaseAreaVO data:dataResult){
allParents.addAll(getAllParents(data, collect)) ;
@ -51,7 +51,7 @@ public class AdminBaseAreaService {
}
private void initNodeChildren(TBaseAreaVO node) {
List<TBaseAreaVO> immediateChildren = findChildDepartmentsByParentId(node.getRowId());
List<TBaseAreaVO> immediateChildren = findChildDepartmentsByParentId(node.getId());
node.setChildren(immediateChildren);
for (TBaseAreaVO child : immediateChildren) {
initNodeChildren(child);
@ -85,7 +85,7 @@ public class AdminBaseAreaService {
private List<TBaseAreaVO> buildTree(List<TBaseAreaVO> nodes) {
// 使用Map存储id到Node的映射便于快速查找父节点
Map<Long, TBaseAreaVO> idToNodeMap = nodes.stream()
.collect(Collectors.toMap(TBaseAreaVO::getRowId, Function.identity()));
.collect(Collectors.toMap(TBaseAreaVO::getId, Function.identity()));
List<TBaseAreaVO> roots = new ArrayList<>();

View File

@ -26,7 +26,7 @@ public class TBaseAreaVO implements Serializable {
/**
* row_id
*/
private Long rowId;
private Long id;
/**
* 区域编码
@ -41,7 +41,7 @@ public class TBaseAreaVO implements Serializable {
/**
* 预期名称
*/
private Long areaName;
private String areaName;
/**
* 状态

View File

@ -21,7 +21,7 @@
<update id="delByIds">
update t_base_area set area_state=0 , data_modify_time=now(), data_modify_user_no=#{userNo},
data_modify_user_name=#{userName} where id in
<foreach collection="ids" item="=item" open="(" close=")" separator=",">
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>

View File

@ -4,7 +4,7 @@
<sql id="whr">
<if test="query.positionCode!=null and query.positionCode!=''">
and position_code=#{positionCode}
and position_code=#{query.positionCode}
</if>
<if test="query.positionName!=null and query.positionName!=''">
and position_name=#{query.positionName}