feat:增加美食朋友圈功能
This commit is contained in:
@@ -22,41 +22,41 @@ public class FoodController {
|
|||||||
|
|
||||||
@Operation(summary = "新增美食菜谱")
|
@Operation(summary = "新增美食菜谱")
|
||||||
@PostMapping("/recipe")
|
@PostMapping("/recipe")
|
||||||
public Boolean addFoodRecipe(@RequestBody @JsonView(WriteView.class) @Validated FoodRecipeDto foodRecipeDto) {
|
public Boolean addRecipe(@RequestBody @JsonView(WriteView.class) @Validated RecipeDto recipeDto) {
|
||||||
return foodService.addFoodRecipe(foodRecipeDto);
|
return foodService.addRecipe(recipeDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新美食菜谱")
|
@Operation(summary = "更新美食菜谱")
|
||||||
@PutMapping("/recipe/{id}")
|
@PutMapping("/recipe/{id}")
|
||||||
public Boolean updateFoodRecipe(@PathVariable("id") long id,
|
public Boolean updateRecipe(@PathVariable("id") long id,
|
||||||
@RequestBody @JsonView(WriteView.class) FoodRecipeDto foodRecipeDto) {
|
@RequestBody @JsonView(WriteView.class) RecipeDto recipeDto) {
|
||||||
return foodService.updateFoodRecipe(id, foodRecipeDto);
|
return foodService.updateRecipe(id, recipeDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除美食菜谱")
|
@Operation(summary = "删除美食菜谱")
|
||||||
@DeleteMapping("/recipe/{id}")
|
@DeleteMapping("/recipe/{id}")
|
||||||
public Boolean deleteFoodRecipe(@PathVariable("id") long id) {
|
public Boolean deleteRecipe(@PathVariable("id") long id) {
|
||||||
return foodService.deleteFoodRecipe(id);
|
return foodService.deleteRecipe(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食菜谱")
|
@Operation(summary = "查询美食菜谱")
|
||||||
@GetMapping("/recipe")
|
@GetMapping("/recipe")
|
||||||
public List<FoodSummaryDto> queryFoodSummary(FoodQueryVo foodQueryVo) {
|
public List<SummaryDto> querySummary(FoodQueryVo foodQueryVo) {
|
||||||
return foodService.queryFoodSummary(foodQueryVo);
|
return foodService.querySummary(foodQueryVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "分页查询美食菜谱")
|
@Operation(summary = "分页查询美食菜谱")
|
||||||
@GetMapping("/recipe/page")
|
@GetMapping("/recipe/page")
|
||||||
public IPage<FoodSummaryDto> queryFoodSummaryByPage(@RequestParam("currentPage") Integer currentPage,
|
public IPage<SummaryDto> querySummaryByPage(@RequestParam("currentPage") Integer currentPage,
|
||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
FoodQueryVo foodQueryVo) {
|
FoodQueryVo foodQueryVo) {
|
||||||
return foodService.queryFoodSummaryByPage(currentPage, pageSize, foodQueryVo);
|
return foodService.querySummaryByPage(currentPage, pageSize, foodQueryVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食")
|
@Operation(summary = "查询美食")
|
||||||
@GetMapping("/recipe/{id}")
|
@GetMapping("/recipe/{id}")
|
||||||
public @JsonView(ReadView.class) FoodRecipeDto queryFoodRecipe(@PathVariable("id") long id) {
|
public @JsonView(ReadView.class) RecipeDto queryRecipe(@PathVariable("id") long id) {
|
||||||
return foodService.queryFoodRecipe(id);
|
return foodService.queryRecipe(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询所有美食名称")
|
@Operation(summary = "查询所有美食名称")
|
||||||
@@ -67,58 +67,58 @@ public class FoodController {
|
|||||||
|
|
||||||
@Operation(summary = "新增美食成果")
|
@Operation(summary = "新增美食成果")
|
||||||
@PostMapping("/record")
|
@PostMapping("/record")
|
||||||
public Boolean addFoodRecord(@RequestBody @JsonView(WriteView.class) @Validated FoodRecordDto foodRecordDto) {
|
public Boolean addRecord(@RequestBody @JsonView(WriteView.class) @Validated RecordDto recordDto) {
|
||||||
return foodService.addFoodRecord(foodRecordDto);
|
return foodService.addRecord(recordDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新美食成果")
|
@Operation(summary = "更新美食成果")
|
||||||
@PutMapping("/record/{id}")
|
@PutMapping("/record/{id}")
|
||||||
public Boolean updateFoodRecord(@PathVariable("id") long id,
|
public Boolean updateRecord(@PathVariable("id") long id,
|
||||||
@RequestBody @JsonView(WriteView.class) FoodRecordDto foodRecordDto) {
|
@RequestBody @JsonView(WriteView.class) RecordDto recordDto) {
|
||||||
return foodService.updateFoodRecord(id, foodRecordDto);
|
return foodService.updateRecord(id, recordDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除美食成果")
|
@Operation(summary = "删除美食成果")
|
||||||
@DeleteMapping("/record/{id}")
|
@DeleteMapping("/record/{id}")
|
||||||
public Boolean deleteFoodRecord(@PathVariable("id") long id) {
|
public Boolean deleteRecord(@PathVariable("id") long id) {
|
||||||
return foodService.deleteFoodRecord(id);
|
return foodService.deleteRecord(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食记录")
|
@Operation(summary = "查询美食记录")
|
||||||
@GetMapping("/record")
|
@GetMapping("/record")
|
||||||
public @JsonView(ReadView.class) List<FoodRecordDto> queryFoodRecord(@RequestParam("startDate") String startDate,
|
public @JsonView(ReadView.class) List<RecordDto> queryRecord(@RequestParam("startDate") String startDate,
|
||||||
@RequestParam("endDate") String endDate) {
|
@RequestParam("endDate") String endDate) {
|
||||||
return foodService.queryFoodRecord(startDate, endDate);
|
return foodService.queryRecord(startDate, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食类别")
|
@Operation(summary = "查询美食类别")
|
||||||
@GetMapping("/category")
|
@GetMapping("/category")
|
||||||
public List<String> queryFoodCategory() {
|
public List<String> queryCategory() {
|
||||||
return foodService.queryFoodCategory();
|
return foodService.queryCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食统计")
|
@Operation(summary = "查询美食统计")
|
||||||
@GetMapping("/stats")
|
@GetMapping("/stats")
|
||||||
public FoodStatsDto queryFoodStats() {
|
public StatsDto queryStats() {
|
||||||
return foodService.queryFoodStats();
|
return foodService.queryStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食记录统计")
|
@Operation(summary = "查询美食记录统计")
|
||||||
@GetMapping("/stats/record")
|
@GetMapping("/stats/record")
|
||||||
public List<StatsChartDto> queryFoodRecordStats() {
|
public List<StatsChartDto> queryRecordStats() {
|
||||||
return foodService.queryFoodRecordStats();
|
return foodService.queryRecordStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食类别统计")
|
@Operation(summary = "查询美食类别统计")
|
||||||
@GetMapping("/stats/category")
|
@GetMapping("/stats/category")
|
||||||
public List<StatsChartDto> queryFoodCategoryStats() {
|
public List<StatsChartDto> queryCategoryStats() {
|
||||||
return foodService.queryFoodCategoryStats();
|
return foodService.queryCategoryStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询美食排行榜统计")
|
@Operation(summary = "查询美食排行榜统计")
|
||||||
@GetMapping("/stats/rank")
|
@GetMapping("/stats/rank")
|
||||||
public List<StatsChartDto> queryFoodRankStats() {
|
public List<StatsChartDto> queryRankStats() {
|
||||||
return foodService.queryFoodRankStats();
|
return foodService.queryRankStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
40
src/main/java/com/cxx/food/controller/MomentController.java
Normal file
40
src/main/java/com/cxx/food/controller/MomentController.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.cxx.food.controller;
|
||||||
|
|
||||||
|
import com.cxx.food.dto.*;
|
||||||
|
import com.cxx.food.service.MomentService;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/moment")
|
||||||
|
@Tag(name = "美食朋友圈")
|
||||||
|
public class MomentController {
|
||||||
|
@Resource
|
||||||
|
private MomentService momentService;
|
||||||
|
|
||||||
|
@Operation(summary = "新增朋友圈")
|
||||||
|
@PostMapping("")
|
||||||
|
public Boolean addMoment(@RequestBody @JsonView(WriteView.class) @Validated MomentDto momentDto) {
|
||||||
|
return momentService.addMoment(momentDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询朋友圈")
|
||||||
|
@GetMapping("")
|
||||||
|
public @JsonView(ReadView.class) List<MomentDto> queryMoment() {
|
||||||
|
return momentService.queryMoment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增评论")
|
||||||
|
@PostMapping("/{id}/comment")
|
||||||
|
public Boolean addMoment(@PathVariable("id") long id,
|
||||||
|
@RequestBody @JsonView(WriteView.class) @Validated CommentDto commentDto) {
|
||||||
|
return momentService.addComment(id, commentDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -10,32 +10,32 @@ import java.util.List;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FoodDao {
|
public interface FoodDao {
|
||||||
FoodRecipeDto queryFoodRecipe(@Param("id") Long id);
|
RecipeDto queryRecipe(@Param("id") Long id);
|
||||||
|
|
||||||
IPage<FoodSummaryDto> queryFoodSummaryByPage(IPage<FoodSummaryDto> page,
|
IPage<SummaryDto> querySummaryByPage(IPage<SummaryDto> page,
|
||||||
@Param("query") FoodQueryVo foodQueryVo);
|
@Param("query") FoodQueryVo foodQueryVo);
|
||||||
|
|
||||||
List<FoodSummaryDto> queryFoodSummary(@Param("query") FoodQueryVo foodQueryVo);
|
List<SummaryDto> querySummary(@Param("query") FoodQueryVo foodQueryVo);
|
||||||
|
|
||||||
List<FoodRecordDto> queryFoodRecordById(@Param("id") Long id);
|
List<RecordDto> queryRecordById(@Param("id") Long id);
|
||||||
|
|
||||||
List<FoodRecordDto> queryFoodRecord(@Param("startDate") String startDate,
|
List<RecordDto> queryRecord(@Param("startDate") String startDate,
|
||||||
@Param("endDate") String endDate);
|
@Param("endDate") String endDate);
|
||||||
|
|
||||||
FoodStatsDto queryFoodStats();
|
StatsDto queryStats();
|
||||||
|
|
||||||
List<StatsChartDto> queryFoodRecordStats();
|
List<StatsChartDto> queryRecordStats();
|
||||||
|
|
||||||
List<StatsChartDto> queryFoodCategoryStats();
|
List<StatsChartDto> queryCategoryStats();
|
||||||
|
|
||||||
List<StatsChartDto> queryFoodRankStats();
|
List<StatsChartDto> queryRankStats();
|
||||||
|
|
||||||
List<String> queryFoodCategory();
|
List<String> queryCategory();
|
||||||
|
|
||||||
void insertFoodMaterial(@Param("foodId") Long foodId,
|
void insertMaterial(@Param("foodId") Long foodId,
|
||||||
@Param("list") List<FoodMaterialDto> list);
|
@Param("list") List<MaterialDto> list);
|
||||||
|
|
||||||
void insertFoodStep(@Param("foodId") Long foodId,
|
void insertStep(@Param("foodId") Long foodId,
|
||||||
@Param("list") List<FoodStepDto> list);
|
@Param("list") List<StepDto> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/main/java/com/cxx/food/dao/MomentDao.java
Normal file
14
src/main/java/com/cxx/food/dao/MomentDao.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.cxx.food.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.cxx.food.dto.*;
|
||||||
|
import com.cxx.food.vo.FoodQueryVo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface MomentDao {
|
||||||
|
List<MomentDto> queryMoment();
|
||||||
|
}
|
||||||
37
src/main/java/com/cxx/food/dto/CommentDto.java
Normal file
37
src/main/java/com/cxx/food/dto/CommentDto.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
package com.cxx.food.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonView(PlainView.class)
|
||||||
|
public class CommentDto {
|
||||||
|
@Schema(description = "id")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "姓名")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(description = "头像")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
@Schema(description = "评论内容")
|
||||||
|
@NotBlank(message = "内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date date;
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@JsonView(PlainView.class)
|
@JsonView(PlainView.class)
|
||||||
public class FoodMaterialDto {
|
public class MaterialDto {
|
||||||
@Schema(description = "id")
|
@Schema(description = "id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
41
src/main/java/com/cxx/food/dto/MomentDto.java
Normal file
41
src/main/java/com/cxx/food/dto/MomentDto.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package com.cxx.food.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonView(PlainView.class)
|
||||||
|
public class MomentDto {
|
||||||
|
@Schema(description = "id")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "姓名")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(description = "头像")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
@Schema(description = "朋友圈内容")
|
||||||
|
@NotBlank(message = "内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
@Schema(description = "评论内容")
|
||||||
|
@JsonView(ReadView.class)
|
||||||
|
private List<CommentDto> commentList;
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@JsonView(PlainView.class)
|
@JsonView(PlainView.class)
|
||||||
public class FoodRecipeDto {
|
public class RecipeDto {
|
||||||
@Schema(description = "id")
|
@Schema(description = "id")
|
||||||
@JsonView(ReadView.class)
|
@JsonView(ReadView.class)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -29,14 +29,14 @@ public class FoodRecipeDto {
|
|||||||
private Integer recommendRate;
|
private Integer recommendRate;
|
||||||
|
|
||||||
@Schema(description = "美食食材")
|
@Schema(description = "美食食材")
|
||||||
private List<FoodMaterialDto> materialList;
|
private List<MaterialDto> materialList;
|
||||||
|
|
||||||
@Schema(description = "美食步骤")
|
@Schema(description = "美食步骤")
|
||||||
private List<FoodStepDto> stepList;
|
private List<StepDto> stepList;
|
||||||
|
|
||||||
@Schema(description = "美食成果")
|
@Schema(description = "美食成果")
|
||||||
@JsonView(ReadView.class)
|
@JsonView(ReadView.class)
|
||||||
private List<FoodRecordDto> recordList;
|
private List<RecordDto> recordList;
|
||||||
|
|
||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
@@ -11,7 +11,7 @@ import java.util.Date;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@JsonView(PlainView.class)
|
@JsonView(PlainView.class)
|
||||||
public class FoodRecordDto {
|
public class RecordDto {
|
||||||
@Schema(description = "id")
|
@Schema(description = "id")
|
||||||
@JsonView(ReadView.class)
|
@JsonView(ReadView.class)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -7,7 +7,7 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class FoodStatsDto {
|
public class StatsDto {
|
||||||
@Schema(description = "菜谱总数")
|
@Schema(description = "菜谱总数")
|
||||||
private Integer recipeCount;
|
private Integer recipeCount;
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@JsonView(PlainView.class)
|
@JsonView(PlainView.class)
|
||||||
public class FoodStepDto {
|
public class StepDto {
|
||||||
@Schema(description = "id")
|
@Schema(description = "id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class FoodSummaryDto {
|
public class SummaryDto {
|
||||||
@Schema(description = "id")
|
@Schema(description = "id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@@ -22,5 +22,5 @@ public class FoodSummaryDto {
|
|||||||
private Integer recommendRate;
|
private Integer recommendRate;
|
||||||
|
|
||||||
@Schema(description = "美食记录")
|
@Schema(description = "美食记录")
|
||||||
private List<FoodRecordDto> recordList;
|
private List<RecordDto> recordList;
|
||||||
}
|
}
|
||||||
18
src/main/java/com/cxx/food/entity/Comment.java
Normal file
18
src/main/java/com/cxx/food/entity/Comment.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.cxx.food.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.cxx.framework.data.AbstractEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("comment")
|
||||||
|
public class Comment extends AbstractEntity {
|
||||||
|
@TableField("moment_id")
|
||||||
|
private Long momentId;
|
||||||
|
|
||||||
|
@TableField("content")
|
||||||
|
private String content;
|
||||||
|
}
|
||||||
18
src/main/java/com/cxx/food/entity/Like.java
Normal file
18
src/main/java/com/cxx/food/entity/Like.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.cxx.food.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.cxx.framework.data.AbstractEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("moment")
|
||||||
|
public class Like extends AbstractEntity {
|
||||||
|
@TableField("moment_id")
|
||||||
|
private Long momentId;
|
||||||
|
|
||||||
|
@TableField("is_delete")
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("food_material")
|
@TableName("food_material")
|
||||||
public class FoodMaterial extends AbstractIdEntity {
|
public class Material extends AbstractIdEntity {
|
||||||
@TableField("food_id")
|
@TableField("food_id")
|
||||||
private Long foodId;
|
private Long foodId;
|
||||||
|
|
||||||
15
src/main/java/com/cxx/food/entity/Moment.java
Normal file
15
src/main/java/com/cxx/food/entity/Moment.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.cxx.food.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.cxx.framework.data.AbstractEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("moment")
|
||||||
|
public class Moment extends AbstractEntity {
|
||||||
|
@TableField("content")
|
||||||
|
private String content;
|
||||||
|
}
|
||||||
@@ -8,8 +8,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("food_recipe")
|
@TableName("recipe")
|
||||||
public class FoodRecipe extends AbstractEntity {
|
public class Recipe extends AbstractEntity {
|
||||||
@TableField("name")
|
@TableField("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ import java.util.Date;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("food_record")
|
@TableName("record")
|
||||||
public class FoodRecord extends AbstractIdEntity {
|
public class Record extends AbstractIdEntity {
|
||||||
@TableField("food_id")
|
@TableField("food_id")
|
||||||
private Long foodId;
|
private Long foodId;
|
||||||
|
|
||||||
@@ -8,8 +8,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("food_step")
|
@TableName("step")
|
||||||
public class FoodStep extends AbstractIdEntity {
|
public class Step extends AbstractIdEntity {
|
||||||
@TableField("food_id")
|
@TableField("food_id")
|
||||||
private Long foodId;
|
private Long foodId;
|
||||||
|
|
||||||
21
src/main/java/com/cxx/food/entity/User.java
Normal file
21
src/main/java/com/cxx/food/entity/User.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package com.cxx.food.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.cxx.framework.data.AbstractEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("user")
|
||||||
|
public class User extends AbstractEntity {
|
||||||
|
@TableField("username")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@TableField("password")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@TableField("avatar")
|
||||||
|
private String avatar;
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.cxx.food.mapper;
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.cxx.food.entity.FoodStep;
|
import com.cxx.food.entity.Comment;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FoodStepMapper extends BaseMapper<FoodStep> {
|
public interface CommentMapper extends BaseMapper<Comment> {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.cxx.food.mapper;
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.cxx.food.entity.FoodRecipe;
|
import com.cxx.food.entity.Like;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FoodRecipeMapper extends BaseMapper<FoodRecipe> {
|
public interface LikeMapper extends BaseMapper<Like> {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.cxx.food.mapper;
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.cxx.food.entity.FoodRecord;
|
import com.cxx.food.entity.Material;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FoodRecordMapper extends BaseMapper<FoodRecord> {
|
public interface MaterialMapper extends BaseMapper<Material> {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.cxx.food.mapper;
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.cxx.food.entity.FoodMaterial;
|
import com.cxx.food.entity.Moment;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FoodMaterialMapper extends BaseMapper<FoodMaterial> {
|
public interface MomentMapper extends BaseMapper<Moment> {
|
||||||
}
|
}
|
||||||
9
src/main/java/com/cxx/food/mapper/RecipeMapper.java
Normal file
9
src/main/java/com/cxx/food/mapper/RecipeMapper.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.cxx.food.entity.Recipe;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface RecipeMapper extends BaseMapper<Recipe> {
|
||||||
|
}
|
||||||
9
src/main/java/com/cxx/food/mapper/RecordMapper.java
Normal file
9
src/main/java/com/cxx/food/mapper/RecordMapper.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.cxx.food.entity.Record;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface RecordMapper extends BaseMapper<Record> {
|
||||||
|
}
|
||||||
9
src/main/java/com/cxx/food/mapper/StepMapper.java
Normal file
9
src/main/java/com/cxx/food/mapper/StepMapper.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.cxx.food.entity.Step;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface StepMapper extends BaseMapper<Step> {
|
||||||
|
}
|
||||||
9
src/main/java/com/cxx/food/mapper/UserMapper.java
Normal file
9
src/main/java/com/cxx/food/mapper/UserMapper.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.cxx.food.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.cxx.food.entity.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
}
|
||||||
@@ -8,35 +8,35 @@ import com.cxx.food.vo.FoodQueryVo;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface FoodService {
|
public interface FoodService {
|
||||||
Boolean addFoodRecipe(FoodRecipeDto foodRecipeDto);
|
Boolean addRecipe(RecipeDto recipeDto);
|
||||||
|
|
||||||
Boolean updateFoodRecipe(Long id, FoodRecipeDto foodRecipeDto);
|
Boolean updateRecipe(Long id, RecipeDto recipeDto);
|
||||||
|
|
||||||
Boolean deleteFoodRecipe(Long id);
|
Boolean deleteRecipe(Long id);
|
||||||
|
|
||||||
Boolean addFoodRecord(FoodRecordDto foodRecordDto);
|
Boolean addRecord(RecordDto foodRecordDto);
|
||||||
|
|
||||||
Boolean updateFoodRecord(Long id, FoodRecordDto foodRecordDto);
|
Boolean updateRecord(Long id, RecordDto recordDto);
|
||||||
|
|
||||||
Boolean deleteFoodRecord(Long id);
|
Boolean deleteRecord(Long id);
|
||||||
|
|
||||||
FoodRecipeDto queryFoodRecipe(Long id);
|
RecipeDto queryRecipe(Long id);
|
||||||
|
|
||||||
List<FoodSummaryDto> queryFoodSummary(FoodQueryVo foodQueryVo);
|
List<SummaryDto> querySummary(FoodQueryVo foodQueryVo);
|
||||||
|
|
||||||
IPage<FoodSummaryDto> queryFoodSummaryByPage(Integer currentPage, Integer pageSize, FoodQueryVo foodQueryVo);
|
IPage<SummaryDto> querySummaryByPage(Integer currentPage, Integer pageSize, FoodQueryVo foodQueryVo);
|
||||||
|
|
||||||
List<FoodRecordDto> queryFoodRecord(String startDate, String endDate);
|
List<RecordDto> queryRecord(String startDate, String endDate);
|
||||||
|
|
||||||
List<String> queryFoodName();
|
List<String> queryFoodName();
|
||||||
|
|
||||||
List<String> queryFoodCategory();
|
List<String> queryCategory();
|
||||||
|
|
||||||
FoodStatsDto queryFoodStats();
|
StatsDto queryStats();
|
||||||
|
|
||||||
List<StatsChartDto> queryFoodRecordStats();
|
List<StatsChartDto> queryRecordStats();
|
||||||
|
|
||||||
List<StatsChartDto> queryFoodCategoryStats();
|
List<StatsChartDto> queryCategoryStats();
|
||||||
|
|
||||||
List<StatsChartDto> queryFoodRankStats();
|
List<StatsChartDto> queryRankStats();
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/main/java/com/cxx/food/service/MomentService.java
Normal file
16
src/main/java/com/cxx/food/service/MomentService.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cxx.food.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.cxx.food.dto.*;
|
||||||
|
import com.cxx.food.vo.FoodQueryVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface MomentService {
|
||||||
|
Boolean addMoment(MomentDto momentDto);
|
||||||
|
|
||||||
|
List<MomentDto> queryMoment();
|
||||||
|
|
||||||
|
Boolean addComment(Long momentId, CommentDto commentDto);
|
||||||
|
}
|
||||||
@@ -6,14 +6,14 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.cxx.food.dao.FoodDao;
|
import com.cxx.food.dao.FoodDao;
|
||||||
import com.cxx.food.dto.*;
|
import com.cxx.food.dto.*;
|
||||||
import com.cxx.food.entity.FoodMaterial;
|
import com.cxx.food.entity.Material;
|
||||||
import com.cxx.food.entity.FoodRecipe;
|
import com.cxx.food.entity.Recipe;
|
||||||
import com.cxx.food.entity.FoodRecord;
|
import com.cxx.food.entity.Record;
|
||||||
import com.cxx.food.entity.FoodStep;
|
import com.cxx.food.entity.Step;
|
||||||
import com.cxx.food.mapper.FoodMaterialMapper;
|
import com.cxx.food.mapper.MaterialMapper;
|
||||||
import com.cxx.food.mapper.FoodRecipeMapper;
|
import com.cxx.food.mapper.RecipeMapper;
|
||||||
import com.cxx.food.mapper.FoodRecordMapper;
|
import com.cxx.food.mapper.RecordMapper;
|
||||||
import com.cxx.food.mapper.FoodStepMapper;
|
import com.cxx.food.mapper.StepMapper;
|
||||||
import com.cxx.food.service.FoodService;
|
import com.cxx.food.service.FoodService;
|
||||||
import com.cxx.food.vo.FoodQueryVo;
|
import com.cxx.food.vo.FoodQueryVo;
|
||||||
import com.cxx.framework.web.CustomException;
|
import com.cxx.framework.web.CustomException;
|
||||||
@@ -32,189 +32,189 @@ public class FoodServiceImpl implements FoodService {
|
|||||||
private FoodDao foodDao;
|
private FoodDao foodDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FoodRecipeMapper foodRecipeMapper;
|
private RecipeMapper recipeMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FoodMaterialMapper foodMaterialMapper;
|
private MaterialMapper materialMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FoodStepMapper foodStepMapper;
|
private StepMapper stepMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FoodRecordMapper foodRecordMapper;
|
private RecordMapper recordMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Boolean addFoodRecipe(FoodRecipeDto foodRecipeDto) {
|
public Boolean addRecipe(RecipeDto recipeDto) {
|
||||||
LambdaQueryWrapper<FoodRecipe> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Recipe> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (foodRecipeMapper.exists(queryWrapper.eq(FoodRecipe::getName, foodRecipeDto.getName()))) {
|
if (recipeMapper.exists(queryWrapper.eq(Recipe::getName, recipeDto.getName()))) {
|
||||||
throw new CustomException("该菜谱已经存在");
|
throw new CustomException("该菜谱已经存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
FoodRecipe foodRecipe = new FoodRecipe();
|
Recipe recipe = new Recipe();
|
||||||
BeanUtils.copyProperties(foodRecipeDto, foodRecipe);
|
BeanUtils.copyProperties(recipeDto, recipe);
|
||||||
foodRecipeMapper.insert(foodRecipe);
|
recipeMapper.insert(recipe);
|
||||||
resetFoodRecipe(foodRecipe.getId(), foodRecipeDto);
|
resetFoodRecipe(recipe.getId(), recipeDto);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Boolean updateFoodRecipe(Long id, FoodRecipeDto foodRecipeDto) {
|
public Boolean updateRecipe(Long id, RecipeDto recipeDto) {
|
||||||
if (foodRecipeMapper.selectById(id) == null) {
|
if (recipeMapper.selectById(id) == null) {
|
||||||
throw new CustomException("该菜谱不存在");
|
throw new CustomException("该菜谱不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
FoodRecipe foodRecipe = new FoodRecipe();
|
Recipe recipe = new Recipe();
|
||||||
BeanUtils.copyProperties(foodRecipeDto, foodRecipe);
|
BeanUtils.copyProperties(recipeDto, recipe);
|
||||||
foodRecipe.setId(id);
|
recipe.setId(id);
|
||||||
foodRecipeMapper.updateById(foodRecipe);
|
recipeMapper.updateById(recipe);
|
||||||
resetFoodRecipe(foodRecipe.getId(), foodRecipeDto);
|
resetFoodRecipe(recipe.getId(), recipeDto);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Boolean deleteFoodRecipe(Long id) {
|
public Boolean deleteRecipe(Long id) {
|
||||||
foodRecipeMapper.deleteById(id);
|
recipeMapper.deleteById(id);
|
||||||
foodMaterialMapper.delete(Wrappers.lambdaQuery(FoodMaterial.class).eq(FoodMaterial::getFoodId, id));
|
materialMapper.delete(Wrappers.lambdaQuery(Material.class).eq(Material::getFoodId, id));
|
||||||
foodStepMapper.delete(Wrappers.lambdaQuery(FoodStep.class).eq(FoodStep::getFoodId, id));
|
stepMapper.delete(Wrappers.lambdaQuery(Step.class).eq(Step::getFoodId, id));
|
||||||
foodRecordMapper.delete(Wrappers.lambdaQuery(FoodRecord.class).eq(FoodRecord::getFoodId, id));
|
recordMapper.delete(Wrappers.lambdaQuery(Record.class).eq(Record::getFoodId, id));
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean addFoodRecord(FoodRecordDto foodRecordDto) {
|
public Boolean addRecord(RecordDto recordDto) {
|
||||||
LambdaQueryWrapper<FoodRecipe> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Recipe> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
FoodRecipe foodRecipe = foodRecipeMapper.selectOne(queryWrapper.eq(FoodRecipe::getName, foodRecordDto.getName()));
|
Recipe recipe = recipeMapper.selectOne(queryWrapper.eq(Recipe::getName, recordDto.getName()));
|
||||||
if (foodRecipe == null) {
|
if (recipe == null) {
|
||||||
throw new CustomException("该菜谱不存在");
|
throw new CustomException("该菜谱不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
FoodRecord foodRecord = new FoodRecord();
|
Record record = new Record();
|
||||||
foodRecord.setFoodId(foodRecipe.getId());
|
record.setFoodId(recipe.getId());
|
||||||
BeanUtils.copyProperties(foodRecordDto, foodRecord);
|
BeanUtils.copyProperties(recordDto, record);
|
||||||
foodRecordMapper.insert(foodRecord);
|
recordMapper.insert(record);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateFoodRecord(Long id, FoodRecordDto foodRecordDto) {
|
public Boolean updateRecord(Long id, RecordDto recordDto) {
|
||||||
if (foodRecordMapper.selectById(id) == null) {
|
if (recordMapper.selectById(id) == null) {
|
||||||
throw new CustomException("该成果不存在");
|
throw new CustomException("该成果不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
FoodRecord foodRecord = new FoodRecord();
|
Record record = new Record();
|
||||||
BeanUtils.copyProperties(foodRecordDto, foodRecord);
|
BeanUtils.copyProperties(recordDto, record);
|
||||||
foodRecord.setId(id);
|
record.setId(id);
|
||||||
foodRecordMapper.updateById(foodRecord);
|
recordMapper.updateById(record);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteFoodRecord(Long id) {
|
public Boolean deleteRecord(Long id) {
|
||||||
foodRecordMapper.deleteById(id);
|
recordMapper.deleteById(id);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetFoodRecipe(Long id, FoodRecipeDto foodRecipeDto) {
|
private void resetFoodRecipe(Long id, RecipeDto recipeDto) {
|
||||||
foodMaterialMapper.delete(Wrappers.lambdaQuery(FoodMaterial.class).eq(FoodMaterial::getFoodId, id));
|
materialMapper.delete(Wrappers.lambdaQuery(Material.class).eq(Material::getFoodId, id));
|
||||||
foodStepMapper.delete(Wrappers.lambdaQuery(FoodStep.class).eq(FoodStep::getFoodId, id));
|
stepMapper.delete(Wrappers.lambdaQuery(Step.class).eq(Step::getFoodId, id));
|
||||||
|
|
||||||
insertFoodMaterial(id, foodRecipeDto.getMaterialList());
|
insertMaterial(id, recipeDto.getMaterialList());
|
||||||
insertFoodStep(id, foodRecipeDto.getStepList());
|
insertStep(id, recipeDto.getStepList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertFoodMaterial(Long foodId, List<FoodMaterialDto> foodMaterialList) {
|
private void insertMaterial(Long foodId, List<MaterialDto> materialDtoList) {
|
||||||
if (foodMaterialList.isEmpty()) {
|
if (materialDtoList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foodMaterialList.forEach((item) -> {
|
materialDtoList.forEach((item) -> {
|
||||||
item.setId(YitIdHelper.nextId());
|
item.setId(YitIdHelper.nextId());
|
||||||
});
|
});
|
||||||
foodDao.insertFoodMaterial(foodId, foodMaterialList);
|
foodDao.insertMaterial(foodId, materialDtoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertFoodStep(Long foodId, List<FoodStepDto> foodStepList) {
|
private void insertStep(Long foodId, List<StepDto> stepDtoList) {
|
||||||
if (foodStepList.isEmpty()) {
|
if (stepDtoList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foodStepList.forEach((item) -> {
|
stepDtoList.forEach((item) -> {
|
||||||
item.setId(YitIdHelper.nextId());
|
item.setId(YitIdHelper.nextId());
|
||||||
});
|
});
|
||||||
foodDao.insertFoodStep(foodId, foodStepList);
|
foodDao.insertStep(foodId, stepDtoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FoodRecipeDto queryFoodRecipe(Long id) {
|
public RecipeDto queryRecipe(Long id) {
|
||||||
if (foodRecipeMapper.selectById(id) == null) {
|
if (recipeMapper.selectById(id) == null) {
|
||||||
throw new CustomException("该美食不存在");
|
throw new CustomException("该美食不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
return foodDao.queryFoodRecipe(id);
|
return foodDao.queryRecipe(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FoodSummaryDto> queryFoodSummary(FoodQueryVo foodQueryVo) {
|
public List<SummaryDto> querySummary(FoodQueryVo foodQueryVo) {
|
||||||
return foodDao.queryFoodSummary(foodQueryVo);
|
return foodDao.querySummary(foodQueryVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<FoodSummaryDto> queryFoodSummaryByPage(Integer currentPage, Integer pageSize, FoodQueryVo foodQueryVo) {
|
public IPage<SummaryDto> querySummaryByPage(Integer currentPage, Integer pageSize, FoodQueryVo foodQueryVo) {
|
||||||
// 这里只能先对主表进行分页 然后在查询子表信息
|
// 这里只能先对主表进行分页 然后在查询子表信息
|
||||||
// 不能使用Left Join关联表查询,因为这里是一对多数据,关联查询会导致数据有重复
|
// 不能使用Left Join关联表查询,因为这里是一对多数据,关联查询会导致数据有重复
|
||||||
// 从而导致page计算错误(会把重复的数据当成多条记录,实际上只有1条记录)
|
// 从而导致page计算错误(会把重复的数据当成多条记录,实际上只有1条记录)
|
||||||
IPage<FoodSummaryDto> foodSummaryPage = foodDao.queryFoodSummaryByPage(new Page<>(currentPage, pageSize), foodQueryVo);
|
IPage<SummaryDto> summaryPage = foodDao.querySummaryByPage(new Page<>(currentPage, pageSize), foodQueryVo);
|
||||||
List<FoodSummaryDto> foodSummaryList = foodSummaryPage.getRecords();
|
List<SummaryDto> summaryList = summaryPage.getRecords();
|
||||||
for (FoodSummaryDto foodSummary : foodSummaryList) {
|
for (SummaryDto foodSummary : summaryList) {
|
||||||
foodSummary.setRecordList(foodDao.queryFoodRecordById(foodSummary.getId()));
|
foodSummary.setRecordList(foodDao.queryRecordById(foodSummary.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
foodSummaryPage.setRecords(foodSummaryList);
|
summaryPage.setRecords(summaryList);
|
||||||
return foodSummaryPage;
|
return summaryPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FoodRecordDto> queryFoodRecord(String startDate, String endDate) {
|
public List<RecordDto> queryRecord(String startDate, String endDate) {
|
||||||
return foodDao.queryFoodRecord(startDate, endDate);
|
return foodDao.queryRecord(startDate, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> queryFoodName() {
|
public List<String> queryFoodName() {
|
||||||
return foodRecipeMapper.selectList(null)
|
return recipeMapper.selectList(null)
|
||||||
.stream().map(FoodRecipe::getName).collect(Collectors.toList());
|
.stream().map(Recipe::getName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> queryFoodCategory() {
|
public List<String> queryCategory() {
|
||||||
return foodDao.queryFoodCategory();
|
return foodDao.queryCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FoodStatsDto queryFoodStats() {
|
public StatsDto queryStats() {
|
||||||
return foodDao.queryFoodStats();
|
return foodDao.queryStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StatsChartDto> queryFoodRecordStats() {
|
public List<StatsChartDto> queryRecordStats() {
|
||||||
return foodDao.queryFoodRecordStats();
|
return foodDao.queryRecordStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StatsChartDto> queryFoodCategoryStats() {
|
public List<StatsChartDto> queryCategoryStats() {
|
||||||
return foodDao.queryFoodCategoryStats();
|
return foodDao.queryCategoryStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StatsChartDto> queryFoodRankStats() {
|
public List<StatsChartDto> queryRankStats() {
|
||||||
return foodDao.queryFoodRankStats();
|
return foodDao.queryRankStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.cxx.food.service.impl;
|
||||||
|
|
||||||
|
import com.cxx.food.dao.MomentDao;
|
||||||
|
import com.cxx.food.dto.CommentDto;
|
||||||
|
import com.cxx.food.dto.MomentDto;
|
||||||
|
import com.cxx.food.entity.Comment;
|
||||||
|
import com.cxx.food.entity.Moment;
|
||||||
|
import com.cxx.food.mapper.CommentMapper;
|
||||||
|
import com.cxx.food.mapper.MomentMapper;
|
||||||
|
import com.cxx.food.service.MomentService;
|
||||||
|
import com.cxx.framework.web.CustomException;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MomentServiceImpl implements MomentService {
|
||||||
|
@Resource
|
||||||
|
private MomentDao momentDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MomentMapper momentMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommentMapper commentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean addMoment(MomentDto momentDto) {
|
||||||
|
Moment moment = new Moment();
|
||||||
|
BeanUtils.copyProperties(momentDto, moment);
|
||||||
|
return momentMapper.insert(moment) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MomentDto> queryMoment() {
|
||||||
|
// TODO 只能查询好友的朋友圈
|
||||||
|
return momentDao.queryMoment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean addComment(Long momentId, CommentDto commentDto) {
|
||||||
|
if (momentMapper.selectById(momentId) == null) {
|
||||||
|
throw new CustomException("该朋友圈不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Comment comment = new Comment();
|
||||||
|
BeanUtils.copyProperties(commentDto, comment);
|
||||||
|
comment.setMomentId(momentId);
|
||||||
|
return commentMapper.insert(comment) == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ public class SessionServiceImpl implements SessionService {
|
|||||||
@Override
|
@Override
|
||||||
public SessionDto create(String name, String password) {
|
public SessionDto create(String name, String password) {
|
||||||
SessionDto sessionDto = new SessionDto();
|
SessionDto sessionDto = new SessionDto();
|
||||||
StpUtil.login(name);
|
StpUtil.login(645808454946885L);
|
||||||
sessionDto.setSaToken(StpUtil.getTokenInfo());
|
sessionDto.setSaToken(StpUtil.getTokenInfo());
|
||||||
|
|
||||||
return sessionDto;
|
return sessionDto;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ spring:
|
|||||||
name: @project.artifactId@
|
name: @project.artifactId@
|
||||||
version: @project.version@
|
version: @project.version@
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: prod
|
||||||
|
|
||||||
# mybatis plus mapper路径
|
# mybatis plus mapper路径
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
|||||||
@@ -1,50 +1,50 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cxx.food.dao.FoodDao">
|
<mapper namespace="com.cxx.food.dao.FoodDao">
|
||||||
<resultMap id="foodRecipeResultMap" type="com.cxx.food.dto.FoodRecipeDto">
|
<resultMap id="foodRecipeResultMap" type="com.cxx.food.dto.RecipeDto">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="name" column="name"/>
|
<result property="name" column="name"/>
|
||||||
<result property="category" column="category"/>
|
<result property="category" column="category"/>
|
||||||
<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.FoodMaterialDto"
|
<collection property="materialList" ofType="com.cxx.food.dto.MaterialDto"
|
||||||
column="id" select="queryFoodMaterial">
|
column="id" select="queryFoodMaterial">
|
||||||
</collection>
|
</collection>
|
||||||
<collection property="stepList" ofType="com.cxx.food.dto.FoodStepDto"
|
<collection property="stepList" ofType="com.cxx.food.dto.StepDto"
|
||||||
column="id" select="queryFoodStep">
|
column="id" select="queryFoodStep">
|
||||||
</collection>
|
</collection>
|
||||||
<collection property="recordList" ofType="com.cxx.food.dto.FoodRecordDto"
|
<collection property="recordList" ofType="com.cxx.food.dto.RecordDto"
|
||||||
column="id" select="queryFoodRecordById">
|
column="id" select="queryFoodRecordById">
|
||||||
</collection>
|
</collection>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="foodMaterialResultMap" type="com.cxx.food.dto.FoodMaterialDto">
|
<resultMap id="foodMaterialResultMap" type="com.cxx.food.dto.MaterialDto">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="type" column="type"/>
|
<result property="type" column="type"/>
|
||||||
<result property="name" column="name"/>
|
<result property="name" column="name"/>
|
||||||
<result property="amount" column="amount"/>
|
<result property="amount" column="amount"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="foodStepResultMap" type="com.cxx.food.dto.FoodStepDto">
|
<resultMap id="foodStepResultMap" type="com.cxx.food.dto.StepDto">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="sort" column="sort"/>
|
<result property="sort" column="sort"/>
|
||||||
<result property="content" column="content"/>
|
<result property="content" column="content"/>
|
||||||
<result property="imageUrl" column="imageUrl"/>
|
<result property="imageUrl" column="imageUrl"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="foodRecordResultMap" type="com.cxx.food.dto.FoodRecordDto">
|
<resultMap id="foodRecordResultMap" type="com.cxx.food.dto.RecordDto">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="person" column="person"/>
|
<result property="person" column="person"/>
|
||||||
<result property="date" column="date"/>
|
<result property="date" column="date"/>
|
||||||
<result property="imageUrl" column="imageUrl"/>
|
<result property="imageUrl" column="imageUrl"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="foodSummaryResultMap" type="com.cxx.food.dto.FoodSummaryDto">
|
<resultMap id="foodSummaryResultMap" type="com.cxx.food.dto.SummaryDto">
|
||||||
<id property="id" column="id"/>
|
<id property="id" column="id"/>
|
||||||
<result property="name" column="name"/>
|
<result property="name" column="name"/>
|
||||||
<result property="category" column="category"/>
|
<result property="category" column="category"/>
|
||||||
<result property="recommendRate" column="recommendRate"/>
|
<result property="recommendRate" column="recommendRate"/>
|
||||||
<collection property="recordList" ofType="com.cxx.food.dto.FoodRecordDto">
|
<collection property="recordList" ofType="com.cxx.food.dto.RecordDto">
|
||||||
<id property="id" column="workId"/>
|
<id property="id" column="workId"/>
|
||||||
<result property="person" column="person"/>
|
<result property="person" column="person"/>
|
||||||
<result property="date" column="recordDate"/>
|
<result property="date" column="recordDate"/>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
type AS type,
|
type AS type,
|
||||||
name AS name,
|
name AS name,
|
||||||
amount AS amount
|
amount AS amount
|
||||||
FROM food_material
|
FROM material
|
||||||
WHERE food_id = #{id}
|
WHERE food_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -66,51 +66,51 @@
|
|||||||
sort AS sort,
|
sort AS sort,
|
||||||
content AS content,
|
content AS content,
|
||||||
image_url AS imageUrl
|
image_url AS imageUrl
|
||||||
FROM food_step
|
FROM step
|
||||||
WHERE food_id = #{id}
|
WHERE food_id = #{id}
|
||||||
ORDER BY sort
|
ORDER BY sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodRecordById" resultMap="foodRecordResultMap">
|
<select id="queryRecordById" resultMap="foodRecordResultMap">
|
||||||
SELECT id AS id,
|
SELECT id AS id,
|
||||||
person AS person,
|
person AS person,
|
||||||
date AS date,
|
date AS date,
|
||||||
image_url AS imageUrl
|
image_url AS imageUrl
|
||||||
FROM food_record
|
FROM record
|
||||||
WHERE food_id = #{id}
|
WHERE food_id = #{id}
|
||||||
ORDER BY date DESC
|
ORDER BY date DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodRecord" resultType="com.cxx.food.dto.FoodRecordDto">
|
<select id="queryRecord" resultType="com.cxx.food.dto.RecordDto">
|
||||||
SELECT a.id AS id,
|
SELECT a.id AS id,
|
||||||
b.name AS name,
|
b.name AS name,
|
||||||
b.category AS category,
|
b.category AS category,
|
||||||
a.person AS person,
|
a.person AS person,
|
||||||
a.date AS date,
|
a.date AS date,
|
||||||
a.image_url AS imageUrl
|
a.image_url AS imageUrl
|
||||||
FROM food_record AS a
|
FROM record AS a
|
||||||
LEFT JOIN food_recipe AS b ON a.food_id = b.id
|
LEFT JOIN recipe AS b ON a.food_id = b.id
|
||||||
WHERE a.date <![CDATA[ >=]]> STR_TO_DATE(#{startDate}, '%Y-%m-%d')
|
WHERE a.date <![CDATA[ >=]]> STR_TO_DATE(#{startDate}, '%Y-%m-%d')
|
||||||
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{endDate}, '%Y-%m-%d')
|
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{endDate}, '%Y-%m-%d')
|
||||||
ORDER BY date DESC
|
ORDER BY date DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodRecipe" resultMap="foodRecipeResultMap">
|
<select id="queryRecipe" resultMap="foodRecipeResultMap">
|
||||||
SELECT a.id AS id,
|
SELECT a.id AS id,
|
||||||
a.name AS name,
|
a.name AS name,
|
||||||
a.category AS category,
|
a.category AS category,
|
||||||
a.recommend_rate AS recommendRate,
|
a.recommend_rate AS recommendRate,
|
||||||
a.remark AS remake
|
a.remark AS remake
|
||||||
FROM food_recipe a
|
FROM recipe a
|
||||||
WHERE a.id = #{id}
|
WHERE a.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodSummaryByPage" resultMap="foodSummaryResultMap">
|
<select id="querySummaryByPage" resultMap="foodSummaryResultMap">
|
||||||
SELECT a.id AS id,
|
SELECT a.id AS id,
|
||||||
a.name AS name,
|
a.name AS name,
|
||||||
a.category AS category,
|
a.category AS category,
|
||||||
a.recommend_rate AS recommendRate
|
a.recommend_rate AS recommendRate
|
||||||
FROM food_recipe a
|
FROM recipe a
|
||||||
<where>
|
<where>
|
||||||
<if test="query.category != null and query.category != ''">
|
<if test="query.category != null and query.category != ''">
|
||||||
a.category = #{query.category}
|
a.category = #{query.category}
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodSummary" resultMap="foodSummaryResultMap">
|
<select id="querySummary" resultMap="foodSummaryResultMap">
|
||||||
SELECT a.id AS id,
|
SELECT a.id AS id,
|
||||||
a.name AS name,
|
a.name AS name,
|
||||||
a.category AS category,
|
a.category AS category,
|
||||||
@@ -126,8 +126,8 @@
|
|||||||
b.person AS person,
|
b.person AS person,
|
||||||
b.date AS recordDate,
|
b.date AS recordDate,
|
||||||
b.image_url AS workImageUrl
|
b.image_url AS workImageUrl
|
||||||
FROM food_recipe a
|
FROM recipe a
|
||||||
LEFT JOIN food_record b ON a.id = b.food_id
|
LEFT JOIN record b ON a.id = b.food_id
|
||||||
<where>
|
<where>
|
||||||
<if test="query.category != null and query.category != ''">
|
<if test="query.category != null and query.category != ''">
|
||||||
a.category = #{query.category}
|
a.category = #{query.category}
|
||||||
@@ -135,54 +135,54 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodStats" resultType="com.cxx.food.dto.FoodStatsDto">
|
<select id="queryStats" resultType="com.cxx.food.dto.StatsDto">
|
||||||
SELECT COUNT(DISTINCT a.name) AS recipeCount,
|
SELECT COUNT(DISTINCT a.name) AS recipeCount,
|
||||||
COUNT(DISTINCT a.category) AS categoryCount,
|
COUNT(DISTINCT a.category) AS categoryCount,
|
||||||
COUNT(b.id) AS workCount
|
COUNT(b.id) AS workCount
|
||||||
FROM food_recipe a
|
FROM recipe a
|
||||||
LEFT JOIN food_record b ON a.id = b.food_id
|
LEFT JOIN record b ON a.id = b.food_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodRecordStats" resultType="com.cxx.food.dto.StatsChartDto">
|
<select id="queryRecordStats" resultType="com.cxx.food.dto.StatsChartDto">
|
||||||
SELECT DATE_FORMAT(date, '%Y-%m') AS name,
|
SELECT DATE_FORMAT(date, '%Y-%m') AS name,
|
||||||
COUNT(id) AS value
|
COUNT(id) AS value
|
||||||
FROM food_record
|
FROM record
|
||||||
GROUP BY DATE_FORMAT(date, '%Y-%m')
|
GROUP BY DATE_FORMAT(date, '%Y-%m')
|
||||||
ORDER BY name DESC;
|
ORDER BY name DESC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodCategoryStats" resultType="com.cxx.food.dto.StatsChartDto">
|
<select id="queryCategoryStats" resultType="com.cxx.food.dto.StatsChartDto">
|
||||||
SELECT category AS name,
|
SELECT category AS name,
|
||||||
COUNT(id) AS value
|
COUNT(id) AS value
|
||||||
FROM food_recipe
|
FROM recipe
|
||||||
GROUP BY category
|
GROUP BY category
|
||||||
ORDER BY value DESC;
|
ORDER BY value DESC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodRankStats" resultType="com.cxx.food.dto.StatsChartDto">
|
<select id="queryRankStats" resultType="com.cxx.food.dto.StatsChartDto">
|
||||||
SELECT a.name AS name,
|
SELECT a.name AS name,
|
||||||
COUNT(b.id) AS value
|
COUNT(b.id) AS value
|
||||||
FROM food_recipe a
|
FROM recipe a
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
food_record b ON a.id = b.food_id
|
record b ON a.id = b.food_id
|
||||||
GROUP BY a.id, a.name
|
GROUP BY a.id, a.name
|
||||||
ORDER BY value DESC;
|
ORDER BY value DESC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryFoodCategory" resultType="string">
|
<select id="queryCategory" resultType="string">
|
||||||
SELECT DISTINCT a.category AS category
|
SELECT DISTINCT a.category AS category
|
||||||
FROM food_recipe a
|
FROM recipe a
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertFoodMaterial">
|
<insert id="insertMaterial">
|
||||||
INSERT INTO food_material (id, food_id, type, name, amount) VALUES
|
INSERT INTO material (id, food_id, type, name, amount) VALUES
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id}, #{foodId}, #{item.type}, #{item.name}, #{item.amount})
|
(#{item.id}, #{foodId}, #{item.type}, #{item.name}, #{item.amount})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertFoodStep">
|
<insert id="insertStep">
|
||||||
INSERT INTO food_step (id, food_id, sort, content, image_url) VALUES
|
INSERT INTO step (id, food_id, sort, content, image_url) VALUES
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id}, #{foodId}, #{item.sort}, #{item.content}, #{item.imageUrl})
|
(#{item.id}, #{foodId}, #{item.sort}, #{item.content}, #{item.imageUrl})
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|||||||
43
src/main/resources/mapper/MomentMapper.xml
Normal file
43
src/main/resources/mapper/MomentMapper.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cxx.food.dao.MomentDao">
|
||||||
|
<resultMap id="momentResultMap" type="com.cxx.food.dto.MomentDto">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="username" column="username"/>
|
||||||
|
<result property="avatar" column="avatar"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
<result property="date" column="date"/>
|
||||||
|
<collection property="commentList" ofType="com.cxx.food.dto.CommentDto"
|
||||||
|
column="id" select="queryComment">
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="commentResultMap" type="com.cxx.food.dto.CommentDto">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="username" column="username"/>
|
||||||
|
<result property="avatar" column="avatar"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
<result property="date" column="date"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="queryComment" resultMap="commentResultMap">
|
||||||
|
SELECT a.id AS id,
|
||||||
|
b.username AS username,
|
||||||
|
b.avatar AS avatar,
|
||||||
|
a.content AS content,
|
||||||
|
a.create_time AS date
|
||||||
|
FROM comment AS a
|
||||||
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
|
WHERE moment_id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryMoment" resultMap="momentResultMap">
|
||||||
|
SELECT a.id AS id,
|
||||||
|
b.username AS username,
|
||||||
|
b.avatar AS avatar,
|
||||||
|
a.content AS content,
|
||||||
|
a.create_time AS date
|
||||||
|
FROM moment AS a
|
||||||
|
LEFT JOIN user AS b ON a.create_by = b.id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user