forked from Gitlink/microservices
Merge pull request '完善专区评论功能' (#1116) from otto/microservices:aiResourceMRCS into aiResourceMRCS
This commit is contained in:
commit
6ff1d78b20
|
|
@ -17,6 +17,7 @@ import com.microservices.zone.detail.domain.vo.ZoneBaseDataVo;
|
|||
import com.microservices.zone.detail.domain.vo.ZoneDetailDataVo;
|
||||
import com.microservices.zone.detail.service.IZoneDetailService;
|
||||
import com.microservices.zone.journals.domain.ZoneJournals;
|
||||
import com.microservices.zone.journals.domain.vo.ZoneJournalsDataTableVo;
|
||||
import com.microservices.zone.journals.domain.vo.ZoneJournalsParentDataVo;
|
||||
import com.microservices.zone.journals.domain.vo.ZoneJournalsSearchVo;
|
||||
import com.microservices.zone.member.domain.vo.ZoneMemberDataVo;
|
||||
|
|
@ -480,18 +481,15 @@ public class OpenController extends BaseController {
|
|||
/**
|
||||
* 公开-资源评论列表
|
||||
*/
|
||||
@GetMapping("/ai-square/{resourceId}/journals")
|
||||
@ApiOperation("公开-资源评论列表")
|
||||
@GetMapping("/{journalizedType}/{journalsId}/journals")
|
||||
@ApiOperation("公开-评论列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "Integer")
|
||||
})
|
||||
public GenericsTableDataInfo<ZoneJournalsParentDataVo> journalsList(
|
||||
@ApiParam(name = "resourceId", value = "资源ID", required = true) @PathVariable("resourceId") Long resourceId,
|
||||
ZoneJournalsSearchVo searchVo) {
|
||||
searchVo.setJournalized_id(resourceId);
|
||||
searchVo.setJournalized_type(ZoneJournals.JOURNAL_TYPE_AI_SKILL);
|
||||
public GenericsAjaxResult<ZoneJournalsDataTableVo> journalsList(@Validated ZoneJournalsSearchVo searchVo) {
|
||||
startPage();
|
||||
return new GenericsTableDataInfo<>(zoneJournalsService.selectJournalsList(searchVo));
|
||||
List<ZoneJournalsParentDataVo> list = zoneJournalsService.selectJournalsList(searchVo);
|
||||
return genericsSuccess(ZoneJournalsDataTableVo.toZoneJournalsDataTableVo(getDataTable(list)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ public class ZoneJournals extends BaseEntity implements Serializable {
|
|||
/**
|
||||
* 评论对象类型常量
|
||||
*/
|
||||
public static final String JOURNAL_TYPE_AI_SKILL = "aiSkill";
|
||||
public static final String JOURNAL_TYPE_AI_MODEL = "aiModel";
|
||||
public static final String JOURNAL_TYPE_AI_DATASET = "aiDataset";
|
||||
public static final String JOURNAL_TYPE_ZONE_RESOURCE = "zoneResource";
|
||||
public static final String JOURNAL_TYPE_ZONE_RESOURCE = "resource";
|
||||
|
||||
/** 评论ID */
|
||||
@ApiModelProperty(value = "评论ID")
|
||||
|
|
@ -71,10 +68,6 @@ public class ZoneJournals extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "@用户列表")
|
||||
private String receiversLogin;
|
||||
|
||||
/** 是否隐私评论 */
|
||||
@ApiModelProperty(value = "是否隐私评论")
|
||||
private String privateNotes;
|
||||
|
||||
/** 删除标志 */
|
||||
@ApiModelProperty(value = "删除标志")
|
||||
private String delFlag;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.microservices.zone.journals.domain.vo;
|
||||
|
||||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 评论列表对象
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("评论列表对象")
|
||||
public class ZoneJournalsDataTableVo {
|
||||
@ApiModelProperty(value = "评论列表")
|
||||
private List<?> journals;
|
||||
|
||||
@ApiModelProperty(value = "评论总数量")
|
||||
private Long total_comment_journals_count;
|
||||
|
||||
@ApiModelProperty(value = "当前总数量")
|
||||
private Long total_count;
|
||||
|
||||
@ApiModelProperty(value = "评论+操作总数量")
|
||||
private Long total_journals_count;
|
||||
|
||||
@ApiModelProperty(value = "操作总数量")
|
||||
private Long total_operate_journals_count;
|
||||
|
||||
public static ZoneJournalsDataTableVo toZoneJournalsDataTableVo(TableDataInfo tableDataInfo) {
|
||||
ZoneJournalsDataTableVo target = new ZoneJournalsDataTableVo();
|
||||
target.setJournals(tableDataInfo.getRows());
|
||||
target.setTotal_comment_journals_count(tableDataInfo.getTotal());
|
||||
target.setTotal_count(tableDataInfo.getTotal());
|
||||
target.setTotal_journals_count(tableDataInfo.getTotal());
|
||||
target.setTotal_operate_journals_count(0L);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ public class ZoneJournalsInputVo {
|
|||
private Long journalized_id;
|
||||
|
||||
/** 评论对象类型 */
|
||||
@NotBlank(message = "评论对象类型不能为空")
|
||||
@NotBlank(message = "评论对象类型不能为空(资源:resource)")
|
||||
@ApiModelProperty(value = "评论对象类型", required = true)
|
||||
private String journalized_type;
|
||||
|
||||
|
|
@ -49,8 +49,4 @@ public class ZoneJournalsInputVo {
|
|||
/** 附件标识列表 */
|
||||
@ApiModelProperty(value = "附件标识列表")
|
||||
private String attachment_identifiers;
|
||||
|
||||
/** 是否隐私评论 */
|
||||
@ApiModelProperty(value = "是否隐私评论")
|
||||
private String private_notes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 通用评论查询VO
|
||||
*
|
||||
|
|
@ -13,20 +16,13 @@ import lombok.Data;
|
|||
@Data
|
||||
@ApiModel("评论查询对象")
|
||||
public class ZoneJournalsSearchVo {
|
||||
|
||||
/** 评论对象ID */
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "评论对象ID")
|
||||
private Long journalized_id;
|
||||
|
||||
/** 评论对象类型 */
|
||||
@ApiModelProperty(value = "评论对象类型")
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "评论对象类型(资源:resource)")
|
||||
private String journalized_type;
|
||||
|
||||
/** 评论用户ID */
|
||||
@ApiModelProperty(value = "评论用户ID")
|
||||
private Long user_id;
|
||||
|
||||
/** 是否隐私评论 */
|
||||
@ApiModelProperty(value = "是否隐私评论")
|
||||
private String private_notes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,6 @@ public class ZoneJournalsServiceImpl implements IZoneJournalsService {
|
|||
ZoneJournals query = new ZoneJournals();
|
||||
query.setJournalizedId(searchVo.getJournalized_id());
|
||||
query.setJournalizedType(searchVo.getJournalized_type());
|
||||
query.setUserId(searchVo.getUser_id());
|
||||
query.setPrivateNotes(searchVo.getPrivate_notes());
|
||||
List<ZoneJournals> parentJournalsList = zoneJournalsMapper.selectZoneJournalsList(query);
|
||||
|
||||
// 转换为VO并组装子评论
|
||||
|
|
@ -149,7 +147,6 @@ public class ZoneJournalsServiceImpl implements IZoneJournalsService {
|
|||
newJournal.setParentId(inputVo.getParent_id());
|
||||
newJournal.setReplyId(inputVo.getReply_id());
|
||||
newJournal.setNotes(inputVo.getNotes());
|
||||
newJournal.setPrivateNotes(StringUtils.isEmpty(inputVo.getPrivate_notes()) ? "0" : inputVo.getPrivate_notes());
|
||||
newJournal.setAttachmentIdentifiers(inputVo.getAttachment_identifiers());
|
||||
|
||||
// 处理@用户列表
|
||||
|
|
@ -295,16 +292,10 @@ public class ZoneJournalsServiceImpl implements IZoneJournalsService {
|
|||
* @param zoneJournals 评论对象
|
||||
*/
|
||||
private void checkByType(ZoneJournals zoneJournals) {
|
||||
switch (zoneJournals.getJournalizedType()) {
|
||||
case ZoneJournals.JOURNAL_TYPE_AI_SKILL:
|
||||
case ZoneJournals.JOURNAL_TYPE_AI_MODEL:
|
||||
case ZoneJournals.JOURNAL_TYPE_AI_DATASET:
|
||||
case ZoneJournals.JOURNAL_TYPE_ZONE_RESOURCE:
|
||||
// 校验资源是否存在
|
||||
zoneResourceService.selectZoneResourceById(zoneJournals.getJournalizedId());
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("当前不支持该类型评论(评论类型[%s])", zoneJournals.getJournalizedType());
|
||||
if (zoneJournals.getJournalizedType().equals(ZoneJournals.JOURNAL_TYPE_ZONE_RESOURCE)) {// 校验资源是否存在
|
||||
zoneResourceService.selectZoneResourceById(zoneJournals.getJournalizedId());
|
||||
} else {
|
||||
throw new ServiceException("当前不支持该类型评论(评论类型[%s])", zoneJournals.getJournalizedType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="commentsCount" column="comments_count" />
|
||||
<result property="attachmentIdentifiers" column="attachment_identifiers"/>
|
||||
<result property="receiversLogin" column="receivers_login" />
|
||||
<result property="privateNotes" column="private_notes" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createdOn" column="created_on" />
|
||||
|
|
@ -34,7 +33,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
comments_count,
|
||||
attachment_identifiers,
|
||||
receivers_login,
|
||||
private_notes,
|
||||
del_flag,
|
||||
create_by,
|
||||
created_on,
|
||||
|
|
@ -49,7 +47,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="journalizedId != null "> and journalized_id = #{journalizedId}</if>
|
||||
<if test="journalizedType != null and journalizedType != ''"> and journalized_type = #{journalizedType}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="privateNotes != null and privateNotes != ''"> and private_notes = #{privateNotes}</if>
|
||||
and del_flag = '0'
|
||||
and parent_id is NULL
|
||||
</where>
|
||||
|
|
@ -88,7 +85,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="commentsCount != null">comments_count,</if>
|
||||
<if test="attachmentIdentifiers != null">attachment_identifiers,</if>
|
||||
<if test="receiversLogin != null">receivers_login,</if>
|
||||
<if test="privateNotes != null">private_notes,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createdOn != null">created_on,</if>
|
||||
|
|
@ -105,7 +101,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="commentsCount != null">#{commentsCount},</if>
|
||||
<if test="attachmentIdentifiers != null">#{attachmentIdentifiers},</if>
|
||||
<if test="receiversLogin != null">#{receiversLogin},</if>
|
||||
<if test="privateNotes != null">#{privateNotes},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createdOn != null">#{createdOn},</if>
|
||||
|
|
@ -127,14 +122,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
|
||||
<update id="updateCommentsCountById">
|
||||
update zone_journals
|
||||
set comments_count = (
|
||||
select count(*)
|
||||
from zone_journals
|
||||
where parent_id = #{id}
|
||||
and del_flag = '0'
|
||||
UPDATE zone_journals
|
||||
SET comments_count = (
|
||||
SELECT COUNT(*)
|
||||
FROM (
|
||||
SELECT 1
|
||||
FROM zone_journals
|
||||
WHERE parent_id = #{id}
|
||||
AND del_flag = '0'
|
||||
) AS tmp
|
||||
)
|
||||
where id = #{id}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateJournalsIdByTypeAndOldId">
|
||||
|
|
|
|||
Loading…
Reference in New Issue