|
|
@@ -0,0 +1,104 @@
|
|
|
+package com.cloud.sa.management.manager;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.cloud.sa.base.common.domain.PageResult;
|
|
|
+import com.cloud.sa.base.common.domain.ResponseDTO;
|
|
|
+import com.cloud.sa.base.common.util.BlinkEntityUtil;
|
|
|
+import com.cloud.sa.base.common.util.BlinkPageUtil;
|
|
|
+import com.cloud.sa.management.domain.dataobject.PostDO;
|
|
|
+import com.cloud.sa.management.domain.dto.PostDTO;
|
|
|
+import com.cloud.sa.management.domain.qry.PostQry;
|
|
|
+import com.cloud.sa.management.objectmapper.PostMapper;
|
|
|
+import com.cloud.sa.management.repository.PostRepository;
|
|
|
+import com.cloud.sa.management.service.IPostService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class PostServiceImpl extends ServiceImpl<PostRepository, PostDO> implements IPostService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PostRepository repository;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PostMapper postMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增岗位
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseDTO<String> supportsPostCreate(PostDTO dto) {
|
|
|
+ // 验证岗位编码是否重复
|
|
|
+ PostDO postDO = repository.queryByPostCode(dto.getPostCode(), null, Boolean.FALSE);
|
|
|
+ if (Objects.nonNull(postDO)) {
|
|
|
+ return ResponseDTO.userErrorParam("岗位已存在!请检查");
|
|
|
+ }
|
|
|
+ PostDO post = new PostDO();
|
|
|
+ postMapper.toPostDO(dto, post);
|
|
|
+ //创建人赋值
|
|
|
+ BlinkEntityUtil.setCreateInfo(post);
|
|
|
+ //执行新增
|
|
|
+ this.save(post);
|
|
|
+ return ResponseDTO.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询岗位列表
|
|
|
+ *
|
|
|
+ * @param qry
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseDTO<PageResult<PostDTO>> supportsPostQueryPage(PostQry qry) {
|
|
|
+ Page<?> page = BlinkPageUtil.convert2PageQuery(qry);
|
|
|
+ List<PostDTO> list = repository.supportsPostQueryPage(page, qry);
|
|
|
+ PageResult<PostDTO> pageResult = BlinkPageUtil.convert2PageResult(page, list);
|
|
|
+ return ResponseDTO.ok(pageResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 岗位信息回显(去修改)
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseDTO<PostDTO> supportsToUpdatePost(Long id) {
|
|
|
+ PostDO postDO = repository.queryByPostCode(null, id, Boolean.FALSE);
|
|
|
+ if (!Objects.nonNull(postDO)) {
|
|
|
+ return ResponseDTO.userErrorParam("岗位不存在!请检查");
|
|
|
+ }
|
|
|
+ PostDTO dto = new PostDTO();
|
|
|
+ postMapper.toPostDTO(postDO, dto);
|
|
|
+ return ResponseDTO.ok(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 岗位信息去修改
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseDTO<String> supportsUpdateFinishPost(PostDTO dto) {
|
|
|
+ // 验证岗位编码是否重复
|
|
|
+ PostDO postDO = repository.queryByPostCode(dto.getPostCode(), dto.getId(), Boolean.FALSE);
|
|
|
+ if (Objects.nonNull(postDO)) {
|
|
|
+ return ResponseDTO.userErrorParam("岗位已存在!请检查");
|
|
|
+ }
|
|
|
+ PostDO post = new PostDO();
|
|
|
+ postMapper.toPostDO(dto, post);
|
|
|
+ //修改人赋值
|
|
|
+ BlinkEntityUtil.setUpdatedInfo(post);
|
|
|
+ //执行修改
|
|
|
+ this.updateById(post);
|
|
|
+ return ResponseDTO.ok();
|
|
|
+ }
|
|
|
+}
|