|
|
|
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.param.SchemeSearchParam;
|
|
|
|
import com.engine.organization.entity.scheme.po.SchemePO;
|
|
|
|
import com.engine.organization.entity.scheme.vo.SchemeTableVO;
|
|
|
|
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.lang3.StringUtils;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
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> 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);
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.success();
|
|
|
|
return result.getResultMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> save(SchemeSearchParam param) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
|
|
|
SchemeMapper mapper = MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
List<SchemePO> list = mapper.listByNo(Util.null2String(param.getSchemeNo()));
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
SchemePO schemePO = SchemePO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
mapper.insertIgnoreNull(schemePO);
|
|
|
|
return apidatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> updateScheme(SchemeSearchParam param) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
SchemeMapper mapper = MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
List<SchemePO> list = mapper.listByNo(Util.null2String(param.getSchemeNo()));
|
|
|
|
OrganizationAssert.isEmpty(list, "当前编号已存在");
|
|
|
|
SchemePO schemePO = SchemePO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
mapper.updateScheme(schemePO);
|
|
|
|
return apidatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateForbiddenTagById(Map<String, Object> params) {
|
|
|
|
SchemeMapper mapper = MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
int id = Integer.parseInt((String) params.get("id"));
|
|
|
|
boolean flag = (Boolean) params.get("forbidden_tag");
|
|
|
|
SchemePO schemePO = SchemePO.builder().id(id).forbiddenTag(flag ? 1 : 0).build();
|
|
|
|
mapper.updateForbiddenTagById(schemePO);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void deleteByIds(Collection<Long> ids) {
|
|
|
|
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
|
|
|
SchemeMapper mapper = MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
List<SchemePO> schemePOS = mapper.listSchemesById(ids);
|
|
|
|
OrganizationAssert.notEmpty(schemePOS, "选择的数据不存在,或数据已删除");
|
|
|
|
mapper.deleteByIds(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void deleteScheme(SchemeSearchParam param) {
|
|
|
|
SchemeMapper mapper = MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
SchemePO schemePO = SchemePO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
mapper.deleteScheme(schemePO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询条件
|
|
|
|
*
|
|
|
|
* @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(no)) {
|
|
|
|
sqlWhere += " AND scheme_no " + dbType.like(no);
|
|
|
|
}
|
|
|
|
return sqlWhere;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|