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

91 lines
3.3 KiB
Java
Raw Normal View History

2022-06-14 09:36:47 +08:00
package com.engine.organization.service.impl;
2022-06-14 17:57:41 +08:00
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
2022-06-14 09:36:47 +08:00
import com.engine.core.impl.Service;
2022-06-14 16:10:26 +08:00
import com.engine.organization.entity.extend.bo.ExtendGroupBO;
import com.engine.organization.entity.extend.po.ExtendGroupPO;
2022-06-14 17:57:41 +08:00
import com.engine.organization.entity.extend.po.ExtendTitlePO;
2022-06-14 16:10:26 +08:00
import com.engine.organization.entity.fieldset.vo.TypeTreeVO;
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.mapper.extend.ExtendGroupMapper;
2022-06-14 17:57:41 +08:00
import com.engine.organization.mapper.extend.ExtendInfoMapper;
import com.engine.organization.mapper.extend.ExtendTitleMapper;
2022-06-14 09:36:47 +08:00
import com.engine.organization.service.FieldDefinedService;
2022-06-14 17:57:41 +08:00
import com.engine.organization.util.OrganizationAssert;
2022-06-14 15:29:22 +08:00
import com.engine.organization.util.db.MapperProxyFactory;
2022-06-14 17:57:41 +08:00
import com.weaver.general.Util;
import org.apache.commons.lang.StringUtils;
2022-06-14 09:36:47 +08:00
2022-06-14 17:57:41 +08:00
import java.util.ArrayList;
import java.util.HashMap;
2022-06-14 09:36:47 +08:00
import java.util.List;
2022-06-14 17:57:41 +08:00
import java.util.Map;
2022-06-14 09:36:47 +08:00
/**
* @Author weaver_cl
2022-06-14 11:07:48 +08:00
* @Description:
2022-06-14 09:36:47 +08:00
* @Date 2022/6/13
* @Version V1.0
**/
public class FieldDefinedServiceImpl extends Service implements FieldDefinedService {
2022-06-14 15:29:22 +08:00
private ExtendTitleMapper getExtendTitleMapper() {
return MapperProxyFactory.getProxy(ExtendTitleMapper.class);
}
private ExtendInfoMapper getExtendInfoMapper() {
return MapperProxyFactory.getProxy(ExtendInfoMapper.class);
}
2022-06-14 09:36:47 +08:00
@Override
2022-06-14 16:10:26 +08:00
public List<TypeTreeVO> getTree(ModuleTypeEnum moduleTypeEnum) {
Integer extendType = moduleTypeEnum.getValue();
List<ExtendGroupPO> extendGroupPOS = MapperProxyFactory.getProxy(ExtendGroupMapper.class).listByType(extendType);
return ExtendGroupBO.buildTypeTree(extendGroupPOS);
2022-06-14 09:36:47 +08:00
}
2022-06-14 15:29:22 +08:00
@Override
public Map<String, Object> getTabInfo(String groupType) {
OrganizationAssert.notBlank(groupType, "分组信息有误,请确认");
Map<String, Object> datas = new HashMap<>();
Long groupId = Long.parseLong(groupType);
List<ExtendTitlePO> extendTitleList = getExtendTitleMapper().getTitlesByGroupID(groupId);
List<Map<String, Object>> tabs = new ArrayList<>();
int idx = 1;
for (ExtendTitlePO extendTitle : extendTitleList) {
Map<String, Object> tab = new HashMap<>();
tab.put("tabkey", idx++);
tab.put("title", extendTitle.getTitle());
tab.put("isShow", extendTitle.getIsShow());
tab.put("groupid", extendTitle.getGroupId());
tab.put("viewAttr", extendTitle.getGroupId() < 0 ? 1 : 2);
tab.put("editable", editTable(extendTitle.getId()));
tabs.add(tab);
}
datas.put("status", "1");
datas.put("tabs", tabs);
return datas;
}
@Override
public int saveFields(String data) {
if (StringUtils.isEmpty(data)) {
return 0;
}
JSONObject jsonObject = JSON.parseObject(data);
2022-06-14 17:57:41 +08:00
String groupType = Util.null2String(jsonObject.getString("groupType"));
String groupId = Util.null2String(jsonObject.getString("groupId"));
return 0;
}
2022-06-14 15:29:22 +08:00
/**
* 判断该分组下是否有字段
*
* @param id
* @return
*/
private boolean editTable(Long id) {
return getExtendInfoMapper().countFieldsByGroupId(id) > 0;
}
2022-06-14 09:36:47 +08:00
}