| | |
| | | package com.gkhy.exam.pay.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.exam.pay.dto.req.NonCoalPayCategoryReqDto; |
| | | import com.gkhy.exam.pay.dto.req.NonCoalPayReqDto; |
| | | import com.gkhy.exam.pay.entity.NonCoalPay; |
| | | import com.gkhy.exam.pay.entity.NonCoalPayCategory; |
| | | import com.gkhy.exam.pay.mapper.NonCoalPayMapper; |
| | | import com.gkhy.exam.pay.service.NonCoalPayCategoryService; |
| | | import com.gkhy.exam.pay.service.NonCoalPayService; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | public class NonCoalPayServiceImpl extends ServiceImpl<NonCoalPayMapper, NonCoalPay> implements NonCoalPayService { |
| | | @Resource |
| | | private NonCoalPayMapper nonCoalPayMapper; |
| | | @Resource |
| | | private NonCoalPayCategoryService nonCoalPayCategoryService; |
| | | |
| | | /** |
| | | * 查询【请填写功能名称】 |
| | |
| | | public NonCoalPay selectNonCoalPayById(Long id) { |
| | | return nonCoalPayMapper.selectNonCoalPayById(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询【请填写功能名称】列表 |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertNonCoalPay(NonCoalPay nonCoalPay) { |
| | | nonCoalPay.setCreateTime(DateUtils.getNowDate()); |
| | | return nonCoalPayMapper.insertNonCoalPay(nonCoalPay); |
| | | @Transactional |
| | | public int insertNonCoalPay(NonCoalPayReqDto nonCoalPay) { |
| | | //todo 校验 |
| | | NonCoalPay nonCoalPay1 = new NonCoalPay(); |
| | | BeanUtils.copyProperties(nonCoalPay, nonCoalPay1); |
| | | nonCoalPay1.setCreateBy(SecurityUtils.getUsername()); |
| | | |
| | | int i = nonCoalPayMapper.insertNonCoalPay(nonCoalPay1); |
| | | if (i > 0) { |
| | | saveNonCoalPayCategory(nonCoalPay.getNonCoalPayCategoryList()); |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | private void saveNonCoalPayCategory(List<NonCoalPayCategoryReqDto> nonCoalPayCategoryList) { |
| | | List<NonCoalPayCategory> nonCoalPayCategories = new ArrayList<>(); |
| | | for (NonCoalPayCategoryReqDto nonCoalPayCategory : nonCoalPayCategoryList) { |
| | | NonCoalPayCategory nonCoalPayCategory1 = new NonCoalPayCategory(); |
| | | BeanUtils.copyProperties(nonCoalPayCategory, nonCoalPayCategory1); |
| | | nonCoalPayCategory1.setCreateBy(SecurityUtils.getUsername()); |
| | | nonCoalPayCategories.add(nonCoalPayCategory1); |
| | | } |
| | | nonCoalPayCategoryService.saveBacth(nonCoalPayCategories); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateNonCoalPay(NonCoalPay nonCoalPay) { |
| | | nonCoalPay.setUpdateTime(DateUtils.getNowDate()); |
| | | return nonCoalPayMapper.updateNonCoalPay(nonCoalPay); |
| | | @Transactional |
| | | public int updateNonCoalPay(NonCoalPayReqDto nonCoalPay) { |
| | | //todo 校验 |
| | | NonCoalPay nonCoalPay1 = new NonCoalPay(); |
| | | BeanUtils.copyProperties(nonCoalPay, nonCoalPay1); |
| | | nonCoalPay1.setUpdateBy(SecurityUtils.getUsername()); |
| | | int i = nonCoalPayMapper.updateNonCoalPay(nonCoalPay1); |
| | | if (i > 0) { |
| | | int i1 = nonCoalPayCategoryService.deleteNonCoalPayCategoryByPayId(nonCoalPay.getId()); |
| | | if (i1 < 1) { |
| | | throw new ServiceException("更新失败"); |
| | | } |
| | | saveNonCoalPayCategory(nonCoalPay.getNonCoalPayCategoryList()); |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | /** |