New file |
| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.enums.PopulCultureLevelEnum; |
| | | import com.panzhihua.common.enums.PopulMarriageEnum; |
| | | import com.panzhihua.common.enums.PopulPoliticalOutlookEnum; |
| | | import com.panzhihua.common.enums.PopulRelationEnum; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActWorkGuideClassifyVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationVO; |
| | | import com.panzhihua.common.utlis.AgeUtils; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActWorkGuideClassifyDAO; |
| | | import com.panzhihua.service_community.dao.ComActWorkGuideDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActWorkGuideClassifyDO; |
| | | import com.panzhihua.service_community.model.dos.ComActWorkGuideDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngUserTagDO; |
| | | import com.panzhihua.service_community.service.ComActWorkGuideClassifyService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * title: ComActWorkGuideClassifyServiceImpl 社区》办事指南》分类管理服务实现类 |
| | | * projectName 成都呐喊信息技术有限公司-智慧社区项目 |
| | | * description: 社区》办事指南》分类管理服务实现类 |
| | | * |
| | | * @author txb |
| | | * @date 2021/8/31 14:21 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActWorkGuideClassifyServiceImpl extends ServiceImpl<ComActWorkGuideClassifyDAO, ComActWorkGuideClassifyDO> implements ComActWorkGuideClassifyService { |
| | | |
| | | @Resource |
| | | private ComActWorkGuideClassifyDAO comActWorkGuideClassifyDAO; |
| | | @Resource |
| | | private ComActWorkGuideDAO comActWorkGuideDAO; |
| | | |
| | | @Override |
| | | public R pageWorkGuideClassify(ComActWorkGuideClassifyVO comActWorkGuideClassifyVO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = comActWorkGuideClassifyVO.getPageNum(); |
| | | Long pageSize = comActWorkGuideClassifyVO.getPageSize(); |
| | | if (null == pageNum || 0 == pageNum) { |
| | | pageNum = 1L; |
| | | } |
| | | if (null == pageSize || 0 == pageSize) { |
| | | pageSize = 10L; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | |
| | | IPage<ComActWorkGuideClassifyVO> iPage = comActWorkGuideClassifyDAO.pageWorkGuideClassify(page, comActWorkGuideClassifyVO); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R addWorkGuideClassify(ComActWorkGuideClassifyVO comActWorkGuideClassifyVO) { |
| | | if (null != comActWorkGuideClassifyVO.getId() && comActWorkGuideClassifyVO.getId() != 0) { |
| | | // 修改 |
| | | ComActWorkGuideClassifyDO comActWorkGuideClassifyDO = comActWorkGuideClassifyDAO.selectById(comActWorkGuideClassifyVO.getId()); |
| | | if (null == comActWorkGuideClassifyDO) { |
| | | return R.fail("该办事指南分类不存在"); |
| | | } |
| | | ComActWorkGuideClassifyDO checkCreditCode = comActWorkGuideClassifyDAO.selectOne( |
| | | new QueryWrapper<ComActWorkGuideClassifyDO>().lambda().eq(ComActWorkGuideClassifyDO::getClassifyName, comActWorkGuideClassifyVO.getClassifyName())); |
| | | if (null != checkCreditCode && !comActWorkGuideClassifyDO.getId().equals(checkCreditCode.getId())) { |
| | | return R.fail("该办事指南分类已存在,办事指南分类名称重复"); |
| | | } |
| | | |
| | | BeanUtils.copyProperties(comActWorkGuideClassifyVO, comActWorkGuideClassifyDO); |
| | | int update = comActWorkGuideClassifyDAO.updateById(comActWorkGuideClassifyDO); |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | } else { |
| | | // 新增 |
| | | Integer count = comActWorkGuideClassifyDAO.selectCount( |
| | | new QueryWrapper<ComActWorkGuideClassifyDO>().lambda().eq(ComActWorkGuideClassifyDO::getClassifyName, comActWorkGuideClassifyVO.getClassifyName())); |
| | | if (count > 0) { |
| | | return R.fail("该办事指南分类已存在,办事指南分类名称重复"); |
| | | } |
| | | ComActWorkGuideClassifyDO comActWorkGuideClassifyDO = new ComActWorkGuideClassifyDO(); |
| | | BeanUtils.copyProperties(comActWorkGuideClassifyVO, comActWorkGuideClassifyDO); |
| | | int insert = comActWorkGuideClassifyDAO.insert(comActWorkGuideClassifyDO); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail("添加失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R deleteWorkGuideClassify(Long workGuideClassifyId) { |
| | | // 查询特殊群体人员 |
| | | ComActWorkGuideClassifyDO comActWorkGuideClassifyDO = comActWorkGuideClassifyDAO.selectById(workGuideClassifyId); |
| | | if (comActWorkGuideClassifyDO == null) { |
| | | return R.fail("办事指南分类不存在"); |
| | | } |
| | | |
| | | Integer count = comActWorkGuideDAO.selectCount(new QueryWrapper<ComActWorkGuideDO>() |
| | | .lambda().eq(ComActWorkGuideDO::getClassify,workGuideClassifyId)); |
| | | if(count > 0){ |
| | | return R.fail("该分类下存在办事指南,不可删除"); |
| | | } |
| | | |
| | | int delete = comActWorkGuideClassifyDAO.deleteById(workGuideClassifyId); |
| | | if (delete > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R getWorkGuideClassifyList() { |
| | | List<ComActWorkGuideClassifyDO> comActWorkGuideClassifyDOS = comActWorkGuideClassifyDAO.selectList(null); |
| | | List<ComActWorkGuideClassifyVO> comActWorkGuideClassifyVOList = new ArrayList<>(); |
| | | if (comActWorkGuideClassifyDOS != null && comActWorkGuideClassifyDOS.size() > 0) { |
| | | comActWorkGuideClassifyDOS.forEach(comActWorkGuideClassifyDO -> { |
| | | ComActWorkGuideClassifyVO comActWorkGuideClassifyVO = new ComActWorkGuideClassifyVO(); |
| | | BeanUtils.copyProperties(comActWorkGuideClassifyDO, comActWorkGuideClassifyVO); |
| | | comActWorkGuideClassifyVOList.add(comActWorkGuideClassifyVO); |
| | | }); |
| | | } |
| | | return R.ok(comActWorkGuideClassifyVOList); |
| | | } |
| | | } |