dev:岗位管理代码修改

main
SondonYong 2025-11-03 10:05:18 +08:00
parent b44001b452
commit d35cc35a03
6 changed files with 79 additions and 65 deletions

View File

@ -1,59 +1,59 @@
//package com.zcloud.basic.info.facade;
//
//import cn.hutool.core.bean.BeanUtil;
//import com.alibaba.cola.dto.MultiResponse;
//import com.alibaba.cola.dto.SingleResponse;
//import com.zcloud.basic.info.api.PostServiceI;
//import com.zcloud.basic.info.dto.PostListQry;
//import com.zcloud.basic.info.dto.clientobject.PostCO;
//import com.zcloud.gbscommon.zcloudpost.facade.ZcloudPostFacade;
//import com.zcloud.gbscommon.zcloudpost.request.ZcloudPostQry;
//import com.zcloud.gbscommon.zcloudpost.response.ZcloudPostCO;
//import org.apache.dubbo.config.annotation.DubboService;
//import org.springframework.beans.BeanUtils;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Objects;
//
///**
// * @author SondonYong
// * @description 岗位管理对其他领域dubbo接口实现
// * @date 2025/11/1/周六 15:28
// */
//@DubboService
//public class ZcloudPostFacadeImpl implements ZcloudPostFacade {
//
// @Resource
// private PostServiceI postService;
//
// public SingleResponse<ZcloudPostCO> listByPostId(ZcloudPostQry qry){
// if(Objects.isNull(qry) || Objects.isNull(qry.getPostId())){
// return null;
// }
// SingleResponse<PostCO> postCO = postService.getInfoById(qry.getPostId());
// if(Objects.isNull(postCO) || Objects.isNull(postCO.getData())){
// return null;
// }
//
// ZcloudPostCO zcloudPostCO = new ZcloudPostCO();
// BeanUtils.copyProperties(postCO.getData(), zcloudPostCO);
//
// return SingleResponse.of(zcloudPostCO);
// }
//
// public MultiResponse<ZcloudPostCO> listByPostIds(ZcloudPostQry qry){
//
// PostListQry postListQry = new PostListQry();
// BeanUtils.copyProperties(qry, postListQry);
// MultiResponse<PostCO> list = postService.list(postListQry);
//
// if(Objects.isNull(list) || Objects.isNull(list.getData())){
// return null;
// }
//
// List<ZcloudPostCO> zcloudPostCOList = BeanUtil.copyToList(list.getData(), ZcloudPostCO.class);
//
// return MultiResponse.of(zcloudPostCOList);
// }
//}
package com.zcloud.basic.info.facade;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.basic.info.api.PostServiceI;
import com.zcloud.basic.info.dto.PostListQry;
import com.zcloud.basic.info.dto.clientobject.PostCO;
import com.zcloud.gbscommon.zcloudpost.facade.ZcloudPostFacade;
import com.zcloud.gbscommon.zcloudpost.request.ZcloudPostQry;
import com.zcloud.gbscommon.zcloudpost.response.ZcloudPostCO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* @author SondonYong
* @description dubbo
* @date 2025/11/1/ 15:28
*/
@DubboService
public class ZcloudPostFacadeImpl implements ZcloudPostFacade {
@Resource
private PostServiceI postService;
public SingleResponse<ZcloudPostCO> listByPostId(ZcloudPostQry qry){
if(Objects.isNull(qry) || Objects.isNull(qry.getPostId())){
return null;
}
SingleResponse<PostCO> postCO = postService.getInfoById(qry.getPostId());
if(Objects.isNull(postCO) || Objects.isNull(postCO.getData())){
return null;
}
ZcloudPostCO zcloudPostCO = new ZcloudPostCO();
BeanUtils.copyProperties(postCO.getData(), zcloudPostCO);
return SingleResponse.of(zcloudPostCO);
}
public MultiResponse<ZcloudPostCO> listByPostIds(ZcloudPostQry qry){
PostListQry postListQry = new PostListQry();
BeanUtils.copyProperties(qry, postListQry);
MultiResponse<PostCO> list = postService.list(postListQry);
if(Objects.isNull(list) || Objects.isNull(list.getData())){
return null;
}
List<ZcloudPostCO> zcloudPostCOList = BeanUtil.copyToList(list.getData(), ZcloudPostCO.class);
return MultiResponse.of(zcloudPostCOList);
}
}

View File

@ -45,7 +45,7 @@ public class PostController {
}
@ApiOperation("所有数据")
@GetMapping("/listAll")
@PostMapping("/listAll")
public MultiResponse<PostCO> listAll(@RequestBody PostListQry qry) {
return postService.list(qry);
}

View File

@ -54,11 +54,16 @@ public class PostQueryExe {
}
public MultiResponse<PostCO> execute(PostListQry qry) {
Map<String, Object> params = PageQueryHelper.toHashMap(qry);
// 岗位集合
MultiResponse<PostDO> postMRDO = postRepository.list(qry.getPostIds());
MultiResponse<PostDO> postMRDO = postRepository.list(params);
if(postMRDO == null || CollUtil.isEmpty(postMRDO.getData())) {
return new MultiResponse<>();
}
Long[] postIds = postMRDO.getData().stream().map(PostDO::getId).toArray(Long[]::new);
// 岗位部门集合
List<PostDepartmentDO> postDepartmentDOList = postDepartmentRepository.list(qry.getPostIds());
List<PostDepartmentDO> postDepartmentDOList = postDepartmentRepository.list(postIds);
// Map<岗位id, List<岗位部门对象>>
Map<Long, List<PostDepartmentCO>> postDepartmentMap = new HashMap<>();

View File

@ -26,5 +26,7 @@ public class PostListQry {
// 主键id集合
private Long[] postIds;
// 部门id
private Long departmentId;
}

View File

@ -18,7 +18,7 @@ public interface PostRepository extends BaseRepository<PostDO> {
PageResponse<PostDO> listPage(Map<String, Object> params);
MultiResponse<PostDO> list(Long[] ids);
MultiResponse<PostDO> list(Map<String, Object> params);
SingleResponse<PostDO> getInfoById(Long id);
}

View File

@ -40,9 +40,16 @@ public class PostRepositoryImpl extends BaseRepositoryImpl<PostMapper, PostDO> i
}
@Override
public MultiResponse<PostDO> list(Long[] ids) {
public MultiResponse<PostDO> list(Map<String, Object> params) {
Long[] ids = (Long[])params.get("postIds");
Long departmentId = (Long)params.get("departmentId");
QueryWrapper<PostDO> queryWrapper = new QueryWrapper<>();
if(ids != null && ids.length > 0) {
queryWrapper.in("id", ids);
}
if(departmentId != null && departmentId > 0) {
queryWrapper.eq("department_id", departmentId);
}
queryWrapper.orderByDesc("create_time");
List<PostDO> postDOS = postMapper.selectList(queryWrapper);
return MultiResponse.of(postDOS);