diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 7ec8b301fd..1cd6ba736c 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -84,7 +84,7 @@ public enum EpmetErrorCode { // 爱心互助 居民端 NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"), NON_CERTIFIED_VOLUNTEER(8511, "活动报名失败,请先认证志愿者"), - ACT_TIME_CONFLICT(8512, "活动时间冲突"), + ACT_TIME_CONFLICT(8512, "报名失败。您本次报名活动时间与已报名活动时间间隔较短,为了不影响您已报名的活动,请选择其他时间的活动,谢谢。"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java index bd67a4a69b..b55dd0e392 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActCaculateDistanceFormDTO.java @@ -3,6 +3,7 @@ package com.epmet.dto.form.resi; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -28,13 +29,13 @@ public class ResiActCaculateDistanceFormDTO implements Serializable { /** * 经度 */ - @NotBlank(message = "经度不能为空", groups = { AddUserInternalGroup.class }) + @NotNull(message = "经度不能为空", groups = { AddUserInternalGroup.class }) private Double longitude; /** * 纬度 */ - @NotBlank(message = "纬度不能为空", groups = { AddUserInternalGroup.class }) + @NotNull(message = "纬度不能为空", groups = { AddUserInternalGroup.class }) private Double latitude; /** diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java index 54182f0da3..b6a0b22542 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActInsertLiveFormDTO.java @@ -21,6 +21,7 @@ import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -43,13 +44,6 @@ public class ResiActInsertLiveFormDTO implements Serializable { */ public interface AddUserInternalGroup {} - /** - * 添加用户操作的用户可见异常分组 - * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup - * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 - */ - public interface AddUserShowGroup extends CustomerClientShowGroup {} - // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< /** @@ -66,19 +60,19 @@ public class ResiActInsertLiveFormDTO implements Serializable { /** * 活动签到位置经度 */ - @NotBlank(message = "活动签到位置经度不能为空", groups = { AddUserInternalGroup.class }) + @NotNull(message = "活动签到位置经度不能为空", groups = { AddUserInternalGroup.class }) private BigDecimal longitude; /** * 活动签到位置纬度 */ - @NotBlank(message = "活动签到位置纬度不能为空", groups = { AddUserInternalGroup.class }) + @NotNull(message = "活动签到位置纬度不能为空", groups = { AddUserInternalGroup.class }) private BigDecimal latitude; /** * 活动签到地址 */ - @NotBlank(message = "活动签到地址不能为空", groups = { AddUserInternalGroup.class, AddUserShowGroup.class}) + @NotBlank(message = "活动签到地址不能为空", groups = { AddUserInternalGroup.class}) private String address; /** @@ -99,6 +93,6 @@ public class ResiActInsertLiveFormDTO implements Serializable { /** * 客户id */ - @NotBlank(message = "客户id不能为空", groups = {AddUserShowGroup.class }) + @NotBlank(message = "客户id不能为空", groups = {AddUserInternalGroup.class }) private String customerId; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java index 69c1486c7f..f315a04449 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiActSignInFormDTO.java @@ -20,7 +20,9 @@ package com.epmet.dto.form.resi; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -43,13 +45,6 @@ public class ResiActSignInFormDTO implements Serializable { */ public interface AddUserInternalGroup {} - /** - * 添加用户操作的用户可见异常分组 - * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup - * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 - */ - public interface AddUserShowGroup extends CustomerClientShowGroup {} - // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< /** @@ -66,19 +61,19 @@ public class ResiActSignInFormDTO implements Serializable { /** * 活动签到位置经度 */ - @NotBlank(message = "活动签到位置经度不能为空", groups = { AddUserInternalGroup.class }) + @NotNull(message = "活动签到位置经度不能为空", groups = { AddUserInternalGroup.class }) private BigDecimal longitude; /** * 活动签到位置纬度 */ - @NotBlank(message = "活动签到位置纬度不能为空", groups = { AddUserInternalGroup.class }) + @NotNull(message = "活动签到位置纬度不能为空", groups = { AddUserInternalGroup.class }) private BigDecimal latitude; /** * 活动签到地址 */ - @NotBlank(message = "活动签到地址不能为空", groups = { AddUserInternalGroup.class, AddUserShowGroup.class}) + @NotBlank(message = "活动签到地址不能为空", groups = { AddUserInternalGroup.class}) private String address; /** @@ -89,7 +84,7 @@ public class ResiActSignInFormDTO implements Serializable { /** * 0不同步实况1同步到实况记录 */ - @NotBlank(message = "是否同步到实况记录不能为空", groups = { AddUserInternalGroup.class, AddUserShowGroup.class}) + @Min(0) private Integer syncLive; /** @@ -100,6 +95,6 @@ public class ResiActSignInFormDTO implements Serializable { /** * 客户id */ - @NotBlank(message = "客户id不能为空", groups = {AddUserShowGroup.class }) + @NotBlank(message = "客户id不能为空", groups = {AddUserInternalGroup.class }) private String customerId; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java index 29cde0e42b..f6c61a6815 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java @@ -275,7 +275,7 @@ public class ResiActListController { **/ @PostMapping("insertlive") public Result insertLive(@LoginUser TokenDto tokenDto, @RequestBody ResiActInsertLiveFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, ResiActInsertLiveFormDTO.AddUserInternalGroup.class, ResiActInsertLiveFormDTO.AddUserShowGroup.class); + ValidatorUtils.validateEntity(formDTO, ResiActInsertLiveFormDTO.AddUserInternalGroup.class); Result result = actLiveRecService.insertLive(tokenDto, formDTO); return new Result(); } @@ -290,7 +290,7 @@ public class ResiActListController { **/ @PostMapping("signin") public Result actSignIn(@LoginUser TokenDto tokenDto, @RequestBody ResiActSignInFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, ResiActSignInFormDTO.AddUserInternalGroup.class, ResiActSignInFormDTO.AddUserShowGroup.class); + ValidatorUtils.validateEntity(formDTO, ResiActSignInFormDTO.AddUserInternalGroup.class); return actSignInRecService.actSignIn(tokenDto, formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java index ed5cd03409..ef55f849ab 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActLiveRecServiceImpl.java @@ -18,16 +18,23 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.alibaba.nacos.client.utils.StringUtils; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; import com.epmet.commons.tools.dto.form.mq.eventmsg.ActPointEventMsg; import com.epmet.commons.tools.enums.EventEnum; -import com.epmet.commons.tools.exception.ErrorCode; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.scan.param.ImgScanParamDTO; +import com.epmet.commons.tools.scan.param.ImgTaskDTO; +import com.epmet.commons.tools.scan.param.TextScanParamDTO; +import com.epmet.commons.tools.scan.param.TextTaskDTO; +import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.commons.tools.utils.SendMqMsgUtils; import com.epmet.constant.ActMessageConstant; import com.epmet.dao.ActLivePicDao; @@ -42,15 +49,14 @@ import com.epmet.entity.ActLiveRecEntity; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.ActLiveRecRedis; import com.epmet.service.ActLiveRecService; -import com.epmet.utils.ValidityVerification; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; -import java.util.stream.Collectors; /** * 活动实况记录 @@ -60,7 +66,7 @@ import java.util.stream.Collectors; */ @Service public class ActLiveRecServiceImpl extends BaseServiceImpl implements ActLiveRecService { - private Logger logger = LogManager.getLogger(VolunteerInfoServiceImpl.class); + private Logger logger = LogManager.getLogger(ActLiveRecServiceImpl.class); @Autowired private ActLiveRecRedis actLiveRecRedis; @@ -71,6 +77,13 @@ public class ActLiveRecServiceImpl extends BaseServiceImpl liveRecList(Map map) { if (map.get("actId") == null){ @@ -125,11 +138,8 @@ public class ActLiveRecServiceImpl extends BaseServiceImpl insertLive(TokenDto tokenDto, ResiActInsertLiveFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); - // 文本校验 - ValidityVerification verification = new ValidityVerification(); - verification.textScanVerification(formDTO.getDesc(),"添加实况-文本内容审核失败"); - // 图片校验 - verification.imgScanVerification(formDTO.getImages(),"添加实况-图片审核失败"); + // 文本校验/图片校验 + this.auditActContent(formDTO.getDesc(),formDTO.getImages()); // 存储活动实况记录表 String uuid = UUID.randomUUID().toString().replaceAll("-",""); @@ -153,6 +163,56 @@ public class ActLiveRecServiceImpl extends BaseServiceImpl().ok(uuid); } + /** + * 内容校验 + * + * @param context 文本 + * @param imgList 图片 + * @return void + * @Author zhangyong + * @Date 10:15 2020-07-28 + **/ + private void auditActContent(String context, List imgList) { + //审核活动详情中的内容 + if(StringUtils.isNotBlank(context)){ + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(context); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result contentSyncScanRes = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!contentSyncScanRes.success()) { + logger.error("添加实况接口失败,返参:", JSON.toJSONString(contentSyncScanRes)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!contentSyncScanRes.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + } + } + logger.info("添加实况成功"); + } + if(null!=imgList&&imgList.size()>0){ + //审核活动详情中的图片 + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + imgList.forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + }); + Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); + if (!imgScanResult.success()){ + logger.error("添加实况图片审核接口失败,返参:", JSON.toJSONString(imgScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!imgScanResult.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); + } + } + logger.info("添加实况审核成功"); + } + } + private void grantActPoints(ResiActInsertLiveFormDTO formDTO){ //备注 String remark=String.format(ActMessageConstant.ACT_POINTS_EVENT_VOLUNTEER_LIVE,formDTO.getUserId(),formDTO.getActId()); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java index c874a61640..c2fdd5c71d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActSignInRecServiceImpl.java @@ -17,11 +17,21 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.nacos.client.utils.StringUtils; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.scan.param.ImgScanParamDTO; +import com.epmet.commons.tools.scan.param.ImgTaskDTO; +import com.epmet.commons.tools.scan.param.TextScanParamDTO; +import com.epmet.commons.tools.scan.param.TextTaskDTO; +import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ActConstant; import com.epmet.dao.ActSignInPicDao; import com.epmet.dao.ActSignInRecDao; @@ -35,8 +45,10 @@ import com.epmet.entity.ActSignInRecEntity; import com.epmet.redis.ActSignInRecRedis; import com.epmet.service.ActLiveRecService; import com.epmet.service.ActSignInRecService; -import com.epmet.utils.ValidityVerification; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -64,15 +76,20 @@ public class ActSignInRecServiceImpl extends BaseServiceImpl imgList) { + //审核活动详情中的内容 + if(StringUtils.isNotBlank(context)){ + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(context); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result contentSyncScanRes = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!contentSyncScanRes.success()) { + logger.error("活动签到接口失败,返参:", JSON.toJSONString(contentSyncScanRes)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!contentSyncScanRes.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + } + } + logger.info("活动签到成功"); + } + if(null!=imgList&&imgList.size()>0){ + //审核活动详情中的图片 + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + imgList.forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + }); + Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); + if (!imgScanResult.success()){ + logger.error("活动签到图片审核接口失败,返参:", JSON.toJSONString(imgScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!imgScanResult.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); + } + } + logger.info("活动签到图片审核成功"); + } + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java index 134ac475e2..7aacc0cd0d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java @@ -237,45 +237,19 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO){ signUp = false; - logger.info("活动报名失败,活动时间冲突"); + logger.info("报名失败。您本次报名活动时间与已报名活动时间间隔较短,为了不影响您已报名的活动,请选择其他时间的活动,谢谢。"); throw new RenException(EpmetErrorCode.ACT_TIME_CONFLICT.getCode()); } } else { // 3.第一次报名 - HeartUserInfoEntity entity = new HeartUserInfoEntity(); - entity.setCustomerId(formDTO.getCustomerId()); - entity.setUserId(formDTO.getUserId()); - entity.setVolunteerFlag(volunteerFlag > NumConstant.ZERO); - entity.setKindnessTime(NumConstant.ZERO); - entity.setParticipationNum(NumConstant.ZERO); - entity.setObtainPointNum(NumConstant.ZERO); - heartUserInfoDao.insert(entity); + this.insertHeartUserInfo(formDTO, volunteerFlag); } if (signUp){ // 4.插入活动日志表 - ActUserLogEntity userLogEntity = new ActUserLogEntity(); - userLogEntity.setActId(formDTO.getActId()); - userLogEntity.setUserId(formDTO.getUserId()); - userLogEntity.setOperationType(ActConstant.ACT_USER_LOG_OPER_AUDITING); - actUserLogService.insert(userLogEntity); + this.insertActUserLog(formDTO); } - ActUserRelationEntity entity = new ActUserRelationEntity(); - entity.setActId(formDTO.getActId()); - entity.setUserId(formDTO.getUserId()); - entity.setStatus(ActConstant.ACT_USER_STATUS_AUDITING); - // 审核开关:1报名人员需要人工审核(true) 0不需要(false) - if (actInfoDTO.getAuditSwitch()){ - entity.setPassedType(ActConstant.PASSEDTYPE_MANUAL); - } else { - entity.setPassedType(ActConstant.PASSEDTYPE_AUTO); - entity.setAuditTime(new Date()); - } - Integer operationCount = baseDao.selectCountByActIdAndUserId(formDTO.getActId(), formDTO.getUserId()); - if (operationCount > NumConstant.ZERO){ - // 用户如果不是第一次参加 这次的活动,先删除关系表中的数据,在插入 - baseDao.delSignUpRecord(entity); - } - baseDao.insert(entity); + // 5.插入 用户活动关系表 + this.insertActUserRelation(formDTO, actInfoDTO); } /** @@ -322,4 +296,67 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl NumConstant.ZERO); + entity.setKindnessTime(NumConstant.ZERO); + entity.setParticipationNum(NumConstant.ZERO); + entity.setObtainPointNum(NumConstant.ZERO); + heartUserInfoDao.insert(entity); + } + + /** + * 每次成功报名活动,都需要插入【用户活动关系日志表】 + * @param formDTO + * @return void + * @Author zhangyong + * @Date 09:37 2020-07-28 + **/ + private void insertActUserLog(ResiActRegistrationFormDTO formDTO){ + ActUserLogEntity userLogEntity = new ActUserLogEntity(); + userLogEntity.setActId(formDTO.getActId()); + userLogEntity.setUserId(formDTO.getUserId()); + userLogEntity.setOperationType(ActConstant.ACT_USER_LOG_OPER_AUDITING); + actUserLogService.insert(userLogEntity); + } + + /** + * 活动报名成功,插入【用户活动关系表】,重复报名,先删除后插入 + * + * @param formDTO + * @param actInfoDTO + * @return void + * @Author zhangyong + * @Date 09:41 2020-07-28 + **/ + private void insertActUserRelation(ResiActRegistrationFormDTO formDTO, ActInfoDTO actInfoDTO){ + ActUserRelationEntity entity = new ActUserRelationEntity(); + entity.setActId(formDTO.getActId()); + entity.setUserId(formDTO.getUserId()); + entity.setStatus(ActConstant.ACT_USER_STATUS_AUDITING); + // 审核开关:1报名人员需要人工审核(true) 0不需要(false) + if (actInfoDTO.getAuditSwitch()){ + entity.setPassedType(ActConstant.PASSEDTYPE_MANUAL); + } else { + entity.setPassedType(ActConstant.PASSEDTYPE_AUTO); + entity.setAuditTime(new Date()); + } + Integer operationCount = baseDao.selectCountByActIdAndUserId(formDTO.getActId(), formDTO.getUserId()); + if (operationCount > NumConstant.ZERO){ + // 用户如果不是第一次参加 这次的活动,先删除关系表中的数据,在插入 + baseDao.delSignUpRecord(entity); + } + baseDao.insert(entity); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java deleted file mode 100644 index 4bb60ab49f..0000000000 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/utils/ValidityVerification.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.epmet.utils; - -import com.alibaba.nacos.client.utils.StringUtils; -import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.RenException; -import com.epmet.commons.tools.scan.param.ImgScanParamDTO; -import com.epmet.commons.tools.scan.param.ImgTaskDTO; -import com.epmet.commons.tools.scan.param.TextScanParamDTO; -import com.epmet.commons.tools.scan.param.TextTaskDTO; -import com.epmet.commons.tools.scan.result.SyncScanResult; -import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.utils.ScanContentUtils; -import org.springframework.beans.factory.annotation.Value; -import lombok.extern.slf4j.Slf4j; - -import java.util.List; -import java.util.UUID; - -/** - * 文字、图片合法性校验 - * - * @author zhangyong - * @date 2020-07-15 14:26 - */ -@Slf4j -public class ValidityVerification { - - @Value("${openapi.scan.server.url}") - private String scanApiUrl; - @Value("${openapi.scan.method.textSyncScan}") - private String textSyncScanMethod; - @Value("${openapi.scan.method.imgSyncScan}") - private String imgSyncScanMethod; - - /** - * 文本校验 - * @param context 被校验的文本,,不能超过10000 - * @param businessEnum 业务枚举,定义校验失败后,输出的日志信息 - * @return void - * @auther zhangyong - * @Date 14:42 2020-07-15 - **/ - public void textScanVerification(String context, String businessEnum){ - if (StringUtils.isNotBlank(context)) { - TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); - TextTaskDTO taskDTO = new TextTaskDTO(); - taskDTO.setContent(context); - taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); - textScanParamDTO.getTasks().add(taskDTO); - Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); - if (!textSyncScanResult.success()) { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } else { - if (!textSyncScanResult.getData().isAllPass()) { - // 业务枚举:例如:评论话题失败,评论内容为:%s" - log.error(String.format(businessEnum, context)); - throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); - } - } - } - } - - /** - * 图片列表校验 - * @param imgList 被校验的图片列表 - * @param businessEnum 业务枚举,定义校验失败后,输出的日志信息 - * - * @return void - * @auther zhangyong - * @Date 14:42 2020-07-15 - **/ - public void imgScanVerification(List imgList, String businessEnum){ - if (null != imgList && NumConstant.ZERO != imgList.size()){ - ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); - imgList.forEach(url -> { - ImgTaskDTO task = new ImgTaskDTO(); - task.setDataId(UUID.randomUUID().toString().replace("-", "")); - task.setUrl(url); - imgScanParamDTO.getTasks().add(task); - }); - Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); - if (!imgScanResult.success()){ - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } else { - if (!imgScanResult.getData().isAllPass()) { - // 业务枚举:例如:评论话题失败,评论内容为:%s" - log.error(String.format(businessEnum)); - throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); - } - } - } - } -} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index 370150c73d..2c83ec6ded 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -300,7 +300,7 @@ then 'in_progress' end as actCurrentState FROM act_info i - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` != 'refused' AND re.`STATUS` != 'canceled' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' AND i.CUSTOMER_ID = #{customerId} AND i.ACT_STATUS != 'finished' AND i.ACT_STATUS != 'canceled' @@ -403,7 +403,7 @@ IF(aur.SIGN_IN_FLAG = 'signed_in', true , false ) as isSignUp-- 是否已签到(true已签到,false未签到) FROM act_info i - LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID + LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` != 'refused' AND re.`STATUS` != 'canceled' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID LEFT JOIN act_user_relation aur ON aur.ACT_ID = i.ID AND aur.DEL_FLAG = '0' AND aur.USER_ID = #{userId} WHERE i.DEL_FLAG = '0' diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml index 71330a10b8..521f29821d 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/DraftDao.xml @@ -143,8 +143,7 @@ TITLE AS "title", IFNULL(PREVIEW_CONTENT, "") AS "content", UNIX_TIMESTAMP(CREATED_TIME) AS "createdTime", - AUDIT_STATUS, - AUDIT_REASON + STATUS_FLAG AS auditStatus FROM draft WHERE DEL_FLAG = '0' AND (STATUS_FLAG = 'unpublish' OR STATUS_FLAG = 'auditfail')