123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package com.imed.costaccount.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.imed.costaccount.common.exception.CostException;
- import com.imed.costaccount.mapper.CostShareLevelMapper;
- import com.imed.costaccount.model.CostShareLevel;
- import com.imed.costaccount.model.User;
- import com.imed.costaccount.model.dto.CostShareLevelEditDto;
- import com.imed.costaccount.model.dto.CostShareLevelSaveDto;
- import com.imed.costaccount.model.vo.CostShareLevelVO;
- import com.imed.costaccount.service.CostShareLevelService;
- import com.imed.costaccount.utils.BeanUtil;
- import com.imed.costaccount.utils.PageUtils;
- import org.apache.shiro.SecurityUtils;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Propagation;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.StringUtils;
- import java.util.List;
- import java.util.Objects;
- @Service("costShareLevelService")
- public class CostShareLevelServiceImpl extends ServiceImpl<CostShareLevelMapper, CostShareLevel> implements CostShareLevelService {
- /**
- * 分页查询相关分摊层级信息
- *
- * @param page
- * @param pageSize
- * @param name
- * @param hospId
- * @return
- */
- @Override
- public PageUtils queryList(Integer page, Integer pageSize, String name, Integer hospId) {
- Page<CostShareLevel> costShareLevelPage = new Page<>(page, pageSize);
- Page<CostShareLevel> pages = this.page(costShareLevelPage, new QueryWrapper<CostShareLevel>().lambda()
- .eq(!StringUtils.isEmpty(hospId), CostShareLevel::getHospId, hospId)
- .like(!StringUtils.isEmpty(name), CostShareLevel::getShareName, name)
- .orderByDesc(CostShareLevel::getLeverSort));
- List<CostShareLevel> costShareLevelList = pages.getRecords();
- List<CostShareLevelVO> costShareLevelVOList = BeanUtil.convertList(costShareLevelList, CostShareLevelVO.class);
- PageUtils pageUtils = new PageUtils(pages);
- pageUtils.setList(costShareLevelVOList);
- return pageUtils;
- }
- /**
- * 保存
- *
- * @param costShareLevelSaveDto
- */
- @Override
- public void addCostShareLevel(CostShareLevelSaveDto costShareLevelSaveDto) {
- User user = (User) SecurityUtils.getSubject().getPrincipal();
- Integer hospId = user.getHospId();
- CostShareLevel costShareLevel = BeanUtil.convertObj(costShareLevelSaveDto, CostShareLevel.class);
- costShareLevel.setCreateTime(System.currentTimeMillis());
- costShareLevel.setHospId(hospId);
- baseMapper.insert(costShareLevel);
- }
- /**
- * 修改分摊层级数据
- *
- * @param costShareLevelEditDto
- */
- @Override
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
- public void updateByCostShareLevel(CostShareLevelEditDto costShareLevelEditDto) {
- User user = (User) SecurityUtils.getSubject().getPrincipal();
- Integer hospId = user.getHospId();
- Integer id = costShareLevelEditDto.getId();
- CostShareLevel costShareLevel = baseMapper.selectById(id);
- if (Objects.isNull(costShareLevel)){
- throw new CostException("分摊层级数据不存在");
- }
- baseMapper.deleteById(id);
- CostShareLevel costShareLevelRequest = BeanUtil.convertObj(costShareLevelEditDto, CostShareLevel.class);
- costShareLevelRequest.setId(null);
- costShareLevelRequest.setCreateTime(System.currentTimeMillis());
- costShareLevelRequest.setHospId(hospId);
- baseMapper.insert(costShareLevelRequest);
- }
- }
|