From 554719d781b3e5c4fd51a3ad34c30e2edb6c3019 Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 16 Apr 2024 15:18:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=94=BF=E7=AD=96?= =?UTF-8?q?=E6=B3=95=E8=A7=84=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PolicyController.java | 36 ++++++++++ .../supervision/mapper/KgPolicyMapper.java | 19 +++-- .../java/com/supervision/model/KgPolicy.java | 70 ------------------- .../supervision/service/KgPolicyService.java | 3 + .../service/impl/KgPolicyServiceImpl.java | 34 +++++++-- .../main/resources/mapper/KgPolicyMapper.xml | 46 ++++++++---- 6 files changed, 114 insertions(+), 94 deletions(-) create mode 100644 kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java diff --git a/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java b/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java new file mode 100644 index 0000000..fadf1c7 --- /dev/null +++ b/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java @@ -0,0 +1,36 @@ +package com.supervision.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.supervision.model.KgPolicy; +import com.supervision.service.KgPolicyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Api(tags = "政策法规") +@RestController +@RequestMapping("policy") +@RequiredArgsConstructor +public class PolicyController { + + private final KgPolicyService kgPolicyService; + + + @GetMapping("queryPolicyPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "keyword", value = "模糊搜索", required = true, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "level", value = "政策层级(1国家级;2省级;3市级;4县级)", required = true, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "subject", value = "主题(1养老退休;2人事人才;3就业创业;4社会保障;5劳动关系)", required = true, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "type", value = "政策类型(1意见;2方案;3通知;4规章;5政策解读)", required = true, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "order", value = "排序方式 默认发文时间降序,1最多收藏降序;2最多浏览降序", required = true, dataType = "Integer", paramType = "query"), + @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "Integer", paramType = "query"), + @ApiImplicitParam(name = "pageNum", value = "pageNum", required = true, dataType = "Integer", paramType = "query") + }) + public IPage queryPolicyPage(String keyword, Integer level, Integer subject, Integer type, Integer order, Integer pageNum, Integer pageSize) { + return kgPolicyService.queryPolicyPage(keyword, level, subject, type, order, pageNum, pageSize); + } +} diff --git a/kbqa-model/src/main/java/com/supervision/mapper/KgPolicyMapper.java b/kbqa-model/src/main/java/com/supervision/mapper/KgPolicyMapper.java index 232e6cd..376a299 100644 --- a/kbqa-model/src/main/java/com/supervision/mapper/KgPolicyMapper.java +++ b/kbqa-model/src/main/java/com/supervision/mapper/KgPolicyMapper.java @@ -1,16 +1,25 @@ package com.supervision.mapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.supervision.model.KgPolicy; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; /** -* @author Administrator -* @description 针对表【kg_policy(政策法规表)】的数据库操作Mapper -* @createDate 2024-04-16 13:05:24 -* @Entity com.supervision.model.KgPolicy -*/ + * @author Administrator + * @description 针对表【kg_policy(政策法规表)】的数据库操作Mapper + * @createDate 2024-04-16 13:05:24 + * @Entity com.supervision.model.KgPolicy + */ public interface KgPolicyMapper extends BaseMapper { + IPage queryPolicyPage(@Param("keyword") String keyword, + @Param("level") Integer level, + @Param("subject") Integer subject, + @Param("type") Integer type, + @Param("page") Page page); + } diff --git a/kbqa-model/src/main/java/com/supervision/model/KgPolicy.java b/kbqa-model/src/main/java/com/supervision/model/KgPolicy.java index 82abe1f..4c8b952 100644 --- a/kbqa-model/src/main/java/com/supervision/model/KgPolicy.java +++ b/kbqa-model/src/main/java/com/supervision/model/KgPolicy.java @@ -84,74 +84,4 @@ public class KgPolicy implements Serializable { @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; - } - KgPolicy other = (KgPolicy) that; - return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) - && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle())) - && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent())) - && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) - && (this.getDocNumber() == null ? other.getDocNumber() == null : this.getDocNumber().equals(other.getDocNumber())) - && (this.getLevel() == null ? other.getLevel() == null : this.getLevel().equals(other.getLevel())) - && (this.getSubject() == null ? other.getSubject() == null : this.getSubject().equals(other.getSubject())) - && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) - && (this.getReadCount() == null ? other.getReadCount() == null : this.getReadCount().equals(other.getReadCount())) - && (this.getMarkCount() == null ? other.getMarkCount() == null : this.getMarkCount().equals(other.getMarkCount())) - && (this.getPublishTime() == null ? other.getPublishTime() == null : this.getPublishTime().equals(other.getPublishTime())) - && (this.getWriteTime() == null ? other.getWriteTime() == null : this.getWriteTime().equals(other.getWriteTime())) - && (this.getPublishDept() == null ? other.getPublishDept() == null : this.getPublishDept().equals(other.getPublishDept())); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); - result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode()); - result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode()); - result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); - result = prime * result + ((getDocNumber() == null) ? 0 : getDocNumber().hashCode()); - result = prime * result + ((getLevel() == null) ? 0 : getLevel().hashCode()); - result = prime * result + ((getSubject() == null) ? 0 : getSubject().hashCode()); - result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); - result = prime * result + ((getReadCount() == null) ? 0 : getReadCount().hashCode()); - result = prime * result + ((getMarkCount() == null) ? 0 : getMarkCount().hashCode()); - result = prime * result + ((getPublishTime() == null) ? 0 : getPublishTime().hashCode()); - result = prime * result + ((getWriteTime() == null) ? 0 : getWriteTime().hashCode()); - result = prime * result + ((getPublishDept() == null) ? 0 : getPublishDept().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(", title=").append(title); - sb.append(", content=").append(content); - sb.append(", status=").append(status); - sb.append(", docNumber=").append(docNumber); - sb.append(", level=").append(level); - sb.append(", subject=").append(subject); - sb.append(", type=").append(type); - sb.append(", readCount=").append(readCount); - sb.append(", markCount=").append(markCount); - sb.append(", publishTime=").append(publishTime); - sb.append(", writeTime=").append(writeTime); - sb.append(", publishDept=").append(publishDept); - sb.append(", serialVersionUID=").append(serialVersionUID); - sb.append("]"); - return sb.toString(); - } } \ No newline at end of file diff --git a/kbqa-model/src/main/java/com/supervision/service/KgPolicyService.java b/kbqa-model/src/main/java/com/supervision/service/KgPolicyService.java index d09822c..85298e3 100644 --- a/kbqa-model/src/main/java/com/supervision/service/KgPolicyService.java +++ b/kbqa-model/src/main/java/com/supervision/service/KgPolicyService.java @@ -1,5 +1,6 @@ package com.supervision.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.supervision.model.KgPolicy; import com.baomidou.mybatisplus.extension.service.IService; @@ -10,4 +11,6 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface KgPolicyService extends IService { + IPage queryPolicyPage(String keyword, Integer level, Integer subject, Integer type, Integer order,Integer pageNum, Integer pageSize); + } diff --git a/kbqa-model/src/main/java/com/supervision/service/impl/KgPolicyServiceImpl.java b/kbqa-model/src/main/java/com/supervision/service/impl/KgPolicyServiceImpl.java index 4b8a514..866fe21 100644 --- a/kbqa-model/src/main/java/com/supervision/service/impl/KgPolicyServiceImpl.java +++ b/kbqa-model/src/main/java/com/supervision/service/impl/KgPolicyServiceImpl.java @@ -1,5 +1,9 @@ package com.supervision.service.impl; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.supervision.model.KgPolicy; import com.supervision.service.KgPolicyService; @@ -7,14 +11,34 @@ import com.supervision.mapper.KgPolicyMapper; import org.springframework.stereotype.Service; /** -* @author Administrator -* @description 针对表【kg_policy(政策法规表)】的数据库操作Service实现 -* @createDate 2024-04-16 13:05:24 -*/ + * @author Administrator + * @description 针对表【kg_policy(政策法规表)】的数据库操作Service实现 + * @createDate 2024-04-16 13:05:24 + */ @Service public class KgPolicyServiceImpl extends ServiceImpl - implements KgPolicyService{ + implements KgPolicyService { + @Override + public IPage queryPolicyPage(String keyword, Integer level, Integer subject, Integer type, Integer order, Integer pageNum, Integer pageSize) { + // 排序方式 默认发文时间降序,1最多收藏降序;2最多浏览降序 + Page page = new Page<>(pageNum, pageSize); + if (ObjectUtils.isNull(order)) { + // 默认发文时间排序 + page.addOrder(OrderItem.desc("publish_time")); + } else { + if (1 == order) { + // 收藏降序 + page.addOrder(OrderItem.desc("mark_count")); + } + if (2 == order) { + // 浏览降序 + page.addOrder(OrderItem.desc("read_count")); + } + } + + return this.baseMapper.queryPolicyPage(keyword, level, subject, type, page); + } } diff --git a/kbqa-model/src/main/resources/mapper/KgPolicyMapper.xml b/kbqa-model/src/main/resources/mapper/KgPolicyMapper.xml index feabc47..209ec4f 100644 --- a/kbqa-model/src/main/resources/mapper/KgPolicyMapper.xml +++ b/kbqa-model/src/main/resources/mapper/KgPolicyMapper.xml @@ -5,26 +5,44 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - id,title,content, + id + ,title,content, status,doc_number,level, subject,type,read_count, mark_count,publish_time,write_time, publish_dept + From 4996d76ad4489874abe4115bbee468c4d03f71ee Mon Sep 17 00:00:00 2001 From: liu Date: Tue, 16 Apr 2024 15:52:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=94=BF=E7=AD=96?= =?UTF-8?q?=E6=B3=95=E8=A7=84=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/supervision/controller/PolicyController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java b/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java index fadf1c7..46dd1f0 100644 --- a/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java +++ b/kbqa-graph/src/main/java/com/supervision/controller/PolicyController.java @@ -22,11 +22,11 @@ public class PolicyController { @GetMapping("queryPolicyPage") @ApiImplicitParams({ - @ApiImplicitParam(name = "keyword", value = "模糊搜索", required = true, dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "level", value = "政策层级(1国家级;2省级;3市级;4县级)", required = true, dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "subject", value = "主题(1养老退休;2人事人才;3就业创业;4社会保障;5劳动关系)", required = true, dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "type", value = "政策类型(1意见;2方案;3通知;4规章;5政策解读)", required = true, dataType = "String", paramType = "query"), - @ApiImplicitParam(name = "order", value = "排序方式 默认发文时间降序,1最多收藏降序;2最多浏览降序", required = true, dataType = "Integer", paramType = "query"), + @ApiImplicitParam(name = "keyword", value = "模糊搜索", required = false, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "level", value = "政策层级(1国家级;2省级;3市级;4县级)", required = false, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "subject", value = "主题(1养老退休;2人事人才;3就业创业;4社会保障;5劳动关系)", required = false, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "type", value = "政策类型(1意见;2方案;3通知;4规章;5政策解读)", required = false, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "order", value = "排序方式 默认发文时间降序,1最多收藏降序;2最多浏览降序", required = false, dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "pageNum", value = "pageNum", required = true, dataType = "Integer", paramType = "query") })