暂时提交

master
hujunbo 3 years ago
parent 599c10da3c
commit f7478d1964

@ -0,0 +1,84 @@
package com.ruoyi.biemo.business.controller;
import com.ruoyi.biemo.business.domain.Category;
import com.ruoyi.biemo.business.service.CategoryService;
import com.ruoyi.biemo.core.page.Page;
import com.ruoyi.biemo.core.page.PageFactory;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@RestController
@RequestMapping(value = "/makesoft/category")
public class CategoryController {
@Autowired
private CategoryService categoryService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:category:list')")
@GetMapping("/list")
public Page<Category> list(Category category)
{
Page<Category> page = categoryService.selectCategoryPage(category,PageFactory.defaultPage());
return page;
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:category:export')")
@Log(title = "分类管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Category category)
{
List<Category> list = categoryService.selectCategoryList(category);
ExcelUtil<Category> util = new ExcelUtil<>(Category.class);
util.exportExcel(response, list, "分类管理数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:category:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(categoryService.selectCategoryById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:category:add')")
@Log(title = "分类管理", businessType = BusinessType.INSERT)
@RequestMapping
public AjaxResult add(@RequestBody Category category)
{
categoryService.insertOrUpdateCategory(category);
return AjaxResult.success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:category:remove')")
@Log(title = "分类管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
categoryService.deleteCategoryByIds(ids);
return AjaxResult.success();
}
}

@ -1,13 +1,22 @@
package com.ruoyi.biemo.business.controller;
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.core.page.Page;
import com.ruoyi.biemo.core.page.PageFactory;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author makesoft
@ -15,26 +24,67 @@ import org.springframework.web.bind.annotation.*;
* @date 2021/1/14 11:19
*/
@RestController
@RequestMapping(value = "/docInfo")
public class DocInfoController {
@RequestMapping(value = "/makesoft/docInfo")
public class DocInfoController extends BaseController {
@Autowired
private DocInfoService docInfoService;
@Autowired
private DocInfoMongoService docInfoMongoService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:docInfo:list')")
@GetMapping("/list")
public Page<DocInfo> list(DocInfo docInfo)
{
Page<DocInfo> page = docInfoService.selectDocInfoPage(docInfo,PageFactory.defaultPage());
return page;
}
@PostMapping(value = "insertEs")
public void insertOrUpdateOne(@RequestBody DocInfo entity) {
docInfoService.insertOrUpdateOne(entity);
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:docInfo:export')")
@Log(title = "文章管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DocInfo docInfo)
{
List<DocInfo> list = docInfoService.selectDocInfoList(docInfo);
ExcelUtil<DocInfo> util = new ExcelUtil<DocInfo>(DocInfo.class);
util.exportExcel(response, list, "文章管理数据");
}
@PostMapping(value = "insertMongo")
public void insertOrUpdateMongo(@RequestBody DocInfo entity) {
docInfoMongoService.insert(entity);
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:docInfo:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(docInfoService.selectDocInfoById(id));
}
@PostMapping(value = "/queryPage")
public Page<DocInfo> queryPage(@RequestBody DocInfo topic ){
return docInfoService.findPage(topic,PageFactory.defaultPage());
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:docInfo:add')")
@Log(title = "文章管理", businessType = BusinessType.INSERT)
@RequestMapping
public AjaxResult add(@RequestBody DocInfo docInfo)
{
docInfoService.insertOrUpdateDocInfo(docInfo);
return AjaxResult.success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('biemo:docInfo:remove')")
@Log(title = "文章管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
docInfoService.deleteDocInfoByIds(ids);
return AjaxResult.success();
}
}

@ -1,40 +1,82 @@
package com.ruoyi.biemo.business.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.TreeEntity;
import org.springframework.data.mongodb.core.mapping.Document;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.biemo.elasticsearch.annotation.EsId;
import com.ruoyi.biemo.elasticsearch.annotation.FieldInfo;
import com.ruoyi.biemo.mongodb.bean.CreateTime;
import com.ruoyi.biemo.mongodb.bean.IgnoreColumn;
import com.ruoyi.biemo.mongodb.bean.UpdateTime;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
@Document
public class Category extends TreeEntity<Category> implements Cloneable {
private static final long serialVersionUID = 1L;
@Document(indexName = "category")
@org.springframework.data.mongodb.core.mapping.Document("category")
@Data
public class Category implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
@EsId
private String id;
/**
*
*
*/
private String cateName;
private Long type;
private String typeName;
@FieldInfo(type = "keyword",participle = 0)
private String name;
/**
*
*/
@FieldInfo(type = "keyword",participle = 0)
private String color;
/**
*
*/
@FieldInfo(type = "keyword",participle = 0)
private String icon;
@FieldInfo(type = "keyword",participle = 0)
private Integer isSync;
/** 父菜单名称 */
@FieldInfo(type = "keyword",participle = 0)
private String parentName;
/** 父菜单ID */
@FieldInfo(type = "keyword",participle = 0)
private String parentId;
/** 显示顺序 */
@FieldInfo(type = "keyword",participle = 0)
private Integer orderNum;
/** 创建人 **/
@FieldInfo(type = "keyword",participle = 0)
private Long createdBy;
/** 修改人 **/
@FieldInfo(type = "keyword",participle = 0)
private Long updatedBy;
@CreateTime
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@FieldInfo(type = "datetime",participle = 0)
private Long createTime;
@UpdateTime
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@FieldInfo(type = "datetime",participle = 0)
private Long updateTime;
// /** 子类 */
// @Transient
// private List<?> children = new ArrayList<>();
}

@ -2,45 +2,68 @@ package com.ruoyi.biemo.business.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.biemo.elasticsearch.annotation.EsId;
import com.ruoyi.biemo.elasticsearch.annotation.FieldInfo;
import com.ruoyi.biemo.mongodb.bean.CreateTime;
import com.ruoyi.biemo.mongodb.bean.IgnoreColumn;
import com.ruoyi.biemo.mongodb.bean.UpdateTime;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.io.Serializable;
import java.util.Date;
@Data
@Document(indexName = "doc_info")
@org.springframework.data.mongodb.core.mapping.Document("doc_info")
public class DocInfo {
public class DocInfo implements Serializable {
private static final long serialVersionUID = 1L;
@EsId
private String id;
@FieldInfo(type = "string",participle = 3)
private String title;
//文档类别 1:新闻、2:公众号
@FieldInfo(type = "keyword",participle = 0)
private Integer type;
@FieldInfo(type = "keyword",participle = 0)
private String thumb;
@Field(type = FieldType.Text,analyzer = "ik_max_word")
@FieldInfo(type = "string",participle = 3)
private String content;
@FieldInfo(type = "keyword",participle = 0)
private String author;
@FieldInfo(type = "keyword",participle = 0)
private String source;
@FieldInfo(type = "keyword",participle = 0)
private String summary;
@FieldInfo(type = "keyword",participle = 0)
private Integer status;
@FieldInfo(type = "long",participle = 0)
private Long score;
private String audio;
private String video;
private Boolean disabled;
private Boolean deleted;
private String createdBy;
private String updatedBy;
private String answer;
@FieldInfo(type = "keyword",participle = 0)
private String cateId;
@FieldInfo(type = "keyword",participle = 0)
private Integer disabled;
@FieldInfo(type = "keyword",participle = 0)
private Integer deleted;
@FieldInfo(type = "long",participle = 0)
private Long createdBy;
@FieldInfo(type = "long",participle = 0)
private Long updatedBy;
@CreateTime
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@FieldInfo(type = "datetime",participle = 0)
private Long createTime;
@UpdateTime
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private String parserInitData;
private String parserBusinessData;
@FieldInfo(type = "datetime",participle = 0)
private Long updateTime;
//图谱数据
private String parserGraphData;
//命名实体数据
private String parserNamedEntity;
//情感数据
private String parserEmotion;
}

@ -0,0 +1,35 @@
package com.ruoyi.biemo.business.domain.event;
import com.ruoyi.biemo.business.domain.DocInfo;
import org.springframework.context.ApplicationEvent;
import java.util.ArrayList;
import java.util.List;
/**
* @author
* @date 2021-03-19 17:13
*/
public class CategoryDeleteEvent extends ApplicationEvent {
private List<String> ids;
public CategoryDeleteEvent(Object source, String id) {
super(source);
this.ids=new ArrayList<>(1);
this.ids.add(id);
}
public CategoryDeleteEvent(Object source, List<String> ids) {
super(source);
this.ids=ids;
}
public List<String> getIds() {
return ids;
}
public void setIds(List<String> ids) {
this.ids = ids;
}
}

@ -0,0 +1,40 @@
package com.ruoyi.biemo.business.domain.event;
import com.ruoyi.biemo.business.domain.Category;
import com.ruoyi.biemo.business.domain.DocInfo;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.context.ApplicationEvent;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author makesoft
* @date 2022-09-10 17:13
*/
public class CategorySaveEvent extends ApplicationEvent {
private List<Category> list;
public CategorySaveEvent(Object source, Category t) {
super(source);
this.list=new ArrayList<>(1);
this.list.add(t);
}
public CategorySaveEvent(Object source, List<Category> t) {
super(source);
this.list = t;
}
public List<Category> getList() {
return list;
}
public void setList(List<Category> list) {
this.list = list;
}
}

@ -0,0 +1,34 @@
package com.ruoyi.biemo.business.domain.event;
import org.springframework.context.ApplicationEvent;
import java.util.ArrayList;
import java.util.List;
/**
* @author
* @date 2021-03-19 17:13
*/
public class DocInfoDeleteEvent extends ApplicationEvent {
private List<String> ids;
public DocInfoDeleteEvent(Object source, String id) {
super(source);
this.ids=new ArrayList<>(1);
this.ids.add(id);
}
public DocInfoDeleteEvent(Object source, List<String> ids) {
super(source);
this.ids=ids;
}
public List<String> getIds() {
return ids;
}
public void setIds(List<String> ids) {
this.ids = ids;
}
}

@ -0,0 +1,142 @@
package com.ruoyi.biemo.business.service;
import com.github.pagehelper.util.StringUtil;
import com.ruoyi.biemo.business.domain.Category;
import com.ruoyi.biemo.business.domain.DocInfo;
import com.ruoyi.biemo.business.domain.event.CategoryDeleteEvent;
import com.ruoyi.biemo.business.domain.event.CategorySaveEvent;
import com.ruoyi.biemo.core.page.Page;
import com.ruoyi.biemo.elasticsearch.util.EsService;
import com.ruoyi.biemo.mongodb.utils.MongoHelper;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author makesoft
* @version 1.0
* @date 2021/1/14 11:59
*/
@Service
public class CategoryService extends EsService<Category> {
@Autowired
private MongoHelper mongoHelper;
@Autowired
private ApplicationContext applicationContext;
@Override
protected Category loadData(SearchSourceBuilder context, SearchHit hit) {
String id = hit.getId();
if (Objects.isNull(id) || StringUtil.isEmpty(id)) return null;
return mongoHelper.findById(id,Category.class);
}
@Override
public List<Category> 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,Category.class);
}
/**
*
*
* @param id
* @return
*/
public Category selectCategoryById(String id)
{
return esLambdaQuery().eq(Category::getId,id).query().get(0);
}
/**
*
*
* @param category
* @return
*/
public List<Category> selectCategoryList(Category category)
{
return esLambdaQuery().eqAll(category).query();
}
/**
*
*
* @param category
* @return
*/
public Page<Category> selectCategoryPage(Category category, Page<Category> page){
return esLambdaQuery().eqAll(category).sort(Category::getOrderNum, SortOrder.ASC).page(page.getPageNum(),page.getPageSize()).queryPage(true);
}
/**
*
*
* @param category
* @return
*/
public String insertOrUpdateCategory(Category category)
{
String id = mongoHelper.insert(category);
category.setId(id);
applicationContext.publishEvent(new CategorySaveEvent(this,category));
return id;
}
/**
*
*
* @param ids
* @return
*/
public void deleteCategoryByIds(String[] ids)
{
List<String> list = Arrays.stream(ids).collect(Collectors.toList());
mongoHelper.deleteByIds(list, DocInfo.class);
applicationContext.publishEvent(new CategoryDeleteEvent(this,list));
}
/**
*
*
* @param id
* @return
*/
public void deleteCategoryById(String id)
{
mongoHelper.deleteById(id,Category.class);
applicationContext.publishEvent(new CategoryDeleteEvent(this,id));
}
@EventListener(classes = {CategorySaveEvent.class})
public void saveIndex(ApplicationEvent event) {
CategorySaveEvent saveEvent = (CategorySaveEvent)event;
List<Category> list = saveEvent.getList();
insertBatch(list);
}
@EventListener(classes = {CategoryDeleteEvent.class})
public void delIndex(ApplicationEvent event) {
CategoryDeleteEvent saveEvent = (CategoryDeleteEvent)event;
List<String> ids = saveEvent.getIds();
deleteBatch(ids);
}
}

@ -1,48 +0,0 @@
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.elasticsearch.util.EsService;
import com.ruoyi.biemo.mongodb.entity.Topic;
import com.ruoyi.biemo.mongodb.utils.MongoHelper;
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.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
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 DocInfoMongoService {
@Autowired
private MongoHelper mongoHelper;
@Autowired
private ApplicationContext applicationContext;
public String insert(DocInfo docInfo) {
String id = mongoHelper.insert(docInfo);
docInfo.setId(id);
applicationContext.publishEvent(new DocInfoSaveEvent(this,docInfo));
return id;
}
}

@ -2,23 +2,27 @@ package com.ruoyi.biemo.business.service;
import com.github.pagehelper.util.StringUtil;
import com.ruoyi.biemo.business.domain.DocInfo;
import com.ruoyi.biemo.business.domain.event.CategoryDeleteEvent;
import com.ruoyi.biemo.business.domain.event.CategorySaveEvent;
import com.ruoyi.biemo.business.domain.event.DocInfoDeleteEvent;
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;
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.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author makesoft
@ -31,18 +35,8 @@ public class DocInfoService extends EsService<DocInfo> {
@Autowired
private MongoHelper mongoHelper;
public Page<DocInfo> findPage(DocInfo docInfo, Page<DocInfo> page){
return esLambdaQuery().eqAll(docInfo).page(page.getPageNum(),page.getPageSize()).queryPage(true);
}
public void delete() {
esLambdaQuery().eq(DocInfo::getId,1).delete();
}
@Override
public XContentBuilder buildMappingContext() {
return null;
}
@Autowired
private ApplicationContext applicationContext;
@Override
protected DocInfo loadData(SearchSourceBuilder context, SearchHit hit) {
@ -50,7 +44,6 @@ public class DocInfoService extends EsService<DocInfo> {
if (Objects.isNull(id) || StringUtil.isEmpty(id)) return null;
return mongoHelper.findById(id,DocInfo.class);
}
@Override
public List<DocInfo> batchLoadData(SearchSourceBuilder context, SearchHit[] hitArr) {
List<String> ids = new ArrayList<>();
@ -61,7 +54,78 @@ public class DocInfoService extends EsService<DocInfo> {
}
return mongoHelper.findListByIds(ids,DocInfo.class);
}
/**
*
*
* @param id
* @return
*/
public DocInfo selectDocInfoById(String id)
{
return esLambdaQuery().eq(DocInfo::getId,id).query().get(0);
}
/**
*
*
* @param docInfo
* @return
*/
public List<DocInfo> selectDocInfoList(DocInfo docInfo)
{
return esLambdaQuery().eqAll(docInfo).query();
}
/**
*
*
* @param docInfo
* @return
*/
public Page<DocInfo> selectDocInfoPage(DocInfo docInfo, Page<DocInfo> page){
return esLambdaQuery().eqAll(docInfo).sort(DocInfo::getCreateTime,SortOrder.DESC).page(page.getPageNum(),page.getPageSize()).queryPage(true);
}
/**
*
*
* @param docInfo
* @return
*/
public String insertOrUpdateDocInfo(DocInfo docInfo)
{
String id = mongoHelper.insert(docInfo);
docInfo.setId(id);
applicationContext.publishEvent(new DocInfoSaveEvent(this,docInfo));
return id;
}
/**
*
*
* @param ids
* @return
*/
public void deleteDocInfoByIds(String[] ids)
{
List<String> list = Arrays.stream(ids).collect(Collectors.toList());
mongoHelper.deleteByIds(list, DocInfo.class);
applicationContext.publishEvent(new DocInfoDeleteEvent(this,list));
}
/**
*
*
* @param id
* @return
*/
public void deleteDocInfoById(String id)
{
mongoHelper.deleteById(id,DocInfo.class);
applicationContext.publishEvent(new DocInfoDeleteEvent(this,id));
}
@EventListener(classes = {DocInfoSaveEvent.class})
public void saveIndex(ApplicationEvent event) {
@ -69,4 +133,13 @@ public class DocInfoService extends EsService<DocInfo> {
List<DocInfo> infoList = saveEvent.getInfos();
insertBatch(infoList);
}
@EventListener(classes = {DocInfoDeleteEvent.class})
public void delIndex(ApplicationEvent event) {
DocInfoDeleteEvent saveEvent = (DocInfoDeleteEvent)event;
List<String> ids = saveEvent.getIds();
deleteBatch(ids);
}
}

@ -6,7 +6,7 @@ import java.util.List;
public class Page<T> {
private static final long serialVersionUID = 8545996863226528798L;
protected List<T> records;
protected List<T> rows;
protected long total;
protected Integer pageSize;
protected Integer pageNum;
@ -15,9 +15,11 @@ public class Page<T> {
protected boolean hitCount;
protected String countId;
protected Long maxLimit;
protected Integer code = 200;
protected String msg = "查询成功";
public Page() {
this.records = Collections.emptyList();
this.rows = Collections.emptyList();
this.total = 0L;
this.pageSize = 10;
this.pageNum = 1;
@ -39,7 +41,7 @@ public class Page<T> {
}
public Page(Integer pageNum, Integer pageSize, long total, boolean isSearchCount) {
this.records = Collections.emptyList();
this.rows = Collections.emptyList();
this.total = 0L;
this.pageSize = 10;
this.pageNum = 1;
@ -75,15 +77,13 @@ public class Page<T> {
return this.pageNum < this.getPages();
}
public List<T> getRecords() {
return this.records;
public List<T> getRows() {
return this.rows;
}
public Page<T> setRecords(List<T> records) {
this.records = records;
public Page<T> setRows(List<T> rows) {
this.rows = rows;
return this;
}
public long getTotal() {
return this.total;
}
@ -156,5 +156,21 @@ public class Page<T> {
public void setMaxLimit(final Long maxLimit) {
this.maxLimit = maxLimit;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}

@ -41,7 +41,7 @@ public class PageResult<T> implements Serializable {
}
public PageResult(Page page) {
this.setRows(page.getRecords());
this.setRows(page.getRows());
this.setTotalRows(page.getTotal());
this.setPage(page.getPageNum());
this.setPageSize(page.getPageSize());

@ -0,0 +1,29 @@
package com.ruoyi.biemo.elasticsearch.annotation;
import java.lang.annotation.*;
@Target({ElementType.FIELD,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FieldInfo {
/**
* @string text ,keyword
* @Numeric long, integer, short, byte, double, float, half_float, scaled_float
* @date date( datetime, timestamp )
* @Object object
*/
String type() default "string";
/**
* 0. not_analyzed 1. ik_smart 2. ik_max_word 3.hanlp
*/
int participle() default 0;
/**
*
* @return
*/
int ignoreAbove() default 256;
}

@ -0,0 +1,19 @@
package com.ruoyi.biemo.elasticsearch.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FieldMapping {
private String field;
private String type;
private int participle;
private int ignoreAbove;
}

@ -0,0 +1,57 @@
package com.ruoyi.biemo.elasticsearch.util;
import com.ruoyi.biemo.elasticsearch.annotation.FieldInfo;
import com.ruoyi.biemo.elasticsearch.entity.FieldMapping;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ElasticSearchUtils {
public static List<FieldMapping> getFieldInfo(Class clazz){
return getFieldInfo(clazz,null);
}
private static List<FieldMapping> getFieldInfo(Class clazz, String fieldName){
Field[] fields = clazz.getDeclaredFields();
List<FieldMapping> fieldMappingList= new ArrayList<>();
for(Field field:fields){
FieldInfo fieldInfo = field.getAnnotation(FieldInfo.class);
if(fieldInfo==null){
continue;
}
if("object".equals(fieldInfo.type())){
Class fc = field.getType();
if(fc.isPrimitive()){ //如果是基本数据类型
String name = field.getName();
if(StringUtils.isNotBlank(fieldName)){
name = name+"."+fieldName;
}
fieldMappingList.add(new FieldMapping(name,fieldInfo.type(),fieldInfo.participle(), fieldInfo.ignoreAbove()));
}else{
if(fc.isAssignableFrom(List.class)){ //判断是否为List
System.out.println("List类型" + field.getName());
Type gt = field.getGenericType(); //得到泛型类型
ParameterizedType pt = (ParameterizedType)gt;
Class lll = (Class)pt.getActualTypeArguments()[0];
fieldMappingList.addAll(getFieldInfo(lll,field.getName()));
}else{
fieldMappingList.addAll(getFieldInfo(fc,field.getName()));
}
}
}else{
String name = field.getName();
if(StringUtils.isNotBlank(fieldName)){
name = fieldName+"."+name;
}
fieldMappingList.add(new FieldMapping(name,fieldInfo.type(),fieldInfo.participle(), fieldInfo.ignoreAbove()));
}
}
return fieldMappingList;
}
}

@ -1,13 +1,18 @@
package com.ruoyi.biemo.elasticsearch.util;
import com.alibaba.fastjson.JSON;
import com.ruoyi.biemo.business.domain.DocInfo;
import com.ruoyi.biemo.core.page.Page;
import com.ruoyi.biemo.elasticsearch.annotation.EsId;
import com.ruoyi.biemo.elasticsearch.entity.FieldMapping;
import com.ruoyi.biemo.elasticsearch.function.GFunction;
import com.ruoyi.biemo.mongodb.config.Constant;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.exception.ServiceException;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.delete.DeleteRequest;
@ -15,17 +20,20 @@ import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.lucene.search.function.CombineFunction;
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
@ -41,12 +49,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.annotations.Document;
import javax.print.Doc;
import java.io.IOException;
import java.lang.reflect.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -56,7 +62,7 @@ import java.util.stream.Collectors;
*/
public abstract class EsService<T> {
protected Logger logger = LoggerFactory.getLogger(getClass());
protected Logger logger = LoggerFactory.getLogger(getClass());
// ES 默认最大返回 10000 与 scroll查询有关
int MAX_RESULT_WINDOW = 10000;
@ -75,9 +81,6 @@ public abstract class EsService<T> {
private Method getId;
// 构建ES 中的mapping
public abstract XContentBuilder buildMappingContext();
protected abstract T loadData(SearchSourceBuilder context,SearchHit hit);
/**
@ -121,50 +124,144 @@ public abstract class EsService<T> {
}
}
}
/**
* Index
* @param shards
* @param replicas
* @param rebuild
* @param indexName
* @return
* mapping
* @param index
* @param type
* @param clazz
*/
protected boolean createIndex(int shards, int replicas, boolean rebuild,String indexName){
boolean result = false;
try {
// 根据索引名称判断是否存在
result = client.indices().exists(new GetIndexRequest(indexName), RequestOptions.DEFAULT);
} catch (IOException e) {
logger.error("检查索引是否存在错误,请检查索引服务是否启动!,错误如下:{}",e);
throw new CustomException("检查索引是否存在错误",e);
}
if (result && rebuild){
try {
// 索引存在且重建 则先删除
client.indices().delete(new DeleteIndexRequest(indexName), RequestOptions.DEFAULT);
} catch (IOException e) {
logger.error("删除索引错误,请检查索引服务是否启动!",e);
throw new CustomException("删除索引错误",e);
public boolean createIndexAndCreateMapping( Class clazz, boolean rebuild, int number_of_shards, int number_of_replicas) {
try{
if (indexExist()) {
if(rebuild){
AcknowledgedResponse deleteIndexResponse = client.indices().delete(new DeleteIndexRequest(index), RequestOptions.DEFAULT);
if(deleteIndexResponse.isAcknowledged()){
return createIndexAndCreateMapping(index,ElasticSearchUtils.getFieldInfo(clazz), number_of_shards, number_of_replicas);
}else{
logger.error("删除旧索引数据失败创建索引mapping失败");
return false;
}
}else{
logger.info("不需要删除旧的索引,没有进一步创建索引结构哦~");
return true;
}
}else{
return createIndexAndCreateMapping(index,ElasticSearchUtils.getFieldInfo(clazz), number_of_shards, number_of_replicas);
}
}catch (Exception e){
return false;
}
}
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
// 设置分片数和副本数
createIndexRequest.settings(createSettings(shards,replicas));
/**
* mapping
* mapping
* @param index
* @param type
* @param fieldMappingList
* @param client es
* @param number_of_shards
* @param number_of_replicas
* @return
*/
public boolean createIndexAndCreateMapping(String index, List<FieldMapping> fieldMappingList, int number_of_shards, int number_of_replicas) {
XContentBuilder mapping = null;
try {
mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("_source").field("enabled","false").endObject()
.startObject("properties"); //设置自定义字段
for(FieldMapping info : fieldMappingList){
String field = info.getField();
String dateType = info.getType();
if(dateType == null || "".equals(dateType.trim())){
dateType = "string";
}
dateType = dateType.toLowerCase();
int participle = info.getParticiple();
if("string".equals(dateType)){
if(participle == 0){
mapping.startObject(field)
.field("type","keyword")
.field("index", false)
.field("ignore_above", info.getIgnoreAbove())
.endObject();
} else if(participle == 1) {
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp")
.endObject();
}else if(participle == 2){
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp_standard")
.endObject();
}else if(participle == 3){
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp_index")
.endObject();
}else if(participle == 4){
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp_nlp")
.endObject();
}else if(participle == 5){
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp_n_short")
.endObject();
}else if(participle == 6){
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp_crf")
.endObject();
}else if(participle == 7){
mapping.startObject(field)
.field("type","text")
.field("analyzer","hanlp_speed")
.endObject();
}
}else if("datetime".equals(dateType)){
mapping.startObject(field)
.field("type","date")
.field("format","yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")
.endObject();
}else if ("timestamp".equals(dateType)){
mapping.startObject(field)
.field("type","date")
.field("format","strict_date_optional_time||epoch_millis")
.endObject();
}else if("float".equals(dateType)||"double".equals(dateType)){
mapping.startObject(field)
.field("type","scaled_float")
.field("scaling_factor",100)
.endObject();
}else {
mapping.startObject(field)
.field("type",dateType)
.field("index",true)
.endObject();
}
}
mapping.endObject()
.endObject();
CreateIndexRequest createIndexRequest = new CreateIndexRequest(index);
// 设置分片数和副本数
createIndexRequest.settings(createSettings(number_of_shards,number_of_replicas));
// 构建对应index的mapping
createIndexRequest.mapping(buildMappingContext());
createIndexRequest.mapping(mapping);
// 发送创建index的请求
CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest,RequestOptions.DEFAULT);
result = createIndexResponse.isAcknowledged();
}catch (IOException e) {
logger.error("创建索引出错,错误如下:{}",e);
throw new CustomException("创建索引出错",e);
return createIndexResponse.isAcknowledged();
} catch (Exception e) {
logger.error("根据信息自动创建索引与mapping创建失败失败信息为:"+ e.getMessage());
return false;
}
return result;
}
public boolean indexExist() throws Exception {
GetIndexRequest request = new GetIndexRequest(index);
request.local(false);
@ -191,6 +288,17 @@ public abstract class EsService<T> {
}
public void insertBatch(List<T> list) {
if(list==null||list.size()==0){
return;
}
try {
if(!indexExist()){
createIndexAndCreateMapping(list.get(0).getClass(),true,1,0);
}
} catch (Exception e) {
e.printStackTrace();
return;
}
BulkRequest request = new BulkRequest();
list.forEach(item -> {
try {
@ -209,9 +317,9 @@ public abstract class EsService<T> {
}
}
public void deleteBatch(List<Long> idList) {
public void deleteBatch(List<String> idList) {
BulkRequest request = new BulkRequest();
idList.forEach(item -> request.add(new DeleteRequest(index, item.toString())));
idList.forEach(item -> request.add(new DeleteRequest(index, item)));
try {
client.bulk(request, RequestOptions.DEFAULT);
} catch (Exception e) {
@ -226,7 +334,8 @@ public abstract class EsService<T> {
SearchHit[] hits = response.getHits().getHits();
List<T> res = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
res.add(JSON.parseObject(hit.getSourceAsString(), entity));
//res.add(JSON.parseObject(hit.getSourceAsString(), entity));
res.add(loadData(builder,hit));
}
return res;
} catch (Exception e) {
@ -247,7 +356,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.setRecords(res);
page.setRows(res);
page.setTotal(total);
return page;
} catch (Exception e) {
@ -512,7 +621,7 @@ public abstract class EsService<T> {
String name = field.getName();
try {
Object value = field.get(t);
if(value==null){
if(value==null||name==null||Constant.SERIALVERSIONUID.equals(name)){
continue;
}
funScoreBuilders = boolTermQueryBuild( funScoreBuilders,name,value);
@ -703,4 +812,21 @@ public abstract class EsService<T> {
}
public Class getGenericType(int index) {
Type genType = getClass().getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
throw new RuntimeException("Index outof bounds");
}
if (!(params[index] instanceof Class)) {
return Object.class;
}
return (Class) params[index];
}
}

@ -3,6 +3,10 @@ package com.ruoyi.biemo.mongodb.config;
public class Constant {
public final static String ID = "id";
public final static String CREATEDBY = "createdBy";
public final static String UPDATEDBY = "updatedBy";
public final static String SERIALVERSIONUID = "serialVersionUID";
public String id;
public String getId() {

@ -1,6 +1,7 @@
package com.ruoyi.biemo.mongodb.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -15,6 +16,7 @@ import com.ruoyi.biemo.mongodb.bean.*;
import com.ruoyi.biemo.mongodb.config.Constant;
import com.ruoyi.biemo.mongodb.reflection.ReflectionUtil;
import com.ruoyi.biemo.mongodb.reflection.SerializableFunction;
import com.ruoyi.common.utils.SecurityUtils;
import org.bson.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -320,12 +322,17 @@ public class MongoHelper {
// 克隆一个@IgnoreColumn的字段设为null的对象;
Object objectClone = BeanUtil.copyProperties(object, object.getClass());
ignoreColumn(objectClone);
//设置创建人
ReflectUtil.setFieldValue(objectClone, Constant.CREATEDBY, SecurityUtils.getUserId());
ReflectUtil.setFieldValue(objectClone, Constant.UPDATEDBY, SecurityUtils.getUserId());
mongoTemplate.save(objectClone);
id = (String) ReflectUtil.getFieldValue(objectClone, Constant.ID);
// 设置id值
ReflectUtil.setFieldValue(object, Constant.ID, id);
//设置创建人
ReflectUtil.setFieldValue(object, Constant.CREATEDBY, SecurityUtils.getUserId());
ReflectUtil.setFieldValue(object, Constant.UPDATEDBY, SecurityUtils.getUserId());
logSave(objectClone, time, true);
@ -334,13 +341,18 @@ public class MongoHelper {
Field[] fields = ReflectUtil.getFields(object.getClass());
// 拷贝属性
for (Field field : fields) {
if (!field.getName().equals(Constant.ID) && ReflectUtil.getFieldValue(object, field) != null) {
if (!field.getName().equals(Constant.ID) && ReflectUtil.getFieldValue(object, field) != null&&!Modifier.isFinal(field.getModifiers())) {
ReflectUtil.setFieldValue(objectOrg, field, ReflectUtil.getFieldValue(object, field));
}
}
// 设置更新时间
setUpdateTime(objectOrg, time);
setUpdateTime(object, time);
//设置更新人
ReflectUtil.setFieldValue(objectOrg, Constant.UPDATEDBY, SecurityUtils.getUserId());
ReflectUtil.setFieldValue(object, Constant.UPDATEDBY, SecurityUtils.getUserId());
// 克隆一个@IgnoreColumn的字段设为null的对象;
Object objectClone = BeanUtil.copyProperties(objectOrg, object.getClass());
ignoreColumn(objectClone);
@ -358,7 +370,7 @@ public class MongoHelper {
* @param object
*/
public String insert(Object object) {
ReflectUtil.setFieldValue(object, Constant.ID, null);
//ReflectUtil.setFieldValue(object, Constant.ID, null);
insertOrUpdate(object);
return (String) ReflectUtil.getFieldValue(object, Constant.ID);
}

@ -0,0 +1,46 @@
package com.ruoyi.biemo.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
public class MyObjects {
/**
*
* ps: booleanfalse null
*
* @param object
* @return
*/
public static boolean IsNull(Object object){
Class clazz = object.getClass(); // 得到类对象
Field fields[] = clazz.getDeclaredFields(); // 利用反射得到所有属性
boolean flag = true; //定义标志flag
/**
*
*/
for(Field f : fields){
f.setAccessible(true);//由于考虑到某些私有属性直接访问肯能访问不到此属性设置为true确保可以访问到
Object fieldValue = null;
try {
Type fieldType =f.getGenericType();//得到属性类型
String fieldName = f.getName(); // 得到属性名
if("serialVersionUID".equals(fieldName)){
continue;
}
fieldValue = f.get(object); //得到属性值
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if(fieldValue != null){ //只要有一个属性值不为null 就返回false 表示对象不为null
flag = false;
break;
}
}
return flag;
}
}

@ -110,7 +110,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.authorizeRequests()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").anonymous()
.antMatchers("/docInfo/**").permitAll()
.antMatchers("/makesoft/**").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询分类管理列表
export function listCategory(query) {
return request({
url: '/makesoft/category/list',
method: 'get',
params: query
})
}
// 查询分类管理详细
export function getCategory(id) {
return request({
url: '/makesoft/category/' + id,
method: 'get'
})
}
// 新增分类管理
export function addCategory(data) {
return request({
url: '/makesoft/category',
method: 'post',
data: data
})
}
// 修改分类管理
export function updateCategory(data) {
return request({
url: '/makesoft/category',
method: 'put',
data: data
})
}
// 删除分类管理
export function delCategory(id) {
return request({
url: '/makesoft/category/' + id,
method: 'delete'
})
}

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询文章管理列表
export function listDocInfo(query) {
return request({
url: '/makesoft/docInfo/list',
method: 'get',
params: query
})
}
// 查询文章管理详细
export function getDocInfo(id) {
return request({
url: '/makesoft/docInfo/' + id,
method: 'get'
})
}
// 新增文章管理
export function addDocInfo(data) {
return request({
url: '/makesoft/docInfo',
method: 'post',
data: data
})
}
// 修改文章管理
export function updateDocInfo(data) {
return request({
url: '/makesoft/docInfo',
method: 'put',
data: data
})
}
// 删除文章管理
export function delDocInfo(id) {
return request({
url: '/makesoft/docInfo/' + id,
method: 'delete'
})
}

@ -160,7 +160,6 @@ export function handleTree(data, id, parentId, children) {
parentId: parentId || 'parentId',
childrenList: children || 'children'
};
var childrenListMap = {};
var nodeIds = {};
var tree = [];

@ -0,0 +1,276 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="分类名" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入分类名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:category:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="categoryList"
row-key="id"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="分类名" prop="name" />
<!-- <el-table-column label="颜色" align="center" prop="color" />-->
<!-- <el-table-column label="图标" align="center" prop="icon" />-->
<el-table-column label="排序" align="center" prop="orderNum" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:category:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['system:category:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:category:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改分类管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名" prop="name">
<el-input v-model="form.name" placeholder="请输入分类名" />
</el-form-item>
<el-form-item label="父类" prop="parentId">
<treeselect v-model="form.parentId" :options="categoryOptions" :normalizer="normalizer" placeholder="请选择父类" />
</el-form-item>
<el-form-item label="排序" prop="orderNum">
<el-input v-model="form.orderNum" placeholder="请输入排序" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCategory, getCategory, delCategory, addCategory, updateCategory } from "@/api/biemo/category";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Category",
components: {
Treeselect
},
data() {
return {
//
loading: true,
//
showSearch: true,
//
categoryList: [],
//
categoryOptions: [],
//
title: "",
//
open: false,
//
isExpandAll: true,
//
refreshTable: true,
//
queryParams: {
name: null,
color: null,
icon: null,
isSync: null,
parentName: null,
parentId: null,
orderNum: null,
createdBy: null
},
//
form: {},
//
rules: {
createdBy: [
{ required: true, message: "创建人不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询分类管理列表 */
getList() {
this.loading = true;
listCategory(this.queryParams).then(response => {
this.categoryList = this.handleTree(response.rows, "id");
this.loading = false;
});
},
/** 转换分类管理数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children
};
},
/** 查询分类管理下拉树结构 */
getTreeselect() {
listCategory().then(response => {
this.categoryOptions = [];
const data = { id: 0, name: '顶级节点', children: [] };
data.children = this.handleTree(response.rows, "id");
this.categoryOptions.push(data);
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
name: null,
color: null,
icon: null,
isSync: null,
parentName: null,
parentId: null,
orderNum: null,
createdBy: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.getTreeselect();
if (row != null && row.id) {
this.form.parentId = row.id;
} else {
this.form.parentId = 0;
}
this.open = true;
this.title = "添加分类管理";
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.getTreeselect();
if (row != null) {
this.form.parentId = row.id;
}
getCategory(row.id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改分类管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateCategory(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addCategory(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除分类管理编号为"' + row.id + '"的数据项?').then(function() {
return delCategory(row.id);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>

@ -0,0 +1,25 @@
<template>
<div>
<iFrame :src="url1"></iFrame>
</div>
</template>
<style scoped>
div{color:red}
</style>
<script>
import iFrame from "@/components/iFrame/index";
export default{
components: {iFrame},
data () {
return {
url1: '',
url2: ''
}
},
mounted () {
this.url1 = 'http://39.108.144.227:9999/spiderList.html'
},
methods: {
}
}
</script>

@ -0,0 +1,347 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="标题" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入标题"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="内容" prop="content">
<el-input
v-model="queryParams.content"
placeholder="请输入内容"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="分类" prop="cateId">
<el-select
v-model="queryParams.cateId"
placeholder="选择分类"
clearable
style="width: 240px"
>
<el-option
v-for="dict in ['分类1','分类2']"
:key="dict"
:label="dict"
:value="dict"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="选择状态"
clearable
style="width: 240px"
>
<el-option
v-for="dict in ['已分析','未分析']"
:key="dict"
:label="dict"
:value="dict"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['biemo:docInfo:add']"
>新建文章</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['biemo:docInfo:edit']"
>批量修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['biemo:docInfo:remove']"
>批量删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['biemo:docInfo:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="docInfoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="标题" align="center" prop="title" />
<el-table-column label="摘要" align="center" prop="summary" />
<el-table-column label="状态" align="center" prop="status" />
<el-table-column label="分属分类" align="center" prop="cateId" />
<el-table-column label="修改时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['biemo:docInfo:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['biemo:docInfo:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改文章管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="内容">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
<el-form-item label="作者" prop="author">
<el-input v-model="form.author" placeholder="请输入作者" />
</el-form-item>
<el-form-item label="来源" prop="source">
<el-input v-model="form.source" placeholder="请输入来源" />
</el-form-item>
<el-form-item label="评分" prop="score">
<el-input v-model="form.score" placeholder="请输入评分" />
</el-form-item>
<el-form-item label="分类" prop="cateId">
<el-input v-model="form.cateId" placeholder="请输入分类" />
</el-form-item>
<el-form-item label="是否禁用" prop="disabled">
<el-input v-model="form.disabled" placeholder="请输入是否禁用0启用1禁用" />
</el-form-item>
<el-form-item label="是否删除" prop="deleted">
<el-input v-model="form.deleted" placeholder="请输入是否删除0正常1删除" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listDocInfo, getDocInfo, delDocInfo, addDocInfo, updateDocInfo } from "@/api/biemo/docInfo";
export default {
name: "DocInfo",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
docInfoList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
title: null,
type: null,
status: null,
content: null,
author: null,
source: null,
score: null,
cateId: null,
disabled: null,
deleted: null,
createdBy: null,
updatedBy: null,
createTime: null,
updateTime: null,
parserGraphData: null,
parserNamedEntity: null,
parserEmotion: null
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询文章管理列表 */
getList() {
this.loading = true;
listDocInfo(this.queryParams).then(response => {
this.docInfoList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
status: null,
title: null,
type: null,
summary: null,
content: null,
author: null,
source: null,
score: null,
cateId: null,
audio: null,
video: null,
disabled: null,
deleted: null,
createdBy: null,
updatedBy: null,
createTime: null,
updateTime: null,
parserGraphData: null,
parserNamedEntity: null,
parserEmotion: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加文章管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getDocInfo(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改文章管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateDocInfo(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDocInfo(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除文章管理编号为"' + ids + '"的数据项?').then(function() {
return delDocInfo(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('biemo/docInfo/export', {
...this.queryParams
}, `docInfo_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Loading…
Cancel
Save