diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/VolunteerInfoEntity.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/VolunteerInfoEntity.java index b2d19c13e..0e4ca8176 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/VolunteerInfoEntity.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/entity/VolunteerInfoEntity.java @@ -19,7 +19,7 @@ package com.elink.esua.epdc.entity; import com.baomidou.mybatisplus.annotation.TableName; -import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import com.elink.esua.epdc.commons.mybatis.entity.DeptScope; import lombok.Data; import lombok.EqualsAndHashCode; @@ -33,126 +33,106 @@ import java.util.Date; * @since v1.0.0 2019-12-11 */ @Data -@EqualsAndHashCode(callSuper=false) +@EqualsAndHashCode(callSuper = false) @TableName("epdc_volunteer_info") -public class VolunteerInfoEntity extends BaseEpdcEntity { +public class VolunteerInfoEntity extends DeptScope { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -4777998686764924965L; /** * 用户ID */ - private String userId; + private String userId; /** * 姓名 */ - private String realName; + private String realName; /** * 性别(0-女,1-男) */ - private String sex; + private String sex; /** * 出生日期 */ - private Date birthday; + private Date birthday; /** * 手机号 */ - private String mobile; + private String mobile; /** * 身份证 */ - private String identityNo; + private String identityNo; /** * 爱心时长(单位:分钟) */ - private BigDecimal kindnessTime; + private BigDecimal kindnessTime; /** * 参加活动次数 */ - private Integer participationNum; + private Integer participationNum; /** * 网格ID */ - private Long gridId; - - /** - * 父所有部门ID - */ - private String parentDeptIds; - - /** - * 父所有部门名称 - */ - private String parentDeptNames; - - /** - * 所有部门ID - */ - private String allDeptIds; - - /** - * 所有部门名称 - */ - private String allDeptNames; + private Long gridId; /** * 所属道路 */ - private String road; + private String road; /** * 小区名称 */ - private String villageName; + private String villageName; /** * 住处 */ - private String dwellingPlace; + private String dwellingPlace; /** * 居住地址 */ - private String address; + private String address; /** * 自我介绍 */ - private String introduce; + private String introduce; /** * 志愿者注册时间 */ - private Date registTime; + private Date registTime; /** * 审核状态(0-未审核,1-审核通过,2-审核不通过) */ - private String auditStatus; + private String auditStatus; /** * 审核不通过的原因 */ - private String failureReason; + private String failureReason; /** * 审核时间 */ - private Date auditTime; + private Date auditTime; /** * 审核人 */ - private Long auditor; + private Long auditor; } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java index 1003b243c..7f40fe2e2 100644 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.elink.esua.epdc.async.NewsTask; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.mybatis.utils.DeptEntityUtils; import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.enums.UserTagEnum; @@ -219,28 +220,44 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl insertVolunteerInfo(EpdcCompleteVolunteerInfoFormDTO epdcCompleteVolunteerInfoFormDTO) { + VolunteerInfoEntity volunteerEntity = ConvertUtils.sourceToTarget(epdcCompleteVolunteerInfoFormDTO, VolunteerInfoEntity.class); + // 补全其他字段 volunteerEntity.setRegistTime(new Date());// 注册时间 - volunteerEntity.setAuditStatus("1"); // 审核状态 默认审核通过 - volunteerEntity.setAuditTime(new Date()); // 审核时间 + volunteerEntity.setAuditStatus(NumConstant.ONE_STR); // 审核状态 默认审核通过 + volunteerEntity.setAuditTime(volunteerEntity.getRegistTime()); // 审核时间 String address = volunteerEntity.getRoad() - .concat(StringUtils.isNotBlank(volunteerEntity.getVillageName()) ? volunteerEntity.getVillageName() : "") - .concat(StringUtils.isNotBlank(volunteerEntity.getDwellingPlace()) ? volunteerEntity.getDwellingPlace() : ""); + .concat(StringUtils.isNotBlank(volunteerEntity.getVillageName()) ? volunteerEntity.getVillageName() : StringUtils.EMPTY) + .concat(StringUtils.isNotBlank(volunteerEntity.getDwellingPlace()) ? volunteerEntity.getDwellingPlace() : StringUtils.EMPTY); volunteerEntity.setAddress(address); // 居住地址 // 获取部门信息 - Result dtoResult = adminFeignClient.getParentAndAllDept(volunteerEntity.getGridId() + ""); - ParentAndAllDeptDTO parentAndAllDeptDTO = dtoResult.getData(); - - volunteerEntity.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds()); // 父所有部门ID - volunteerEntity.setParentDeptNames(parentAndAllDeptDTO.getParentDeptNames());// 父所有部门 - volunteerEntity.setAllDeptIds(parentAndAllDeptDTO.getAllDeptIds()); // 所有部门ID - volunteerEntity.setAllDeptNames(parentAndAllDeptDTO.getAllDeptNames()); // 所有部门 + Result dtoResult = adminFeignClient.getParentAndAllDept(String.valueOf(volunteerEntity.getGridId())); + // 机构信息 + DeptEntityUtils.loadDeptInfo( + ConvertUtils.sourceToTarget(dtoResult.getData(), DeptEntityUtils.DeptDto.class), + volunteerEntity + ); + deleteVolunteerByUserId(volunteerEntity.getUserId()); insert(volunteerEntity); - return new Result().ok(1); + return new Result().ok(NumConstant.ONE); + } + + /** + * 清除志愿者认证历史 + * + * @param userId + * @return void + * @author work@yujt.net.cn + * @date 2020/4/3 16:11 + */ + private void deleteVolunteerByUserId(String userId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(UserFieldConsant.USER_ID, userId); + baseDao.delete(wrapper); } /**