feat: 修改

master
yang 2025-01-22 18:36:25 +08:00
parent 70aa6a6b27
commit f5309a6759
8 changed files with 22 additions and 10 deletions

View File

@ -43,8 +43,8 @@ public class ModelCommentController {
@ApiOperation(value = "模型点赞/取消")
@RepeatSubmit
@GetMapping("/modelLike/{modelId}")
public AjaxResult like(@PathVariable Long imageId) {
modelLikeService.like(imageId);
public AjaxResult like(@PathVariable Long modelId) {
modelLikeService.like(modelId);
return AjaxResult.success();
}

View File

@ -1,10 +1,12 @@
package com.mcwl.resource.domain.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mcwl.common.core.page.PageDomain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.util.Date;
@ -27,12 +29,14 @@ public class ModelImagePageRes extends PageDomain {
*
*/
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
*
*/
@ApiModelProperty(value = "结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;

View File

@ -10,5 +10,5 @@ import org.apache.ibatis.annotations.Param;
public interface ModelImageLikeMapper extends BaseMapper<ModelImageLike> {
ModelImageLike getLikeImage(@Param("userId") Long userId, @Param("imageId") Long imageId);
void updateDelFlagById(@Param("userId") Long userId, @Param("imageId") Long imageId);
void updateDelFlagById(ModelImageLike modelImageLike);
}

View File

@ -17,4 +17,5 @@ import org.apache.ibatis.annotations.Param;
public interface ModelLikeMapper extends BaseMapper<ModelLike> {
ModelLike getLike(@Param("userId") Long userId, @Param("modelId") Long modelId);
void updateDelFlagById(ModelLike modelLike);
}

View File

@ -59,7 +59,7 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
}
// 更新点赞记录
baseMapper.updateDelFlagById(userId, imageId);
baseMapper.updateDelFlagById(modelImageLike);
// 更新图片点赞数
modelImageMapper.updateById(modelImage);
return;

View File

@ -51,14 +51,14 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
ModelLike modelLike = baseMapper.getLike(userId, modelId);
if (Objects.nonNull(modelLike)) {
if (Objects.equals(modelLike.getDelFlag(), "0")) {
modelLike.setDelFlag("1");
model.setNumbers(model.getNumbers() - 1);
modelLike.setDelFlag("2");
model.setLikeNum(model.getLikeNum() - 1);
} else {
modelLike.setDelFlag("0");
model.setNumbers(model.getNumbers() + 1);
model.setLikeNum(model.getLikeNum() + 1);
}
// 更新点赞记录
baseMapper.updateById(modelLike);
baseMapper.updateDelFlagById(modelLike);
// 更新图片点赞数
modelMapper.updateById(model);
return;

View File

@ -31,7 +31,7 @@
</sql>
<update id="updateDelFlagById">
update model_image_like
set del_flag = !del_flag
set del_flag = #{delFlag}
where user_id = #{userId} and model_image_id = #{imageId}
</update>

View File

@ -3,6 +3,11 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mcwl.resource.mapper.ModelLikeMapper">
<update id="updateDelFlagById">
update model_like
set del_flag = #{delFlag}
where user_id = #{userId} and model_id = #{modelId}
</update>
<select id="getLike" resultType="com.mcwl.resource.domain.ModelLike">
@ -14,6 +19,8 @@
update_by,
update_time,
del_flag,
remark where user_id = #{userId} and model_id = #{modelId}
remark
from model_like
where user_id = #{userId} and model_id = #{modelId}
</select>
</mapper>