Compare commits

...

10 Commits

Author SHA1 Message Date
dc18d77c00 feat:更新配置文件 2025-10-16 22:06:59 +08:00
2e4c1046a0 feat:增加Docker部署 2025-10-16 17:41:16 +08:00
6ccc3911a8 Merge branch 'master' of https://gitee.com/Cxx0822/food-hub-service 2025-07-31 22:27:35 +08:00
76379aab18 feat:删除日志 2025-07-31 22:27:17 +08:00
3ca59c36f1 fix:修复remark拼写错误 2025-07-31 22:26:41 +08:00
e47a7a8510 feat:增加分页查询朋友圈功能 2025-07-24 14:02:05 +08:00
9dd7b4e146 fix:修复查询为null的问题 2025-07-23 19:33:55 +08:00
e34a2ccae7 feat:更新朋友圈排序规则 2025-07-18 17:16:44 +08:00
dcc3ca38a7 feat:更新菜谱mysql语句 2025-07-16 20:00:37 +08:00
2c3fa19cbb feat:删除日志 2025-07-11 17:00:57 +08:00
18 changed files with 172 additions and 95 deletions

6
Dockerfile Normal file
View File

@@ -0,0 +1,6 @@
FROM openjdk:17-jdk
ARG JAR_FILE=target/*.jar
COPY $JAR_FILE app.jar
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' > /etc/timezone
ENTRYPOINT ["java","-jar","/app.jar"]

View File

@@ -1,29 +0,0 @@
2025-07-11 16:54:01 |INFO |background-preinit |Version.java:21 |org.hibernate.validator.internal.util.Version |HV000001: Hibernate Validator 8.0.2.Final
2025-07-11 16:54:01 |INFO |main |StartupInfoLogger.java:53 |com.cxx.food.FoodHubServiceApplication |Starting FoodHubServiceApplication v0.0.1 using Java 17.0.12 with PID 30460 (D:\Cxx\GitHubProjects\food-hub-service\target\classes started by chenxiuxiang in D:\Cxx\GitHubProjects\food-hub-service)
2025-07-11 16:54:01 |INFO |main |SpringApplication.java:658 |com.cxx.food.FoodHubServiceApplication |The following 1 profile is active: "prod"
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.dao.FoodDao
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/FoodDao.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.dao.MomentDao
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/MomentDao.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.CommentRecordMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/CommentRecordMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.FavouriteRecordMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/FavouriteRecordMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.FileRecordMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/FileRecordMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.LikeRecordMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/LikeRecordMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.MaterialMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/MaterialMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.MomentImageMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/MomentImageMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.MomentMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/MomentMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.RecipeMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/RecipeMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.RecordMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/RecordMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.StepMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/StepMapper.xml
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:204 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper interface: com.cxx.food.mapper.UserMapper
2025-07-11 16:54:04 |INFO |main |MyBatisNativeConfiguration.java:210 |com.cxx.autoconfigure.data.MyBatisNativeConfiguration$MyBatisBeanFactoryInitializationAotProcessor |Registering MyBatis mapper xml: mapper/UserMapper.xml

View File

@@ -11,9 +11,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
@Value("${file.path}") @Value("${file.path}")
private String filePath; private String filePath;
@Value("${file.log-path}")
private String logFilePath;
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/" + FileConstant.FILE_URL_PREFIX + "/**") registry.addResourceHandler("/" + FileConstant.FILE_URL_PREFIX + "/**")

View File

@@ -1,5 +1,6 @@
package com.cxx.food.controller; package com.cxx.food.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cxx.food.dto.*; import com.cxx.food.dto.*;
import com.cxx.food.service.MomentService; import com.cxx.food.service.MomentService;
import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.annotation.JsonView;
@@ -43,6 +44,13 @@ public class MomentController {
return momentService.queryMomentList(); return momentService.queryMomentList();
} }
@Operation(summary = "分页查询所有朋友圈")
@GetMapping("/page")
public IPage<MomentDto> queryMomentByPage(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize) {
return momentService.queryMomentByPage(currentPage, pageSize);
}
@Operation(summary = "查询朋友圈") @Operation(summary = "查询朋友圈")
@GetMapping("/{id}") @GetMapping("/{id}")
public @JsonView(ReadView.class) List<MomentDto> queryMomentById(@PathVariable("id") long id) { public @JsonView(ReadView.class) List<MomentDto> queryMomentById(@PathVariable("id") long id) {

View File

@@ -10,7 +10,7 @@ import java.util.List;
@Mapper @Mapper
public interface FoodDao { public interface FoodDao {
RecipeDto queryRecipe(@Param("id") Long id); RecipeDto queryRecipeById(@Param("id") Long id);
List<SummaryDto> queryRecipeByUser(@Param("id") Long id); List<SummaryDto> queryRecipeByUser(@Param("id") Long id);

View File

@@ -1,5 +1,7 @@
package com.cxx.food.dao; package com.cxx.food.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cxx.food.dto.*; import com.cxx.food.dto.*;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -10,6 +12,8 @@ import java.util.List;
public interface MomentDao { public interface MomentDao {
List<MomentDto> queryMomentList(); List<MomentDto> queryMomentList();
IPage<MomentDto> queryMomentByPage(Page<MomentDto> page);
List<MomentDto> queryMomentById(@Param("id") Long id); List<MomentDto> queryMomentById(@Param("id") Long id);
void insertMomentImage(@Param("momentId") Long momentId, void insertMomentImage(@Param("momentId") Long momentId,

View File

@@ -0,0 +1,41 @@
package com.cxx.food.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import java.util.List;
@Getter
@Setter
public class MomentPageDto {
@Schema(description = "id")
private Long id;
@Schema(description = "用户id")
private Long userId;
@Schema(description = "姓名")
private String username;
@Schema(description = "头像")
private String avatar;
@Schema(description = "朋友圈内容")
private String content;
@Schema(description = "朋友圈图片")
private List<String> imageList;
@Schema(description = "时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date date;
@Schema(description = "点赞用户")
private List<Long> likeList;
@Schema(description = "评论内容")
private List<CommentDto> commentList;
}

View File

@@ -1,6 +1,7 @@
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 java.util.List; import java.util.List;
@@ -14,6 +15,8 @@ public interface MomentService {
List<MomentDto> queryMomentList(); List<MomentDto> queryMomentList();
IPage<MomentDto> queryMomentByPage(int currentPage, int pageSize);
List<MomentDto> queryMomentById(Long id); List<MomentDto> queryMomentById(Long id);
Boolean addComment(Long momentId, String content); Boolean addComment(Long momentId, String content);

View File

@@ -220,7 +220,7 @@ public class FoodServiceImpl implements FoodService {
throw new CustomException("该美食不存在"); throw new CustomException("该美食不存在");
} }
return foodDao.queryRecipe(id); return foodDao.queryRecipeById(id);
} }
@Override @Override

View File

@@ -1,6 +1,8 @@
package com.cxx.food.service.impl; package com.cxx.food.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cxx.food.constant.BizType; import com.cxx.food.constant.BizType;
import com.cxx.food.dao.MomentDao; import com.cxx.food.dao.MomentDao;
import com.cxx.food.dto.MomentDto; import com.cxx.food.dto.MomentDto;
@@ -74,6 +76,12 @@ public class MomentServiceImpl implements MomentService {
return momentDao.queryMomentList(); return momentDao.queryMomentList();
} }
@Override
public IPage<MomentDto> queryMomentByPage(int currentPage, int pageSize) {
Page<MomentDto> page = new Page<>(currentPage, pageSize);
return momentDao.queryMomentByPage(page);
}
@Override @Override
public List<MomentDto> queryMomentById(Long id) { public List<MomentDto> queryMomentById(Long id) {
return momentDao.queryMomentById(id); return momentDao.queryMomentById(id);

View File

@@ -7,4 +7,3 @@ spring:
file: file:
path: D:\\temp\\ path: D:\\temp\\
log-path: D:\\temp\\

View File

@@ -1,9 +1,14 @@
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/food_hub?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false url: jdbc:mysql://host.docker.internal:3306/food_hub?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: docker username: root
password: 19940822Cxx password: 19940822Cxx@1213
file: file:
path: /upload-file/ path: /upload-file/
logging:
fluentd:
host: host.docker.internal
port: 24224

View File

@@ -7,4 +7,3 @@ spring:
file: file:
path: /root/docker/upload-file/ path: /root/docker/upload-file/
log-path: /root/service/logs/

View File

@@ -1,12 +1,12 @@
server: server:
port: 8100 port: 8083
spring: spring:
application: application:
name: @project.artifactId@ name: @project.artifactId@
version: @project.version@ version: @project.version@
profiles: profiles:
active: dev active: docker
# mybatis plus mapper路径 # mybatis plus mapper路径
mybatis-plus: mybatis-plus:

View File

@@ -47,7 +47,7 @@
<resultMap id="foodRecordResultMap" type="com.cxx.food.dto.RecordDto"> <resultMap id="foodRecordResultMap" type="com.cxx.food.dto.RecordDto">
<id property="id" column="id"/> <id property="id" column="id"/>
<result property="name" column="person"/> <result property="name" column="name"/>
<result property="category" column="category"/> <result property="category" column="category"/>
<result property="person" column="person"/> <result property="person" column="person"/>
<result property="date" column="date"/> <result property="date" column="date"/>
@@ -67,7 +67,9 @@
<result property="favouriteCount" column="favouriteCount"/> <result property="favouriteCount" column="favouriteCount"/>
<result property="commentCount" column="commentCount"/> <result property="commentCount" column="commentCount"/>
<collection property="recordList" ofType="com.cxx.food.dto.RecordDto"> <collection property="recordList" ofType="com.cxx.food.dto.RecordDto">
<id property="id" column="workId"/> <id property="id" column="recordId"/>
<result property="name" column="name"/>
<result property="category" column="category"/>
<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"/>
@@ -128,11 +130,14 @@
</select> </select>
<select id="queryRecordById" resultMap="foodRecordResultMap"> <select id="queryRecordById" resultMap="foodRecordResultMap">
SELECT id AS id, SELECT a.id AS id,
person AS person, b.name AS name,
date AS date, b.category AS category,
image_url AS imageUrl a.person AS person,
FROM record a.date AS date,
a.image_url AS imageUrl
FROM record AS a
LEFT JOIN recipe AS b ON a.food_id = b.id
WHERE food_id = #{id} WHERE food_id = #{id}
ORDER BY date DESC ORDER BY date DESC
</select> </select>
@@ -152,12 +157,12 @@
ORDER BY date DESC ORDER BY date DESC
</select> </select>
<select id="queryRecipe" resultMap="foodRecipeResultMap"> <select id="queryRecipeById" 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 remark,
a.is_share AS isShare, a.is_share AS isShare,
b.id AS userId, b.id AS userId,
b.username AS username, b.username AS username,
@@ -172,9 +177,11 @@
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.is_share AS isShare,
u.id AS userId, u.id AS userId,
u.username AS username, u.username AS username,
u.avatar AS avatar, u.avatar AS avatar,
b.id AS recordId,
b.person AS person, b.person AS person,
b.date AS date, b.date AS date,
b.image_url AS imageUrl, b.image_url AS imageUrl,

View File

@@ -18,6 +18,23 @@
</collection> </collection>
</resultMap> </resultMap>
<resultMap id="momentPageResultMap" type="com.cxx.food.dto.MomentPageDto">
<id property="id" column="id"/>
<result property="userId" column="userId"/>
<result property="username" column="username"/>
<result property="avatar" column="avatar"/>
<result property="content" column="content"/>
<result property="date" column="date"/>
<collection property="imageList" ofType="java.lang.String"
column="id" select="queryMomentImage"/>
<collection property="likeList" ofType="long"
column="id" select="queryMomentLike">
</collection>
<collection property="commentList" ofType="com.cxx.food.dto.CommentDto"
column="id" select="queryMomentComment">
</collection>
</resultMap>
<resultMap id="commentResultMap" type="com.cxx.food.dto.CommentDto"> <resultMap id="commentResultMap" type="com.cxx.food.dto.CommentDto">
<id property="id" column="id"/> <id property="id" column="id"/>
<result property="username" column="username"/> <result property="username" column="username"/>
@@ -35,7 +52,7 @@
<select id="queryMomentComment" resultMap="commentResultMap"> <select id="queryMomentComment" resultMap="commentResultMap">
SELECT a.id AS id, SELECT a.id AS id,
b.username AS username, b.username AS username,
b.avatar AS avatar, COALESCE(b.avatar, '') AS avatar,
a.content AS content, a.content AS content,
a.create_time AS date a.create_time AS date
FROM comment_record AS a FROM comment_record AS a
@@ -48,25 +65,37 @@
SELECT a.id AS id, SELECT a.id AS id,
b.id AS userId, b.id AS userId,
b.username AS username, b.username AS username,
b.avatar AS avatar, COALESCE(b.avatar, '') AS avatar,
a.content AS content, a.content AS content,
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 ORDER BY a.create_time DESC
</select>
<select id="queryMomentByPage" resultMap="momentPageResultMap">
SELECT a.id AS id,
b.id AS userId,
b.username AS username,
COALESCE(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
ORDER BY a.create_time DESC
</select> </select>
<select id="queryMomentById" resultMap="momentResultMap"> <select id="queryMomentById" resultMap="momentResultMap">
SELECT a.id AS id, SELECT a.id AS id,
b.id AS userId, b.id AS userId,
b.username AS username, b.username AS username,
b.avatar AS avatar, COALESCE(b.avatar, '') AS avatar,
a.content AS content, a.content AS content,
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
WHERE a.create_by = #{id} WHERE a.create_by = #{id}
ORDER BY a.update_time DESC ORDER BY a.create_time DESC
</select> </select>
<select id="queryMomentImage" resultType="java.lang.String"> <select id="queryMomentImage" resultType="java.lang.String">