新增动态返回字段处理
This commit is contained in:
parent
5fbbac4dcc
commit
03039f99a9
@ -47,7 +47,7 @@ public class DynamicRestController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
public Long create(@RequestBody @Validated DynamicContentAddCmd cmd) {
|
public DynamicListCO create(@RequestBody @Validated DynamicContentAddCmd cmd) {
|
||||||
return dynamicService.createDynamic(cmd);
|
return dynamicService.createDynamic(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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.CensorMqMessage;
|
||||||
import com.red.circle.mq.rocket.business.producer.DynamicMqMessage;
|
import com.red.circle.mq.rocket.business.producer.DynamicMqMessage;
|
||||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
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.dto.cmd.dynamic.DynamicContentAddCmd;
|
||||||
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
||||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||||
@ -88,7 +89,7 @@ public class DynamicContentAddCmdExe {
|
|||||||
private final AdministratorService administratorService;
|
private final AdministratorService administratorService;
|
||||||
private final AdministratorAuthService administratorAuthService;
|
private final AdministratorAuthService administratorAuthService;
|
||||||
|
|
||||||
public Long execute(DynamicContentAddCmd cmd) {
|
public DynamicListCO execute(DynamicContentAddCmd cmd) {
|
||||||
|
|
||||||
//校验参数
|
//校验参数
|
||||||
checkParameters(cmd);
|
checkParameters(cmd);
|
||||||
@ -96,16 +97,16 @@ public class DynamicContentAddCmdExe {
|
|||||||
Long contentId = IdWorkerUtils.getId();
|
Long contentId = IdWorkerUtils.getId();
|
||||||
|
|
||||||
//保存动态
|
//保存动态
|
||||||
save(cmd, contentId);
|
DynamicListCO save = save(cmd, contentId);
|
||||||
|
|
||||||
dynamicCacheService.incrUserTodayDynamicCount(cmd.getReqUserId());
|
dynamicCacheService.incrUserTodayDynamicCount(cmd.getReqUserId());
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(cmd.getPictures())) {
|
if (CollectionUtils.isEmpty(cmd.getPictures())) {
|
||||||
return contentId;
|
return save;
|
||||||
}
|
}
|
||||||
sendViolationContentMq(cmd);
|
|
||||||
return contentId;
|
|
||||||
|
|
||||||
|
sendViolationContentMq(cmd);
|
||||||
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendViolationContentMq(DynamicContentAddCmd cmd) {
|
private void sendViolationContentMq(DynamicContentAddCmd cmd) {
|
||||||
@ -213,17 +214,21 @@ public class DynamicContentAddCmdExe {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save(DynamicContentAddCmd cmd, Long contentId) {
|
private DynamicListCO save(DynamicContentAddCmd cmd, Long contentId) {
|
||||||
|
|
||||||
Timestamp timestamp = TimestampUtils.now();
|
Timestamp timestamp = TimestampUtils.now();
|
||||||
|
|
||||||
String regionId = userRegionGateway.getRegionId(cmd.getReqUserId());
|
String regionId = userRegionGateway.getRegionId(cmd.getReqUserId());
|
||||||
|
|
||||||
dynamicContentService.save(
|
DynamicContent dynamicContent = new DynamicContent()
|
||||||
new DynamicContent().setId(contentId).setSysOrigin(cmd.requireReqSysOrigin())
|
.setId(contentId)
|
||||||
.setContent(cmd.getContent()).setDel(Boolean.FALSE).setLocation("")
|
.setSysOrigin(cmd.requireReqSysOrigin())
|
||||||
.setTagId(cmd.getTagId()).setCreateUser(cmd.getReqUserId()).setCreateTime(timestamp)
|
.setContent(cmd.getContent())
|
||||||
.setLanguageType(cmd.getReqLanguage()).setRegion(regionId));
|
.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())) {
|
if (CollectionUtils.isNotEmpty(cmd.getPictures())) {
|
||||||
dynamicPictureService.saveBatch(validFillParamToEntity(cmd, contentId));
|
dynamicPictureService.saveBatch(validFillParamToEntity(cmd, contentId));
|
||||||
@ -236,15 +241,26 @@ public class DynamicContentAddCmdExe {
|
|||||||
dynamicMqMessage.sendDynamic(IdWorkerUtils.getIdStr(),
|
dynamicMqMessage.sendDynamic(IdWorkerUtils.getIdStr(),
|
||||||
new DynamicEvent().setDynamicContentId(contentId).setUserId(cmd.getReqUserId())
|
new DynamicEvent().setDynamicContentId(contentId).setUserId(cmd.getReqUserId())
|
||||||
.setType(DynamicEventTypeEnum.CREATE).setTimestamp(timestamp).setRegion(regionId));
|
.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) {
|
private void checkParameters(DynamicContentAddCmd cmd) {
|
||||||
|
|
||||||
ResponseAssert.isTrue(DynamicErrorCode.CONTENT_IS_NULL,
|
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())) {
|
if (CollectionUtils.isNotEmpty(cmd.getPictures())) {
|
||||||
ResponseAssert.isTrue(DynamicErrorCode.IMAGE_LIMIT_ERROR, cmd.getPictures().size() <= 9);
|
ResponseAssert.isTrue(DynamicErrorCode.IMAGE_LIMIT_ERROR, cmd.getPictures().size() <= 9);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,7 +77,7 @@ public class DynamicServiceImpl implements DynamicService {
|
|||||||
private final DynamicBlacklistDelCmdExe dynamicBlacklistDelCmdExe;
|
private final DynamicBlacklistDelCmdExe dynamicBlacklistDelCmdExe;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createDynamic(DynamicContentAddCmd cmd) {
|
public DynamicListCO createDynamic(DynamicContentAddCmd cmd) {
|
||||||
return dynamicContentAddCmdExe.execute(cmd);
|
return dynamicContentAddCmdExe.execute(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public interface DynamicService {
|
|||||||
/**
|
/**
|
||||||
* 创建动态.
|
* 创建动态.
|
||||||
*/
|
*/
|
||||||
Long createDynamic(DynamicContentAddCmd cmd);
|
DynamicListCO createDynamic(DynamicContentAddCmd cmd);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user