|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
import com.engine.organization.entity.scheme.po.SchemePO;
|
|
|
|
import com.engine.organization.entity.scheme.vo.SchemeTableVO;
|
|
|
|
import com.engine.organization.exception.OrganizationRunTimeException;
|
|
|
|
import com.engine.organization.mapper.scheme.SchemeMapper;
|
|
|
|
import com.engine.organization.service.SchemeService;
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
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.collections4.CollectionUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.conn.mybatis.MyBatisFactory;
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author weaver_cl
|
|
|
|
* @Description: TODO
|
|
|
|
* @Date 2022/4/27
|
|
|
|
* @Version V1.0
|
|
|
|
**/
|
|
|
|
@WeaIocService
|
|
|
|
public class SchemeServiceImpl extends Service implements SchemeService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> save(Map<String, Object> params) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
|
|
|
SchemeMapper mapper = MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
List<SchemePO> list = mapper.listByNo(Util.null2String(params.get("scheme_no")));
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
throw new OrganizationRunTimeException("编号不允许重复");
|
|
|
|
}
|
|
|
|
OrganizationAssert.notEmpty(list,"");
|
|
|
|
SchemePO schemePO = SchemePO.convertToPO(params, (long) user.getUID());
|
|
|
|
mapper.insertIgnoreNull(schemePO);
|
|
|
|
return apidatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> listPage(Map<String, Object> params) {
|
|
|
|
OrganizationWeaTable<SchemeTableVO> table = new OrganizationWeaTable<>(user, SchemeTableVO.class);
|
|
|
|
|
|
|
|
String sqlWhere = buildSqlWhere(params);
|
|
|
|
table.setSqlwhere(sqlWhere);
|
|
|
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
String tableString = table.getTableString();
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.success();
|
|
|
|
return result.getResultMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询条件
|
|
|
|
*
|
|
|
|
* @param params
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private String buildSqlWhere(Map<String, Object> params) {
|
|
|
|
DBType dbType = DBType.get(new RecordSet().getDBType());
|
|
|
|
String sqlWhere = " where delete_type ='0' ";
|
|
|
|
String name = (String) params.get("name");
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
sqlWhere += " AND scheme_name " + dbType.like(name);
|
|
|
|
}
|
|
|
|
String no = (String) params.get("no");
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
sqlWhere += " AND scheme_no " + dbType.like(no);
|
|
|
|
}
|
|
|
|
return sqlWhere;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|