package com.miniframe.bisiness.system; import java.util.Map; import com.miniframe.core.ExecProcessFlow; import com.miniframe.core.exception.BusinessException; import com.miniframe.core.ext.UtilTools; import com.miniframe.generate.business.system.model.D10031BaseModel; import com.miniframe.mappers.system.dao.CodeOnlyOneMapper; import com.miniframe.model.system.DWay; import com.miniframe.model.system.DWaySQLBuilder; import com.miniframe.model.system.dao.DWayMapper; /** * 基础系统,“预设路径添加修改”逻辑处理(重新生成不覆盖)。 */ public class D10031Service extends D10031BaseModel implements ExecProcessFlow { private static final long serialVersionUID = -7051358269847459502L; /** * 基础系统,“预设路径添加修改”业务核心处理 */ public void transExecute() throws Exception { Integer wid =this.getA_d10031().getWid(); String name =this.getA_d10031().getName(); String code =this.getA_d10031().getCode(); DWayMapper wayMapper = UtilTools.getBean(DWayMapper.class); if(wid==null||wid ==0){ DWaySQLBuilder wsb =new DWaySQLBuilder(); DWaySQLBuilder.Criteria wsc =wsb.createCriteria(); wsc.andCodeEqualTo(code); int count =wayMapper.selectCountByExample(wsb); if(count>0){ throw new BusinessException("EB3100030"); } CodeOnlyOneMapper codedao =UtilTools.getBean(CodeOnlyOneMapper.class); Integer codenum =codedao.getWayCodeNum(code,-1); if(codenum!=0){ throw new BusinessException("EB3100039",new String[]{code}); } DWay way =new DWay(); way.setCode(code); way.setName(name); wayMapper.insertSelective(way); }else{ DWay way =wayMapper.selectByPrimaryKey(wid); if(way==null){ throw new BusinessException("EB3100029"); } CodeOnlyOneMapper codedao =UtilTools.getBean(CodeOnlyOneMapper.class); Integer codenum =codedao.getWayCodeNum(code,wid); if(codenum!=0){ throw new BusinessException("EB3100039",new String[]{code}); } DWaySQLBuilder wsb =new DWaySQLBuilder(); DWaySQLBuilder.Criteria wsc =wsb.createCriteria(); wsc.andCodeEqualTo(code); wsc.andIdNotEqualTo(wid); int count =wayMapper.selectCountByExample(wsb); if(count>0){ throw new BusinessException("EB3100030"); } way.setName(name); way.setCode(code); wayMapper.updateByPrimaryKey(way); } } /** * 基础系统,“预设路径添加修改”业务前处理 */ public void preTransFlow() throws Exception { this.validater(); } /** * 基础系统,“预设路径添加修改”业务后处理 */ public void afterTransFlow() throws Exception { } /** * 基础系统,“预设路径添加修改”逻辑入口处理方法 */ @SuppressWarnings("rawtypes") @Override public Map execute(Map vars) throws Exception { this.setTransMap(vars); preTransFlow();// 执行业务开始的规则检查和校验 transExecute();// 执行核心业务段 afterTransFlow();// 执行核心逻辑完成后的收尾逻辑 return this.getTransMap(); } }