|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
import com.engine.organization.entity.scheme.dto.LevelDTO;
|
|
|
|
import com.engine.organization.entity.scheme.param.LevelSearchParam;
|
|
|
|
import com.engine.organization.entity.scheme.po.LevelPO;
|
|
|
|
import com.engine.organization.entity.scheme.vo.LevelTableVO;
|
|
|
|
import com.engine.organization.mapper.scheme.LevelMapper;
|
|
|
|
import com.engine.organization.service.LevelService;
|
|
|
|
import com.engine.organization.util.MenuBtn;
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
import com.engine.organization.util.OrganizationFormItemUtil;
|
|
|
|
import com.engine.organization.util.db.DBType;
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocService;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description: TODO
|
|
|
|
* @author:dxfeng
|
|
|
|
* @createTime: 2022/05/10
|
|
|
|
* @version: 1.0
|
|
|
|
*/
|
|
|
|
@WeaIocService
|
|
|
|
public class LevelServiceImpl extends Service implements LevelService {
|
|
|
|
|
|
|
|
private LevelMapper getLevelMapper() {
|
|
|
|
return MapperProxyFactory.getProxy(LevelMapper.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> listPage(Map<String, Object> params) {
|
|
|
|
OrganizationWeaTable<LevelTableVO> table = new OrganizationWeaTable<>(user, LevelTableVO.class);
|
|
|
|
String sqlWhere = buildSqlWhere(params);
|
|
|
|
table.setSqlwhere(sqlWhere);
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.success();
|
|
|
|
return result.getResultMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int saveLevel(LevelSearchParam param) {
|
|
|
|
List<LevelPO> list = getLevelMapper().listByNo(Util.null2String(param.getLevelNo()));
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
LevelPO levelPO = LevelDTO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
System.out.println(levelPO);
|
|
|
|
return getLevelMapper().insertIgnoreNull(levelPO);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int updateLevel(LevelSearchParam param) {
|
|
|
|
LevelPO levelPO = LevelDTO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
return getLevelMapper().updateLevel(levelPO);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int updateForbiddenTagById(LevelSearchParam params) {
|
|
|
|
LevelPO levelPO = LevelPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
|
|
|
|
return getLevelMapper().updateForbiddenTagById(levelPO);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int deleteByIds(Collection<Long> ids) {
|
|
|
|
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
|
|
|
return getLevelMapper().deleteByIds(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
SearchConditionItem levelNameCondition = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "levelName");
|
|
|
|
SearchConditionItem levelNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "levelNo");
|
|
|
|
conditionItems.add(levelNameCondition);
|
|
|
|
conditionItems.add(levelNoCondition);
|
|
|
|
addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems));
|
|
|
|
apiDatas.put("conditions", addGroups);
|
|
|
|
return apiDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getLevelForm(Map<String, Object> params) {
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
List<SearchConditionItem> selectItems = new ArrayList<>();
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
SearchConditionItem levelNameCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "名称", "levelName");
|
|
|
|
levelNameCondition.setRules("required|string");
|
|
|
|
SearchConditionItem levelNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "编号", "levelNo");
|
|
|
|
levelNoCondition.setRules("required|string");
|
|
|
|
SearchConditionItem descriptionCondition = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "描述说明", "description");
|
|
|
|
|
|
|
|
// TODO 浏览按钮
|
|
|
|
SearchConditionItem browserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, true, "等级方案", "17", "levelScheme");
|
|
|
|
|
|
|
|
// 编辑状态下赋值操作
|
|
|
|
String id = Util.null2String(params.get("id"));
|
|
|
|
if (!StringUtil.isEmpty(id)) {
|
|
|
|
LevelPO levelPO = getLevelMapper().getLevelByID(Integer.parseInt(id));
|
|
|
|
OrganizationAssert.notNull(levelPO, "选择的数据不存在,或数据已删除");
|
|
|
|
|
|
|
|
levelNameCondition.setValue(levelPO.getLevelName());
|
|
|
|
levelNoCondition.setValue(levelPO.getLevelNo());
|
|
|
|
descriptionCondition.setValue(levelPO.getDescription());
|
|
|
|
// TODO 浏览按钮赋值
|
|
|
|
// 编辑状态下,编号只读
|
|
|
|
levelNoCondition.setViewAttr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
selectItems.add(levelNoCondition);
|
|
|
|
selectItems.add(levelNameCondition);
|
|
|
|
selectItems.add(descriptionCondition);
|
|
|
|
selectItems.add(browserItem);
|
|
|
|
addGroups.add(new SearchConditionGroup("基本信息", true, selectItems));
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
return apiDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getTableBtn() {
|
|
|
|
return MenuBtn.getCommonBtnDatas();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询条件
|
|
|
|
*
|
|
|
|
* @param params
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private String buildSqlWhere(Map<String, Object> params) {
|
|
|
|
DBType dbType = DBType.get(new RecordSet().getDBType());
|
|
|
|
String sqlWhere = " where t.delete_type ='0' ";
|
|
|
|
String name = (String) params.get("levelName");
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
sqlWhere += " AND t.level_name " + dbType.like(name);
|
|
|
|
}
|
|
|
|
String no = (String) params.get("levelNo");
|
|
|
|
if (StringUtils.isNotBlank(no)) {
|
|
|
|
sqlWhere += " AND t.level_no " + dbType.like(no);
|
|
|
|
}
|
|
|
|
return sqlWhere;
|
|
|
|
}
|
|
|
|
}
|