Browse Source

临时提交:组信息编辑内容提交

dev_shibei_match
wxz 5 years ago
parent
commit
595c9ca11d
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 14
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/EditGroupFormDTO.java
  3. 20
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  4. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/GroupEditSubmitRecordEntity.java
  5. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java
  6. 96
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -41,6 +41,7 @@ public enum EpmetErrorCode {
MOBILE_GET_CODE_ERROR(8104,"获取验证码失败"),
MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"),
NOT_DEL_GRID(8106,"该网格存在工作人员,不允许删除"),
GROUP_EDIT_ERROR(8107,"组信息编辑失败"),
ORG_IS_NOT_NULL(8107,"党组织关系不能为空"),
CANNOT_DELETE_PARTY_BRANCH(8108,"当前支部存在党员,不允许删除"),

14
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/EditGroupFormDTO.java

@ -14,11 +14,23 @@ public class EditGroupFormDTO {
// 分组详情校验
public interface GroupDetailVG {}
// 提交组编辑校验组
public interface SubmitGroupEditVG {}
/**
* 组id
*/
@NotBlank(message = "组ID不能为空", groups = { GroupDetailVG.class })
@NotBlank(message = "组ID不能为空", groups = { GroupDetailVG.class, SubmitGroupEditVG.class })
private String groupId;
@NotBlank(message = "组头像不能为空", groups = { SubmitGroupEditVG.class })
private String groupHeadPhoto;
@NotBlank(message = "组名称不能为空", groups = { SubmitGroupEditVG.class })
private String groupName;
@NotBlank(message = "组介绍不能为空", groups = { SubmitGroupEditVG.class })
private String groupIntroduction;
}

20
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java

@ -360,11 +360,27 @@ public class ResiGroupController {
return new Result();
}
/**
* 查询组详情
* @param form
* @return
*/
@PostMapping("get-detail")
public Result getGroupDetail(@RequestBody EditGroupFormDTO form){
ValidatorUtils.validateEntity(form, EditGroupFormDTO.GroupDetailVG.class);
resiGroupService.getGroupDetail(form.getGroupId());
GroupDetailResultDTO groupDetail = resiGroupService.getGroupDetail(form.getGroupId());
return new Result().ok(groupDetail);
}
/**
* 提交小组信息编辑
* @param form
* @return
*/
@PostMapping("submit-edit")
public Result submitGroupEdit(@RequestBody EditGroupFormDTO form){
ValidatorUtils.validateEntity(form, EditGroupFormDTO.SubmitGroupEditVG.class);
resiGroupService.submitGroupEdit(form.getGroupId(), form.getGroupName(), form.getGroupHeadPhoto(), form.getGroupIntroduction());
return new Result();
}

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/GroupEditSubmitRecordEntity.java

@ -51,7 +51,7 @@ public class GroupEditSubmitRecordEntity extends BaseEpmetEntity {
/**
* 网格ID
*/
private Integer gridId;
private String gridId;
/**
* 头像

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java

@ -295,4 +295,6 @@ public interface ResiGroupService extends BaseService<ResiGroupEntity> {
List<RecommendedListResultDTO> recommendedList(RecommendedListFormDTO formDTO);
GroupDetailResultDTO getGroupDetail(String groupId);
void submitGroupEdit(String groupId, String groupName, String groupHeadPhoto, String groupIntroduction);
}

96
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

@ -27,9 +27,15 @@ 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.page.PageData;
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.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.constant.ReadFlagConstant;
import com.epmet.dto.form.*;
import com.epmet.dto.result.UserResiInfoResultDTO;
@ -68,6 +74,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
@ -127,6 +134,15 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
@Autowired
private GroupEditSubmitRecordDao groupEditSubmitRecordDao;
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@Value("${openapi.scan.method.textSyncScan}")
private String textSyncScanMethod;
@Value("${openapi.scan.method.imgSyncScan}")
private String imgSyncScanMethod;
@Override
public PageData<ResiGroupDTO> page(Map<String, Object> params) {
IPage<ResiGroupEntity> page = baseDao.selectPage(
@ -980,7 +996,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
public GroupDetailResultDTO getGroupDetail(String groupId) {
GroupDetailResultDTO groupDetail = new GroupDetailResultDTO();
// 组基本信息
// 1.拼装组基本信息
GroupEditSubmitRecordEntity ler = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId);
if (ler != null) {
@ -988,7 +1004,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
groupDetail.setRemark(ler.getRemark());
}
if (GroupAuditStatusConstant.UNDER_AUDITING.equals(ler.getAuditStatus())) {
if (ler != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(ler.getAuditStatus())) {
// 审核中,显示待审核内容
groupDetail.setGroupHeadPhoto(ler.getGroupHeadPhoto());
groupDetail.setGroupName(ler.getGroupName());
@ -1005,7 +1021,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
groupDetail.setGroupIntroduction(resiGroupEntity.getGroupIntroduction());
}
// 编辑次数及其限制
// 2.编辑次数及其限制
groupDetail.setEditNumLimit(GroupLimitConstant.EDIT_NUM_LIMIT_MONTH);
Date now = new Date();
int usedEditNum = groupEditSubmitRecordDao.countEditNum(groupId, DateUtils.getMonthStart(now), DateUtils.getMonthEnd(now));
@ -1026,7 +1042,79 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
}
groupDetail.setEditable(editable);
return groupDetail;
}
@Override
public void submitGroupEdit(String groupId, String groupName, String groupHeadPhoto, String groupIntroduction) {
// 1.判断小组是否存在,判断是否已经在"待审核"状态
ResiGroupEntity group = resiGroupDao.selectById(groupId);
if (group == null) {
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "组信息不存在");
}
GroupEditSubmitRecordEntity lre = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId);
if (lre != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(lre.getAuditStatus())) {
// 在待审核状态,不允许再次提交编辑
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "该组已提交编辑待审核,完成审核前不可再次提交");
}
// 2.内容检查
//scanGroupEditContent(groupName, groupIntroduction, groupHeadPhoto);
// 3.创建编辑提交记录
GroupEditSubmitRecordEntity editRecord = new GroupEditSubmitRecordEntity();
editRecord.setAuditStatus(GroupAuditStatusConstant.UNDER_AUDITING);
editRecord.setCustomerId(group.getCustomerId());
editRecord.setGridId(group.getGridId());
editRecord.setGroupHeadPhoto(groupHeadPhoto);
editRecord.setGroupIntroduction(groupIntroduction);
editRecord.setGroupId(groupId);
editRecord.setGroupName(groupName);
if (groupEditSubmitRecordDao.insert(editRecord) == 0) {
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), EpmetErrorCode.GROUP_EDIT_ERROR.getMsg());
}
}
/**
* 内容检查
* @param groupName
* @param groupIntroduction
* @param groupHeadPhoto
*/
private void scanGroupEditContent(String groupName, String groupIntroduction, String groupHeadPhoto) {
// 文本内容审核
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO();
String content = groupName.concat("-").concat(groupIntroduction);
taskDTO.setContent(content);
textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) {
logger.error("调用内容审核服务审核文本发生错误:{}", textSyncScanResult.getInternalMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg());
}
}
// 图片内容审核
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO();
ImgTaskDTO task = new ImgTaskDTO();
task.setUrl(groupHeadPhoto);
imgScanParamDTO.getTasks().add(task);
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO);
if (!imgScanResult.success()){
logger.error("调用内容审核服务审核图片发生错误:{}", textSyncScanResult.getInternalMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
} else {
if (!textSyncScanResult.getData().isAllPass()) {
throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode(), EpmetErrorCode.IMG_SCAN_FAILED.getMsg());
}
}
}
}

Loading…
Cancel
Save