评论及敏感词管理

pull/1/MERGE
chenyuepan 2 months ago
parent eb1aa6d0fd
commit 75cff39e5e

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -24,6 +25,7 @@ import java.util.TimeZone;
@EnableScheduling // 启用调度功能 @EnableScheduling // 启用调度功能
@EnableAsync @EnableAsync
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) @SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
@MapperScan({"com.example.venue_reservation_service.mapper"})
public class VenueReservationServiceApplication { public class VenueReservationServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {

@ -0,0 +1,24 @@
package com.example.venue_reservation_service.config;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.format.DateTimeFormatter;
@Configuration
public class DateTimeConfig {
@Value("${spring.jackson.date-format}") // 支持配置文件覆盖
private String pattern;
@Bean
public LocalDateTimeSerializer localDateTimeSerializer() {
return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern));
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jacksonCustomizer() {
return builder -> builder.serializers(localDateTimeSerializer());
}
}

@ -41,5 +41,4 @@ public class MinioConfig {
.build(); .build();
} }
} }

@ -0,0 +1,26 @@
package com.example.venue_reservation_service.controller;
import com.example.venue_reservation_service.domain.Comment;
import com.example.venue_reservation_service.service.CommentService;
import com.example.venue_reservation_service.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/comment")
@CrossOrigin
@Api("用户评论管理")
public class CommentController {
@Autowired
private CommentService commentService;
@ApiOperation("发布评论")
@PostMapping("/create")
public Result create(@RequestBody Comment comment){
return null;
}
}

@ -0,0 +1,14 @@
package com.example.venue_reservation_service.controller;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/word")
@CrossOrigin
@Api("敏感词管理")
public class WordController {
}

@ -0,0 +1,59 @@
package com.example.venue_reservation_service.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
*
* @TableName venue_comment
*/
@TableName(value ="venue_comment")
@Data
public class Comment implements Serializable {
/**
*
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* ID
*/
private Integer userId;
/**
*
*/
private String content;
/**
* 012
*/
private String status;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,85 @@
package com.example.venue_reservation_service.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName venue_user_like
*/
@TableName(value ="venue_user_like")
@Data
public class UserLike implements Serializable {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* ID
*/
private Integer userId;
/**
* ID
*/
private Integer commentId;
/**
*
*/
private Date createTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
UserLike other = (UserLike) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCommentId() == null ? other.getCommentId() == null : this.getCommentId().equals(other.getCommentId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCommentId() == null) ? 0 : getCommentId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", commentId=").append(commentId);
sb.append(", createTime=").append(createTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,85 @@
package com.example.venue_reservation_service.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName venue_word
*/
@TableName(value ="venue_word")
@Data
public class Word implements Serializable {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
*
*/
private String word;
/**
* 1-2-
*/
private String level;
/**
*
*/
private Date createTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
Word other = (Word) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getWord() == null ? other.getWord() == null : this.getWord().equals(other.getWord()))
&& (this.getLevel() == null ? other.getLevel() == null : this.getLevel().equals(other.getLevel()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getWord() == null) ? 0 : getWord().hashCode());
result = prime * result + ((getLevel() == null) ? 0 : getLevel().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", word=").append(word);
sb.append(", level=").append(level);
sb.append(", createTime=").append(createTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,18 @@
package com.example.venue_reservation_service.mapper;
import com.example.venue_reservation_service.domain.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 31586
* @description venue_comment()Mapper
* @createDate 2025-06-03 15:00:23
* @Entity generator.domain.Comment
*/
public interface CommentMapper extends BaseMapper<Comment> {
}

@ -0,0 +1,18 @@
package com.example.venue_reservation_service.mapper;
import com.example.venue_reservation_service.domain.UserLike;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 31586
* @description venue_user_like()Mapper
* @createDate 2025-06-03 15:00:23
* @Entity generator.domain.UserLike
*/
public interface UserLikeMapper extends BaseMapper<UserLike> {
}

@ -0,0 +1,18 @@
package com.example.venue_reservation_service.mapper;
import com.example.venue_reservation_service.domain.Word;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 31586
* @description venue_word()Mapper
* @createDate 2025-06-03 15:00:23
* @Entity generator.domain.Word
*/
public interface WordMapper extends BaseMapper<Word> {
}

@ -0,0 +1,16 @@
package com.example.venue_reservation_service.service;
import com.example.venue_reservation_service.domain.Comment;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.venue_reservation_service.vo.Result;
/**
* @author 31586
* @description venue_comment()Service
* @createDate 2025-06-03 15:00:23
*/
public interface CommentService extends IService<Comment> {
Result createComment(Comment comment);
}

@ -0,0 +1,13 @@
package com.example.venue_reservation_service.service;
import com.example.venue_reservation_service.domain.UserLike;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 31586
* @description venue_user_like()Service
* @createDate 2025-06-03 15:00:23
*/
public interface UserLikeService extends IService<UserLike> {
}

@ -0,0 +1,13 @@
package com.example.venue_reservation_service.service;
import com.example.venue_reservation_service.domain.Word;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 31586
* @description venue_word()Service
* @createDate 2025-06-03 15:00:23
*/
public interface WordService extends IService<Word> {
}

@ -0,0 +1,33 @@
package com.example.venue_reservation_service.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.venue_reservation_service.domain.Comment;
import com.example.venue_reservation_service.mapper.CommentMapper;
import com.example.venue_reservation_service.service.CommentService;
import com.example.venue_reservation_service.vo.Result;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* @author 31586
* @description venue_comment()Service
* @createDate 2025-06-03 15:00:23
*/
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>
implements CommentService{
@Override
public Result createComment(Comment comment) {
// TODO 对敏感词进行脱敏处理 --
comment.setCreateTime(LocalDateTime.now());
comment.setUpdateTime(LocalDateTime.now());
// TODO 保存评论记录
return null;
}
}

@ -0,0 +1,22 @@
package com.example.venue_reservation_service.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.venue_reservation_service.domain.UserLike;
import com.example.venue_reservation_service.mapper.UserLikeMapper;
import com.example.venue_reservation_service.service.UserLikeService;
import org.springframework.stereotype.Service;
/**
* @author 31586
* @description venue_user_like()Service
* @createDate 2025-06-03 15:00:23
*/
@Service
public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike>
implements UserLikeService{
}

@ -48,9 +48,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
@Resource @Resource
private RestTemplate restTemplate; private RestTemplate restTemplate;
private final String APP_ID = "wxce0025f2c0b10a8e"; @Value("${weixin.app_id}")
private String APP_ID;
private final String SECRET = "686870f1b1a875369ee979e0648fa950"; @Value("${weixin.secret}")
private String SECRET;
@Resource @Resource
private SchoolService schoolService; private SchoolService schoolService;

@ -0,0 +1,22 @@
package com.example.venue_reservation_service.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.venue_reservation_service.domain.Word;
import com.example.venue_reservation_service.service.WordService;
import com.example.venue_reservation_service.mapper.WordMapper;
import org.springframework.stereotype.Service;
/**
* @author 31586
* @description venue_word()Service
* @createDate 2025-06-03 15:00:23
*/
@Service
public class WordServiceImpl extends ServiceImpl<WordMapper, Word>
implements WordService{
}

@ -31,11 +31,16 @@ spring:
max-wait: -1 max-wait: -1
max-idle: 5 max-idle: 5
min-idle: 0 min-idle: 0
jackson:
date-format: yyyy-MM-dd HH:mm:ss
weixin:
app_id: wxce0025f2c0b10a8e
secret: 686870f1b1a875369ee979e0648fa950
mybatis-plus: mybatis-plus:
configuration: configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:/mapper/*.xml
minio: minio:
host: http://${localhosturl}:9000 host: http://${localhosturl}:9000
# access-key: admin # access-key: admin

@ -0,0 +1,20 @@
<?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.example.venue_reservation_service.mapper.CommentMapper">
<resultMap id="BaseResultMap" type="com.example.venue_reservation_service.domain.Comment">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="CHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,user_id,content,
status,create_time,update_time
</sql>
</mapper>

@ -0,0 +1,18 @@
<?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.example.venue_reservation_service.mapper.UserLikeMapper">
<resultMap id="BaseResultMap" type="com.example.venue_reservation_service.domain.UserLike">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="commentId" column="comment_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,user_id,comment_id,
create_time
</sql>
</mapper>

@ -0,0 +1,18 @@
<?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.example.venue_reservation_service.mapper.WordMapper">
<resultMap id="BaseResultMap" type="com.example.venue_reservation_service.domain.Word">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="word" column="word" jdbcType="VARCHAR"/>
<result property="level" column="level" jdbcType="CHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,word,level,
create_time
</sql>
</mapper>
Loading…
Cancel
Save