|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.organization.entity.TreeData;
|
|
|
|
import com.engine.organization.entity.post.dto.PostDTO;
|
|
|
|
import com.engine.organization.entity.post.po.PostPO;
|
|
|
|
import com.engine.organization.mapper.post.PostMapper;
|
|
|
|
import com.engine.organization.service.PostService;
|
|
|
|
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 {
|
|
|
|
|
|
|
|
private PostMapper getPostMapper() {
|
|
|
|
return MapperProxyFactory.getProxy(PostMapper.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int savePost(PostPO postPO) {
|
|
|
|
List<PostPO> list = getPostMapper().listByNo(Util.null2String(postPO.getPostNo()));
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
return getPostMapper().insertIgnoreNull(PostDTO.convertPO(postPO,user.getUID()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int updatePost(PostPO postPO) {
|
|
|
|
return getPostMapper().updatePost(PostDTO.convertPO(postPO,user.getUID()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int deleteByIds(Collection<Long> ids) {
|
|
|
|
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
|
|
|
return getPostMapper().deleteByIds(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getPostForm(Map<String, Object> params) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TreeData getTreeData() {
|
|
|
|
ArrayList<TreeData> treeDataList = getPostMapper().getTreeData();
|
|
|
|
return TreeData.builder().children(treeDataList).title("全部类型").key("").build();
|
|
|
|
}
|
|
|
|
}
|