diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java index ef0daa2d..5bbb397d 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java @@ -47,7 +47,7 @@ public class DynamicRestController extends BaseController { */ @PostMapping("/create") @JsonSerialize(using = ToStringSerializer.class) - public Long create(@RequestBody @Validated DynamicContentAddCmd cmd) { + public DynamicListCO create(@RequestBody @Validated DynamicContentAddCmd cmd) { return dynamicService.createDynamic(cmd); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/add/DynamicContentAddCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/add/DynamicContentAddCmdExe.java index 174f82cc..ce1372dc 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/add/DynamicContentAddCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/add/DynamicContentAddCmdExe.java @@ -18,6 +18,7 @@ import com.red.circle.mq.business.model.event.dynamic.DynamicEvent; import com.red.circle.mq.rocket.business.producer.CensorMqMessage; import com.red.circle.mq.rocket.business.producer.DynamicMqMessage; import com.red.circle.mq.rocket.business.producer.TaskMqMessage; +import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO; import com.red.circle.other.app.dto.cmd.dynamic.DynamicContentAddCmd; import com.red.circle.other.app.enums.violation.ViolationTypeEnum; import com.red.circle.other.domain.gateway.user.UserProfileGateway; @@ -88,7 +89,7 @@ public class DynamicContentAddCmdExe { private final AdministratorService administratorService; private final AdministratorAuthService administratorAuthService; - public Long execute(DynamicContentAddCmd cmd) { + public DynamicListCO execute(DynamicContentAddCmd cmd) { //校验参数 checkParameters(cmd); @@ -96,16 +97,16 @@ public class DynamicContentAddCmdExe { Long contentId = IdWorkerUtils.getId(); //保存动态 - save(cmd, contentId); + DynamicListCO save = save(cmd, contentId); dynamicCacheService.incrUserTodayDynamicCount(cmd.getReqUserId()); if (CollectionUtils.isEmpty(cmd.getPictures())) { - return contentId; + return save; } - sendViolationContentMq(cmd); - return contentId; + sendViolationContentMq(cmd); + return save; } private void sendViolationContentMq(DynamicContentAddCmd cmd) { @@ -213,17 +214,21 @@ public class DynamicContentAddCmdExe { }).toList(); } - private void save(DynamicContentAddCmd cmd, Long contentId) { - + private DynamicListCO save(DynamicContentAddCmd cmd, Long contentId) { Timestamp timestamp = TimestampUtils.now(); - String regionId = userRegionGateway.getRegionId(cmd.getReqUserId()); - dynamicContentService.save( - new DynamicContent().setId(contentId).setSysOrigin(cmd.requireReqSysOrigin()) - .setContent(cmd.getContent()).setDel(Boolean.FALSE).setLocation("") - .setTagId(cmd.getTagId()).setCreateUser(cmd.getReqUserId()).setCreateTime(timestamp) - .setLanguageType(cmd.getReqLanguage()).setRegion(regionId)); + DynamicContent dynamicContent = new DynamicContent() + .setId(contentId) + .setSysOrigin(cmd.requireReqSysOrigin()) + .setContent(cmd.getContent()) + .setDel(Boolean.FALSE).setLocation("") + .setTagId(cmd.getTagId()) + .setCreateUser(cmd.getReqUserId()) + .setCreateTime(timestamp) + .setLanguageType(cmd.getReqLanguage()) + .setRegion(regionId); + dynamicContentService.save(dynamicContent); if (CollectionUtils.isNotEmpty(cmd.getPictures())) { dynamicPictureService.saveBatch(validFillParamToEntity(cmd, contentId)); @@ -236,15 +241,26 @@ public class DynamicContentAddCmdExe { dynamicMqMessage.sendDynamic(IdWorkerUtils.getIdStr(), new DynamicEvent().setDynamicContentId(contentId).setUserId(cmd.getReqUserId()) .setType(DynamicEventTypeEnum.CREATE).setTimestamp(timestamp).setRegion(regionId)); + + return convert(dynamicContent); + } + + private DynamicListCO convert(DynamicContent dynamicContent) { + DynamicListCO listCO = new DynamicListCO(); + listCO.setDynamicId(dynamicContent.getId()); + listCO.setContent(dynamicContent.getContent()); + listCO.setTagId(dynamicContent.getTagId()); + listCO.setCreateTime(dynamicContent.getCreateTime()); + return listCO; } /** * 校验参数 */ private void checkParameters(DynamicContentAddCmd cmd) { - ResponseAssert.isTrue(DynamicErrorCode.CONTENT_IS_NULL, - StringUtils.isNotBlank(cmd.getContent().trim())); + StringUtils.isNotBlank(cmd.getContent().trim()) || CollectionUtils.isNotEmpty(cmd.getPictures())); + if (CollectionUtils.isNotEmpty(cmd.getPictures())) { ResponseAssert.isTrue(DynamicErrorCode.IMAGE_LIMIT_ERROR, cmd.getPictures().size() <= 9); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java index 7888880a..fcffc861 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java @@ -77,7 +77,7 @@ public class DynamicServiceImpl implements DynamicService { private final DynamicBlacklistDelCmdExe dynamicBlacklistDelCmdExe; @Override - public Long createDynamic(DynamicContentAddCmd cmd) { + public DynamicListCO createDynamic(DynamicContentAddCmd cmd) { return dynamicContentAddCmdExe.execute(cmd); } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java index 0980760a..639d3d8a 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java @@ -27,7 +27,7 @@ public interface DynamicService { /** * 创建动态. */ - Long createDynamic(DynamicContentAddCmd cmd); + DynamicListCO createDynamic(DynamicContentAddCmd cmd); /**