diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java index 41dcf98..4bb8ead 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java @@ -21,7 +21,7 @@ import com.ruoyi.system.service.ISysLogininforService; /** * 系统访问记录 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java index b6ba56b..95af098 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -2,6 +2,8 @@ package com.ruoyi.web.controller.monitor; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.page.TableDataInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; @@ -13,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.SysOperLog; @@ -21,7 +22,7 @@ import com.ruoyi.system.service.ISysOperLogService; /** * 操作日志记录 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java index 294318d..e913da2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java @@ -25,7 +25,7 @@ import com.ruoyi.system.service.ISysUserOnlineService; /** * 在线用户监控 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index b53fe47..8e7c38c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -27,7 +27,7 @@ import com.ruoyi.system.service.ISysDictTypeService; /** * 数据字典信息 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java index f8b7dbc..789cf03 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -25,7 +25,7 @@ import com.ruoyi.system.service.ISysDictTypeService; /** * 数据字典信息 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 4da9f04..fab7f61 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -22,7 +22,7 @@ import com.ruoyi.system.service.ISysNoticeService; /** * 公告 信息操作处理 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index f73cea4..0cf7aea 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -25,7 +25,7 @@ import com.ruoyi.system.service.ISysPostService; /** * 岗位信息操作处理 - * + * * @author ruoyi */ @RestController @@ -46,7 +46,7 @@ public class SysPostController extends BaseController List list = postService.selectPostList(post); return getDataTable(list); } - + @Log(title = "岗位管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:post:export')") @PostMapping("/export") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java index 2abec1b..a0e5347 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -32,7 +32,7 @@ import com.ruoyi.system.service.ISysUserService; /** * 角色信息 - * + * * @author ruoyi */ @RestController @@ -44,10 +44,10 @@ public class SysRoleController extends BaseController @Autowired private TokenService tokenService; - + @Autowired private SysPermissionService permissionService; - + @Autowired private ISysUserService userService; @@ -121,7 +121,7 @@ public class SysRoleController extends BaseController return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setUpdateBy(getUsername()); - + if (roleService.updateRole(role) > 0) { // 更新缓存用户权限 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 089f711..5d4e63b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -33,7 +33,7 @@ import com.ruoyi.system.service.ISysUserService; /** * 用户信息 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-admin/src/main/resources/CoreNLP-chinese.properties b/ruoyi-admin/src/main/resources/CoreNLP-chinese.properties deleted file mode 100644 index b3c4593..0000000 --- a/ruoyi-admin/src/main/resources/CoreNLP-chinese.properties +++ /dev/null @@ -1,46 +0,0 @@ -# Pipeline options - lemma is no-op for Chinese but currently needed because coref demands it (bad old requirements system) - -#\u8BBE\u5B9A\u4E86\u7BA1\u9053\u4E2D\u5305\u62EC\u54EA\u4E9BAnnotators\uFF08\u4E00\u4E2AAnnotator\u5C31\u662F\u4F60\u9700\u8981\u7684\u6587\u672C\u5206\u6790\u5206\u6790\u5DE5\u5177\uFF0C \u4ED6\u7684\u7ED3\u679C\u5C31\u662F\u4E00\u4E2A\u6216\u591A\u4E2AAnnotation\uFF09 -#segment:\u5206\u8BCD, ssplit:\u5206\u9694, pos: \u8BCD\u6027\u6807\u6CE8, lemma: has->have, ner:\u547D\u540D\u5B9E\u4F53\u8BC6\u522B, parse\uFF1A\u8BED\u6CD5\u5206\u6790 -#annotators = segment, tokenize,ssplit, pos, lemma, ner, parse, sentiment, mention, coref -annotators = segment,tokenize, ssplit, pos,ner - - -# segment \u5206\u8BCD -customAnnotatorClass.segment = edu.stanford.nlp.pipeline.ChineseSegmenterAnnotator -#segment.model = edu/stanford/nlp/models/segmenter/chinese/pku.gz -segment.model = edu/stanford/nlp/models/segmenter/chinese/ctb.gz -segment.sighanCorporaDict = edu/stanford/nlp/models/segmenter/chinese -segment.serDictionary = edu/stanford/nlp/models/segmenter/chinese/dict-chris6.ser.gz -segment.sighanPostProcessing = true -tokenize.language = zh -ssplit.isOneSentence = true -# sentence split -ssplit.boundaryTokenRegex = [.]|[!?]+|[\u3002]|[\uFF01\uFF1F]+ - -# pos -pos.model = edu/stanford/nlp/models/pos-tagger/chinese-distsim/chinese-distsim.tagger - -#ner \u6B64\u5904\u8BBE\u5B9A\u4E86ner\u4F7F\u7528\u7684\u8BED\u8A00\u3001\u6A21\u578B\uFF08crf\uFF09\uFF0C\u76EE\u524DSUTime\u53EA\u652F\u6301\u82F1\u6587\uFF0C\u4E0D\u652F\u6301\u4E2D\u6587\uFF0C\u6240\u4EE5\u8BBE\u7F6E\u4E3Afalse\u3002 -ner.language = chinese -ner.model = edu/stanford/nlp/models/ner/chinese.misc.distsim.crf.ser.gz -ner.applyNumericClassifiers = true -ner.useSUTime = false - -#parse -parse.model = edu/stanford/nlp/models/lexparser/chineseFactored.ser.gz - -# coref -coref.sieves = ChineseHeadMatch, ExactStringMatch, PreciseConstructs, StrictHeadMatch1, StrictHeadMatch2, StrictHeadMatch3, StrictHeadMatch4, PronounMatch -coref.input.type = raw -coref.postprocessing = true -coref.calculateFeatureImportance = false -coref.useConstituencyTree = true -coref.useSemantics = false -coref.md.type = RULE -coref.mode = hybrid -coref.path.word2vec = -coref.language = zh -coref.print.md.log = false -coref.defaultPronounAgreement = true -coref.zh.dict = edu/stanford/nlp/models/dcoref/zh-attributes.txt.gz diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 45a59a4..138b64a 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -17,7 +17,7 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://59.110.45.20:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://39.108.144.227:3306/makesoft?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: Biemo123 # 从库数据源 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 95c3da5..d1d3731 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -18,7 +18,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 7777 servlet: # 应用的访问路径 context-path: / @@ -62,7 +62,7 @@ spring: # redis 配置 redis: # 地址 - host: 59.110.45.20 + host: 39.108.144.227 # 端口,默认为6379 port: 6379 # 数据库索引 diff --git a/ruoyi-biemo/pom.xml b/ruoyi-biemo/pom.xml index 7287351..917f82c 100644 --- a/ruoyi-biemo/pom.xml +++ b/ruoyi-biemo/pom.xml @@ -51,7 +51,7 @@ com.alibaba fastjson - 1.2.4 + 1.2.68 diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java index a042a7b..9e4165e 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java @@ -1,16 +1,13 @@ package com.ruoyi.biemo.business.controller; -import com.github.pagehelper.Page; import com.ruoyi.biemo.business.domain.DocInfo; import com.ruoyi.biemo.business.service.DocInfoMongoService; import com.ruoyi.biemo.business.service.DocInfoService; -import com.ruoyi.biemo.elasticsearch.entity.Topic; -import com.ruoyi.biemo.elasticsearch.service.TestService; +import com.ruoyi.biemo.core.page.Page; +import com.ruoyi.biemo.core.page.PageFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.List; - /** * @author makesoft @@ -37,9 +34,7 @@ public class DocInfoController { } @PostMapping(value = "/queryPage") - public Page queryPage(@RequestBody DocInfo topic, @RequestParam Integer pageNum,@RequestParam Integer pageSize ){ - Page page = new Page<>(pageNum,pageSize); - return docInfoService.findPage(topic,page); + public Page queryPage(@RequestBody DocInfo topic ){ + return docInfoService.findPage(topic,PageFactory.defaultPage()); } - } diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java index bd4d46f..bc95c4e 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java @@ -1,9 +1,9 @@ package com.ruoyi.biemo.business.service; -import com.github.pagehelper.Page; import com.github.pagehelper.util.StringUtil; import com.ruoyi.biemo.business.domain.DocInfo; import com.ruoyi.biemo.business.domain.event.DocInfoSaveEvent; +import com.ruoyi.biemo.core.page.Page; import com.ruoyi.biemo.elasticsearch.entity.Topic; import com.ruoyi.biemo.elasticsearch.util.EsService; import com.ruoyi.biemo.mongodb.utils.MongoHelper; @@ -31,7 +31,7 @@ public class DocInfoService extends EsService { @Autowired private MongoHelper mongoHelper; - public Page findPage(DocInfo docInfo,Page page){ + public Page findPage(DocInfo docInfo, Page page){ return esLambdaQuery().eqAll(docInfo).page(page.getPageNum(),page.getPageSize()).queryPage(true); } diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/context/RequestDataHolder.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/context/RequestDataHolder.java new file mode 100644 index 0000000..bb62fe0 --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/context/RequestDataHolder.java @@ -0,0 +1,44 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.context; + + +import com.ruoyi.biemo.core.request.RequestData; + +/** + * 请求数据的临时容器 + * + * + * @date 2018-05-04 11:33 + */ +public class RequestDataHolder { + + private static ThreadLocal holder = new ThreadLocal<>(); + + public static void put(RequestData s) { + if (holder.get() == null) { + holder.set(s); + } + } + + public static RequestData get() { + return holder.get(); + } + + public static void remove() { + holder.remove(); + } +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/Page.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/Page.java new file mode 100644 index 0000000..4977e1d --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/Page.java @@ -0,0 +1,160 @@ +package com.ruoyi.biemo.core.page; + + +import java.util.Collections; +import java.util.List; + +public class Page { + private static final long serialVersionUID = 8545996863226528798L; + protected List records; + protected long total; + protected Integer pageSize; + protected Integer pageNum; + protected boolean optimizeCountSql; + protected boolean isSearchCount; + protected boolean hitCount; + protected String countId; + protected Long maxLimit; + + public Page() { + this.records = Collections.emptyList(); + this.total = 0L; + this.pageSize = 10; + this.pageNum = 1; + this.optimizeCountSql = true; + this.isSearchCount = true; + this.hitCount = false; + } + + public Page(Integer pageNum, Integer pageSize) { + this(pageNum, pageSize, 0L); + } + + public Page(Integer pageNum, Integer pageSize, long total) { + this(pageNum, pageSize, total, true); + } + + public Page(Integer pageNum, Integer pageSize, boolean isSearchCount) { + this(pageNum, pageSize, 0L, isSearchCount); + } + + public Page(Integer pageNum, Integer pageSize, long total, boolean isSearchCount) { + this.records = Collections.emptyList(); + this.total = 0L; + this.pageSize = 10; + this.pageNum = 1; + this.optimizeCountSql = true; + this.isSearchCount = true; + this.hitCount = false; + if (pageNum > 1L) { + this.pageNum = pageNum; + } + + this.pageSize = pageSize; + this.total = total; + this.isSearchCount = isSearchCount; + } + + long getPages() { + if (this.getPageSize() == 0) { + return 0; + } else { + long pages = this.getTotal() / this.getPageSize(); + if (this.getTotal() % this.getPageSize() != 0) { + ++pages; + } + + return pages; + } + } + public boolean hasPrevious() { + return this.pageNum > 1L; + } + + public boolean hasNext() { + return this.pageNum < this.getPages(); + } + + public List getRecords() { + return this.records; + } + + public Page setRecords(List records) { + this.records = records; + return this; + } + + public long getTotal() { + return this.total; + } + + public Page setTotal(long total) { + this.total = total; + return this; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getPageNum() { + return pageNum; + } + + public void setPageNum(Integer pageNum) { + this.pageNum = pageNum; + } + + public String countId() { + return this.getCountId(); + } + + public Long maxLimit() { + return this.getMaxLimit(); + } + + public boolean isSearchCount() { + return this.total < 0L ? false : this.isSearchCount; + } + + public Page setSearchCount(boolean isSearchCount) { + this.isSearchCount = isSearchCount; + return this; + } + + public Page setOptimizeCountSql(boolean optimizeCountSql) { + this.optimizeCountSql = optimizeCountSql; + return this; + } + public void hitCount(boolean hit) { + this.hitCount = hit; + } + + public void setHitCount(boolean hit) { + this.hitCount = hit; + } + public boolean isHitCount() { + return this.hitCount; + } + + public String getCountId() { + return this.countId; + } + + public void setCountId(final String countId) { + this.countId = countId; + } + + public Long getMaxLimit() { + return this.maxLimit; + } + + public void setMaxLimit(final Long maxLimit) { + this.maxLimit = maxLimit; + } +} + diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageFactory.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageFactory.java new file mode 100644 index 0000000..225a84d --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageFactory.java @@ -0,0 +1,256 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.page; + + +import com.ruoyi.biemo.core.context.RequestDataHolder; +import com.ruoyi.biemo.core.request.RequestData; +import com.ruoyi.biemo.core.utils.HttpContext; +import com.ruoyi.biemo.core.utils.ValidateUtil; +import com.ruoyi.common.utils.StringUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.Set; + + +/** + * 默认分页参数构建 + * + * + * @date 2017年11月15日13:52:16 + */ +public class PageFactory { + + /** + * 排序,升序还是降序 + */ + private static final String ASC = "asc"; + + /** + * 每页大小的param名称 + */ + public static final String PAGE_SIZE_PARAM_NAME = "pageSize"; + + /** + * 第几页的param名称 + */ + public static final String PAGE_NO_PARAM_NAME = "pageNum"; + + /** + * 升序还是降序的param名称 + */ + public static final String SORT_PARAM_NAME = "sort"; + + /** + * 根据那个字段排序的param名称 + */ + public static final String ORDER_BY_PARAM_NAME = "orderBy"; + + public static final Integer PAGE_SIZE = 10; + + /** + * 默认规则的分页 + * + * + * @Date 2018/7/23 下午4:11 + */ + public static Page defaultPage() { + + int pageSize = PAGE_SIZE; + int pageNo = 1; + + HttpServletRequest request = HttpContext.getRequest(); + + if (request == null) { + return new Page<>(pageNo, pageSize); + } + + //每页条数 + String pageSizeString = getFieldValue(request, PAGE_SIZE_PARAM_NAME); + if (StringUtils.isNotEmpty(pageSizeString)) { + pageSize = Integer.parseInt(pageSizeString); + } + + //第几页 + String pageNoString = getFieldValue(request, PAGE_NO_PARAM_NAME); + if (StringUtils.isNotEmpty(pageNoString)) { + pageNo = Integer.parseInt(pageNoString); + } + + //获取排序字段和排序类型(asc/desc) + String sort = getFieldValue(request, SORT_PARAM_NAME); + String orderByField = getFieldValue(request, ORDER_BY_PARAM_NAME); + + Page page = new Page<>(pageNo, pageSize); + if (StringUtils.isEmpty(orderByField)) { + return page; + } + if (StringUtils.isEmpty(sort)) { + // 默认降序 + //待实现 + return page; + } + if (ASC.equalsIgnoreCase(sort)) { + // 待实现 + } else { + //待实现 + } + return page; + } + + /** + * 自定义参数的分页 + * + * + * @Date 2018/7/23 下午4:11 + */ + public static Page createPage(PageQuery pageQuery) { + + int pageSize = PAGE_SIZE; + int pageNo = 1; + + if (pageQuery != null && ValidateUtil.isNotEmpty(pageQuery.getPageSize())) { + pageSize = pageQuery.getPageSize(); + } + + if (pageQuery != null && ValidateUtil.isNotEmpty(pageQuery.getPageNo())) { + pageNo = pageQuery.getPageNo(); + } + + if (pageQuery == null) { + return new Page<>(pageNo, pageSize); + } + + Page page = new Page<>(pageNo, pageSize); + if (StringUtils.isEmpty(pageQuery.getSort())) { + return page; + } + if (ASC.equalsIgnoreCase(pageQuery.getSort())) { + //page.setAsc(pageQuery.getOrderByField()); + } else { + //page.setDesc(pageQuery.getOrderByField()); + } + return page; + } + + /** + * 获取参数值,通过param或从requestBody中取 + * + * + * @Date 2018/7/25 下午1:12 + */ + private static String getFieldValue(HttpServletRequest request, String type) { + + // 先从requestParam中获取值,如果没有就从requestData中获取 + String parameterValue = getRequestParameter(request, type); + if (parameterValue == null) { + return getRequestData(type); + } else { + return parameterValue; + } + } + + /** + * 获取请求参数的值(从param中获取) + * + * + * @Date 2019-09-29 15:33 + */ + private static String getRequestParameter(HttpServletRequest request, String type) { + if (PAGE_SIZE_PARAM_NAME.equals(type)) { + Set pageSizeFieldNames = PageFieldNamesContainer.getInstance().getPageSizeFieldNames(); + for (String fieldName : pageSizeFieldNames) { + String pageSizeValue = request.getParameter(fieldName); + if (ValidateUtil.isNotEmpty(pageSizeValue)) { + return pageSizeValue; + } + } + return null; + } else if (PAGE_NO_PARAM_NAME.equals(type)) { + Set pageNoFieldNames = PageFieldNamesContainer.getInstance().getPageNoFieldNames(); + for (String fieldName : pageNoFieldNames) { + String pageNoValue = request.getParameter(fieldName); + if (ValidateUtil.isNotEmpty(pageNoValue)) { + return pageNoValue; + } + } + return null; + } else if (SORT_PARAM_NAME.equals(type)) { + Set sortFieldNames = PageFieldNamesContainer.getInstance().getSortFieldNames(); + for (String fieldName : sortFieldNames) { + String sortValue = request.getParameter(fieldName); + if (ValidateUtil.isNotEmpty(sortValue)) { + return sortValue; + } + } + return null; + } else if (ORDER_BY_PARAM_NAME.equals(type)) { + Set orderByFieldNames = PageFieldNamesContainer.getInstance().getOrderByFieldNames(); + for (String fieldName : orderByFieldNames) { + String orderByValue = request.getParameter(fieldName); + if (ValidateUtil.isNotEmpty(orderByValue)) { + return orderByValue; + } + } + return null; + } + return null; + } + + /** + * 获取请求参数的值(从requestData中获取) + * + * + * @Date 2019-09-29 15:33 + */ + private static String getRequestData(String type) { + if (PAGE_SIZE_PARAM_NAME.equals(type)) { + Set pageSizeFieldNames = PageFieldNamesContainer.getInstance().getPageSizeFieldNames(); + return getValueFromRequestData(pageSizeFieldNames); + } else if (PAGE_NO_PARAM_NAME.equals(type)) { + Set pageNoFieldNames = PageFieldNamesContainer.getInstance().getPageNoFieldNames(); + return getValueFromRequestData(pageNoFieldNames); + } else if (SORT_PARAM_NAME.equals(type)) { + Set sortFieldNames = PageFieldNamesContainer.getInstance().getSortFieldNames(); + return getValueFromRequestData(sortFieldNames); + } else if (ORDER_BY_PARAM_NAME.equals(type)) { + Set orderByFieldNames = PageFieldNamesContainer.getInstance().getOrderByFieldNames(); + return getValueFromRequestData(orderByFieldNames); + } + return null; + } + + /** + * 从requestData中获取指定字段集合名称中某一个值 + * + * + * @Date 2019-09-29 15:40 + */ + private static String getValueFromRequestData(Set fieldNames) { + for (String fieldName : fieldNames) { + RequestData requestData = RequestDataHolder.get(); + if (requestData == null) { + return null; + } else { + Object fieldValue = requestData.get(fieldName); + if (fieldValue != null) { + return fieldValue.toString(); + } + } + } + return null; + } +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageFieldNamesContainer.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageFieldNamesContainer.java new file mode 100644 index 0000000..16d56b4 --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageFieldNamesContainer.java @@ -0,0 +1,137 @@ +package com.ruoyi.biemo.core.page; + +import java.util.HashSet; +import java.util.Set; + + +/** + * 分页参数字段名称集合 + *

+ * 说明:为了兼容系统内分页参数不统一的问题 + * + * + * @date 2019-09-29-10:17 + */ +public class PageFieldNamesContainer { + + private static PageFieldNamesContainer pageFieldNamesContainer = new PageFieldNamesContainer(); + + /** + * 分页大小字段名称集合 + */ + private Set pageSizeFieldNames = new HashSet<>(); + + /** + * 分页位置字段名称集合 + */ + private Set pageNoFieldNames = new HashSet<>(); + + /** + * 升序或降序 + */ + private Set sortFieldNames = new HashSet<>(); + + /** + * 根据那个字段排序的param名称 + */ + private Set orderByFieldNames = new HashSet<>(); + + private PageFieldNamesContainer() { + //默认的字段名称 + pageSizeFieldNames.add(PageFactory.PAGE_SIZE_PARAM_NAME); + pageNoFieldNames.add(PageFactory.PAGE_NO_PARAM_NAME); + sortFieldNames.add(PageFactory.SORT_PARAM_NAME); + orderByFieldNames.add(PageFactory.ORDER_BY_PARAM_NAME); + } + + /** + * 获取实例 + * + * + * @Date 2019-09-29 16:03 + */ + public static PageFieldNamesContainer getInstance() { + return pageFieldNamesContainer; + } + + /** + * 初始化分页大小字段集合 + * + * + * @Date 2019-09-29 10:20 + */ + public void initPageSizeFieldNames(Set pageSizeFieldNames) { + this.pageSizeFieldNames.addAll(pageSizeFieldNames); + } + + /** + * 初始化分页位置字段集合 + * + * + * @Date 2019-09-29 10:20 + */ + public void initPageNoFieldNames(Set pageNoFieldNames) { + this.pageNoFieldNames.addAll(pageNoFieldNames); + } + + /** + * 升序或降序 + * + * + * @Date 2019-09-29 10:20 + */ + public void initSortFieldNames(Set sortFieldNames) { + this.sortFieldNames.addAll(sortFieldNames); + } + + /** + * 根据那个字段排序的param名称字段集合 + * + * + * @Date 2019-09-29 10:20 + */ + public void initOrderByFieldNames(Set orderByFieldNames) { + this.orderByFieldNames.addAll(orderByFieldNames); + } + + /** + * 获取分页大小字段名称集合 + * + * + * @Date 2019-09-29 10:24 + */ + public Set getPageSizeFieldNames() { + return pageFieldNamesContainer.pageSizeFieldNames; + } + + /** + * 获取分页位置字段名称集合 + * + * + * @Date 2019-09-29 10:24 + */ + public Set getPageNoFieldNames() { + return pageFieldNamesContainer.pageNoFieldNames; + } + + /** + * 升序或降序 + * + * + * @Date 2019-09-29 10:24 + */ + public Set getSortFieldNames() { + return pageFieldNamesContainer.sortFieldNames; + } + + /** + * 根据那个字段排序的param名称字段集合 + * + * + * @Date 2019-09-29 10:24 + */ + public Set getOrderByFieldNames() { + return pageFieldNamesContainer.orderByFieldNames; + } + +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageQuery.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageQuery.java new file mode 100644 index 0000000..9bf77ff --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageQuery.java @@ -0,0 +1,58 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.page; + +import lombok.Data; + +/** + * 分页查询的请求参数封装 + * + * + * @date 2017-11-08-上午11:18 + */ +@Data +public class PageQuery { + + /** + * 每页的条数 + */ + private Integer pageSize; + + /** + * 页编码(第几页) + */ + private Integer pageNo; + + /** + * 排序方式(asc 或者 desc) + */ + private String sort; + + /** + * 排序的字段名称 + */ + private String orderByField; + + public PageQuery() { + } + + public PageQuery(Integer pageSize, Integer pageNo, String sort, String orderByField) { + this.pageSize = pageSize; + this.pageNo = pageNo; + this.sort = sort; + this.orderByField = orderByField; + } +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageResult.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageResult.java new file mode 100644 index 0000000..f9ad495 --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/page/PageResult.java @@ -0,0 +1,50 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.page; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 封装分页结果集 + * + * @author makesoft + * @Date 2018/7/22 23:00 + */ +@Data +public class PageResult implements Serializable { + + private static final long serialVersionUID = -4071521319254024213L; + + private Integer page = 1;// 要查找第几页 + private Integer pageSize = 20;// 每页显示多少条 + private Integer totalPage = 0;// 总页数 + private Long totalRows = 0L;// 总记录数 + private List rows;// 结果集 + + public PageResult() { + } + + public PageResult(Page page) { + this.setRows(page.getRecords()); + this.setTotalRows(page.getTotal()); + this.setPage(page.getPageNum()); + this.setPageSize(page.getPageSize()); + } + +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/request/RequestData.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/request/RequestData.java new file mode 100644 index 0000000..4919369 --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/request/RequestData.java @@ -0,0 +1,179 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.request; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.io.Serializable; +import java.util.*; + +/** + * 响应结果封装 + * + * + * @Date 2018/2/11 23:04 + */ +public class RequestData implements Serializable { + + private static final long serialVersionUID = 9081406366569775542L; + + /** + * 封装前端请求的json数据 + */ + private JSONObject data; + + /** + * 客户端请求的ip + */ + private String ip; + + /** + * 客户端请求的地址 + */ + private String url; + + /** + * 解析请求json为指定类 + */ + public T parse(Class clazz) { + Map innerMap = this.data.getInnerMap(); + HashMap resultMap = new HashMap<>(); + Set> entries = innerMap.entrySet(); + for (Map.Entry entry : entries) { + String key = entry.getKey(); + String fieldName = StrUtil.toCamelCase(key); + resultMap.put(fieldName, entry.getValue()); + } + return BeanUtil.mapToBean(resultMap, clazz, true); + } + + /** + * 解析请求json中指定key,并转化为指定类 + */ + public T parse(String key, Class clazz) { + return this.data.getObject(key, clazz); + } + + /** + * 解析指定key,转化为object数组 + */ + public Object[] getObjectArray(String key) { + JSONArray jsonArray = this.data.getJSONArray(key); + if (jsonArray != null) { + return jsonArray.toArray(); + } else { + return new Object[]{}; + } + } + + /** + * 解析指定key,转化为带有类类型的list + */ + public List getList(String key, Class clazz) { + JSONArray jsonArray = this.data.getJSONArray(key); + if (jsonArray != null) { + return jsonArray.toJavaList(clazz); + } else { + return new ArrayList(); + } + } + + /** + * 解析指定key,转化为指定数组 + */ + public T[] getArray(String key, T[] array) { + JSONArray jsonArray = this.data.getJSONArray(key); + if (jsonArray != null) { + return jsonArray.toArray(array); + } else { + return array; + } + } + + /** + * 获取指定key对应的值 + */ + public Object get(String key) { + return this.data.get(key); + } + + /** + * 获取指定key对应的string值 + */ + public String getString(String key) { + return this.data.getString(key); + } + + /** + * 获取指定key对应的integer值 + */ + public Integer getInteger(String key) { + return this.data.getInteger(key); + } + + /** + * 获取指定key对应的long值 + */ + public Long getLong(String key) { + return this.data.getLong(key); + } + + /** + * 解析请求数据转化为map + */ + public Map parseMap() { + return this.jsonObjet2Map(this.data); + } + + private Map jsonObjet2Map(JSONObject jsonObj) { + Map map = new HashMap(); + Set> entries = jsonObj.getInnerMap().entrySet(); + Iterator> itera = entries.iterator(); + Map.Entry entry = null; + Object value = null; + while (itera.hasNext()) { + entry = itera.next(); + value = entry.getValue(); + map.put(entry.getKey(), traversalData(value)); + } + return map; + } + + private Object jsonArray2List(JSONArray array) { + List list = new ArrayList<>(); + Iterator itera = array.iterator(); + Object value; + while (itera.hasNext()) { + value = itera.next(); + list.add(traversalData(value)); + } + return list; + } + + private Object traversalData(Object value) { + if (value instanceof JSONObject) { + return this.jsonObjet2Map((JSONObject) value); + } else if (value instanceof JSONArray) { + return this.jsonArray2List((JSONArray) value); + } else { + return value; + } + } + +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/HttpContext.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/HttpContext.java new file mode 100644 index 0000000..e95cdfb --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/HttpContext.java @@ -0,0 +1,101 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.utils; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +/** + * 快捷获取HttpServletRequest,HttpServletResponse + * + * @author makesoft + * @Date 2018/1/4 21:24 + */ +public class HttpContext { + + /** + * 获取请求的ip地址 + * + * + * @Date 2018/7/23 下午3:44 + */ + public static String getIp() { + HttpServletRequest request = HttpContext.getRequest(); + if (request == null) { + return "127.0.0.1"; + } else { + return request.getRemoteHost(); + } + } + + /** + * 获取当前请求的Request对象 + * + * + * @Date 2018/7/23 下午3:44 + */ + public static HttpServletRequest getRequest() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (requestAttributes == null) { + return null; + } else { + return requestAttributes.getRequest(); + } + } + + /** + * 获取当前请求的Response对象 + * + * + * @Date 2018/7/23 下午3:44 + */ + public static HttpServletResponse getResponse() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (requestAttributes == null) { + return null; + } else { + return requestAttributes.getResponse(); + } + } + + /** + * 获取所有请求的值 + * + * + * @Date 2018/7/23 下午3:44 + */ + public static Map getRequestParameters() { + HashMap values = new HashMap<>(); + HttpServletRequest request = HttpContext.getRequest(); + if (request == null) { + return values; + } + Enumeration enums = request.getParameterNames(); + while (enums.hasMoreElements()) { + String paramName = (String) enums.nextElement(); + String paramValue = request.getParameter(paramName); + values.put(paramName, paramValue); + } + return values; + } + +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/HttpSessionContext.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/HttpSessionContext.java new file mode 100644 index 0000000..34004bc --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/HttpSessionContext.java @@ -0,0 +1,41 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.utils; + +import javax.servlet.http.HttpSession; + +/** + * 非Controller中获取当前session的工具类 + * + * + * @date 2016年11月28日 上午10:24:31 + */ +public class HttpSessionContext { + + private static ThreadLocal tl = new ThreadLocal(); + + public static void put(HttpSession s) { + tl.set(s); + } + + public static HttpSession get() { + return tl.get(); + } + + public static void remove() { + tl.remove(); + } +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/ValidateUtil.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/ValidateUtil.java new file mode 100644 index 0000000..75c3cc5 --- /dev/null +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/core/utils/ValidateUtil.java @@ -0,0 +1,111 @@ +/** + * Copyright 2018-2020 & (admin@makesoft.cn) + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ruoyi.biemo.core.utils; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 空参数校验工具类 + * + * + * @date 2018-08-08-下午3:15 + */ +public class ValidateUtil { + + /** + * 对象是否不为空(新增) + * + * + * @Date 2018/3/18 21:57 + */ + public static boolean isNotEmpty(Object o) { + return !isEmpty(o); + } + + /** + * 对象是否为空 + * + * + * @Date 2018/3/18 21:57 + */ + public static boolean isEmpty(Object o) { + if (o == null) { + return true; + } + if (o instanceof String) { + if (o.toString().trim().equals("")) { + return true; + } + } else if (o instanceof List) { + if (((List) o).size() == 0) { + return true; + } + } else if (o instanceof Map) { + if (((Map) o).size() == 0) { + return true; + } + } else if (o instanceof Set) { + if (((Set) o).size() == 0) { + return true; + } + } else if (o instanceof Object[]) { + if (((Object[]) o).length == 0) { + return true; + } + } else if (o instanceof int[]) { + if (((int[]) o).length == 0) { + return true; + } + } else if (o instanceof long[]) { + if (((long[]) o).length == 0) { + return true; + } + } + return false; + } + + /** + * 对象组中是否存在空对象 + * + * + * @Date 2018/3/18 21:59 + */ + public static boolean isOneEmpty(Object... os) { + for (Object o : os) { + if (isEmpty(o)) { + return true; + } + } + return false; + } + + /** + * 对象组中是否全是空对象 + * + * + * @Date 2018/3/18 21:59 + */ + public static boolean isAllEmpty(Object... os) { + for (Object o : os) { + if (!isEmpty(o)) { + return false; + } + } + return true; + } +} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/controller/TestESController.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/controller/TestESController.java deleted file mode 100644 index b9376b7..0000000 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/controller/TestESController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.ruoyi.biemo.elasticsearch.controller; - -import com.github.pagehelper.Page; -import com.ruoyi.biemo.elasticsearch.entity.Topic; -import com.ruoyi.biemo.elasticsearch.service.TestService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - - -/** - * @author makesoft - * @version 1.0 - * @date 2021/1/14 11:19 - */ -@RestController -@RequestMapping(value = "/es") -public class TestESController { - - @Autowired - private TestService testService; - - @PostMapping(value = "insert") - public void insertOrUpdateOne(@RequestBody Topic entity) { - testService.insertOrUpdateOne(entity); - } - - @GetMapping(value = "/get") - public List get(String keyword) { - return testService.match(keyword); - } - - @GetMapping(value = "/query") - public Page query(@RequestBody Topic topic, @RequestParam Integer pageNum,@RequestParam Integer pageSize ){ - Page page = new Page<>(pageNum,pageSize); - return testService.findPage(topic,page); - } - -} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/service/TestService.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/service/TestService.java deleted file mode 100644 index 2d4602f..0000000 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/service/TestService.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.ruoyi.biemo.elasticsearch.service; - -import com.github.pagehelper.Page; -import com.github.pagehelper.util.StringUtil; -import com.ruoyi.biemo.elasticsearch.entity.Topic; -import com.ruoyi.biemo.elasticsearch.util.EsService; -import com.ruoyi.biemo.mongodb.utils.MongoHelper; -import org.elasticsearch.common.unit.Fuzziness; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * @author makesoft - * @version 1.0 - * @date 2021/1/14 11:59 - */ -@Service -public class TestService extends EsService { - - @Autowired - private MongoHelper mongoHelper; - - public List test() { - esLambdaQuery().notIn(Topic::getId, 1, 2).delete(); - List topics = esLambdaQuery().between(Topic::getId, 2, 3).query(); - return topics; - } - - public List match(String keyword) { - return esLambdaQuery().fuzzyAll(Topic::getContent, Fuzziness.TWO, keyword).query(); - } - - public Page findPage(Topic topic,Page page){ - return esLambdaQuery().eqAll(topic).page(page.getPageNum(),page.getPageSize()).queryPage(true); - } - - public void delete() { - esLambdaQuery().eq(Topic::getId,1).delete(); - } - - @Override - public XContentBuilder buildMappingContext() { - return null; - } - - @Override - protected Topic loadData(SearchSourceBuilder context, SearchHit hit) { - String id = hit.getId(); - if (Objects.isNull(id) || StringUtil.isEmpty(id)) return null; - return mongoHelper.findById(id,Topic.class); - } - - @Override - public List batchLoadData(SearchSourceBuilder context, SearchHit[] hitArr) { - List ids = new ArrayList<>(); - for(SearchHit hit:hitArr){ - String id = hit.getId(); - if (Objects.isNull(id) || StringUtil.isEmpty(id)) continue; - ids.add(id); - } - return mongoHelper.findListByIds(ids,Topic.class); - } -} diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/util/EsService.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/util/EsService.java index 5fc9529..94df6d2 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/util/EsService.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/elasticsearch/util/EsService.java @@ -1,7 +1,7 @@ package com.ruoyi.biemo.elasticsearch.util; import com.alibaba.fastjson.JSON; -import com.github.pagehelper.Page; +import com.ruoyi.biemo.core.page.Page; import com.ruoyi.biemo.elasticsearch.annotation.EsId; import com.ruoyi.biemo.elasticsearch.function.GFunction; import com.ruoyi.common.exception.CustomException; @@ -247,7 +247,7 @@ public abstract class EsService { } Integer pageNo = builder.from(); Page page=new Page<>(pageNo<=0?1:pageNo/builder.size()+1,builder.size()); - page.addAll(res); + page.setRecords(res); page.setTotal(total); return page; } catch (Exception e) { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index 80e31cb..ea2d243 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -23,7 +23,7 @@ import com.ruoyi.common.utils.sql.SqlUtil; /** * web层通用数据处理 - * + * * @author ruoyi */ public class BaseController @@ -124,7 +124,7 @@ public class BaseController /** * 响应返回结果 - * + * * @param rows 影响行数 * @return 操作结果 */ @@ -135,7 +135,7 @@ public class BaseController /** * 响应返回结果 - * + * * @param result 结果 * @return 操作结果 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java index 70e9b08..7bce5da 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java @@ -7,7 +7,7 @@ import com.ruoyi.common.utils.sql.SqlUtil; /** * 分页工具类 - * + * * @author ruoyi */ public class PageUtils extends PageHelper diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 4583d64..2314026 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -110,7 +110,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 .antMatchers("/login", "/register", "/captchaImage").anonymous() - .antMatchers("/**").anonymous() + .antMatchers("/docInfo/**").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java index 8521b53..1592ae5 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java @@ -30,7 +30,7 @@ import com.ruoyi.generator.service.IGenTableService; /** * 代码生成 操作处理 - * + * * @author ruoyi */ @RestController @@ -211,4 +211,4 @@ public class GenController extends BaseController response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } -} \ No newline at end of file +} diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index ab19cf5..e1b0f4f 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -20,13 +20,13 @@ import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; import com.ruoyi.common.utils.poi.ExcelUtil; #if($table.crud || $table.sub) -import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.biemo.core.page.TableDataInfo; #elseif($table.tree) #end /** * ${functionName}Controller - * + * * @author ${author} * @date ${datetime} */ diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index f248430..e9a8910 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -29,7 +29,7 @@ import com.ruoyi.quartz.util.ScheduleUtils; /** * 调度任务信息操作处理 - * + * * @author ruoyi */ @RestController diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java index d27100d..70b8a9d 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -21,7 +21,7 @@ import com.ruoyi.quartz.service.ISysJobLogService; /** * 调度日志操作处理 - * + * * @author ruoyi */ @RestController @@ -55,7 +55,7 @@ public class SysJobLogController extends BaseController ExcelUtil util = new ExcelUtil(SysJobLog.class); util.exportExcel(response, list, "调度日志"); } - + /** * 根据调度编号获取详细信息 */ diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index bef6d58..7ca1ae9 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -39,7 +39,7 @@ "@riophae/vue-treeselect": "0.4.0", "axios": "0.24.0", "clipboard": "2.0.8", - "core-js": "3.19.1", + "core-js": "^3.25.0", "echarts": "4.9.0", "element-ui": "2.15.8", "file-saver": "2.0.5", diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 2b646aa..8202a6e 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -35,7 +35,7 @@ module.exports = { proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - target: `http://localhost:8080`, + target: `http://localhost:7777`, changeOrigin: true, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: ''