| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package cn.com.goldenwater.dcproj.service.impl.rsfco;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.dao.BisInspRsfcoRgstrBaseInfoDao;
- import cn.com.goldenwater.dcproj.dao.BisInspRsfcoRgstrDao;
- import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstr;
- import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstrBaseInfo;
- import cn.com.goldenwater.dcproj.param.BisInspRsfcoRgstrBaseInfoParam;
- import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrBaseInfoService;
- import cn.com.goldenwater.dcproj.util.CheckUtil;
- import cn.com.goldenwater.dcproj.utils.Builder;
- import org.apache.http.util.TextUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- /**
- * @author lune
- * @date 2021年3月29日
- */
- @Service
- @Transactional(rollbackFor = Exception.class)
- public class BisInspRsfcoRgstrBaseInfoServiceImpl extends AbstractCrudService<BisInspRsfcoRgstrBaseInfo, BisInspRsfcoRgstrBaseInfoParam> implements BisInspRsfcoRgstrBaseInfoService {
- @Autowired
- private BisInspRsfcoRgstrBaseInfoDao bisInspRsfcoRgstrBaseInfoDao;
- @Autowired
- private BisInspRsfcoRgstrDao bisInspRsfcoRgstrDao;
- public BisInspRsfcoRgstrBaseInfoServiceImpl(BisInspRsfcoRgstrBaseInfoDao bisInspRsfcoRgstrBaseInfoDao) {
- super(bisInspRsfcoRgstrBaseInfoDao);
- this.bisInspRsfcoRgstrBaseInfoDao = bisInspRsfcoRgstrBaseInfoDao;
- }
- @Override
- public int insert(BisInspRsfcoRgstrBaseInfo entity) {
- CheckUtil.notEmpty(entity.getRgstrId(), "rgstrId.no");
- BisInspRsfcoRgstrBaseInfo info = getBy(Builder.of(BisInspRsfcoRgstrBaseInfoParam::new)
- .with(BisInspRsfcoRgstrBaseInfoParam::setRgstrId, entity.getRgstrId())
- .build());
- if (info != null) {
- if (null == bisInspRsfcoRgstrBaseInfoDao.get(entity.getId())) {
- return super.insert(entity);
- } else {
- return update(entity);
- }
- }
- return super.insert(entity);
- }
- @Override
- public BisInspRsfcoRgstrBaseInfo getBy(BisInspRsfcoRgstrBaseInfoParam bisInspRsfcoRgstrBaseInfoParam) {
- BisInspRsfcoRgstrBaseInfo info = super.getBy(bisInspRsfcoRgstrBaseInfoParam);
- if (info == null && bisInspRsfcoRgstrBaseInfoParam != null && !TextUtils.isBlank(bisInspRsfcoRgstrBaseInfoParam.getRgstrId())) {
- info = new BisInspRsfcoRgstrBaseInfo();
- BisInspRsfcoRgstr rgstr = bisInspRsfcoRgstrDao.get(bisInspRsfcoRgstrBaseInfoParam.getRgstrId());
- info.setEngScal(rgstr.getEngScal());
- info.setRsName(rgstr.getRsName());
- info.setAdCode(rgstr.getAdCode());
- info.setRgstrId(rgstr.getId());
- info.setLocation(rgstr.getLocation());
- }
- return info;
- }
- }
|