|
|
@@ -2,14 +2,18 @@ package com.usoftchina.saas.document.service.impl;
|
|
|
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
import com.usoftchina.saas.commons.api.MessageLogService;
|
|
|
+import com.usoftchina.saas.commons.dto.ComboDTO;
|
|
|
import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.document.entities.Customerkind;
|
|
|
import com.usoftchina.saas.document.mapper.CustomerkindMapper;
|
|
|
import com.usoftchina.saas.document.service.CustomerkindService;
|
|
|
+import com.usoftchina.saas.exception.BizException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@@ -29,10 +33,18 @@ public class CustomerkindServiceImpl extends CommonBaseServiceImpl<CustomerkindM
|
|
|
public boolean save(Customerkind customerkind){
|
|
|
if(customerkind.getId() == 0){
|
|
|
customerkind.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ customerkind.setCreateTime(new Date());
|
|
|
+ customerkind.setCreatorId(BaseContextHolder.getUserId());
|
|
|
+ //验证名称是否重复
|
|
|
+ validName(customerkind.getCk_name());
|
|
|
customerkindMapper.insertSelective(customerkind);
|
|
|
//记录LOG
|
|
|
messageLogService.save(generateMsgObj(customerkind.getId()));
|
|
|
}else{
|
|
|
+ customerkind.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
+ customerkind.setUpdateTime(new Date());
|
|
|
+ //验证名称是否重复
|
|
|
+ validName(customerkind.getCk_name());
|
|
|
customerkindMapper.updateByPrimaryKeySelective(customerkind);
|
|
|
//记录LOG
|
|
|
messageLogService.update(generateMsgObj(customerkind.getId()));
|
|
|
@@ -64,8 +76,21 @@ public class CustomerkindServiceImpl extends CommonBaseServiceImpl<CustomerkindM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Customerkind> getCombo() {
|
|
|
- List<Customerkind> customerkindList = getMapper().getCombo();
|
|
|
+ public List<ComboDTO> getCombo() {
|
|
|
+ List<ComboDTO> customerkindList = getMapper().getCombo(BaseContextHolder.getCompanyId());
|
|
|
return customerkindList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验
|
|
|
+ * @param name
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean validName(String name){
|
|
|
+ int count = getMapper().selectCountByName(name, BaseContextHolder.getCompanyId());
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.REPEAT_NAME);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|