feat:更新朋友圈功能
This commit is contained in:
@@ -24,6 +24,13 @@ public class MomentController {
|
|||||||
return momentService.addMoment(momentDto);
|
return momentService.addMoment(momentDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新朋友圈")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public Boolean updateMoment(@PathVariable("id") long id,
|
||||||
|
@RequestBody @JsonView(WriteView.class) @Validated MomentDto momentDto) {
|
||||||
|
return momentService.updateMoment(id, momentDto);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询朋友圈")
|
@Operation(summary = "查询朋友圈")
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public @JsonView(ReadView.class) List<MomentDto> queryMoment() {
|
public @JsonView(ReadView.class) List<MomentDto> queryMoment() {
|
||||||
@@ -32,9 +39,9 @@ public class MomentController {
|
|||||||
|
|
||||||
@Operation(summary = "新增评论")
|
@Operation(summary = "新增评论")
|
||||||
@PostMapping("/{id}/comment")
|
@PostMapping("/{id}/comment")
|
||||||
public Boolean addMoment(@PathVariable("id") long id,
|
public Boolean addComment(@PathVariable("id") long id,
|
||||||
@RequestBody @JsonView(WriteView.class) @Validated CommentDto commentDto) {
|
@RequestParam String content) {
|
||||||
return momentService.addComment(id, commentDto);
|
return momentService.addComment(id, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
package com.cxx.food.service;
|
package com.cxx.food.service;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.cxx.food.dto.*;
|
import com.cxx.food.dto.*;
|
||||||
import com.cxx.food.vo.FoodQueryVo;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MomentService {
|
public interface MomentService {
|
||||||
Boolean addMoment(MomentDto momentDto);
|
Boolean addMoment(MomentDto momentDto);
|
||||||
|
|
||||||
|
Boolean updateMoment(Long id, MomentDto momentDto);
|
||||||
|
|
||||||
List<MomentDto> queryMoment();
|
List<MomentDto> queryMoment();
|
||||||
|
|
||||||
Boolean addComment(Long momentId, CommentDto commentDto);
|
Boolean addComment(Long momentId, String content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,18 @@ public class MomentServiceImpl implements MomentService {
|
|||||||
return momentMapper.insert(moment) == 1;
|
return momentMapper.insert(moment) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateMoment(Long id, MomentDto momentDto) {
|
||||||
|
if (momentMapper.selectById(id) == null) {
|
||||||
|
throw new CustomException("该朋友圈不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Moment moment = new Moment();
|
||||||
|
BeanUtils.copyProperties(momentDto, moment);
|
||||||
|
moment.setId(id);
|
||||||
|
return momentMapper.updateById(moment) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MomentDto> queryMoment() {
|
public List<MomentDto> queryMoment() {
|
||||||
// TODO 只能查询好友的朋友圈
|
// TODO 只能查询好友的朋友圈
|
||||||
@@ -40,13 +52,13 @@ public class MomentServiceImpl implements MomentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean addComment(Long momentId, CommentDto commentDto) {
|
public Boolean addComment(Long momentId, String content) {
|
||||||
if (momentMapper.selectById(momentId) == null) {
|
if (momentMapper.selectById(momentId) == null) {
|
||||||
throw new CustomException("该朋友圈不存在");
|
throw new CustomException("该朋友圈不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
Comment comment = new Comment();
|
Comment comment = new Comment();
|
||||||
BeanUtils.copyProperties(commentDto, comment);
|
comment.setContent(content);
|
||||||
comment.setMomentId(momentId);
|
comment.setMomentId(momentId);
|
||||||
return commentMapper.insert(comment) == 1;
|
return commentMapper.insert(comment) == 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ spring:
|
|||||||
name: @project.artifactId@
|
name: @project.artifactId@
|
||||||
version: @project.version@
|
version: @project.version@
|
||||||
profiles:
|
profiles:
|
||||||
active: prod
|
active: dev
|
||||||
|
|
||||||
# mybatis plus mapper路径
|
# mybatis plus mapper路径
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
<result property="recommendRate" column="recommendRate"/>
|
<result property="recommendRate" column="recommendRate"/>
|
||||||
<result property="remark" column="remark"/>
|
<result property="remark" column="remark"/>
|
||||||
<collection property="materialList" ofType="com.cxx.food.dto.MaterialDto"
|
<collection property="materialList" ofType="com.cxx.food.dto.MaterialDto"
|
||||||
column="id" select="queryFoodMaterial">
|
column="id" select="queryMaterial">
|
||||||
</collection>
|
</collection>
|
||||||
<collection property="stepList" ofType="com.cxx.food.dto.StepDto"
|
<collection property="stepList" ofType="com.cxx.food.dto.StepDto"
|
||||||
column="id" select="queryFoodStep">
|
column="id" select="queryStep">
|
||||||
</collection>
|
</collection>
|
||||||
<collection property="recordList" ofType="com.cxx.food.dto.RecordDto"
|
<collection property="recordList" ofType="com.cxx.food.dto.RecordDto"
|
||||||
column="id" select="queryFoodRecordById">
|
column="id" select="queryRecordById">
|
||||||
</collection>
|
</collection>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
</collection>
|
</collection>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryFoodMaterial" resultMap="foodMaterialResultMap">
|
<select id="queryMaterial" resultMap="foodMaterialResultMap">
|
||||||
SELECT id AS id,
|
SELECT id AS id,
|
||||||
type AS type,
|
type AS type,
|
||||||
name AS name,
|
name AS name,
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
WHERE food_id = #{id}
|
WHERE food_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodStep" resultMap="foodStepResultMap">
|
<select id="queryStep" resultMap="foodStepResultMap">
|
||||||
SELECT id AS id,
|
SELECT id AS id,
|
||||||
sort AS sort,
|
sort AS sort,
|
||||||
content AS content,
|
content AS content,
|
||||||
|
|||||||
@@ -39,5 +39,6 @@
|
|||||||
a.create_time AS date
|
a.create_time AS date
|
||||||
FROM moment AS a
|
FROM moment AS a
|
||||||
LEFT JOIN user AS b ON a.create_by = b.id
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
|
ORDER BY a.update_time DESC
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user