55 lines
1.7 KiB
Java
55 lines
1.7 KiB
Java
package com.engine.organization.cmd.scheme;
|
|
|
|
import com.engine.common.biz.AbstractCommonCommand;
|
|
import com.engine.common.entity.BizLogContext;
|
|
import com.engine.core.interceptor.CommandContext;
|
|
import com.engine.organization.entity.scheme.po.SchemePO;
|
|
import com.engine.organization.exception.OrganizationRunTimeException;
|
|
import com.engine.organization.mapper.scheme.SchemeMapper;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.ibatis.session.SqlSession;
|
|
import weaver.conn.mybatis.MyBatisFactory;
|
|
import weaver.general.Util;
|
|
import weaver.hrm.User;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class SchemeSaveCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
public SchemeSaveCmd(Map<String, Object> params, User user) {
|
|
this.user = user;
|
|
this.params = params;
|
|
}
|
|
|
|
@Override
|
|
public BizLogContext getLogContext() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Object> execute(CommandContext commandContext) {
|
|
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
|
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
|
|
try {
|
|
SchemeMapper mapper = sqlSession.getMapper(SchemeMapper.class);
|
|
|
|
List<SchemePO> list = mapper.listByNo(Util.null2String(this.params.get("scheme_no")));
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
throw new OrganizationRunTimeException("编号不允许重复");
|
|
}
|
|
|
|
SchemePO schemePO = SchemePO.convertToPO(params, (long) user.getUID());
|
|
mapper.insertIgnoreNull(schemePO);
|
|
|
|
sqlSession.commit();
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
return apidatas;
|
|
}
|
|
|
|
|
|
}
|