56 lines
1.8 KiB
Java
56 lines
1.8 KiB
Java
package com.engine.salary.cmd.TaxAgent;
|
|
|
|
import com.engine.common.biz.AbstractCommonCommand;
|
|
import com.engine.common.entity.BizLogContext;
|
|
import com.engine.core.interceptor.CommandContext;
|
|
import com.engine.salary.entity.salaryarchive.bo.TaxAgentBO;
|
|
import com.engine.salary.entity.salaryarchive.po.TaxAgentPO;
|
|
import com.engine.salary.entity.taxrate.TaxAgent;
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
|
import com.engine.salary.mapper.TaxAgentMapper;
|
|
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 TaxAgentSaveCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
public TaxAgentSaveCmd(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 {
|
|
TaxAgentMapper mapper = sqlSession.getMapper(TaxAgentMapper.class);
|
|
|
|
List<TaxAgent> list = mapper.listByName(Util.null2String(this.params.get("name")));
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
throw new SalaryRunTimeException("名称不允许重复");
|
|
}
|
|
|
|
TaxAgent taxAgent = TaxAgentBO.convertToPO(params, (long) user.getUID());
|
|
mapper.insert(taxAgent);
|
|
|
|
} finally {
|
|
sqlSession.close();
|
|
}
|
|
return apidatas;
|
|
}
|
|
|
|
|
|
}
|