新增分页对象
parent
8b30113565
commit
599c10da3c
@ -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
|
@ -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,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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析请求json中指定key,并转化为指定类
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定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<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;
|
||||
|
||||
/**
|
||||
* 非Controller中获取当前session的工具类
|
||||
*
|
||||
*
|
||||
* @date 2016年11月28日 上午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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue