You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hrm-organization/src/com/engine/organization/service/impl/CodeSettingServiceImpl.java

82 lines
3.2 KiB
Java

3 years ago
package com.engine.organization.service.impl;
3 years ago
import com.engine.common.util.ServiceUtil;
3 years ago
import com.engine.core.impl.Service;
3 years ago
import com.engine.hrm.entity.RuleCodeType;
3 years ago
import com.engine.organization.entity.codesetting.bo.CodeSettingBO;
import com.engine.organization.entity.codesetting.param.CodeSaveParam;
import com.engine.organization.entity.codesetting.po.CodeRuleDetailPO;
import com.engine.organization.entity.codesetting.po.CodeRulePO;
import com.engine.organization.mapper.codesetting.CodeRuleDetailMapper;
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
3 years ago
import com.engine.organization.service.CodeSettingService;
3 years ago
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.MapperProxyFactory;
3 years ago
import com.engine.organization.util.response.ReturnResult;
import weaver.hrm.HrmUserVarify;
3 years ago
import weaver.hrm.User;
3 years ago
import java.util.HashMap;
3 years ago
import java.util.List;
3 years ago
import java.util.Map;
3 years ago
/**
* @Author weaver_cl
* @Description: TODO
* @Date 2022/5/30
* @Version V1.0
**/
public class CodeSettingServiceImpl extends Service implements CodeSettingService {
3 years ago
3 years ago
public CodeSettingService getCodeSettingService(User user) {
return ServiceUtil.getService(CodeSettingServiceImpl.class,user);
}
3 years ago
@Override
public ReturnResult getHasRight(String serialtype) {
boolean hasRight = false;
Map<String, Object> retmap = new HashMap<>();
switch (RuleCodeType.getByValue(serialtype)) {
case SUBCOMPANY:
hasRight = HrmUserVarify.checkUserRight("HrmCodeRuleSubcompany:All", user);
break;
case DEPARTMENT:
hasRight = HrmUserVarify.checkUserRight("HrmCodeRuleDepartment:All", user);
break;
case JOBTITLES:
hasRight = HrmUserVarify.checkUserRight("HrmCodeRuleJobtitles:All", user);
break;
case USER:
hasRight = HrmUserVarify.checkUserRight("HrmCodeRuleUser:All", user);
break;
}
retmap.put("hasRight", hasRight);
return ReturnResult.successed(retmap);
}
3 years ago
@Override
public void saveOrUpdateCodeSetting(CodeSaveParam params) {
OrganizationAssert.notNull(params,"参数不能为空");
Long codeRuleId = getCodeSettingService(user).getCodeRuleId(params.getSerialType());
CodeRulePO codeRulePO = CodeSettingBO.buildCodeRule(params,(long)user.getUID(),codeRuleId);
//1.新增或更新主表
if (codeRulePO != null) {
MapperProxyFactory.getProxy(CodeRuleMapper.class).updateCodeRule(codeRulePO);
}else {
MapperProxyFactory.getProxy(CodeRuleMapper.class).insertCodeRule(codeRulePO);
}
//2.插入明细表
codeRuleId = getCodeSettingService(user).getCodeRuleId(params.getSerialType());
MapperProxyFactory.getProxy(CodeRuleDetailMapper.class).delete(codeRuleId);
List<CodeRuleDetailPO> codeRuleDetailPO = CodeSettingBO.bulidCodeDetailList(params.getCodeSaveDetailParams(),(long)user.getUID(),codeRuleId);
}
@Override
public Long getCodeRuleId(String serialType) {
return MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleId(serialType);
}
3 years ago
}