From 179c4d64313c9b7572778da4aaaf6c6584fe457d Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期二, 20 五月 2025 23:48:08 +0800
Subject: [PATCH] 修改文件上传类型限制

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVolunteerMngServiceImpl.java |   73 +++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVolunteerMngServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVolunteerMngServiceImpl.java
index 7b333ab..fed909f 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVolunteerMngServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngVolunteerMngServiceImpl.java
@@ -10,6 +10,7 @@
 import cn.hutool.core.util.IdcardUtil;
 import com.panzhihua.common.model.vos.community.volunteer.ComMngVolunteerErrorExcelVO;
 import com.panzhihua.common.model.vos.community.volunteer.ComMngVolunteerExcelVO;
+import com.panzhihua.common.service.user.UserService;
 import com.panzhihua.common.utlis.StringUtils;
 import com.panzhihua.service_community.dao.ComMngVolunteerOrgTeamMapper;
 import com.panzhihua.service_community.dao.ComMngVolunteerSkillMapper;
@@ -34,6 +35,8 @@
 import com.panzhihua.service_community.model.dos.ComMngVolunteerMngDO;
 import com.panzhihua.service_community.service.ComMngVolunteerMngService;
 
+import static java.util.Objects.nonNull;
+
 /**
  * @program: springcloud_k8s_panzhihuazhihuishequ
  * @description: 志愿者
@@ -48,6 +51,8 @@
     private ComMngVolunteerOrgTeamMapper comMngVolunteerOrgTeamMapper;
     @Resource
     private ComMngVolunteerSkillMapper comMngVolunteerSkillMapper;
+    @Resource
+    private UserService userService;
 
     /**
      * 增加志愿者
@@ -59,8 +64,10 @@
     @Override
     public R addVolunteer(ComMngVolunteerMngVO comMngVolunteerMngVO) {
         String phone = comMngVolunteerMngVO.getPhone();
+        String idCard = comMngVolunteerMngVO.getIdCard();
         Integer integer = comMngVolunteerMngDAO.selectCount(new QueryWrapper<ComMngVolunteerMngDO>().lambda()
-            .eq(ComMngVolunteerMngDO::getPhone, phone).in(ComMngVolunteerMngDO::getState, Arrays.asList(1, 2)));
+                .and(wrapper -> wrapper.eq(ComMngVolunteerMngDO::getPhone, phone).or().eq(ComMngVolunteerMngDO::getIdCard, idCard))
+                .in(ComMngVolunteerMngDO::getState, Arrays.asList(1, 2)));
         if (null != integer && integer.intValue() > 0) {
             return R.fail("请勿重复申请");
         }
@@ -171,12 +178,7 @@
      */
     @Override
     public R detailVolunteerExamine(Long id) {
-        ComMngVolunteerMngDO comMngVolunteerMngDO = comMngVolunteerMngDAO.selectById(id);
-        if (ObjectUtils.isEmpty(comMngVolunteerMngDO)) {
-            return R.fail("审核不存在");
-        }
-        ComMngVolunteerMngVO comMngVolunteerMngVO = new ComMngVolunteerMngVO();
-        BeanUtils.copyProperties(comMngVolunteerMngDO, comMngVolunteerMngVO);
+        ComMngVolunteerMngVO comMngVolunteerMngVO = comMngVolunteerMngDAO.detailVolunteerExamine(id);
         // String phone = comMngVolunteerMngVO.getPhone();
         // comMngVolunteerMngVO.setUserId(comMngVolunteerMngDAO.selectUserIdByPhone(phone));
         return R.ok(comMngVolunteerMngVO);
@@ -294,34 +296,34 @@
             ComMngVolunteerOrgTeam orgVo = comMngVolunteerOrgTeamMapper.selectOne(new QueryWrapper<ComMngVolunteerOrgTeam>().lambda()
                     .eq(ComMngVolunteerOrgTeam::getName,excel.getOrgName()).eq(ComMngVolunteerOrgTeam::getCommunityId,communityId)
                     .eq(ComMngVolunteerOrgTeam::getParentId,0));
-            if(orgVo == null){
-                ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
-                BeanUtils.copyProperties(excel,errorExcelVO);
-                errorExcelVO.setError("该志愿者组织不存在,请先通过后台添加该志愿者组织");
-                errorList.add(errorExcelVO);
-                continue;
-            }
+//            if(orgVo == null){
+//                ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
+//                BeanUtils.copyProperties(excel,errorExcelVO);
+//                errorExcelVO.setError("该志愿者组织不存在,请先通过后台添加该志愿者组织");
+//                errorList.add(errorExcelVO);
+//                continue;
+//            }
             //查询队伍
             ComMngVolunteerOrgTeam teamVo = comMngVolunteerOrgTeamMapper.selectOne(new QueryWrapper<ComMngVolunteerOrgTeam>().lambda()
                     .eq(ComMngVolunteerOrgTeam::getName,excel.getTeamName()).eq(ComMngVolunteerOrgTeam::getCommunityId,communityId)
-                    .eq(ComMngVolunteerOrgTeam::getParentId,orgVo.getId()));
-            if(teamVo == null){
-                ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
-                BeanUtils.copyProperties(excel,errorExcelVO);
-                errorExcelVO.setError("该志愿者队伍不存在,请先通过后台添加该志愿者队伍");
-                errorList.add(errorExcelVO);
-                continue;
-            }
+                    .eq(ComMngVolunteerOrgTeam::getParentId, nonNull(orgVo) ? orgVo.getId() : null));
+//            if(teamVo == null){
+//                ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
+//                BeanUtils.copyProperties(excel,errorExcelVO);
+//                errorExcelVO.setError("该志愿者队伍不存在,请先通过后台添加该志愿者队伍");
+//                errorList.add(errorExcelVO);
+//                continue;
+//            }
             //查询技能
             ComMngVolunteerSkill skillVo = comMngVolunteerSkillMapper.selectOne(new QueryWrapper<ComMngVolunteerSkill>().lambda()
                     .eq(ComMngVolunteerSkill::getName,excel.getSkillName()).eq(ComMngVolunteerSkill::getCommunityId,communityId));
-            if(skillVo == null){
-                ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
-                BeanUtils.copyProperties(excel,errorExcelVO);
-                errorExcelVO.setError("该志愿者技能不存在,请先通过后台添加该志愿者技能");
-                errorList.add(errorExcelVO);
-                continue;
-            }
+//            if(skillVo == null){
+//                ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
+//                BeanUtils.copyProperties(excel,errorExcelVO);
+//                errorExcelVO.setError("该志愿者技能不存在,请先通过后台添加该志愿者技能");
+//                errorList.add(errorExcelVO);
+//                continue;
+//            }
             Date nowDate = new Date();
             ComMngVolunteerMngDO comMngVolunteerMngDO = comMngVolunteerMngDAO.selectOne(new QueryWrapper<ComMngVolunteerMngDO>().lambda()
                     .eq(ComMngVolunteerMngDO::getIdCard,excel.getIdCard()).in(ComMngVolunteerMngDO::getState,1,2));
@@ -329,9 +331,9 @@
                 if(comMngVolunteerMngDO.getState().equals(1)){
                     BeanUtils.copyProperties(excel,comMngVolunteerMngDO);
                     comMngVolunteerMngDO.setState(2);
-                    comMngVolunteerMngDO.setOrgId(orgVo.getId());
-                    comMngVolunteerMngDO.setTeamId(teamVo.getId());
-                    comMngVolunteerMngDO.setSkillId(skillVo.getId());
+                    comMngVolunteerMngDO.setOrgId(nonNull(orgVo) ? orgVo.getId() : null);
+                    comMngVolunteerMngDO.setTeamId(nonNull(teamVo) ? teamVo.getId() : null);
+                    comMngVolunteerMngDO.setSkillId(nonNull(skillVo) ? skillVo.getId() : null);
                     comMngVolunteerMngDAO.updateById(comMngVolunteerMngDO);
                 }else{
                     ComMngVolunteerErrorExcelVO errorExcelVO = new ComMngVolunteerErrorExcelVO();
@@ -344,9 +346,9 @@
                 BeanUtils.copyProperties(excel,comMngVolunteerMngDO);
                 comMngVolunteerMngDO.setCommunityId(communityId);
                 comMngVolunteerMngDO.setState(2);
-                comMngVolunteerMngDO.setOrgId(orgVo.getId());
-                comMngVolunteerMngDO.setTeamId(teamVo.getId());
-                comMngVolunteerMngDO.setSkillId(skillVo.getId());
+                comMngVolunteerMngDO.setOrgId(nonNull(orgVo) ? orgVo.getId() : null);
+                comMngVolunteerMngDO.setTeamId(nonNull(teamVo) ? teamVo.getId() : null);
+                comMngVolunteerMngDO.setSkillId(nonNull(skillVo) ? skillVo.getId() : null);
                 comMngVolunteerMngDO.setCreateAt(nowDate);
                 //查询用户id,如果存在则需要绑定
                 Long volunteerUserId = comMngVolunteerMngDAO.selectUserIdByIdCard(excel.getIdCard());
@@ -354,6 +356,7 @@
                     comMngVolunteerMngDO.setSubmitUserId(volunteerUserId);
                 }
                 comMngVolunteerMngDAO.insert(comMngVolunteerMngDO);
+                userService.putUserIsVolunteer(comMngVolunteerMngDO.getPhone(), 1);
             }
         }
         if(errorList.size() > 0){

--
Gitblit v1.7.1