|
@@ -0,0 +1,128 @@
|
|
|
+package org.dromara.business.matters_list.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.dromara.business.common.service.impl.BaseServiceImpl;
|
|
|
+import org.dromara.business.common.utils.BusinessUtil;
|
|
|
+import org.dromara.business.common.utils.QueryHelpPlus;
|
|
|
+import org.dromara.business.constants.BusinessConstants;
|
|
|
+import org.dromara.business.matters_list.domain.MattersList;
|
|
|
+import org.dromara.business.matters_list.service.MattersListService;
|
|
|
+import org.dromara.business.matters_list.service.dto.MattersListDto;
|
|
|
+import org.dromara.business.matters_list.service.dto.MattersListQueryCriteria;
|
|
|
+import org.dromara.business.matters_list.service.mapper.MattersListMapper;
|
|
|
+import org.dromara.business.domain.PageResult;
|
|
|
+import org.dromara.business.dozer.service.IGenerator;
|
|
|
+import org.dromara.business.enums.ErrorEnums;
|
|
|
+import org.dromara.business.exception.BusinessException;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Matters List Service Implementation
|
|
|
+ * 通报事项清单服务实现类
|
|
|
+ *
|
|
|
+ * @author abai
|
|
|
+ * @date 2025-01-07
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class MattersListServiceImpl extends BaseServiceImpl<MattersListMapper, MattersList> implements MattersListService {
|
|
|
+
|
|
|
+ private final IGenerator generator;
|
|
|
+
|
|
|
+ public MattersListServiceImpl(IGenerator generator) {
|
|
|
+ this.generator = generator;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResult<MattersListDto> queryAll(MattersListQueryCriteria criteria, Pageable pageable) {
|
|
|
+ getPage(pageable);
|
|
|
+ PageInfo<MattersListDto> page = new PageInfo<>(queryAll(criteria));
|
|
|
+ return generator.convertPageInfo(page, MattersListDto.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<MattersListDto> queryAll(MattersListQueryCriteria criteria) {
|
|
|
+ QueryWrapper wrapper = QueryHelpPlus.getPredicate(MattersList.class, criteria);
|
|
|
+ wrapper.orderByDesc("create_time");
|
|
|
+ return baseMapper.selectList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public MattersList saveOrUpdateMattersList(MattersList resources) {
|
|
|
+ // 检查唯一性
|
|
|
+ unique(resources);
|
|
|
+ // 新增或更新
|
|
|
+ if (resources.getId() == null) {
|
|
|
+ // 保存数据
|
|
|
+ save(resources);
|
|
|
+ } else {
|
|
|
+ // 更新数据
|
|
|
+ updateById(resources);
|
|
|
+ }
|
|
|
+ return resources;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MattersListDto getById(Long id) {
|
|
|
+ MattersList entity = baseMapper.selectById(id);
|
|
|
+ return entity != null ? generator.convert(entity, MattersListDto.class) : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void deleteById(Long id) {
|
|
|
+ baseMapper.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void deleteByIds(List<Long> ids) {
|
|
|
+ baseMapper.deleteBatchIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateStatus(Long id, Integer status) {
|
|
|
+ MattersList entity = new MattersList();
|
|
|
+ entity.setId(id);
|
|
|
+ entity.setStatus(status);
|
|
|
+ baseMapper.updateById(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断数据是否唯一
|
|
|
+ */
|
|
|
+ private void unique(MattersList resources) {
|
|
|
+ // 事项编号唯一性检查
|
|
|
+ String matterNo = resources.getMatterNo();
|
|
|
+ if (matterNo != null && !matterNo.trim().isEmpty()) {
|
|
|
+ MattersListDto existing = this.queryByMatterNo(matterNo);
|
|
|
+ if (existing != null) {
|
|
|
+ if (resources.getId() == null || !resources.getId().equals(existing.getId())) {
|
|
|
+ throw new BusinessException(String.format("事项编号%s已存在", matterNo));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public MattersListDto queryByMatterNo(String matterNo) {
|
|
|
+ List<MattersList> mattersList = baseMapper.selectList(new LambdaQueryWrapper<MattersList>()
|
|
|
+ .eq(MattersList::getMatterNo, matterNo));
|
|
|
+ if (CollectionUtils.isNotEmpty(mattersList)) {
|
|
|
+ if (mattersList.size() > 1) {
|
|
|
+ throw new BusinessException(String.format("事项编号%s有多条信息", matterNo));
|
|
|
+ }
|
|
|
+ return generator.convert(mattersList.get(0), MattersListDto.class);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|