新增分页对象

master
hujunbo 3 years ago
parent 8b30113565
commit 599c10da3c

@ -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;

@ -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

@ -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
# 从库数据源

@ -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
# 数据库索引

@ -51,7 +51,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.4</version>
<version>1.2.68</version>
</dependency>
</dependencies>

@ -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<DocInfo> queryPage(@RequestBody DocInfo topic, @RequestParam Integer pageNum,@RequestParam Integer pageSize ){
Page<DocInfo> page = new Page<>(pageNum,pageSize);
return docInfoService.findPage(topic,page);
public Page<DocInfo> queryPage(@RequestBody DocInfo topic ){
return docInfoService.findPage(topic,PageFactory.defaultPage());
}
}

@ -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<DocInfo> {
@Autowired
private MongoHelper mongoHelper;
public Page<DocInfo> findPage(DocInfo docInfo,Page<DocInfo> page){
public Page<DocInfo> findPage(DocInfo docInfo, Page<DocInfo> page){
return esLambdaQuery().eqAll(docInfo).page(page.getPageNum(),page.getPageSize()).queryPage(true);
}

@ -0,0 +1,44 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<RequestData> 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();
}
}

@ -0,0 +1,160 @@
package com.ruoyi.biemo.core.page;
import java.util.Collections;
import java.util.List;
public class Page<T> {
private static final long serialVersionUID = 8545996863226528798L;
protected List<T> 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<T> getRecords() {
return this.records;
}
public Page<T> setRecords(List<T> records) {
this.records = records;
return this;
}
public long getTotal() {
return this.total;
}
public Page<T> 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<T> setSearchCount(boolean isSearchCount) {
this.isSearchCount = isSearchCount;
return this;
}
public Page<T> 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;
}
}

@ -0,0 +1,256 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 2017111513: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 <T> Page<T> 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<T> 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 <T> Page<T> 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<T> 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;
}
/**
* paramrequestBody
*
*
* @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<String> 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<String> 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<String> 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<String> 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<String> pageSizeFieldNames = PageFieldNamesContainer.getInstance().getPageSizeFieldNames();
return getValueFromRequestData(pageSizeFieldNames);
} else if (PAGE_NO_PARAM_NAME.equals(type)) {
Set<String> pageNoFieldNames = PageFieldNamesContainer.getInstance().getPageNoFieldNames();
return getValueFromRequestData(pageNoFieldNames);
} else if (SORT_PARAM_NAME.equals(type)) {
Set<String> sortFieldNames = PageFieldNamesContainer.getInstance().getSortFieldNames();
return getValueFromRequestData(sortFieldNames);
} else if (ORDER_BY_PARAM_NAME.equals(type)) {
Set<String> orderByFieldNames = PageFieldNamesContainer.getInstance().getOrderByFieldNames();
return getValueFromRequestData(orderByFieldNames);
}
return null;
}
/**
* requestData
*
*
* @Date 2019-09-29 15:40
*/
private static String getValueFromRequestData(Set<String> 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;
}
}

@ -0,0 +1,137 @@
package com.ruoyi.biemo.core.page;
import java.util.HashSet;
import java.util.Set;
/**
*
* <p>
*
*
*
* @date 2019-09-29-10:17
*/
public class PageFieldNamesContainer {
private static PageFieldNamesContainer pageFieldNamesContainer = new PageFieldNamesContainer();
/**
*
*/
private Set<String> pageSizeFieldNames = new HashSet<>();
/**
*
*/
private Set<String> pageNoFieldNames = new HashSet<>();
/**
*
*/
private Set<String> sortFieldNames = new HashSet<>();
/**
* param
*/
private Set<String> 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<String> pageSizeFieldNames) {
this.pageSizeFieldNames.addAll(pageSizeFieldNames);
}
/**
*
*
*
* @Date 2019-09-29 10:20
*/
public void initPageNoFieldNames(Set<String> pageNoFieldNames) {
this.pageNoFieldNames.addAll(pageNoFieldNames);
}
/**
*
*
*
* @Date 2019-09-29 10:20
*/
public void initSortFieldNames(Set<String> sortFieldNames) {
this.sortFieldNames.addAll(sortFieldNames);
}
/**
* param
*
*
* @Date 2019-09-29 10:20
*/
public void initOrderByFieldNames(Set<String> orderByFieldNames) {
this.orderByFieldNames.addAll(orderByFieldNames);
}
/**
*
*
*
* @Date 2019-09-29 10:24
*/
public Set<String> getPageSizeFieldNames() {
return pageFieldNamesContainer.pageSizeFieldNames;
}
/**
*
*
*
* @Date 2019-09-29 10:24
*/
public Set<String> getPageNoFieldNames() {
return pageFieldNamesContainer.pageNoFieldNames;
}
/**
*
*
*
* @Date 2019-09-29 10:24
*/
public Set<String> getSortFieldNames() {
return pageFieldNamesContainer.sortFieldNames;
}
/**
* param
*
*
* @Date 2019-09-29 10:24
*/
public Set<String> getOrderByFieldNames() {
return pageFieldNamesContainer.orderByFieldNames;
}
}

@ -0,0 +1,58 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}
}

@ -0,0 +1,50 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<T> 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<T> rows;// 结果集
public PageResult() {
}
public PageResult(Page page) {
this.setRows(page.getRecords());
this.setTotalRows(page.getTotal());
this.setPage(page.getPageNum());
this.setPageSize(page.getPageSize());
}
}

@ -0,0 +1,179 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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> T parse(Class<T> clazz) {
Map<String, Object> innerMap = this.data.getInnerMap();
HashMap<String, Object> resultMap = new HashMap<>();
Set<Map.Entry<String, Object>> entries = innerMap.entrySet();
for (Map.Entry<String, Object> entry : entries) {
String key = entry.getKey();
String fieldName = StrUtil.toCamelCase(key);
resultMap.put(fieldName, entry.getValue());
}
return BeanUtil.mapToBean(resultMap, clazz, true);
}
/**
* jsonkey,
*/
public <T> T parse(String key, Class<T> 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 <T> List<T> getList(String key, Class<T> clazz) {
JSONArray jsonArray = this.data.getJSONArray(key);
if (jsonArray != null) {
return jsonArray.toJavaList(clazz);
} else {
return new ArrayList<T>();
}
}
/**
* key,
*/
public <T> 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);
}
/**
* keystring
*/
public String getString(String key) {
return this.data.getString(key);
}
/**
* keyinteger
*/
public Integer getInteger(String key) {
return this.data.getInteger(key);
}
/**
* keylong
*/
public Long getLong(String key) {
return this.data.getLong(key);
}
/**
* map
*/
public Map<String, Object> parseMap() {
return this.jsonObjet2Map(this.data);
}
private Map<String, Object> jsonObjet2Map(JSONObject jsonObj) {
Map<String, Object> map = new HashMap();
Set<Map.Entry<String, Object>> entries = jsonObj.getInnerMap().entrySet();
Iterator<Map.Entry<String, Object>> itera = entries.iterator();
Map.Entry<String, Object> 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<Object> list = new ArrayList<>();
Iterator<Object> 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;
}
}
}

@ -0,0 +1,101 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<String, String> getRequestParameters() {
HashMap<String, String> 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;
}
}

@ -0,0 +1,41 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
/**
* Controllersession
*
*
* @date 20161128 10:24:31
*/
public class HttpSessionContext {
private static ThreadLocal<HttpSession> tl = new ThreadLocal<HttpSession>();
public static void put(HttpSession s) {
tl.set(s);
}
public static HttpSession get() {
return tl.get();
}
public static void remove() {
tl.remove();
}
}

@ -0,0 +1,111 @@
/**
* Copyright 2018-2020 & (admin@makesoft.cn)
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}
}

@ -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<Topic> get(String keyword) {
return testService.match(keyword);
}
@GetMapping(value = "/query")
public Page<Topic> query(@RequestBody Topic topic, @RequestParam Integer pageNum,@RequestParam Integer pageSize ){
Page<Topic> page = new Page<>(pageNum,pageSize);
return testService.findPage(topic,page);
}
}

@ -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<Topic> {
@Autowired
private MongoHelper mongoHelper;
public List<Topic> test() {
esLambdaQuery().notIn(Topic::getId, 1, 2).delete();
List<Topic> topics = esLambdaQuery().between(Topic::getId, 2, 3).query();
return topics;
}
public List<Topic> match(String keyword) {
return esLambdaQuery().fuzzyAll(Topic::getContent, Fuzziness.TWO, keyword).query();
}
public Page<Topic> findPage(Topic topic,Page<Topic> 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<Topic> batchLoadData(SearchSourceBuilder context, SearchHit[] hitArr) {
List<String> 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);
}
}

@ -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<T> {
}
Integer pageNo = builder.from();
Page<T> 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) {

@ -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()

@ -20,7 +20,7 @@ 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

@ -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",

@ -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]: ''

Loading…
Cancel
Save