weaver-hrm-organization/src/com/engine/organization/service/impl/PostServiceImpl.java

95 lines
3.7 KiB
Java
Raw Normal View History

2022-05-13 10:32:33 +08:00
package com.engine.organization.service.impl;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.engine.core.impl.Service;
2022-05-13 17:10:00 +08:00
import com.engine.organization.entity.TreeData;
2022-05-30 18:40:25 +08:00
import com.engine.organization.entity.postion.dto.PostDTO;
import com.engine.organization.entity.postion.po.PostPO;
2022-05-13 10:32:33 +08:00
import com.engine.organization.mapper.post.PostMapper;
import com.engine.organization.service.PostService;
2022-06-07 12:02:36 +08:00
import com.engine.organization.util.HasRightUtil;
2022-05-13 10:32:33 +08:00
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import weaver.general.StringUtil;
import weaver.general.Util;
import java.util.*;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/13
* @version: 1.0
*/
public class PostServiceImpl extends Service implements PostService {
2022-06-07 12:02:36 +08:00
private static final String RIGHT_NAME = "Post:All";
2022-05-13 10:32:33 +08:00
private PostMapper getPostMapper() {
return MapperProxyFactory.getProxy(PostMapper.class);
}
@Override
public int savePost(PostPO postPO) {
2022-06-07 12:02:36 +08:00
HasRightUtil.hasRight(user, RIGHT_NAME, false);
2022-05-13 10:32:33 +08:00
List<PostPO> list = getPostMapper().listByNo(Util.null2String(postPO.getPostNo()));
OrganizationAssert.isEmpty(list, "编号不允许重复");
2022-06-06 19:19:28 +08:00
return getPostMapper().insertIgnoreNull(PostDTO.convertPO(postPO, user.getUID()));
2022-05-13 10:32:33 +08:00
}
@Override
public int updatePost(PostPO postPO) {
2022-06-07 12:02:36 +08:00
HasRightUtil.hasRight(user, RIGHT_NAME, false);
2022-06-06 19:19:28 +08:00
return getPostMapper().updatePost(PostDTO.convertPO(postPO, user.getUID()));
2022-05-13 10:32:33 +08:00
}
@Override
public int deleteByIds(Collection<Long> ids) {
2022-06-07 12:02:36 +08:00
HasRightUtil.hasRight(user, RIGHT_NAME, false);
2022-05-13 10:32:33 +08:00
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
return getPostMapper().deleteByIds(ids);
}
@Override
public Map<String, Object> getPostForm(Map<String, Object> params) {
2022-06-07 12:02:36 +08:00
HasRightUtil.hasRight(user, RIGHT_NAME, false);
2022-05-13 10:32:33 +08:00
Map<String, Object> apiDatas = new HashMap<>();
List<SearchConditionItem> selectItems = new ArrayList<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
SearchConditionItem postNameItem = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "名称", "postName");
postNameItem.setRules("required|string");
SearchConditionItem postNoItem = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "编号", "postNo");
postNoItem.setRules("required|string");
SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "描述说明", "description");
// 编辑状态下赋值操作
String id = Util.null2String(params.get("id"));
if (!StringUtil.isEmpty(id)) {
PostPO postPO = getPostMapper().getPostByID(Integer.parseInt(id));
OrganizationAssert.notNull(postPO, "选择的数据不存在,或数据已删除");
postNameItem.setValue(postPO.getPostName());
postNoItem.setValue(postPO.getPostNo());
descriptionItem.setValue(postPO.getDescription());
}
selectItems.add(postNoItem);
selectItems.add(postNameItem);
selectItems.add(descriptionItem);
addGroups.add(new SearchConditionGroup("基本信息", true, selectItems));
apiDatas.put("condition", addGroups);
return apiDatas;
}
2022-05-13 17:10:00 +08:00
@Override
public TreeData getTreeData() {
ArrayList<TreeData> treeDataList = getPostMapper().getTreeData();
2022-05-16 11:33:19 +08:00
return TreeData.builder().children(treeDataList).title("全部类型").key("-1").build();
2022-05-13 17:10:00 +08:00
}
2022-06-06 19:19:28 +08:00
2022-06-07 12:02:36 +08:00
2022-05-13 10:32:33 +08:00
}