|
@@ -1,20 +1,29 @@
|
|
package com.zhongzheng.modules.financial.service.impl;
|
|
package com.zhongzheng.modules.financial.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
-import com.zhongzheng.modules.financial.bo.TopCostTpAddBo;
|
|
|
|
-import com.zhongzheng.modules.financial.bo.TopCostTpEditBo;
|
|
|
|
-import com.zhongzheng.modules.financial.bo.TopCostTpQueryBo;
|
|
|
|
|
|
+import com.zhongzheng.modules.course.bo.CourseChapterBusinessAddBo;
|
|
|
|
+import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
|
|
|
|
+import com.zhongzheng.modules.financial.bo.*;
|
|
import com.zhongzheng.modules.financial.domain.TopCostTp;
|
|
import com.zhongzheng.modules.financial.domain.TopCostTp;
|
|
|
|
+import com.zhongzheng.modules.financial.domain.TopCostTpItem;
|
|
import com.zhongzheng.modules.financial.mapper.TopCostTpMapper;
|
|
import com.zhongzheng.modules.financial.mapper.TopCostTpMapper;
|
|
|
|
+import com.zhongzheng.modules.financial.service.ITopCostTpItemService;
|
|
import com.zhongzheng.modules.financial.service.ITopCostTpService;
|
|
import com.zhongzheng.modules.financial.service.ITopCostTpService;
|
|
|
|
+import com.zhongzheng.modules.financial.vo.TopCostTpItemVo;
|
|
import com.zhongzheng.modules.financial.vo.TopCostTpVo;
|
|
import com.zhongzheng.modules.financial.vo.TopCostTpVo;
|
|
|
|
+import com.zhongzheng.modules.sdk.domain.TopNuoMplatformLog;
|
|
|
|
+import com.zhongzheng.modules.sdk.service.NuonuoService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -30,10 +39,18 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp> implements ITopCostTpService {
|
|
public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp> implements ITopCostTpService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCostTpItemService iTopCostTpItemService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public TopCostTpVo queryById(Long tpId){
|
|
public TopCostTpVo queryById(Long tpId){
|
|
TopCostTp db = this.baseMapper.selectById(tpId);
|
|
TopCostTp db = this.baseMapper.selectById(tpId);
|
|
- return BeanUtil.toBean(db, TopCostTpVo.class);
|
|
|
|
|
|
+ TopCostTpItemQueryBo itemQueryBo = new TopCostTpItemQueryBo();
|
|
|
|
+ itemQueryBo.setTpId(db.getTpId());
|
|
|
|
+ List<TopCostTpItemVo> itemList = iTopCostTpItemService.queryList(itemQueryBo);
|
|
|
|
+ TopCostTpVo vo = BeanUtil.toBean(db, TopCostTpVo.class);
|
|
|
|
+ vo.setItemList(itemList);
|
|
|
|
+ return vo;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -41,7 +58,14 @@ public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp
|
|
LambdaQueryWrapper<TopCostTp> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<TopCostTp> lqw = Wrappers.lambdaQuery();
|
|
lqw.like(StrUtil.isNotBlank(bo.getTpName()), TopCostTp::getTpName, bo.getTpName());
|
|
lqw.like(StrUtil.isNotBlank(bo.getTpName()), TopCostTp::getTpName, bo.getTpName());
|
|
lqw.eq(bo.getStatus() != null, TopCostTp::getStatus, bo.getStatus());
|
|
lqw.eq(bo.getStatus() != null, TopCostTp::getStatus, bo.getStatus());
|
|
- return entity2Vo(this.list(lqw));
|
|
|
|
|
|
+ List<TopCostTpVo> list = entity2Vo(this.list(lqw));
|
|
|
|
+ for(TopCostTpVo vo:list){
|
|
|
|
+ TopCostTpItemQueryBo itemQueryBo = new TopCostTpItemQueryBo();
|
|
|
|
+ itemQueryBo.setTpId(vo.getTpId());
|
|
|
|
+ List<TopCostTpItemVo> itemList = iTopCostTpItemService.queryList(itemQueryBo);
|
|
|
|
+ vo.setItemList(itemList);
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -65,19 +89,40 @@ public class TopCostTpServiceImpl extends ServiceImpl<TopCostTpMapper, TopCostTp
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean insertByAddBo(TopCostTpAddBo bo) {
|
|
public Boolean insertByAddBo(TopCostTpAddBo bo) {
|
|
|
|
+ if(Validator.isEmpty(bo.getTpName())){
|
|
|
|
+ throw new CustomException("参数缺少");
|
|
|
|
+ }
|
|
|
|
+ TopCostTp mplatformLog = getOne(new LambdaQueryWrapper<TopCostTp>()
|
|
|
|
+ .eq(TopCostTp::getTpName,bo.getTpName()).ne(TopCostTp::getStatus,-1).last("limit 1"));
|
|
|
|
+ if(Validator.isNotEmpty(mplatformLog)){
|
|
|
|
+ throw new CustomException("该模板名称已存在");
|
|
|
|
+ }
|
|
TopCostTp add = BeanUtil.toBean(bo, TopCostTp.class);
|
|
TopCostTp add = BeanUtil.toBean(bo, TopCostTp.class);
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
- return this.save(add);
|
|
|
|
|
|
+ if(this.save(add)){
|
|
|
|
+ for(TopCostTpItemAddBo itemBo : bo.getItemList()){
|
|
|
|
+ itemBo.setTpId(add.getTpId());
|
|
|
|
+ iTopCostTpItemService.insertByAddBo(itemBo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean updateByEditBo(TopCostTpEditBo bo) {
|
|
public Boolean updateByEditBo(TopCostTpEditBo bo) {
|
|
TopCostTp update = BeanUtil.toBean(bo, TopCostTp.class);
|
|
TopCostTp update = BeanUtil.toBean(bo, TopCostTp.class);
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ iTopCostTpItemService.remove(new LambdaQueryWrapper<TopCostTpItem>().eq(TopCostTpItem::getTpId, bo.getTpId()));
|
|
|
|
+ for(TopCostTpItemAddBo itemBo : bo.getItemList()){
|
|
|
|
+ itemBo.setTpId(bo.getTpId());
|
|
|
|
+ iTopCostTpItemService.insertByAddBo(itemBo);
|
|
|
|
+ }
|
|
return this.updateById(update);
|
|
return this.updateById(update);
|
|
}
|
|
}
|
|
|
|
|