|
|
@@ -3,14 +3,19 @@ package com.usoftchina.saas.document.service.impl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
+import com.usoftchina.saas.commons.api.MessageLogService;
|
|
|
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.document.dto.CurrencyDTO;
|
|
|
import com.usoftchina.saas.document.entities.Currency;
|
|
|
import com.usoftchina.saas.document.mapper.CurrencyMapper;
|
|
|
import com.usoftchina.saas.document.service.CurrencyService;
|
|
|
+import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
@@ -22,14 +27,27 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class CurrencyServiceImpl extends CommonBaseServiceImpl<CurrencyMapper, Currency> implements CurrencyService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MessageLogService messageLogService;
|
|
|
|
|
|
@Override
|
|
|
public void save(CurrencyDTO currencyDTO) {
|
|
|
+ Currency currency = BeanMapper.map(currencyDTO, Currency.class);
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ DocBaseDTO docBaseDTO = null;
|
|
|
if (currencyDTO.getId() == 0){
|
|
|
-
|
|
|
+ currency.setCompanyId(companyId);
|
|
|
+ int count = getMapper().selectCountByName(currency.getCr_name(), companyId);
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.REPEAT_NAME);
|
|
|
+ }
|
|
|
+ getMapper().insertSelective(currency);
|
|
|
+ docBaseDTO = generateMsgObj(currency.getId());
|
|
|
+ messageLogService.save(docBaseDTO);
|
|
|
}else{
|
|
|
- Currency currency = BeanMapper.map(currencyDTO, Currency.class);
|
|
|
getMapper().updateByPrimaryKeySelective(currency);
|
|
|
+ docBaseDTO = generateMsgObj(currency.getId());
|
|
|
+ messageLogService.update(docBaseDTO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -41,4 +59,17 @@ public class CurrencyServiceImpl extends CommonBaseServiceImpl<CurrencyMapper, C
|
|
|
PageInfo<Currency> pageInfo = new PageInfo<Currency>(currencyList);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setStandard(CurrencyDTO currencyDTO) {
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ getMapper().clearStandard(companyId);
|
|
|
+ getMapper().setStandard(currencyDTO.getCr_name(), companyId, currencyDTO.getCr_standard());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private DocBaseDTO generateMsgObj(Long id){
|
|
|
+ return new DocBaseDTO(id, "", "Currency");
|
|
|
+ }
|
|
|
+
|
|
|
}
|