删除不需要的代码,优化结构

This commit is contained in:
暮光:城中城
2022-12-07 20:21:18 +08:00
parent e82937297b
commit c62d733869
215 changed files with 334 additions and 57771 deletions

View File

@@ -3,7 +3,6 @@ package com.zyplayer.doc.data.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.pagehelper.PageInterceptor;
import com.zyplayer.doc.data.repository.support.interceptor.SqlLogInterceptor;
import com.zyplayer.doc.data.utils.DruidDataSourceUtil;
import org.mybatis.spring.annotation.MapperScan;
@@ -29,10 +28,6 @@ public class MybatisPlusConfig {
* sql日志
**/
private static final SqlLogInterceptor SQL_LOG_INTERCEPTOR = new SqlLogInterceptor();
/**
* MYSQL 分页
**/
private static final PageInterceptor MYSQL_PAGE_HELPER = new PageInterceptor();
/**
* 数据库配置
@@ -62,7 +57,7 @@ public class MybatisPlusConfig {
public MybatisSqlSessionFactoryBean manageSqlSessionFactory() throws Exception {
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(manageDatasource());
sqlSessionFactoryBean.setPlugins(SQL_LOG_INTERCEPTOR, MYSQL_PAGE_HELPER, paginationInterceptor);
sqlSessionFactoryBean.setPlugins(SQL_LOG_INTERCEPTOR, paginationInterceptor);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mapper/manage/*Mapper.xml"));

View File

@@ -19,9 +19,11 @@ public interface WikiPageMapper extends BaseMapper<WikiPage> {
@Update("update wiki_page set zan_num=zan_num + #{numAdd} where id=#{id}")
void updateZanNum(@Param("id") Long id, @Param("numAdd") Integer numAdd);
@Update("update wiki_page set seq_no=seq_no + 1 where parent_id=#{parentId} and seq_no >= #{afterSeq} and del_flag=0")
void updateAfterSeq(@Param("parentId") Long parentId, @Param("afterSeq") Integer afterSeq);
@Update("update wiki_page set seq_no=seq_no + 1 where space_id = #{spaceId} and parent_id=#{parentId} and seq_no >= #{afterSeq} and del_flag=0")
void updateAfterSeq(@Param("spaceId") Long spaceId, @Param("parentId") Long parentId, @Param("afterSeq") Integer afterSeq);
@Select("select max(seq_no) from wiki_page where parent_id=#{parentId} and del_flag=0")
Integer getLastSeq(@Param("parentId") Long parentId);
@Select("select max(seq_no) from wiki_page where space_id = #{spaceId} and parent_id=#{parentId} and del_flag=0")
Integer getLastSeq(@Param("spaceId") Long spaceId, @Param("parentId") Long parentId);
void updateChildrenSeq(@Param("spaceId") Long spaceId, @Param("parentId") Long parentId);
}

View File

@@ -1,5 +1,6 @@
package com.zyplayer.doc.data.service.common;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.zyplayer.doc.core.exception.ConfirmException;
import com.zyplayer.doc.data.config.security.DocUserDetails;
import com.zyplayer.doc.data.config.security.DocUserUtil;
@@ -12,7 +13,6 @@ import com.zyplayer.doc.data.repository.support.consts.DocSysType;
import com.zyplayer.doc.data.service.manage.ApiDocService;
import com.zyplayer.doc.data.service.manage.AuthInfoService;
import com.zyplayer.doc.data.service.manage.UserAuthService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

View File

@@ -1,246 +0,0 @@
package com.zyplayer.doc.data.service.elasticsearch.entity;
import com.zyplayer.doc.data.service.elasticsearch.support.Document;
import java.util.Date;
/**
* wiki文档搜索
*
* @author 暮光:城中城
* @since 2019-07-07
*/
@Document(indexName = "zyplayer_doc_wiki", indexType = "_doc")
public class EsWikiPage {
private Long id;
/**
* 空间ID
*/
private Long spaceId;
/**
* 名字
*/
private String name;
/**
* 父ID
*/
private Long parentId;
/**
* 节点类型 0=有子节点 1=终节点
*/
private Integer nodeType;
/**
* 赞的数量
*/
private Integer zanNum;
/**
* 编辑类型 0=可编辑 1=不允许编辑
*/
private Integer editType;
/**
* 创建人ID
*/
private Long createUserId;
/**
* 创建人名字
*/
private String createUserName;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改人ID
*/
private Long updateUserId;
/**
* 修改人名字
*/
private String updateUserName;
/**
* 修改时间
*/
private Date updateTime;
/**
* 0=有效 1=删除
*/
private Integer delFlag;
/**
* 阅读数
*/
private Integer viewNum;
/**
* 顺序
*/
private Integer seqNo;
/**
* 内容
*/
private String content;
/**
* 预览内容
*/
private String preview;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getSpaceId() {
return spaceId;
}
public void setSpaceId(Long spaceId) {
this.spaceId = spaceId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Integer getNodeType() {
return nodeType;
}
public void setNodeType(Integer nodeType) {
this.nodeType = nodeType;
}
public Integer getZanNum() {
return zanNum;
}
public void setZanNum(Integer zanNum) {
this.zanNum = zanNum;
}
public Integer getEditType() {
return editType;
}
public void setEditType(Integer editType) {
this.editType = editType;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Long updateUserId) {
this.updateUserId = updateUserId;
}
public String getUpdateUserName() {
return updateUserName;
}
public void setUpdateUserName(String updateUserName) {
this.updateUserName = updateUserName;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public Integer getViewNum() {
return viewNum;
}
public void setViewNum(Integer viewNum) {
this.viewNum = viewNum;
}
public Integer getSeqNo() {
return seqNo;
}
public void setSeqNo(Integer seqNo) {
this.seqNo = seqNo;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getPreview() {
return preview;
}
public void setPreview(String preview) {
this.preview = preview;
}
}

View File

@@ -1,25 +0,0 @@
//package com.zyplayer.doc.data.service.elasticsearch.service;
//
//import com.zyplayer.doc.data.service.elasticsearch.entity.EsWikiPage;
//import com.zyplayer.doc.data.service.elasticsearch.support.EsAbstractService;
//import org.springframework.stereotype.Service;
//
///**
// * wiki文档搜索
// *
// * @author 暮光:城中城
// * @since 2019-07-07
// */
//@Service
//public class EsWikiPageService extends EsAbstractService<EsWikiPage> {
//
// @Override
// public Class<EsWikiPage> getObjClass() {
// return EsWikiPage.class;
// }
//
// @Override
// public String getPrimaryKey(EsWikiPage tableIndex) {
// return String.valueOf(tableIndex.getId());
// }
//}

View File

@@ -1,17 +0,0 @@
package com.zyplayer.doc.data.service.elasticsearch.support;
import java.lang.annotation.*;
/**
* es文档定义
* @author 暮光:城中城
* @since 2019-07-07
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface Document {
String indexName();
String indexType();
}

View File

@@ -1,73 +0,0 @@
//package com.zyplayer.doc.data.service.elasticsearch.support;
//
//import org.apache.http.HttpHost;
//import org.elasticsearch.client.RestClient;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.LinkedList;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//import java.util.concurrent.ConcurrentHashMap;
//
///**
// * 开启es客户端
// *
// * @author 暮光:城中城
// * @since 2019-07-07
// */
//@Configuration
//public class ElasticSearchUtil {
// private static Logger logger = LoggerFactory.getLogger(ElasticSearchUtil.class);
//
// @Value(value = "${zyplayer.doc.manage.elasticsearch.hostPort:}")
// private String hostAndPort;
// @Value(value = "${zyplayer.doc.manage.elasticsearch.scheme:}")
// private String esScheme;
// @Value("${zyplayer.doc.manage.elasticsearch.open:}")
// private String elasticsearchOpen;
//
// private static final Object createLock = new Object();
// private static Map<String, RestHighLevelClient> restClientMap = new ConcurrentHashMap<>();
//
// public boolean isOpen() {
// return Objects.equals("true", elasticsearchOpen);
// }
//
// public RestHighLevelClient getEsClient() {
// if (!this.isOpen()) {
// return null;
// }
// return this.getEsClient(hostAndPort, esScheme);
// }
//
// public RestHighLevelClient getEsClient(String hostPort, String scheme) {
// String mapKey = scheme + "_" + hostPort;
// RestHighLevelClient restClient = restClientMap.get(mapKey);
// if (restClient == null) {
// synchronized (createLock) {
// restClient = restClientMap.get(mapKey);
// if (restClient == null) {
// try {
// // rest请求客户端
// // 例10.16.32.12:9200,10.16.32.12:9201
// List<HttpHost> hostPortList = new LinkedList<>();
// for (String hostPortStr : hostPort.split(",")) {
// String[] splitArr = hostPortStr.split(":");
// hostPortList.add(new HttpHost(splitArr[0], Integer.valueOf(splitArr[1]), scheme));
// }
// restClient = new RestHighLevelClient(RestClient.builder(hostPortList.toArray(new HttpHost[]{})));
// restClientMap.put(mapKey, restClient);
// } catch (Exception e) {
// logger.error("创建es客户端失败", e);
// }
// }
// }
// }
// return restClient;
// }
//}

View File

@@ -1,217 +0,0 @@
//package com.zyplayer.doc.data.service.elasticsearch.support;
//
//import com.alibaba.fastjson.JSON;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.dozer.Mapper;
//import org.elasticsearch.action.DocWriteResponse;
//import org.elasticsearch.action.delete.DeleteRequest;
//import org.elasticsearch.action.delete.DeleteResponse;
//import org.elasticsearch.action.search.SearchRequest;
//import org.elasticsearch.action.search.SearchResponse;
//import org.elasticsearch.action.update.UpdateRequest;
//import org.elasticsearch.action.update.UpdateResponse;
//import org.elasticsearch.client.RequestOptions;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.elasticsearch.common.text.Text;
//import org.elasticsearch.common.unit.TimeValue;
//import org.elasticsearch.common.xcontent.XContentType;
//import org.elasticsearch.index.query.BoolQueryBuilder;
//import org.elasticsearch.index.query.QueryBuilder;
//import org.elasticsearch.index.query.QueryBuilders;
//import org.elasticsearch.rest.RestStatus;
//import org.elasticsearch.search.SearchHit;
//import org.elasticsearch.search.builder.SearchSourceBuilder;
//import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
//import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import javax.annotation.Resource;
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.LinkedList;
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.TimeUnit;
//
///**
// * es抽象类
// *
// * @author 暮光:城中城
// * @since 2019-07-07
// */
//public abstract class EsAbstractService<T> {
// private static final Logger logger = LoggerFactory.getLogger(EsAbstractService.class);
//
// @Resource
// private ElasticSearchUtil elasticSearchUtil;
// @Resource
// private Mapper mapper;
//
// public abstract Class<T> getObjClass();
//
// public abstract String getPrimaryKey(T table);
//
// private String getIndexName() {
// Document annotation = this.getObjClass().getAnnotation(Document.class);
// return annotation.indexName();
// }
//
// private String getIndexType() {
// Document annotation = this.getObjClass().getAnnotation(Document.class);
// return annotation.indexType();
// }
//
// public boolean isOpen() {
// return elasticSearchUtil.isOpen();
// }
//
// public boolean upsert(T table) {
// String pk = getPrimaryKey(table);
// UpdateRequest request = new UpdateRequest(this.getIndexName(), pk);
// request.timeout(TimeValue.timeValueMinutes(2));
// request.doc(JSON.toJSONString(table), XContentType.JSON);
// request.docAsUpsert(true);
// RestHighLevelClient esClient = elasticSearchUtil.getEsClient();
// try {
// UpdateResponse updateResponse = esClient.update(request, RequestOptions.DEFAULT);
// return updateResponse.status() == RestStatus.OK;
// } catch (IOException e) {
// e.printStackTrace();
// }
// return false;
// }
//
// public void delete(T table) {
// String pk = getPrimaryKey(table);
// RestHighLevelClient esClient = elasticSearchUtil.getEsClient();
// DeleteRequest request = new DeleteRequest(this.getIndexName(), pk);
// request.timeout(TimeValue.timeValueMinutes(2));
// try {
// DeleteResponse deleteResponse = esClient.delete(request, RequestOptions.DEFAULT);
// if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
// logger.warn("ElasticSearch delete index id: {} but not found!", pk);
// } else {
// logger.warn("ElasticSearch delete index id: {}", pk);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 多条件 模糊查询查询前100条
// *
// * @param condition 查询条件
// */
// public List<T> getDataByCondition(List<EsQueryColumn> condition) {
// return getDataByCondition(condition, null, 0, 100).getData();
// }
//
// /**
// * 多条件 模糊查询
// *
// * @param condition 查询条件
// * @param startIndex 开始行
// * @param pageSize 每页数量
// */
// public EsPage<T> getDataByCondition(List<EsQueryColumn> condition, String[] fields, Integer startIndex, Integer pageSize) {
// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
// // 组装条件
// for (EsQueryColumn column : condition) {
// if (StringUtils.isBlank(column.getValue())) {
// if (CollectionUtils.isEmpty(column.getValues())) {
// continue;
// }
// for (Object value : column.getValues()) {
// if (column.getType() == 0) {
// boolQueryBuilder.must(QueryBuilders.wildcardQuery(column.getKey(), value.toString()));
// } else if (column.getType() == 1) {
// boolQueryBuilder.must(QueryBuilders.termQuery(column.getKey(), value));
// }
// }
// } else {
// if (column.getType() == 0) {
// boolQueryBuilder.must(QueryBuilders.wildcardQuery(column.getKey(), column.getValue()));
// } else if (column.getType() == 1) {
// boolQueryBuilder.must(QueryBuilders.termQuery(column.getKey(), column.getValue()));
// }
// }
// }
// condition.forEach(val -> {
// if (StringUtils.isNotBlank(val.getValue())) {
// if (val.getType() == 0) {
// boolQueryBuilder.must(QueryBuilders.wildcardQuery(val.getKey(), val.getValue()));
// } else if (val.getType() == 1) {
// boolQueryBuilder.must(QueryBuilders.termQuery(val.getKey(), val.getValue()));
// }
// }
// });
// return this.getDataByQuery(boolQueryBuilder, fields, startIndex, pageSize);
// }
//
// /**
// * 多条件 模糊查询
// *
// * @param queryBuilders 查询条件
// * @param startIndex 开始行
// * @param pageSize 每页数量
// */
// public EsPage<T> getDataByQuery(QueryBuilder queryBuilders, String[] fields, Integer startIndex, Integer pageSize) {
// // 设置高亮标签
// HighlightBuilder highlightBuilder = new HighlightBuilder();
// highlightBuilder.preTags("<span style=\"color:red\">");
// highlightBuilder.postTags("</span>");
// highlightBuilder.field("*");
// // 组装条件
// SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
// sourceBuilder.query(queryBuilders)
// .highlighter(highlightBuilder).from(startIndex).size(pageSize)
// .timeout(new TimeValue(60, TimeUnit.SECONDS));
// // 查询指定字段
// if (fields != null && fields.length > 0) {
// sourceBuilder.fetchSource(fields, new String[]{});
// }
// // 组装请求
// SearchRequest searchRequest = new SearchRequest();
// searchRequest.indices(this.getIndexName());
// searchRequest.source(sourceBuilder);
// RestHighLevelClient esClient = elasticSearchUtil.getEsClient();
// try {
// SearchResponse response = esClient.search(searchRequest, RequestOptions.DEFAULT);
// return responseToList(response);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return null;
// }
//
// public EsPage<T> responseToList(SearchResponse response) {
// List<T> tableList = new LinkedList<>();
// for (SearchHit searchHit : response.getHits().getHits()) {
// // 获取表ID和表类型
// Map<String, Object> sourceMap = searchHit.getSourceAsMap();
// if (sourceMap == null) {
// sourceMap = new HashMap<>();
// }
// // 获取高亮文本
// Map<String, HighlightField> highlightFieldMap = searchHit.getHighlightFields();
// for (String key : highlightFieldMap.keySet()) {
// HighlightField hf = highlightFieldMap.get(key);
// StringBuilder fragments = new StringBuilder();
// for (Text text : hf.getFragments()) {
// fragments.append(text.toString());
// }
// sourceMap.put(key, fragments.toString());
// }
// T table = mapper.map(sourceMap, this.getObjClass());
// tableList.add(table);
// }
// EsPage<T> esPage = new EsPage<>();
// esPage.setTotal(response.getHits().getTotalHits().value);
// esPage.setData(tableList);
// return esPage;
// }
//
//}

View File

@@ -1,29 +0,0 @@
package com.zyplayer.doc.data.service.elasticsearch.support;
import java.util.List;
/**
* es分页结果
* @author 暮光:城中城
* @since 2019-07-07
*/
public class EsPage<T> {
private Long total;
private List<T> data;
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}

View File

@@ -1,76 +0,0 @@
package com.zyplayer.doc.data.service.elasticsearch.support;
import java.util.List;
/**
* es查询字段封装
* @author 暮光:城中城
* @since 2019-07-07
*/
public class EsQueryColumn {
private String key;
private String value;
private List<Object> values;
// 类型0=分词搜索 1=不分词
private int type;
public EsQueryColumn(String key, String value) {
this(key, value, 0);
}
public EsQueryColumn(String key, String value, int type) {
this.key = key;
this.value = value;
this.type = type;
}
public EsQueryColumn(String key, List<Object> values, int type) {
this.key = key;
this.values = values;
this.type = type;
}
public static EsQueryColumn like(String key, String value){
return new EsQueryColumn(key, value, 0);
}
public static EsQueryColumn must(String key, String value){
return new EsQueryColumn(key, value, 1);
}
public static EsQueryColumn in(String key, List<Object> values){
return new EsQueryColumn(key, values, 1);
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public List<Object> getValues() {
return values;
}
public void setValues(List<Object> values) {
this.values = values;
}
}

View File

@@ -9,7 +9,7 @@ import com.zyplayer.doc.data.repository.manage.entity.DbTableRelation;
import com.zyplayer.doc.data.repository.manage.mapper.DbTableRelationMapper;
import com.zyplayer.doc.data.repository.manage.param.TableRelationParam;
import com.zyplayer.doc.data.service.manage.DbTableRelationService;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;