src/main/java/com/linghu/config/MybatisPlusConfig.java
@@ -1,24 +1,18 @@ package com.linghu.config; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.mybatis.spring.annotation.MapperScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration @MapperScan("com.linghu.mapper") public class MybatisPlusConfig { public class MyBatisPlusConfig { /** * 添加分页插件 */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加 // 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType // 添加分页插件,这里可指定数据库类型(如 MySQL),也可默认 interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); return interceptor; } } src/main/java/com/linghu/controller/KeywordController.java
@@ -10,6 +10,9 @@ import com.linghu.model.common.ResponseResult; import com.linghu.model.dto.ExportFeedDTO; import com.linghu.model.dto.ExportGetResultByPlatformIdDTO; import com.linghu.model.dto.ExportGetResultDTO; import com.linghu.model.dto.ExportStaticsDTO; import com.linghu.model.entity.Keyword; import com.linghu.model.entity.Platform; import com.linghu.model.entity.Reference; @@ -77,10 +80,9 @@ @PostMapping(value = "/exportStatics") @ApiOperation(value = "EChart图导出") public ResponseEntity<byte[]> exportStatics(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId", required = false) Integer questionId, HttpServletResponse response) { Keyword keyword = keywordMapper.selectById(keywordId); List<KeywordStaticsVO> voList = keywordMapper.statics(keywordId, questionId, keyword.getNum()); public ResponseEntity<byte[]> exportStatics(@RequestBody ExportStaticsDTO exportStaticsDTO) { Keyword keyword = keywordMapper.selectById(exportStaticsDTO.getKeywordId()); List<KeywordStaticsVO> voList = keywordMapper.statics(exportStaticsDTO.getKeywordId(), exportStaticsDTO.getQuestionId(), keyword.getNum()); // 3. 导出Excel ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -105,10 +107,21 @@ @RequestParam(value = "typeId", required = false) Integer typeId, @RequestParam(value = "isNow") Integer isNow) { Keyword keyword = keywordService.getById(keywordId); if (isNow == 0) { List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId, keyword.getNum() , typeId); return ResponseResult.success(result); } if (isNow > 0 && keyword.getNum()>isNow){ List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId, keyword.getNum() - isNow, typeId); return ResponseResult.success(result); }else { return ResponseResult.success(new ArrayList<>()); } } /** @@ -116,13 +129,10 @@ */ @PostMapping(value = "/exportGetResultByTypeId") @ApiOperation(value = "导出:根据类别查看") public ResponseEntity<byte[]> exportGetResultByTypeId(@RequestParam("keywordId") Integer keywordId, @RequestParam(value = "questionId", required = false) Integer questionId, @RequestParam(value = "typeId", required = false) Integer typeId, @RequestParam(value = "isNow") Integer isNow) { Keyword keyword = keywordService.getById(keywordId); List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId, keyword.getNum() - isNow, typeId); public ResponseEntity<byte[]> exportGetResultByTypeId(@RequestBody ExportGetResultDTO dto) { Keyword keyword = keywordService.getById(dto.getKeywordId()); List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(dto.getKeywordId(), dto.getQuestionId(), keyword.getNum() - dto.getIsNow(), dto.getTypeId()); // 3. 导出Excel ByteArrayOutputStream out = new ByteArrayOutputStream(); EasyExcel.write(out, PlatformProportionVO.class) @@ -139,31 +149,37 @@ /** * 根据平台查看 */ @GetMapping("/getResultByPlatformId") @PostMapping("/getResultByPlatformId") @ApiOperation(value = "根据平台查看") public ResponseResult<List<ResultListVO>> getResultByPlatformId(@RequestParam("keywordId") Integer keywordId, @RequestParam(value = "questionId", required = false) Integer questionId, @RequestParam(value = "platformId", required = false) Integer platformId, @RequestParam(value = "isNow") Integer isNow) { Keyword keyword = keywordService.getById(keywordId); if (isNow==0){ List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum(), platformId); return ResponseResult.success(result); } if (isNow > 0 && keyword.getNum()>isNow){ List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum() - isNow, platformId); return ResponseResult.success(result); }else { return ResponseResult.success(new ArrayList<>()); } } /** * 根据平台查看 0-当前轮 1-代表前1轮 2-代表前2轮 */ @GetMapping("/exportGetResultByPlatformId") @PostMapping("/exportGetResultByPlatformId") @ApiOperation(value = "导出:根据平台查看") public ResponseEntity<byte[]> exportGetResultByPlatformId(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId", required = false) Integer questionId, @RequestParam(value = "platformId", required = false) Integer platformId, @RequestParam(value = "isNow") Integer isNow) { Keyword keyword = keywordService.getById(keywordId); List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum() - isNow, platformId); public ResponseEntity<byte[]> exportGetResultByPlatformId(@RequestBody ExportGetResultByPlatformIdDTO dto) { Keyword keyword = keywordService.getById(dto.getKeywordId()); List<ResultListVO> result = keywordMapper.getResultByPlatformId(dto.getKeywordId(), dto.getQuestionId(), keyword.getNum() - dto.getIsNow(), dto.getPlatformId()); // 3. 导出Excel ByteArrayOutputStream out = new ByteArrayOutputStream(); EasyExcel.write(out, ResultListVO.class) @@ -206,9 +222,9 @@ /** * 投喂 */ @PostMapping("/importFeed") @PostMapping("/importFeed/{keywordId}") @ApiOperation("投喂") public ResponseResult<List<FeedExportExcel>> importTemplate(@RequestParam("file") MultipartFile file,@RequestParam("keywordId") Integer keywordId) { public ResponseResult<List<FeedExportExcel>> importTemplate(@PathVariable("keywordId") Integer keywordId,@RequestParam("file") MultipartFile file) { Keyword keyword = keywordService.getById(keywordId); //查找出最近一次的结果 List<FeedExportExcel> references = referenceMapper.importTemplateList(keywordId,keyword.getNum()); src/main/java/com/linghu/controller/PlatformController.java
@@ -87,11 +87,9 @@ return ResponseResult.error("平台域名不能为空"); } boolean success = platformService.updateById(platform); if (success) { platformService.updateById(platform); return ResponseResult.success(); } return ResponseResult.error("更新平台失败"); } @GetMapping("/{platformId}") src/main/java/com/linghu/controller/SectionalizationController.java
New file @@ -0,0 +1,46 @@ package com.linghu.controller; import com.linghu.service.SectionalizationService; import com.linghu.service.UserService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/sectionalization") @Api(value = "分组相关接口", tags = "设置-账号管理-分组") public class SectionalizationController { @Autowired private SectionalizationService sectionalizationService; /* @PostMapping @ApiOperation(value = "添加类型") public ResponseResult<User> add(@RequestBody User user) { boolean success = typeService.save(type); if (success) { return ResponseResult.success(type); } return ResponseResult.error("添加类型失败"); } */ /** * 新增分组 */ /** * 修改分组 */ /** * 删除分组 */ /** * 分组列表 */ } src/main/java/com/linghu/controller/TypeController.java
@@ -44,23 +44,17 @@ @DeleteMapping("/{typeId}") @ApiOperation(value = "删除类型") public ResponseResult<Void> delete(@PathVariable Integer typeId) { Type type = new Type(); type.setType_id(typeId); boolean success = typeService.updateById(type); if (success) { typeService.removeById(typeId); return ResponseResult.success(); } return ResponseResult.error("删除类型失败"); } @PutMapping @ApiOperation(value = "更新类型") public ResponseResult<Void> update(@RequestBody Type type) { boolean success = typeService.updateById(type); if (success) { typeService.updateById(type); return ResponseResult.success(); } return ResponseResult.error("更新类型失败"); } @PutMapping("/batch") src/main/java/com/linghu/controller/UserController.java
New file @@ -0,0 +1,52 @@ package com.linghu.controller; import com.linghu.model.common.ResponseResult; import com.linghu.model.entity.Type; import com.linghu.model.entity.User; import com.linghu.service.UserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/user") @Api(value = "账号相关接口", tags = "设置-账号管理") public class UserController { @Autowired private UserService userService; /* @PostMapping @ApiOperation(value = "添加类型") public ResponseResult<User> add(@RequestBody User user) { boolean success = typeService.save(type); if (success) { return ResponseResult.success(type); } return ResponseResult.error("添加类型失败"); } */ /** * 新增用户 */ /** * 修改用户 */ /** * 删除用户 */ /** * 分页查询 */ } src/main/java/com/linghu/mapper/OrderMapper.java
@@ -1,7 +1,11 @@ package com.linghu.mapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.linghu.model.entity.Orders; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import java.time.LocalDateTime; /** * @author xy src/main/java/com/linghu/mapper/SectionalizationMapper.java
New file @@ -0,0 +1,19 @@ package com.linghu.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.linghu.model.entity.Orders; import com.linghu.model.entity.Sectionalization; /** * @author xy * @description 针对表【Sectionalization】的数据库操作Mapper * @createDate 2025-07-04 20:17:33 * @Entity com.linghu.model.entity.Sectionalization */ public interface SectionalizationMapper extends BaseMapper<Sectionalization> { } src/main/java/com/linghu/model/dto/ExportGetResultByPlatformIdDTO.java
New file @@ -0,0 +1,14 @@ package com.linghu.model.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ExportGetResultByPlatformIdDTO { @ApiModelProperty("") private Integer keywordId; private Integer questionId; private Integer platformId; @ApiModelProperty("轮数 0:当前 1:前一轮") private Integer isNow; } src/main/java/com/linghu/model/dto/ExportGetResultDTO.java
New file @@ -0,0 +1,14 @@ package com.linghu.model.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ExportGetResultDTO { @ApiModelProperty("") private Integer keywordId; private Integer questionId; private Integer typeId; @ApiModelProperty("轮数 0:当前 1:前一轮") private Integer isNow; } src/main/java/com/linghu/model/dto/ExportStaticsDTO.java
New file @@ -0,0 +1,12 @@ package com.linghu.model.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class ExportStaticsDTO { @ApiModelProperty("关键词id") private Integer keywordId; @ApiModelProperty("提问词id") private Integer questionId; } src/main/java/com/linghu/model/entity/Orders.java
@@ -51,7 +51,7 @@ /** * 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private LocalDateTime create_time; /** @@ -62,7 +62,7 @@ /** * */ @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private LocalDateTime update_time; @TableField(exist = false) src/main/java/com/linghu/model/entity/Sectionalization.java
New file @@ -0,0 +1,63 @@ package com.linghu.model.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @TableName(value = "sectionalization") public class Sectionalization { @TableField(exist = false) private static final long serialVersionUID = 1L; @TableId private Integer sectionalization_id; @NotBlank(message = "用户名不能为空") private String sectionalization_name; @Override public boolean equals(Object that) { if (this == that) { return true; } if (that == null) { return false; } if (getClass() != that.getClass()) { return false; } Sectionalization other = (Sectionalization) that; return (this.getSectionalization_id() == null ? other.getSectionalization_id() == null : this.getSectionalization_id().equals(other.getSectionalization_id())) && (this.getSectionalization_name() == null ? other.getSectionalization_name() == null : this.getSectionalization_name().equals(other.getSectionalization_name())) ; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getSectionalization_id() == null) ? 0 : getSectionalization_id().hashCode()); result = prime * result + ((getSectionalization_name() == null) ? 0 : getSectionalization_name().hashCode()); return result; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", sectionalization_id=").append(sectionalization_id); sb.append(", sectionalization_name=").append(sectionalization_name); sb.append(", serialVersionUID=").append(serialVersionUID); sb.append("]"); return sb.toString(); } } src/main/java/com/linghu/model/entity/User.java
@@ -49,6 +49,17 @@ */ private Integer phone; /** * 分组id */ private Integer sectionalization_id; /** * 状态 */ private String status; @TableField(exist = false) private static final long serialVersionUID = 1L; @@ -71,7 +82,10 @@ : this.getUser_email().equals(other.getUser_email())) && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword())) && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone())); && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone())) && (this.getSectionalization_id() == null ? other.getSectionalization_id() == null : this.getSectionalization_id().equals(other.getSectionalization_id())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) ; } @Override @@ -83,6 +97,8 @@ result = prime * result + ((getUser_email() == null) ? 0 : getUser_email().hashCode()); result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode()); result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode()); result = prime * result + ((getSectionalization_id() == null) ? 0 : getSectionalization_id().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); return result; } @@ -97,6 +113,8 @@ sb.append(", user_email=").append(user_email); sb.append(", password=").append(password); sb.append(", phone=").append(phone); sb.append(", sectionalization_id=").append(sectionalization_id); sb.append(", status=").append(status); sb.append(", serialVersionUID=").append(serialVersionUID); sb.append("]"); return sb.toString(); src/main/java/com/linghu/model/excel/ReferenceExcel.java
@@ -1,5 +1,6 @@ package com.linghu.model.excel; import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; @@ -20,7 +21,7 @@ @ExcelProperty("发布网址") private String url; @ExcelIgnore private LocalDateTime createTimeAsDateTime; } src/main/java/com/linghu/model/vo/ResultListVO.java
@@ -1,5 +1,6 @@ package com.linghu.model.vo; import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -13,6 +14,7 @@ public class ResultListVO { @ApiModelProperty("结果id") @ExcelIgnore private Integer reference_id; @ApiModelProperty("平台名称") src/main/java/com/linghu/service/OrderService.java
@@ -1,9 +1,11 @@ package com.linghu.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.linghu.model.entity.Orders; import com.linghu.model.dto.KeywordDto; import com.linghu.model.dto.OrderDto; import java.time.LocalDateTime; import java.util.List; import com.baomidou.mybatisplus.extension.service.IService; src/main/java/com/linghu/service/SectionalizationService.java
New file @@ -0,0 +1,18 @@ package com.linghu.service; import com.baomidou.mybatisplus.extension.service.IService; import com.linghu.model.dto.KeywordDto; import com.linghu.model.dto.OrderDto; import com.linghu.model.entity.Orders; import com.linghu.model.entity.Sectionalization; import java.util.List; /** * @author xy * @description 针对表【order】的数据库操作Service * @createDate 2025-07-04 20:17:33 */ public interface SectionalizationService extends IService<Sectionalization> { } src/main/java/com/linghu/service/impl/KeywordServiceImpl.java
@@ -40,7 +40,7 @@ } List<KeywordStaticsVO> statics = this.getBaseMapper().statics(keywordId, questionId, keyword.getNum()); vo.setNowRecord(statics); if (keyword.getNum() != 0) { if (keyword.getNum() > 1) { statics = this.getBaseMapper().statics(keywordId, questionId, keyword.getNum() - 1); vo.setBeforeRecord(statics); } src/main/java/com/linghu/service/impl/OrderServiceImpl.java
@@ -1,5 +1,6 @@ package com.linghu.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.linghu.model.dto.KeywordDto; import com.linghu.model.dto.OrderDto; @@ -10,6 +11,7 @@ import com.linghu.service.OrderService; import com.linghu.mapper.OrderMapper; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; src/main/java/com/linghu/service/impl/SectionalizationServiceImpl.java
New file @@ -0,0 +1,25 @@ package com.linghu.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.linghu.mapper.SectionalizationMapper; import com.linghu.mapper.UserMapper; import com.linghu.model.entity.Sectionalization; import com.linghu.model.entity.User; import com.linghu.service.SectionalizationService; import com.linghu.service.UserService; import org.springframework.stereotype.Service; /** * @author xy * @description 针对表【user】的数据库操作Service实现 * @createDate 2025-07-07 10:26:00 */ @Service public class SectionalizationServiceImpl extends ServiceImpl<SectionalizationMapper, Sectionalization> implements SectionalizationService { } src/main/resources/mapper/SectionalizationMapper.xml
New file @@ -0,0 +1,16 @@ <?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.linghu.mapper.SectionalizationMapper"> <resultMap id="BaseResultMap" type="com.linghu.model.entity.Sectionalization"> <id property="sectionalization_id" column="sectionalization_id" jdbcType="INTEGER"/> <result property="sectionalization_name" column="sectionalization_name" jdbcType="VARCHAR"/> </resultMap> <sql id="Base_Column_List"> sectionalization_id,sectionalization_name </sql> </mapper> src/main/resources/mapper/UserMapper.xml
@@ -10,10 +10,12 @@ <result property="user_email" column="user_email" jdbcType="VARCHAR"/> <result property="password" column="password" jdbcType="VARCHAR"/> <result property="phone" column="phone" jdbcType="INTEGER"/> <result property="sectionalization_id" column="sectionalization_id" jdbcType="INTEGER"/> <result property="status" column="status" jdbcType="VARCHAR"/> </resultMap> <sql id="Base_Column_List"> user_id,user_name,user_email, password,phone password,phone,sectionalization_id,status </sql> </mapper> src/main/resources/mapper/keywordMapper.xml
@@ -92,10 +92,8 @@ <if test="typeId != null"> AND p.type_id = #{typeId} </if> GROUP BY t.type_id, t.type_name, p.platform_id, p.platform_name ORDER BY t.type_name, total_repetitions DESC r.repetition_num DESC </select> <select id="getResultByPlatformId" resultType="com.linghu.model.vo.ResultListVO"> SELECT @@ -119,6 +117,7 @@ AND r.platform_id = #{platformId} </if> ORDER BY r.repetition_num, r.create_time DESC </select> </mapper>