feat: 修改
parent
70aa6a6b27
commit
f5309a6759
|
@ -43,8 +43,8 @@ public class ModelCommentController {
|
||||||
@ApiOperation(value = "模型点赞/取消")
|
@ApiOperation(value = "模型点赞/取消")
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@GetMapping("/modelLike/{modelId}")
|
@GetMapping("/modelLike/{modelId}")
|
||||||
public AjaxResult like(@PathVariable Long imageId) {
|
public AjaxResult like(@PathVariable Long modelId) {
|
||||||
modelLikeService.like(imageId);
|
modelLikeService.like(modelId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package com.mcwl.resource.domain.dto;
|
package com.mcwl.resource.domain.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.mcwl.common.core.page.PageDomain;
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -27,12 +29,14 @@ public class ModelImagePageRes extends PageDomain {
|
||||||
* 开始时间
|
* 开始时间
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "开始时间")
|
@ApiModelProperty(value = "开始时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束时间
|
* 结束时间
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "结束时间")
|
@ApiModelProperty(value = "结束时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,5 @@ import org.apache.ibatis.annotations.Param;
|
||||||
public interface ModelImageLikeMapper extends BaseMapper<ModelImageLike> {
|
public interface ModelImageLikeMapper extends BaseMapper<ModelImageLike> {
|
||||||
ModelImageLike getLikeImage(@Param("userId") Long userId, @Param("imageId") Long imageId);
|
ModelImageLike getLikeImage(@Param("userId") Long userId, @Param("imageId") Long imageId);
|
||||||
|
|
||||||
void updateDelFlagById(@Param("userId") Long userId, @Param("imageId") Long imageId);
|
void updateDelFlagById(ModelImageLike modelImageLike);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ import org.apache.ibatis.annotations.Param;
|
||||||
public interface ModelLikeMapper extends BaseMapper<ModelLike> {
|
public interface ModelLikeMapper extends BaseMapper<ModelLike> {
|
||||||
ModelLike getLike(@Param("userId") Long userId, @Param("modelId") Long modelId);
|
ModelLike getLike(@Param("userId") Long userId, @Param("modelId") Long modelId);
|
||||||
|
|
||||||
|
void updateDelFlagById(ModelLike modelLike);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
||||||
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
||||||
}
|
}
|
||||||
// 更新点赞记录
|
// 更新点赞记录
|
||||||
baseMapper.updateDelFlagById(userId, imageId);
|
baseMapper.updateDelFlagById(modelImageLike);
|
||||||
// 更新图片点赞数
|
// 更新图片点赞数
|
||||||
modelImageMapper.updateById(modelImage);
|
modelImageMapper.updateById(modelImage);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,14 +51,14 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
||||||
ModelLike modelLike = baseMapper.getLike(userId, modelId);
|
ModelLike modelLike = baseMapper.getLike(userId, modelId);
|
||||||
if (Objects.nonNull(modelLike)) {
|
if (Objects.nonNull(modelLike)) {
|
||||||
if (Objects.equals(modelLike.getDelFlag(), "0")) {
|
if (Objects.equals(modelLike.getDelFlag(), "0")) {
|
||||||
modelLike.setDelFlag("1");
|
modelLike.setDelFlag("2");
|
||||||
model.setNumbers(model.getNumbers() - 1);
|
model.setLikeNum(model.getLikeNum() - 1);
|
||||||
} else {
|
} else {
|
||||||
modelLike.setDelFlag("0");
|
modelLike.setDelFlag("0");
|
||||||
model.setNumbers(model.getNumbers() + 1);
|
model.setLikeNum(model.getLikeNum() + 1);
|
||||||
}
|
}
|
||||||
// 更新点赞记录
|
// 更新点赞记录
|
||||||
baseMapper.updateById(modelLike);
|
baseMapper.updateDelFlagById(modelLike);
|
||||||
// 更新图片点赞数
|
// 更新图片点赞数
|
||||||
modelMapper.updateById(model);
|
modelMapper.updateById(model);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</sql>
|
</sql>
|
||||||
<update id="updateDelFlagById">
|
<update id="updateDelFlagById">
|
||||||
update model_image_like
|
update model_image_like
|
||||||
set del_flag = !del_flag
|
set del_flag = #{delFlag}
|
||||||
where user_id = #{userId} and model_image_id = #{imageId}
|
where user_id = #{userId} and model_image_id = #{imageId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.mcwl.resource.mapper.ModelLikeMapper">
|
<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">
|
<select id="getLike" resultType="com.mcwl.resource.domain.ModelLike">
|
||||||
|
@ -14,6 +19,8 @@
|
||||||
update_by,
|
update_by,
|
||||||
update_time,
|
update_time,
|
||||||
del_flag,
|
del_flag,
|
||||||
remark where user_id = #{userId} and model_id = #{modelId}
|
remark
|
||||||
|
from model_like
|
||||||
|
where user_id = #{userId} and model_id = #{modelId}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue