Commit 16b8cf03 authored by 李成龙's avatar 李成龙

合并知识库代码到新框架

parent c6ab331e
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-biz</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-knowledgebase-biz</artifactId>
<name>amos-boot-module-knowledgebase-biz</name>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-emq</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 规则模块 -->
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<version>${amos.version}</version>
</dependency>
<!-- 解析word -->
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-ImportXHTML</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-export-fo</artifactId>
<version>3.3.6</version>
</dependency>
<!-- 解析html -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<!-- 解析pdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>html2pdf</artifactId>
<version>2.0.1</version>
</dependency>
<!-- 解析excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</dependencies>
</project>
//package com.yeejoin.amos.knowledgebase.config;
//
//import com.baomidou.mybatisplus.core.toolkit.Sequence;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @author 杨博超
// * @ClassName Config
// * @Deacription TODO
// **/
//@Configuration
//public class Config {
//
// @Bean
// public Sequence sequence() {
// return new Sequence();
// }
//}
package com.yeejoin.amos.knowledgebase.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ElasticSearchClientConfig {
@Value("${spring.elasticsearch.rest.uris}")
private String uris;
@Bean
@Qualifier("highLevelClient")
public RestHighLevelClient restHighLevelClient() {
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
throw new IllegalStateException("Invalid ES nodes " + "property '" + uris + "'", e);
}
}
}
package com.yeejoin.amos.knowledgebase.config;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
/**
* @author 杨博超
* @ClassName SimpleCORSFilter
* @Deacription TODO
**/
@Component
public class SimpleCORSFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {
}
public void destroy() {
}
@Override
public boolean isLoggable(LogRecord logRecord) {
return false;
}
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel;
import com.yeejoin.amos.knowledgebase.face.service.DocAnnotateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/**
* <p>
* 知识库文档注释 前端控制器
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "docannotate")
@RequestMapping(value = "/v1/docannotate")
@Api(tags = "knowledgebase-文档注释")
public class DocAnnotateResource {
private final Logger logger = LogManager.getLogger(DocAnnotateResource.class);
@Autowired
private DocAnnotateService docAnnotateService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "创建注释")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseModel<KnowledgeDocAnnotateModel> create(@RequestBody KnowledgeDocAnnotateModel model) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getDocSeq())
|| ValidationUtil.isEmpty(model.getAnnotateContent()))
throw new BadRequest("参数校验失败.");
return ResponseHelper.buildResponse(docAnnotateService.createAnnotate(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "更新注释")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.PUT)
public ResponseModel<KnowledgeDocAnnotateModel> update(
@RequestBody KnowledgeDocAnnotateModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getDocSeq())
|| ValidationUtil.isEmpty(model.getAnnotateContent()))
throw new BadRequest("参数校验失败.");
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(docAnnotateService.updateAnnotate(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量删除注释")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.DELETE)
public ResponseModel deleteComments(
@RequestBody KnowledgeDocAnnotateModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(docAnnotateService.deleteAnnotate(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据文档id获取文档下注释集合")
@RequestMapping(value = "/{docSeq}", method = RequestMethod.GET)
public ResponseModel getAnnotateByDocSeq(@PathVariable(value = "docSeq") String docSeq) {
List<KnowledgeDocAnnotateModel> list = docAnnotateService.queryForAnnotateList(docSeq);
return ResponseHelper.buildResponse(list);
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.DocAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
/**
* <p>
* 知识库文档发布审核流程 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "docaudit")
@RequestMapping(value = "/v1/doccontent/docaudit")
@Api(tags = "knowledgebase-文档发布审核流程")
public class DocAuditResource {
private final Logger logger = LogManager.getLogger(DocAuditResource.class);
@Autowired
private DocAuditService docAuditService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档发布")
@RequestMapping(value = "/status/publish/{ids}", method = RequestMethod.PUT)
public ResponseModel docPublish(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(docAuditService.publish(StringUtil.String2LongList(ids)));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档取消发布")
@RequestMapping(value = "/status/unpublish/{ids}", method = RequestMethod.PUT)
public ResponseModel docUnpublish(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(docAuditService.unpublish(StringUtil.String2LongList(ids)));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档提交")
@RequestMapping(value = "/status/submit/{ids}", method = RequestMethod.PUT)
public ResponseModel docSubmit(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(docAuditService.submit(StringUtil.String2LongList(ids)));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档审核-通过")
@RequestMapping(value = "/status/pass/{ids}", method = RequestMethod.PUT)
public ResponseModel docPass(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(docAuditService.pass(StringUtil.String2LongList(ids)));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档审核-驳回")
@RequestMapping(value = "/status/reject/{id}", method = RequestMethod.PUT)
public ResponseModel docReject(@PathVariable(value = "id") Long id,
@RequestBody Map<String, Object> body) {
String rejectionComment = body.containsKey("rejectionComment") ? body.get("rejectionComment").toString() : null;
return ResponseHelper.buildResponse(docAuditService.reject(id, rejectionComment));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCategoryModel;
import com.yeejoin.amos.knowledgebase.face.service.DocCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Collection;
import java.util.List;
/**
* <p>
* 知识库文档分类 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "doccategory")
@RequestMapping(value = "/v1/doccategory")
@Api(tags = "knowledgebase-知识库文档分类")
public class DocCategoryResource {
private final Logger logger = LogManager.getLogger(DocCategoryResource.class);
@Autowired
private DocCategoryService docCategoryService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "创建")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseModel<KnowledgeDocCategoryModel> create(@RequestBody KnowledgeDocCategoryModel model) {
model = docCategoryService.createOne(model);
return ResponseHelper.buildResponse(model);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "更新")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.PUT)
public ResponseModel<KnowledgeDocCategoryModel> update(
@RequestBody KnowledgeDocCategoryModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(docCategoryService.updateOne(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询单个对象")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel<KnowledgeDocCategoryModel> seleteOne(@PathVariable("sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(docCategoryService.queryBySeq(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询")
@RequestMapping(value = "/page", method = RequestMethod.GET)
public ResponseModel<Page> queryForPage(
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page page = new Page();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(docCategoryService.queryForKnowledgeDocCategoryPage(page, RequestContext.getAgencyCode()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "列表查询")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseModel selectForList(@RequestParam(value = "parentId", required = false) Long parentId) {
return ResponseHelper.buildResponse(docCategoryService.queryForKnowledgeDocCategoryList(parentId));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档分类树查询")
@RequestMapping(value = "/tree", method = RequestMethod.GET)
public ResponseModel<Collection<KnowledgeDocCategoryModel>> docCategoryTree() {
return ResponseHelper.buildResponse(docCategoryService.queryDocCategoryTree(RequestContext.getAgencyCode(), 0L));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档分类树删除")
@RequestMapping(value = "/{ids}", method = RequestMethod.DELETE)
public ResponseModel<List<Long>> deleteDocCategory(@PathVariable("ids") String ids) {
return ResponseHelper.buildResponse(docCategoryService.deleteDocCategory(ids));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档分类树查询-携带文档基本信息(包含根节点信息)")
@RequestMapping(value = "/tree-extra", method = RequestMethod.GET)
public ResponseModel<Collection> docCategoryTreeExtra(@RequestParam(value = "root", required = false) Long root,
@RequestParam(value = "onlyPublish", defaultValue = "true", required = false) Boolean onlyPublish) {
if (ValidationUtil.isEmpty(root)) {
root = DocCategoryService.ROOT;
}
return ResponseHelper.buildResponse(docCategoryService.queryDocCategoryTreeExtra(RequestContext.getAgencyCode(), root, onlyPublish));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel;
import com.yeejoin.amos.knowledgebase.face.service.DocCommentsService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/**
* <p>
* 知识库评论信息 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "doccomments")
@RequestMapping(value = "/v1/doccomments")
@Api(tags = "knowledgebase-知识库评论信息")
public class DocCommentsResource {
private final Logger logger = LogManager.getLogger(DocCommentsResource.class);
@Autowired
private DocCommentsService docCommentsService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "创建评论")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseModel<KnowledgeDocCommentsModel> create(@RequestBody KnowledgeDocCommentsModel model) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getDocSeq())
|| ValidationUtil.isEmpty(model.getCommentsContent()))
throw new BadRequest("参数校验失败.");
return ResponseHelper.buildResponse(docCommentsService.createComments(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量删除评论")
@RequestMapping(value = "/{ids}", method = RequestMethod.DELETE)
public ResponseModel deleteComments(
@PathVariable(value = "ids") String ids) {
List<Long> seqs = StringUtil.String2LongList(ids);
docCommentsService.deleteBatchSeq(seqs);
return ResponseHelper.buildResponse(seqs);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "给评论点赞")
@RequestMapping(value = "/{sequenceNbr}/like", method = RequestMethod.PUT)
public ResponseModel<Boolean> like(
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(docCommentsService.like(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询文档的评论")
@RequestMapping(value = "/page", method = RequestMethod.GET)
public ResponseModel<Page> queryForPage(
@RequestParam(value = "docSeq") Long docSeq,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page page = new Page();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(docCommentsService.queryDocCommentsPage(page, RequestContext.getAgencyCode(), docSeq));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.service.DocContentService;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 文档库管理
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "doclibrary")
@RequestMapping(value = "/v1/doccontent/outer")
@Api(tags = "knowledgebase-文档库对外接口")
public class DocOuterResource {
@Autowired
private DocLibraryService docLibraryService;
@Autowired
private DocContentService docContentService;
/**
* 分页列表展示
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询文档信息")
@RequestMapping(value = "/page", method = RequestMethod.GET)
public ResponseModel<Page> queryDocPage(@RequestParam(value = "current") Integer current,
@RequestParam(value = "size") Integer size,
@RequestParam(value = "code", required = false) String code,
@RequestParam(value = "docTitle", required = false) String docTitle) {
Page page = new Page(current, size);
return ResponseHelper.buildResponse(docLibraryService.queryDocPage(page, docTitle, code));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询文档内容信息")
@RequestMapping(value = "/{ids}", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeDocContentModel>> selectOne(@PathVariable("ids") String ids) {
String[] idList = ids.split(",");
List<KnowledgeDocContentModel> res = new ArrayList();
for (String id : idList) {
if (!ValidationUtil.isEmpty(id)) {
res.add(docContentService.queryOneDocDetail(Long.parseLong(id.trim())));
}
}
return ResponseHelper.buildResponse(res);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据分类查询随机N条已发布文档")
@RequestMapping(value = "random-list", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeDocContentModel>> selectByDirsRand(
@RequestParam(value = "directories") String directories,
@RequestParam(value = "total",required = false) Integer total) {
List<Long> directoryList;
try {
directoryList = StringUtil.String2LongList(directories);
} catch (Exception e) {
throw new BadRequest("参数有误");
}
if (ValidationUtil.isEmpty(total) || total==0) {
total = null;
}
return ResponseHelper.buildResponse(docLibraryService.selectByDirsRand(directoryList, total));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.StatisticsRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController
//@TycloudResource(module = "knowledgebase", value = "docstatistics")
//@RequestMapping(value = "/v1/doccontent/docstatistics")
//@Api(tags = "knowledgebase-文档统计报表")
public class DocStatisticsResource {
@Autowired
private StatisticsRecordService statisticsRecordService;
/*@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "耗时* 刷新统计数据")
@RequestMapping(value = "/record/init", method = RequestMethod.PUT)
public ResponseModel init() {
return ResponseHelper.buildResponse(statisticsRecordService.init());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "灾情统计")
@RequestMapping(value = "/count/disaster", method = RequestMethod.GET)
public ResponseModel selectDisasterCount() {
return ResponseHelper.buildResponse(statisticsRecordService.selectDisasterCount());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "燃烧物质统计分类")
@RequestMapping(value = "/count/burning", method = RequestMethod.GET)
public ResponseModel selectBurningCategory() {
return ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(StatisticsRecordService.STATISTICS_BURNING_CATEGORY));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "到场时间统计分类")
@RequestMapping(value = "/count/present", method = RequestMethod.GET)
public ResponseModel selectPresentCategory() {
return ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(StatisticsRecordService.STATISTICS_PRESENT_CATEGORY));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "伤亡人数趋势统计")
@RequestMapping(value = "/count/casualties", method = RequestMethod.GET)
public ResponseModel selectCasualtiesSum(@RequestParam(value = "dateType") String dateType,
@RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
@RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_CASUALTIES_SUM));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "参战车辆数量统计")
@RequestMapping(value = "/count/power", method = RequestMethod.GET)
public ResponseModel selectPowerSum(@RequestParam(value = "dateType") String dateType,
@RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
@RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_POWER_SUM));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "过火面积统计")
@RequestMapping(value = "/count/area", method = RequestMethod.GET)
public ResponseModel selectAreaSum(@RequestParam(value = "dateType") String dateType,
@RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
@RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_AREA_COUNT));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "灭火药剂统计")
@RequestMapping(value = "/count/extinguishing", method = RequestMethod.GET)
public ResponseModel selectExtinguishingSum(@RequestParam(value = "dateType") String dateType,
@RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
@RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_EXTINGUISHING_SUM));
}*/
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsGroupModel;
import com.yeejoin.amos.knowledgebase.face.service.DynamicsGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "dynamicsgroup")
@RequestMapping(value = "/v1/dynamicsgroup")
@Api(tags = "knowledgebase-统动态选项配置的分组")
public class DynamicsGroupResource {
private final Logger logger = LogManager.getLogger(DynamicsGroupResource.class);
@Autowired
private DynamicsGroupService dynamicsGroupService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "动态配置分组列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeDynamicsGroupModel>> queryByGroup() {
return ResponseHelper.buildResponse(dynamicsGroupService.queryGroupList(RequestContext.getAppKey()));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel;
import com.yeejoin.amos.knowledgebase.face.service.DynamicsOptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "dynamicsoption")
@RequestMapping(value = "/v1/dynamicsoption")
@Api(tags = "knowledgebase-动态选项配置")
public class DynamicsOptionResource {
private final Logger logger = LogManager.getLogger(DynamicsOptionResource.class);
@Autowired
private DynamicsOptionService dynamicsOptionService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "创建动态配置字段")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseModel<KnowledgeDynamicsOptionModel> createOption(@RequestBody KnowledgeDynamicsOptionModel model) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getFieldLabel())
|| ValidationUtil.isEmpty(model.getDataType())
|| ValidationUtil.isEmpty(model.getGroupSeq())
|| ValidationUtil.isEmpty(model.getFieldName()))
throw new BadRequest("参数校验失败.");
return ResponseHelper.buildResponse(dynamicsOptionService.createOption(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "更新动态配置字段")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.PUT)
public ResponseModel<KnowledgeDynamicsOptionModel> udpateOption(
@RequestBody KnowledgeDynamicsOptionModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(dynamicsOptionService.udpateOption(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询单个字段信息")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel<KnowledgeDynamicsOptionModel> seleteOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(dynamicsOptionService.queryBySeq(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "删除单个字段定义")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.DELETE)
public ResponseModel<Boolean> deleteOption(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(dynamicsOptionService.deleteOption(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据分组查询动态字段列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeDynamicsOptionModel>> queryByGroup(@RequestParam("groupSeq") Long groupSeq) {
return ResponseHelper.buildResponse(dynamicsOptionService.queryByGroupSeq(groupSeq));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档基础信息动态字段查询")
@RequestMapping(value = "/functional/list", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeDynamicsOptionModel>> queryByFunctional() {
return ResponseHelper.buildResponse(dynamicsOptionService.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name()));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.DynamicsValueService;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
/**
* <p>
* 知识库系统动态选项配置的实例值 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "dynamicsvalue")
@RequestMapping(value = "/v1/dynamicsvalue")
@Api(tags = "knowledgebase-知识库系统动态选项配置的实例值")
public class DynamicsValueResource {
private final Logger logger = LogManager.getLogger(DynamicsValueResource.class);
@Autowired
private DynamicsValueService dynamicsValueService;
}
package com.yeejoin.amos.knowledgebase.controller;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
/**
* <p>
* 知识库内容交互计数表 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "interactioncount")
@RequestMapping(value = "/v1/interactioncount")
@Api(tags = "knowledgebase-知识库内容交互计数表")
public class InteractionCountResource {
private final Logger logger = LogManager.getLogger(InteractionCountResource.class);
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.InteractionRecordService;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
/**
* <p>
* 知识库内容交互记录 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "interactionrecord")
@RequestMapping(value = "/v1/interactionrecord")
@Api(tags = "knowledgebase-知识库内容交互记录")
public class InteractionRecordResource {
private final Logger logger = LogManager.getLogger(InteractionRecordResource.class);
@Autowired
private InteractionRecordService interactionRecordService;
}
package com.yeejoin.amos.knowledgebase.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
@RestController
@TycloudResource(module = "knowledgebase", value = "interactionrecord")
@RequestMapping(value = "/v1/message")
@Api(tags = "knowledgebase-推送消息")
public class MessageResource {
private final String paramUsers = "target";
private final String paramTitle = "docTitle";
private final String paramContent = "content";
private final String paramDocSeq = "docSeq";
private final String paramWay = "way";
private final Logger logger = LogManager.getLogger(MessageResource.class);
@Autowired
private MessageService messageService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询用户的消息列表.")
@RequestMapping(value = "/list/owner", method = RequestMethod.GET)
public ResponseModel list(@RequestParam(value = "messageType", required = false) String messageType) {
if (ValidationUtil.isEmpty(messageType)) {
messageType = null;
}
return ResponseHelper.buildResponse(messageService.queryByOwner(RequestContext.getExeUserId(), messageType));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据id查询消息详情.")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel queryOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(messageService.queryById(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "阅读消息.")
@RequestMapping(value = "/status/read/{ids}", method = RequestMethod.PUT)
public ResponseModel readMessage(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(messageService.readMessage(StringUtil.String2LongList(ids)));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "阅读全部消息.")
@RequestMapping(value = "/status/read/all", method = RequestMethod.PUT)
public ResponseModel readAllMessageByUserId() {
return ResponseHelper.buildResponse(messageService.readAllMessageByUserId(RequestContext.getExeUserId()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "要点推送.")
@RequestMapping(value = "/essential", method = RequestMethod.POST)
public ResponseModel pushEssential(@RequestBody Map<String, Object> body) {
if (body.containsKey(paramUsers) && body.containsKey(paramContent) && body.containsKey(paramDocSeq)) {
Object usersObj = body.get(paramUsers);
Object contentObj = body.get(paramContent);
Object docSeqObj = body.get(paramDocSeq);
Object titleObj = body.get(paramTitle);
if (ValidationUtil.isEmpty(usersObj)
|| !(usersObj instanceof List)
|| ValidationUtil.isEmpty(contentObj)
|| ValidationUtil.isEmpty(docSeqObj)
|| ValidationUtil.isEmpty(titleObj)) {
throw new BadRequest("参数不能为空");
}
try {
List<Map<String, Object>> users = (List<Map<String, Object>>) body.get(paramUsers);
String title = titleObj.toString();
String content = contentObj.toString();
Long docSeq = Long.valueOf(docSeqObj.toString());
return ResponseHelper.buildResponse(messageService.pushEssential(users, title, content, docSeq));
} catch (ClassCastException e) {
}
}
throw new BadRequest("参数格式有误");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "战例分享.")
@RequestMapping(value = "/doccontent", method = RequestMethod.POST)
public ResponseModel shareDoc(@RequestBody Map<String, Object> body) {
if (body.containsKey(paramUsers) && body.containsKey(paramContent) && body.containsKey(paramWay)) {
Object usersObj = body.get(paramUsers);
Object contentObj = body.get(paramContent);
Object wayObj = body.get(paramWay);
if (ValidationUtil.isEmpty(usersObj)
|| !(usersObj instanceof List)
|| ValidationUtil.isEmpty(contentObj)
|| !(contentObj instanceof List)
|| ValidationUtil.isEmpty(wayObj)) {
throw new BadRequest("参数不能为空");
}
try {
List<Map<String, Object>> users = (List<Map<String, Object>>) usersObj;
List<Map<String, Object>> content = (List<Map<String, Object>>) contentObj;
String way = wayObj.toString();
return ResponseHelper.buildResponse(messageService.shareDoc(users, content, way));
} catch (ClassCastException e) {
logger.error(e.getMessage());
}
}
throw new BadRequest("参数格式有误");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询查询用户的消息列表.")
@RequestMapping(value = "/list/page", method = RequestMethod.GET)
public ResponseModel<Page> list(
@RequestParam(value = "current", required = true) int current,
@RequestParam(value = "size", required = true) int size,
@RequestParam(value = "messageType", required = false) String messageType) {
if (size < 0 && current < 1) {
throw new BadRequest("参数有误");
}
List<Map> list = messageService.queryByPage(RequestContext.getExeUserId(), current,size,messageType);
Integer total = messageService.queryByPageCount(RequestContext.getExeUserId(),messageType);
//构建分页参数
Page page = new Page();
page.setCurrent(current);
page.setSize(size);
page.setRecords(list);
page.setTotal(total);
return ResponseHelper.buildResponse(page);
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagGroupModel;
import com.yeejoin.amos.knowledgebase.face.service.TagGroupService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Collection;
import java.util.List;
/**
* <p>
* 标签分组 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "taggroup")
@RequestMapping(value = "/v1/taggroup")
@Api(tags = "knowledgebase-标签分组")
public class TagGroupResource {
private final Logger logger = LogManager.getLogger(TagGroupResource.class);
@Autowired
private TagGroupService tagGroupService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "创建标签分组.")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseModel<KnowledgeTagGroupModel> createGroup(@RequestBody KnowledgeTagGroupModel model) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getGroupName()))
throw new BadRequest("参数校验失败.");
return ResponseHelper.buildResponse(tagGroupService.createGroup(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "更新标签分组")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.PUT)
public ResponseModel<KnowledgeTagGroupModel> updateGroup(
@RequestBody KnowledgeTagGroupModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getGroupName()))
throw new BadRequest("参数校验失败.");
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(tagGroupService.updateGroup(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "删除标签分组")
@RequestMapping(value = "/{ids}", method = RequestMethod.DELETE)
public ResponseModel<List<Long>> deleteGroup(@PathVariable("ids") String ids) {
return ResponseHelper.buildResponse(tagGroupService.deleteGroup(ids));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "标签分组树结构")
@RequestMapping(value = "/tree", method = RequestMethod.GET)
public ResponseModel<Collection<KnowledgeTagGroupModel>> groupTree(@RequestParam("groupName") String groupName) {
return ResponseHelper.buildResponse(tagGroupService.queryGroupTree(RequestContext.getAgencyCode(),groupName));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.TagInstanceService;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
/**
* <p>
* 标签实例 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "taginstance")
@RequestMapping(value = "/v1/taginstance")
@Api(tags = "knowledgebase-标签实例")
public class TagInstanceResource {
private final Logger logger = LogManager.getLogger(TagInstanceResource.class);
@Autowired
private TagInstanceService tagInstanceService;
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
/**
* <p>
* 标签库 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "tag")
@RequestMapping(value = "/v1/tag")
@Api(tags = "knowledgebase-标签库")
public class TagResource {
private final Logger logger = LogManager.getLogger(TagResource.class);
@Autowired
private TagService tagService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "创建标签")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseModel<KnowledgeTagModel> create(@RequestBody KnowledgeTagModel model) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getTagName())
|| ValidationUtil.isEmpty(model.getTagGroup())
|| ValidationUtil.isEmpty(model.getTagType())) {
throw new BadRequest("参数校验失败.");
}
return ResponseHelper.buildResponse(tagService.createTag(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "更新标签")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.PUT)
public ResponseModel<KnowledgeTagModel> update(
@RequestBody KnowledgeTagModel model,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
if (ValidationUtil.isEmpty(model)
|| ValidationUtil.isEmpty(model.getTagName())
|| ValidationUtil.isEmpty(model.getTagGroup())) {
throw new BadRequest("参数校验失败.");
}
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(tagService.updateTag(model));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询单个对象")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel seleteOne(@PathVariable(value="sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tagService.detailTag(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "条件查询")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseModel queryMapList(
@RequestParam(value = "groupSeq", required = false) Long groupSeq,
@RequestParam(value = "tagName", required = false) String tagName,
@RequestParam(value = "tagCode", required = false) String tagCode,
@RequestParam(value = "tagStatus", required = false) String tagStatus) {
return ResponseHelper.buildResponse(tagService.queryTagMap(groupSeq, tagName, tagCode, tagStatus));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "按名称搜索")
@RequestMapping(value = "/list4doc", method = RequestMethod.GET)
public ResponseModel queryListForDoc(
@RequestParam(value = "tagName", required = false) String tagName) {
return ResponseHelper.buildResponse(tagService.queryTagDetailList(tagName));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询TOP15")
@RequestMapping(value = "/list/top", method = RequestMethod.GET)
public ResponseModel selectForList(@RequestParam(value = "quoteType", required = false) String quoteType) {
boolean isAll = ValidationUtil.equalsIgnoreCase(quoteType, TagService.APPKEY_ALL);
return ResponseHelper.buildResponse(tagService.queryTopList(isAll));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量删除")
@RequestMapping(value = "/{ids}", method = RequestMethod.DELETE)
public ResponseModel batchOperate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.delete(StringUtil.String2LongList(ids)));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "启用标签")
@RequestMapping(value = "status/activate/{ids}", method = RequestMethod.PUT)
public ResponseModel batchActivate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), TagService.TAG_STATUS_ACTIVATE));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "停用标签")
@RequestMapping(value = "status/deactivate/{ids}", method = RequestMethod.PUT)
public ResponseModel batchDeactivate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), TagService.TAG_STATUS_DEACTIVATE));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "检查标签名称是否已存在")
@RequestMapping(value = "/name/exist", method = RequestMethod.GET)
public ResponseModel checkTagName(@RequestParam("tagName") String tagName,
@RequestParam(value = "sequenceNbr", required = false) Long sequenceNbr) {
if (ValidationUtil.isEmpty(tagName)) {
throw new BadRequest("参数校验失败");
}
return ResponseHelper.buildResponse(tagService.tagNameIsExist(tagName, sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询标签关联的战例列表")
@RequestMapping(value = "/{sequenceNbr}/related/doc", method = RequestMethod.GET)
public ResponseModel queryRelatedDocList(@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tagService.queryRelatedDocList(sequenceNbr));
}
}
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.TagValueService;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
/**
* <p>
* 值标签的实例值 前端控制器
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@RestController
@TycloudResource(module = "knowledgebase", value = "tagvalue")
@RequestMapping(value = "/v1/tagvalue")
@Api(tags = "knowledgebase-值标签的实例值")
public class TagValueResource {
private final Logger logger = LogManager.getLogger(TagValueResource.class);
@Autowired
private TagValueService tagValueService;
}
package com.yeejoin.amos.knowledgebase.face.enumeration;
/**
* @author 杨博超
* @ClassName DynamicsFunctional
**/
public enum DynamicsFunctional {
DOC_BASEINFO,//文档基础信息动态字段配置
VALUE_TAG_CONFIG//标签配置信息动态字段
}
package com.yeejoin.amos.knowledgebase.face.enumeration;
import java.util.Comparator;
import java.util.List;
/**
* @author 杨博超
* @ClassName RoleName
* @Deacription
**/
public enum KnowledgeRoleName {
VIEWER("浏览者", 0, 0, 1, 1),
INPUTER("录入者", 0, 1, 1, 1),
AUDITOR("审核者", 0, 2, 1, 1),
TAG_MANAGER("标签管理员", 1, 0, 0, 0);
private String roleName;
private int tagManagerScore;
private int docManagerScore;
private int docGroupManagerScore;
private int searchScore;
KnowledgeRoleName(String roleName, int tagManagerScore, int docManagerScore, int docGroupManagerScore, int searchScore) {
this.roleName = roleName;
this.tagManagerScore = tagManagerScore;
this.docManagerScore = docManagerScore;
this.docGroupManagerScore = docGroupManagerScore;
this.searchScore = searchScore;
}
public String getRoleName() {
return roleName;
}
public int getTagManagerScore() {
return tagManagerScore;
}
public int getDocManagerScore() {
return docManagerScore;
}
public int getDocGroupManagerScore() {
return docGroupManagerScore;
}
public int getSearchScore() {
return searchScore;
}
public static KnowledgeRoleName getInstance(String roleName) {
KnowledgeRoleName knowledgeRoleName = null;
for (KnowledgeRoleName roleNameIns : KnowledgeRoleName.values()) {
if (roleNameIns.getRoleName().equals(roleName))
knowledgeRoleName = roleNameIns;
}
return knowledgeRoleName;
}
public static KnowledgeRoleName getMaxScore(List<String> roleNames, Comparator<KnowledgeRoleName> comparator) {
KnowledgeRoleName maxScore = null;
for (String roleName : roleNames) {
if (maxScore == null) {
maxScore = getInstance(roleName);
continue;
}
KnowledgeRoleName current = getInstance(roleName);
if(comparator.compare(current,maxScore) > 0)
maxScore = current;
}
return maxScore;
}
}
package com.yeejoin.amos.knowledgebase.face.enumeration;
/**
* @author 杨博超
* @ClassName OperateType
* @Deacription 内容操作类型
**/
public enum OperateType {
LIKE, //点赞
DIS_LIKE, //吐槽
COMMENT, //评论
REFERENCE, //引用
COLLECT //收藏
}
package com.yeejoin.amos.knowledgebase.face.enumeration;
/**
* @author 杨博超
* @ClassName DataType
* @Deacription 动态配置的值类型
**/
public enum OptionDataType {
String, Integer,datetime, Enum,Double,Date
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
/**
* @author 杨博超
* @ClassName AttachmentModel
**/
@Data
public class AttachmentModel {
private String fileType;
private String filename;
private String originalFileName;
private String fileUrl;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
/**
* <p>
* 知识库文档注释信息
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocAnnotateModel extends BaseModel {
/**
* 文档id
*/
private Long docSeq;
/**
* 添加注释的用户id
*/
private String userId;
/**
* 添加注释的用户名称
*/
private String username;
/**
* 是否是当前用户添加的注释
*/
private Boolean isCurrentUser;
/**
* 添加注释后文档内容
*/
private String htmlContent;
/**
* 注释内容
*/
private String annotateContent;
/**
* 注释位置信息(前端定义和使用的内容)
*/
private String positionInfo;
/**
* 机构编号
*/
private String agencyCode;
private Date createTime;
private Date updateTime;
public Date getUpdateTime() {
return recDate;
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Collection;
/**
* <p>
* 知识库文档分类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocCategoryModel extends BaseModel implements TreeNode<KnowledgeDocCategoryModel,Long> {
/**
* 分组名称
*/
private String categoryName;
private Long parentId;
/**
* 机构编号
*/
private String agencyCode;
private Collection<KnowledgeDocCategoryModel> children;
@Override
public Long getMyParentId() {
return this.parentId;
}
@Override
public Long getMyId() {
return this.sequenceNbr;
}
@Override
public Collection<KnowledgeDocCategoryModel> getChildren() {
return children;
}
@Override
public void setChildren(Collection<KnowledgeDocCategoryModel> children) {
this.children = children;
}
@Override
public int compareTo(KnowledgeDocCategoryModel groupModel) {
return this.getMyId().compareTo(groupModel.getMyId());
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
/**
* <p>
* 知识库评论信息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocCommentsModel extends BaseModel {
/**
* 文档id
*/
private Long docSeq;
/**
* 发表评论的用户id
*/
private String userId;
private String username;
/**
* 评论内容
*/
private String commentsContent;
/**
* 父级评论id
*/
private Long parentId;
/**
* 机构编号
*/
private String agencyCode;
/**
* 是否点赞
*/
private Boolean like;
/**
* 总点赞数量
*/
private Integer likedNum;
private Date createTime;
public Date getCreateTime() {
return recDate;
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 知识库文档存储
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocContentModel extends BaseModel {
/**
* 富文本内容存储
*/
private String htmlContent;
/**
* 文档状态:发布,未发布
*/
private String docStatus;
/**
* 录入者id
*/
private String userId;
/**
* 录入者姓名
*/
private String userName;
/**
* 创建时间
*/
private Date createTime;
/**
* 是否有附件
*/
private Boolean haveAttachment;
/**
* 摘要
*/
private String summary;
/**
* 机构编号
*/
private String agencyCode;
/**
* 审核状态:通过,驳回,待审核,待提交
**/
private String auditStatus;
/**
* 驳回意见
**/
private String rejectionComment;
/**
* 审核人id
**/
private String auditorUserId;
private String orgCode;
/**
* 纯文本内容
*/
private String textContent;
/**
* 排序内容
*/
private String sortStr;
/**
* 所属目录
*/
private Long directoryId;
/**
* 文档标题
*/
private String docTitle;
private String directoryName; // 目录名称
private Date lastUpdateTime;
private Map<String, Object> docBaseInfo; // 文档基础信息<feildName,value>
private List<KnowledgeTagInstanceModel> docTags; // 文档标签<tagInstanceModel,>
private List<KnowledgeTagInstanceModel> docContentTags; // 文档内容标签<tagInstanceModel>
private List<KnowledgeTagInstanceModel> tagsToShow; // 只能搜索列表显示的标签信息
private List<AttachmentModel> attachments; // 附件信息;<附件id,附件原始名称>
private Boolean collected; // 收藏标识
public Date getLastUpdateTime() {
return recDate;
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import com.baomidou.mybatisplus.annotation.TableField;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDynamicsGroupModel extends BaseModel {
/**
* 分组名称
*/
private String groupName;
/**
* 前端配置
*/
private String frontEndConfig;
/**
* 机构编号
*/
private String agencyCode;
/**
* 功能标识
*/
private String functional;
/**
* 业务项目标识
*/
private String appKey;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDynamicsOptionModel extends BaseModel {
/**
* 字段名
*/
private String fieldName;
/**
* 中文名
*/
private String fieldLabel;
/**
* 数据类型:文本,数字,枚举,日期
*/
private String dataType;
/**
* 功能标识
*/
private String functional;
/**
* 业务项目标识
*/
private String appKey;
private String frontEndConfig;
/**
* 机构编号
*/
private String agencyCode;
/**
* 字段分组主键
**/
private Long groupSeq;
private String queryStrategy;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置的实例值
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDynamicsValueModel extends BaseModel {
/**
* 字段名
*/
private String fieldName;
/**
* 中文名
*/
private String fieldLabel;
/**
* 数据类型:文本,数字,枚举,日期
*/
private String dataType;
/**
* 字段分组id
*/
private Long groupSeq;
/**
* 动态配置字段的值
*/
private String fieldValue;
/**
* 关联的对象id,即文档id
*/
private Long instanceId;
/**
* 机构编号
*/
private String agencyCode;
private Long optionSeq;
private String queryStrategy;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库内容交互计数表
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeInteractionCountModel extends BaseModel {
/**
* 操作类型(标签所有情况引用,标签被已审核/已发布文档引用,文档引用)
*/
private String operateType;
/**
* 关联对象类型
*/
private String entityType;
/**
* 关联对象id
*/
private String entityId;
/**
* 计数
*/
private Integer operateCount;
/**
* 机构编号
*/
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库内容交互记录
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeInteractionRecordModel extends BaseModel {
/**
* 用户id
*/
private String userId;
/**
* 操作类型(点赞,吐槽,收藏)
*/
private String operateType;
/**
* 关联对象类型
*/
private String entityType;
/**
* 关联对象id
*/
private String entityId;
/**
* 机构编号
*/
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 消息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeMessageModel extends BaseModel {
/**
* 消息类型
*/
private String messageType;
/**
* 消息标题
*/
private String messageTitle;
/**
* 消息内容
*/
private String messageContent;
/**
* 相关文档ID
*/
private Long targetSeq;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 个人消息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeMessagePersonalModel extends BaseModel {
/**
* 接收人
*/
private String messageOwner;
/**
* 消息ID
*/
private Long messageSeq;
/**
* 消息状态
*/
private Integer messageStatus;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Collection;
/**
* <p>
* 标签分组
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagGroupModel extends BaseModel implements TreeNode<KnowledgeTagGroupModel,Long> {
/**
* 标签分类名称
*/
private String groupName;
/**
* 父级分类id
*/
private Long parentId;
/**
* 机构编号
*/
private String agencyCode;
private Collection<KnowledgeTagGroupModel> children;
@Override
public Long getMyParentId() {
return this.parentId;
}
@Override
public Long getMyId() {
return this.sequenceNbr;
}
@Override
public Collection<KnowledgeTagGroupModel> getChildren() {
return children;
}
@Override
public void setChildren(Collection<KnowledgeTagGroupModel> children) {
this.children = children;
}
@Override
public int compareTo(KnowledgeTagGroupModel groupModel) {
return this.getMyId().compareTo(groupModel.getMyId());
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 标签分组
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagGroupRefModel extends BaseModel {
/**
* 标签分组id
*/
private Long groupSeq;
/**
* 标签id
*/
private Long tagSeq;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* <p>
* 标签实例
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagInstanceModel extends BaseModel {
/**
* 标签id
*/
private Long tagSeq;
/**
* 标签标记的目标id
*/
private Long targetSeq;
/**
* 标签名称
*/
private String tagName;
/**
* 标记方式:文档,内容
*/
private String markingType;
/**
* 机构编号
*/
private String agencyCode;
private String tagType;
private String frontEndConfig;
private List<KnowledgeTagValueModel> tagValues;//值标签的具体值
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
import java.util.Map;
/**
* <p>
* 标签库
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagModel extends BaseModel {
/**
* 标签名称
*/
private String tagName;
/**
* 标签编码
*/
private String tagCode;
/**
* 标签分类:文本标签,值标签,
*/
private String tagType;
/**
* 标签状态:启用,禁用
*/
private String tagStatus;
/**
* 标签备注
*/
private String tagRemark;
/**
* 机构编号
*/
private String agencyCode;
/**
* 被引用数量(所有文档)
*/
private Integer referenceNumber;
/**
* 动态值
*/
private Map<String, Object> tagValues;
/**
* 标签分类
*/
private List<Long> tagGroup;
/**
* 创建人姓名
*/
private String creator;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 值标签的实例值
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagValueModel extends BaseModel {
/**
* 标签实例id
*/
private Long instanceSeq;
/**
* 值标签的扩展字段名,内容标签文本位置,值标签文本内容/单值/日期,值标签范围最大值-最小值
*/
private String fieldName;
/**
* 值标签扩展字段的值
*/
private String tagValue;
/**
* 机构编号
*/
private String agencyCode;
private String unit;
}
package com.yeejoin.amos.knowledgebase.face.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
/**
* <p>
* 标签分组
* </p>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowlege_statistics_record")
public class KnowlegeStatisticsRecordModel extends BaseModel {
/**
* 文档ID
*/
@TableField("DOC_SEQ")
private Long docSeq;
/**
* 警情发生时间
*/
@TableField("DISASTER_TIME")
private Date disasterTime;
/**
* 记录类型
*/
@TableField("RECORD_NAME")
private String recordName;
/**
* 分类字段值
*/
@TableField("CATEGORY_VALUE")
private String categoryValue;
/**
* 统计数值
*/
@TableField("COUNT_VALUE")
private Long countValue;
/**
* 值放大倍数
*/
@TableField("VALUE_WEIGHT")
private Integer valueWeight;
/**
* 数值单位
*/
@TableField("UNIT")
private Long unit;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import java.util.Collection;
/**
* <h1><h1>
*
* @author tiantao
* @date 2021/1/18 11:36
*/
@EqualsAndHashCode
@Data
public class MultipleNodeModel implements TreeNode<MultipleNodeModel, Long> {
private String nodeType;
private Long nodeKey;
private String nodeTitle;
private Long nodeParent;
private Collection<MultipleNodeModel> nodeChildren;
private Object nodeExtraInfo;
@Override
public Long getMyParentId() {
return this.nodeParent;
}
@Override
public Long getMyId() {
return this.nodeKey;
}
@Override
public Collection<MultipleNodeModel> getChildren() {
return this.nodeChildren;
}
@Override
public void setChildren(Collection<MultipleNodeModel> collection) {
this.setNodeChildren(collection);
}
@Override
public int compareTo(MultipleNodeModel o) {
return this.getNodeKey().compareTo(o.getNodeKey());
}
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
/**
* <p>
* 知识库文档注释 Mapper 接口
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
public interface DocAnnotateMapper extends BaseMapper<KnowledgeDocAnnotate> {
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.model.MultipleNodeModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocCategory;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 知识库文档分类 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DocCategoryMapper extends BaseMapper<KnowledgeDocCategory> {
List<MultipleNodeModel> queryDocAndCategoryTree(@Param("categoryIds") List<Long> categoryIds, @Param("docStatus") String docStatus);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments;
/**
* <p>
* 知识库评论信息 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DocCommentsMapper extends BaseMapper<KnowledgeDocComments> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 知识库文档存储 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> {
List<Map<String,Long>> searchForDocIds(@Param("agencyCode") String agencyCode,
@Param("queryStr") String queryStr,
@Param("docStatus")String []docStatus,
@Param("auditStatus")String [] auditStatus,
@Param("userId")String userId,
@Param("orgCode")String orgCode,
@Param("offset") long offset,
@Param("length") long length);
List<Map<String,Object>> queryDocBaseInfoList(Map<String, Object> paramMap);
int queryDocBaseInfoTotal(Map<String, Object> paramMap);
List<Long> getAllPublishedDocIds();
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsGroup;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DynamicsGroupMapper extends BaseMapper<KnowledgeDynamicsGroup> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsOption;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DynamicsOptionMapper extends BaseMapper<KnowledgeDynamicsOption> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue;
/**
* <p>
* 知识库系统动态选项配置的实例值 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DynamicsValueMapper extends BaseMapper<KnowledgeDynamicsValue> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository;
public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> {
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionCount;
import java.util.List;
/**
* <p>
* 知识库内容交互计数表 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface InteractionCountMapper extends BaseMapper<KnowledgeInteractionCount> {
/**
* 查询标签被所有文档的引用状况
* @return
*/
List<KnowledgeInteractionCount> queryTagQuoteAll();
/**
* 查询标签被发布文档的引用状况
* @return
*/
List<KnowledgeInteractionCount> queryTagQuotePublish();
/**
* 根据实体类型删除记录
* @param entityType 类型
* @return
*/
int deleteByEntityType(String entityType);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionRecord;
/**
* <p>
* 知识库内容交互记录 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface InteractionRecordMapper extends BaseMapper<KnowledgeInteractionRecord> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface MessageMapper extends BaseMapper<KnowledgeMessage> {
List<Map> selectMessageListByOwner(@Param("owner") String owner, @Param("messageType")String messageType);
Map selectMessageBySeq(Long sequenceNbr);
List<Map> selectMessageListByPage(Map<String,Object> param );
Integer selectMessageListByCount(Map<String,Object> param);
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessagePersonal;
/**
* <p>
* 标签库 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface MessagePersonalMapper extends BaseMapper<KnowledgeMessagePersonal> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
import java.util.List;
import java.util.Map;
/**
* <p>
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRecord> {
/**
* 表清空
* @return
*/
void deleteAll();
/**
* 查询灾情总计
* @return
*/
Map<String, Object> selectDisasterCount();
/**
* 按类型分组查询
*/
List<Map<String, Object>> selectCategoryByName(String recordName);
/**
* 按类型查询/按时间分段总计
*/
List<Map<String, Object>> selectCountByNameAndDateRange(Map<String, Object> queryMap);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagGroup;
/**
* <p>
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagGroupMapper extends BaseMapper<KnowledgeTagGroup> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagGroupRef;
/**
* <p>
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagGroupRefMapper extends BaseMapper<KnowledgeTagGroupRef> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
/**
* <p>
* 标签实例 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagInstanceMapper extends BaseMapper<KnowledgeTagInstance> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import java.util.List;
/**
* <p>
* 标签库 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagMapper extends BaseMapper<KnowledgeTag> {
List<KnowledgeTag> queryTagByNameInPublishedDoc(String tagName);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
* <p>
* 值标签的实例值 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagValueMapper extends BaseMapper<KnowledgeTagValue> {
/**
* 根据文档id查询标签值列表
* @param docSeq 文档id
* @return
*/
List<KnowledgeTagValue> queryTagValuesByDocId(Long docSeq);
/**
* 根据文档id查询标签值列表
* @param docIds 文档id列表
* @return
*/
List<KnowledgeTagValue> queryTagValuesByDocIds(@Param("docIds") Collection<Long> docIds);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
import java.util.List;
@Data
@Accessors(chain = true)
@Document(indexName = "knowledgebase", type = "doc", shards = 1, replicas = 0)
public class ESDocEntity {
/** 主键 */
@Id
private Long sequenceNbr;
/** 文档标题 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_max_word", analyzer = "ik_max_word")
private String docTitle;
/** 主键 */
private Long directoryId;
/** 分类 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_smart")
private String directoryName;
/** 作者 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_smart")
private String author;
/** 发布时间 */
@Field(type = FieldType.Date, format = DateFormat.basic_date_time)
private Date lastUpdateTime;
/** 正文文字 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_max_word", analyzer = "ik_max_word")
private String textContent;
/** 基本信息 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_max_word")
private String docInfo;
/** 文档正文HTML */
private String htmlContent;
/** 文档摘要 */
private String summary;
/** 文档标签 */
@Field(type = FieldType.Nested, includeInParent = true)
private List<ESTagEntity> docTags;
/** 文档内容标签 */
@Field(type = FieldType.Nested, includeInParent = true)
private List<ESTagEntity> contentTags;
private String docJson;
@Field(type = FieldType.Keyword)
private String sortStr;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Parent;
@Data
@Accessors(chain = true)
@Document(indexName = "knowledgebase",type = "tag", shards = 1, replicas = 0)
public class ESTagEntity {
/** 主键 */
@Id
private Long sequenceNbr;
private Long tagSeq;
/** 标签名称 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_max_word", analyzer = "ik_max_word")
private String tagName;
/** 标签值信息 */
@Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_smart")
private String tagInfo;
/**原生数据*/
private String tagJson;
/** 绑定外键 */
@Parent(type = "doc")
private String docId;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* <p>
* 知识库文档注释
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_doc_annotate")
public class KnowledgeDocAnnotate extends BaseEntity {
/**
* 文档id
*/
@TableField("DOC_SEQ")
private Long docSeq;
/**
* 添加注释的用户id
*/
@TableField("USER_ID")
private String userId;
/**
* 注释内容
*/
@TableField("ANNOTATE_CONTENT")
private String annotateContent;
/**
* 注释位置信息(前端定义和使用的内容)
*/
@TableField("POSITION_INFO")
private String positionInfo;
/**
* 创建时间
*/
@TableField("CREATE_TIME")
private Date createTime;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库文档分类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_doc_category")
public class KnowledgeDocCategory extends BaseEntity {
/**
* 分组名称
*/
@TableField("CATEGORY_NAME")
private String categoryName;
@TableField("PARENT_ID")
private Long parentId;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库评论信息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_doc_comments")
public class KnowledgeDocComments extends BaseEntity {
/**
* 文档id
*/
@TableField("DOC_SEQ")
private Long docSeq;
/**
* 发表评论的用户id
*/
@TableField("USER_ID")
private String userId;
/**
* 评论内容
*/
@TableField("COMMENTS_CONTENT")
private String commentsContent;
/**
* 父级评论id
*/
@TableField("PARENT_ID")
private Long parentId;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date;
/**
* <p>
* 知识库文档存储
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_doc_content")
public class KnowledgeDocContent extends BaseEntity {
/**
* 富文本内容存储
*/
@TableField("HTML_CONTENT")
private String htmlContent;
/**
* 文档状态:发布,未发布
*/
@TableField("DOC_STATUS")
private String docStatus;
/**
* 发布者
*/
@TableField("USER_ID")
private String userId;
/**
* 创建时间
*/
@TableField("CREATE_TIME")
private Date createTime;
/**
* 是否有附件
*/
@TableField("HAVE_ATTACHMENT")
private Boolean haveAttachment;
/**
* 摘要
*/
@TableField("SUMMARY")
private String summary;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
/**
* 审核状态:通过,驳回,待审核,待提交
**/
@TableField("AUDIT_STATUS")
private String auditStatus;
/**
* 驳回意见
**/
@TableField("REJECTION_COMMENT")
private String rejectionComment;
/**
* 审核人id
**/
@TableField("AUDITOR_USER_ID")
private String auditorUserId;
@TableField("ORG_CODE")
private String orgCode;
/**
* 纯文本内容
*/
@TableField("TEXT_CONTENT")
private String textContent;
/**
* 排序内容
*/
@TableField("SORT_STR")
private String sortStr;
/**
* 所属目录
*/
@TableField("DIRECTORY_ID")
private Long directoryId;
/**
* 文档标题
*/
@TableField("DOC_TITLE")
private String docTitle;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_dynamics_group")
public class KnowledgeDynamicsGroup extends BaseEntity {
/**
* 分组名称
*/
@TableField("GROUP_NAME")
private String groupName;
/**
* 前端配置
*/
@TableField("FRONT_END_CONFIG")
private String frontEndConfig;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
/**
* 功能标识
*/
@TableField("FUNCTIONAL")
private String functional;
/**
* 业务项目标识
*/
@TableField("APP_KEY")
private String appKey;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_dynamics_option")
public class KnowledgeDynamicsOption extends BaseEntity {
/**
* 字段名
*/
@TableField("FIELD_NAME")
private String fieldName;
/**
* 中文名
*/
@TableField("FIELD_LABEL")
private String fieldLabel;
/**
* 数据类型:文本,数字,枚举,日期
*/
@TableField("DATA_TYPE")
private String dataType;
/**
* 功能标识
*/
@TableField("FUNCTIONAL")
private String functional;
/**
* 业务项目标识
*/
@TableField("APP_KEY")
private String appKey;
@TableField("FRONT_END_CONFIG")
private String frontEndConfig;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
/**
* 分组主键
*/
@TableField("GROUP_SEQ")
private Long groupSeq;
/**
* 查询策略
*/
@TableField("QUERY_STRATEGY")
private String queryStrategy;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置的实例值
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_dynamics_value")
public class KnowledgeDynamicsValue extends BaseEntity {
/**
* 字段名
*/
@TableField("FIELD_NAME")
private String fieldName;
/**
* 中文名
*/
@TableField("FIELD_LABEL")
private String fieldLabel;
/**
* 数据类型:文本,数字,枚举,日期
*/
@TableField("DATA_TYPE")
private String dataType;
/**
* 字段分组id
*/
@TableField("GROUP_SEQ")
private Long groupSeq;
/**
* 动态配置字段的值
*/
@TableField("FIELD_VALUE")
private String fieldValue;
/**
* 关联的对象id,即文档id
*/
@TableField("INSTANCE_ID")
private Long instanceId;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
@TableField("OPTION_SEQ")
private Long optionSeq;
@TableField("QUERY_STRATEGY")
private String queryStrategy;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库内容交互计数表
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_interaction_count")
public class KnowledgeInteractionCount extends BaseEntity {
/**
* 操作类型(标签所有情况引用,标签被已审核/已发布文档引用,文档引用)
*/
@TableField("OPERATE_TYPE")
private String operateType;
/**
* 关联对象类型
*/
@TableField("ENTITY_TYPE")
private String entityType;
/**
* 关联对象id
*/
@TableField("ENTITY_ID")
private String entityId;
/**
* 计数
*/
@TableField("OPERATE_COUNT")
private Integer operateCount;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库内容交互记录
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_interaction_record")
public class KnowledgeInteractionRecord extends BaseEntity {
/**
* 用户id
*/
@TableField("USER_ID")
private String userId;
/**
* 操作类型(点赞,吐槽,收藏)
*/
@TableField("OPERATE_TYPE")
private String operateType;
/**
* 关联对象类型
*/
@TableField("ENTITY_TYPE")
private String entityType;
/**
* 关联对象id
*/
@TableField("ENTITY_ID")
private String entityId;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
* 消息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_message")
public class KnowledgeMessage extends BaseEntity {
/**
* 消息类型
*/
@TableField("MESSAGE_TYPE")
private String messageType;
/**
* 消息标题
*/
@TableField("MESSAGE_TITLE")
private String messageTitle;
/**
* 消息内容
*/
@TableField("MESSAGE_CONTENT")
private String messageContent;
/**
* 相关文档ID
*/
@TableField("TARGET_SEQ")
private Long targetSeq;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
* 个人消息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_message_personal")
public class KnowledgeMessagePersonal extends BaseEntity {
/**
* 接收人
*/
@TableField("MESSAGE_OWNER")
private String messageOwner;
/**
* 消息ID
*/
@TableField("MESSAGE_SEQ")
private Long messageSeq;
/**
* 消息状态
*/
@TableField("MESSAGE_STATUS")
private Integer messageStatus;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 标签库
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_tag")
public class KnowledgeTag extends BaseEntity {
/**
* 标签名称
*/
@TableField("TAG_NAME")
private String tagName;
/**
* 标签编码
*/
@TableField("TAG_CODE")
private String tagCode;
/**
* 标签分类:文本标签,值标签,
*/
@TableField("TAG_TYPE")
private String tagType;
/**
* 标签状态:启用,禁用
*/
@TableField("TAG_STATUS")
private String tagStatus;
/**
* 标签备注
*/
@TableField("TAG_REMARK")
private String tagRemark;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
/**
* 创建人姓名
*/
@TableField("CREATOR")
private String creator;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 标签分组
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_tag_group")
public class KnowledgeTagGroup extends BaseEntity {
/**
* 标签名称
*/
@TableField("GROUP_NAME")
private String groupName;
/**
* 父级分类id
*/
@TableField("PARENT_ID")
private Long parentId;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
* 标签分组
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_tag_group_ref")
public class KnowledgeTagGroupRef extends BaseEntity {
/**
* 标签分组id
*/
@TableField("GROUP_SEQ")
private Long groupSeq;
/**
* 标签id
*/
@TableField("TAG_SEQ")
private Long tagSeq;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 标签实例
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_tag_instance")
public class KnowledgeTagInstance extends BaseEntity {
/**
* 标签id
*/
@TableField("TAG_SEQ")
private Long tagSeq;
/**
* 标签标记的目标id
*/
@TableField("TARGET_SEQ")
private Long targetSeq;
/**
* 标签名称
*/
@TableField("TAG_NAME")
private String tagName;
/**
* 标记方式:文档,内容
*/
@TableField("MARKING_TYPE")
private String markingType;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
/**
* 标签类型
*/
@TableField("TAG_TYPE")
private String tagType;
@TableField("FRONT_END_CONFIG")
private String frontEndConfig;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 值标签的实例值
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowledge_tag_value")
public class KnowledgeTagValue extends BaseEntity {
/**
* 标签实例id
*/
@TableField("INSTANCE_SEQ")
private Long instanceSeq;
/**
* 值标签的扩展字段名,内容标签文本位置,值标签文本内容/单值/日期,值标签范围最大值-最小值
*/
@TableField("FIELD_NAME")
private String fieldName;
/**
* 值标签扩展字段的值
*/
@TableField("TAG_VALUE")
private String tagValue;
/**
* 机构编号
*/
@TableField("AGENCY_CODE")
private String agencyCode;
@TableField("UNIT")
private String unit;
}
package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date;
/**
* <p>
* 标签分组
* </p>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowlege_statistics_record")
public class KnowlegeStatisticsRecord extends BaseEntity {
/**
* 文档ID
*/
@TableField("DOC_SEQ")
private Long docSeq;
/**
* 警情发生时间
*/
@TableField("DISASTER_TIME")
private Date disasterTime;
/**
* 记录类型
*/
@TableField("RECORD_NAME")
private String recordName;
/**
* 分类字段值
*/
@TableField("CATEGORY_VALUE")
private String categoryValue;
/**
* 统计数值
*/
@TableField("COUNT_VALUE")
private Long countValue;
/**
* 值放大倍数
*/
@TableField("VALUE_WEIGHT")
private Integer valueWeight;
/**
* 数值单位
*/
@TableField("UNIT")
private Long unit;
}
package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* <p>
* 知识库文档注释 服务类
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
@Component
public class DocAnnotateService extends BaseService<KnowledgeDocAnnotateModel, KnowledgeDocAnnotate, DocAnnotateMapper> {
@Autowired
private DocContentService docContentService;
/**
* @author ningtianqing
* @description 创建注释信息
* @Param [commentsModel]
* @return com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel
**/
@Transactional(rollbackFor = {Exception.class, BaseException.class})
public KnowledgeDocAnnotateModel createAnnotate(KnowledgeDocAnnotateModel annotateModel) {
annotateModel.setAgencyCode(RequestContext.getAgencyCode());
annotateModel.setUserId(RequestContext.getExeUserId());
annotateModel.setCreateTime(new Date());
docContentService.updateHtmlContent(annotateModel.getDocSeq(), annotateModel.getHtmlContent());
return this.createWithModel(annotateModel);
}
/**
* @author ningtianqing
* @description 更新注释信息ss
* @Param [commentsModel]
* @return com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel
**/
public KnowledgeDocAnnotateModel updateAnnotate(KnowledgeDocAnnotateModel annotateModel) {
KnowledgeDocAnnotateModel oldModel = this.queryBySeq(annotateModel.getSequenceNbr());
Bean.copyExistPropertis(annotateModel, oldModel);
return this.updateWithModel(oldModel);
}
/**
* @author ningtianqing
* @description 删除注释
* @Param [id]
* @return String
**/
@Transactional(rollbackFor = {Exception.class, BaseException.class})
public Long deleteAnnotate(KnowledgeDocAnnotateModel annotateModel) {
if (ValidationUtil.isEmpty(annotateModel.getDocSeq()) || ValidationUtil.isEmpty(annotateModel.getHtmlContent())) {
this.deleteBySeq(annotateModel.getSequenceNbr());
return annotateModel.getSequenceNbr();
} else {
docContentService.updateHtmlContent(annotateModel.getDocSeq(), annotateModel.getHtmlContent());
this.deleteBySeq(annotateModel.getSequenceNbr());
return annotateModel.getSequenceNbr();
}
}
/**
* @author ningtianqing
* @description 根据文档id查询注释列表
* @Param [docSeq]
* @return List
**/
public List<KnowledgeDocAnnotateModel> queryForAnnotateList(String docSeq) {
List<KnowledgeDocAnnotateModel> list = this.queryForList("CREATE_TIME",true, docSeq);
Set<String> userIds = list.stream().filter(item -> !ValidationUtil.isEmpty(item)).map(arg0 -> arg0.getUserId()).collect(Collectors.toSet());
Map<String, String> userMap = RemoteData.getUserMap(userIds);
list.forEach(item -> {
item.setUsername(userMap.get(item.getUserId()));
item.setIsCurrentUser(ValidationUtil.equals(item.getUserId(),RequestContext.getExeUserId()));
});
return list;
}
}
package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCommentsMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
import java.util.List;
/**
* <p>
* 知识库评论信息 服务类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@Component
public class DocCommentsService extends BaseService<KnowledgeDocCommentsModel, KnowledgeDocComments, DocCommentsMapper> {
public static final Long ROOT = 0L;
@Autowired
private InteractionRecordService interactionRecordService;
/**
* @author 杨博超
* @description 创建评论信息
* @Param [commentsModel]
* @return com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel
**/
public KnowledgeDocCommentsModel createComments(KnowledgeDocCommentsModel commentsModel) {
commentsModel.setAgencyCode(RequestContext.getAgencyCode());
commentsModel.setUserId(RequestContext.getExeUserId());
if (ValidationUtil.isEmpty(commentsModel.getParentId())) {
commentsModel.setParentId(ROOT);
}
return this.createWithModel(commentsModel);
}
/**
* @return boolean
* @author 杨博超
* @description 给评论点赞
* @Param [sequenceNbr]
**/
public boolean like(Long sequenceNbr) {
KnowledgeInteractionRecordModel recordModel = createLikeRecord(sequenceNbr);
KnowledgeInteractionRecordModel oldModel = interactionRecordService.queryUniqueModel(recordModel.getUserId(),recordModel.getEntityType(),recordModel.getEntityId(),recordModel.getOperateType());
if (!ValidationUtil.isEmpty(oldModel)) {
interactionRecordService.deleteInteractionRecord(oldModel);
} else {
interactionRecordService.createInteractionRecord(recordModel);
}
return true;
}
/**
* 获取文档的评论总数
* @param docSeq
* @return
*/
public int getCommentsTotal(Long docSeq) {
return this.queryCount(docSeq);
}
/** 分页查询文档评论 */
public Page queryDocCommentsPage(Page page, String agencyCode,Long docSeq) {
Page commentsPage = this.queryForPage(page, "REC_DATE", false, agencyCode, docSeq);
List<KnowledgeDocCommentsModel> records = commentsPage.getRecords();
if (!ValidationUtil.isEmpty(records)) {
for (KnowledgeDocCommentsModel commentsModel : records) {
setLikeAndCount(commentsModel);
}
}
return commentsPage;
}
private KnowledgeInteractionRecordModel createLikeRecord(Long sequenceNbr){
KnowledgeInteractionRecordModel recordModel = new KnowledgeInteractionRecordModel();
recordModel.setAgencyCode(RequestContext.getAgencyCode());
recordModel.setUserId(RequestContext.getExeUserId());
recordModel.setEntityType(KnowledgeDocCommentsModel.class.getSimpleName());
recordModel.setEntityId(String.valueOf(sequenceNbr));
recordModel.setOperateType(OperateType.LIKE.name());
recordModel.setRecUserId(RequestContext.getExeUserId());
recordModel.setRecDate(new Date());
return recordModel;
}
private void setLikeAndCount (KnowledgeDocCommentsModel commentsModel){
KnowledgeInteractionRecordModel recordModel = createLikeRecord(commentsModel.getSequenceNbr());
KnowledgeInteractionRecordModel oldRecordModel = interactionRecordService.queryUniqueModel(recordModel.getUserId(),recordModel.getEntityType(),recordModel.getEntityId(),recordModel.getOperateType());
int likedNum = interactionRecordService.countByInstance(OperateType.LIKE.name(), KnowledgeDocCommentsModel.class.getSimpleName(), commentsModel.getSequenceNbr().toString());
commentsModel.setLike(!ValidationUtil.isEmpty(oldRecordModel));
commentsModel.setLikedNum(likedNum);
// 加入用户姓名
commentsModel.setUsername(RemoteData.getUserRealNamById(commentsModel.getUserId()));
}
}
package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsGroupModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsGroupMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表 服务类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@Component
public class DynamicsGroupService extends BaseService<KnowledgeDynamicsGroupModel, KnowledgeDynamicsGroup, DynamicsGroupMapper> {
// @Autowired
// private DynamicsOptionService dynamicsOptionService;
public KnowledgeDynamicsGroupModel queryByFunctional(String appKey,String functional) {
return this.queryModelByParamsWithCache(appKey,functional);
}
public List<KnowledgeDynamicsGroupModel> queryGroupList(String appKey) {
return this.queryForList("", false, appKey);
}
}
package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsGroupModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsOptionMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsOption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import java.util.List;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置 服务类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@Component
public class DynamicsOptionService extends BaseService<KnowledgeDynamicsOptionModel, KnowledgeDynamicsOption, DynamicsOptionMapper> {
@Autowired
private DynamicsGroupService dynamicsGroupService;
@Autowired
private DynamicsValueService dynamicsValueService;
public KnowledgeDynamicsOptionModel createOption(KnowledgeDynamicsOptionModel model) {
model.setAgencyCode(RequestContext.getAgencyCode());
model.setFunctional(DynamicsFunctional.DOC_BASEINFO.name());
if (ValidationUtil.isEmpty(model.getQueryStrategy())) {
model.setQueryStrategy(Operator.eq.name());
}
model = fillGroupInfo(model);
return this.createWithModel(model);
}
public KnowledgeDynamicsOptionModel udpateOption(KnowledgeDynamicsOptionModel model) {
KnowledgeDynamicsOptionModel oldModel = this.queryBySeq(model.getSequenceNbr());
if (ValidationUtil.isEmpty(oldModel)) {
throw new DataNotFound("找不到制定的动态字段.");
}
oldModel = Bean.copyExistPropertis(model, oldModel);
oldModel = fillGroupInfo(oldModel);
return this.updateWithModel(oldModel);
}
public boolean deleteOption(Long sequenceNbr) {
KnowledgeDynamicsOptionModel oldModel = this.queryBySeq(sequenceNbr);
if (ValidationUtil.isEmpty(oldModel)) {
throw new DataNotFound("找不到制定的动态字段.");
}
List<KnowledgeDynamicsValueModel> valueModels = dynamicsValueService.queryByOptionSeq(oldModel.getSequenceNbr());
if (!ValidationUtil.isEmpty(valueModels)) {
throw new BadRequest("字段已经被引用.");
}
this.deleteBySeq(oldModel.getSequenceNbr());
return true;
}
/**
* @return com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel
* @author 杨博超
* @description 填充字段分组信息.
* @Param [model]
**/
private KnowledgeDynamicsOptionModel fillGroupInfo(KnowledgeDynamicsOptionModel model) {
KnowledgeDynamicsGroupModel groupModel = dynamicsGroupService.queryBySeq(model.getGroupSeq());
if (ValidationUtil.isEmpty(groupModel)) {
throw new BadRequest("字段分组不存在.");
}
if (!groupModel.getAppKey().equals(RequestContext.getAppKey())) {
throw new BadRequest("分组选择有误.");
}
model.setFunctional(groupModel.getFunctional());
model.setAppKey(groupModel.getAppKey());
return model;
}
/**
* @return java.util.List<com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel>
* @author 杨博超
* @description 根据分组编号获取
* @Param [groupCode]
**/
public List<KnowledgeDynamicsOptionModel> queryByFunctional( String appKey, String functional) {
return this.queryForList("", false, appKey, functional);
}
public List<KnowledgeDynamicsOptionModel> queryByGroupSeq(Long groupSeq) {
return this.queryForList("", false, groupSeq);
}
}
package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionCountModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.InteractionCountMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* <p>
* 知识库内容交互计数表 服务类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@Component
public class InteractionCountService extends BaseService<KnowledgeInteractionCountModel, KnowledgeInteractionCount, InteractionCountMapper> {
/*@Autowired
private TagInstanceService tagInstanceService;*/
@Autowired
private Sequence sequence;
/**
* 统计方式-标签全部引用
*/
public static final String QUOTE_TYPE_ALL = "ALL";
/**
* 统计方式-标签发布引用
*/
public static final String QUOTE_TYPE_PUBLISH = "PUBLISH";
/**
* 统计目标类型-标签
*/
public static final String QUOTE_ENTITY_TAG = "TAG";
/**
* 统计目标类型-文档
*/
public static final String QUOTE_ENTITY_DOCUMENT = "DOCUMENT";
/**
* 获取统计数
*
* @param operateType 统计类型
* @param entityType 关联对象类型
* @param entityId 关联对象id
* @return 数量
*/
public int getOperateCount(String operateType, String entityType, String entityId) {
KnowledgeInteractionCountModel model = queryByEntity(operateType, entityType, entityId);
return ValidationUtil.isEmpty(model) ? 0 : model.getOperateCount();
}
/**
* 文档引用总数改变
*
* @param tagSeq 标签id
* @param changeNum 改变数量
*/
/*public void changeOneDocumentCount(Long tagSeq, int changeNum) {
KnowledgeInteractionCountModel countModel = queryByEntity(QUOTE_TYPE_ALL, QUOTE_ENTITY_DOCUMENT, tagSeq.toString());
int count;
if (ValidationUtil.isEmpty(countModel)) {
count = changeNum;
} else {
count = countModel.getOperateCount() + changeNum;
}
updateOneCount(QUOTE_TYPE_ALL, QUOTE_ENTITY_DOCUMENT, tagSeq.toString(), count);
}*/
/*public void flushOneTagCountAll(Long tagSeq) {
int count = tagInstanceService.queryCountByTagSeq(tagSeq);
//更新
updateOneCount(QUOTE_TYPE_ALL, QUOTE_ENTITY_TAG, tagSeq.toString(), count);
}
public void flushOneTagCountPublished(Set targets, Long tagSeq) {
int count = tagInstanceService.countByTagSeqAndTargetSeqs(tagSeq, targets);
//更新
updateOneCount(QUOTE_TYPE_PUBLISH, QUOTE_ENTITY_TAG, tagSeq.toString(), count);
}*/
//刷新某个统计目标的引用数
private void updateOneCount(String operateType, String entityType, String entityId, int count) {
KnowledgeInteractionCountModel countModel = queryByEntity(operateType, entityType, entityId);
if (ValidationUtil.isEmpty(countModel)) {
countModel = new KnowledgeInteractionCountModel();
countModel.setOperateType(operateType);
countModel.setEntityType(entityType);
countModel.setEntityId(entityId);
countModel.setOperateCount(count);
countModel.setAgencyCode(RequestContext.getAgencyCode());
this.createWithModel(countModel);
} else {
countModel.setOperateCount(count);
this.updateWithModel(countModel);
}
}
private KnowledgeInteractionCountModel queryByEntity(String operateType, String entityType, String entityId) {
List<KnowledgeInteractionCountModel> list = this.queryForTopList(1, null, false, operateType, entityType, entityId);
if (list.isEmpty()) {
return null;
}
return list.get(0);
}
/**
* 获取总数前top个
*/
public List<KnowledgeInteractionCountModel> queryTop(int top, String operateType, String entityType, String agencyCode) {
return this.queryForTopList(top, "operate_count", false, operateType, entityType, agencyCode);
}
@Transactional(rollbackFor = {Exception.class, BaseException.class})
public void deleteByEntity(String entityType, String entityId) {
List<KnowledgeInteractionCountModel> countModels = this.queryForList(null, false, entityType, entityId);
for (KnowledgeInteractionCountModel countModel : countModels) {
this.deleteBySeq(countModel.getSequenceNbr());
}
}
public void deleteAllTagQuote() {
this.getBaseMapper().deleteByEntityType(QUOTE_ENTITY_TAG);
}
public List<KnowledgeInteractionCount> getAllTagQuoteRecords() {
List<KnowledgeInteractionCount> resList = new ArrayList<>();
List<KnowledgeInteractionCount> tagQuoteAll = this.getBaseMapper().queryTagQuoteAll();
List<KnowledgeInteractionCount> tagQuotePublish = this.getBaseMapper().queryTagQuotePublish();
resList.addAll(interactionCountList2ModelList(tagQuoteAll, QUOTE_ENTITY_TAG, QUOTE_TYPE_ALL));
resList.addAll(interactionCountList2ModelList(tagQuotePublish, QUOTE_ENTITY_TAG, QUOTE_TYPE_PUBLISH));
return resList;
}
private List<KnowledgeInteractionCount> interactionCountList2ModelList(List<KnowledgeInteractionCount> list, String entityType, String operateType) {
Date now = new Date();
List<KnowledgeInteractionCount> modelList = new ArrayList<>();
if (!ValidationUtil.isEmpty(list)) {
list.forEach(model -> {
model.setSequenceNbr(sequence.nextId());
model.setRecDate(now);
model.setRecUserId("system");
model.setEntityType(entityType);
model.setOperateType(operateType);
});
modelList = list;
}
return modelList;
}
}
package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.InteractionRecordMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionRecord;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
import java.util.List;
/**
* <p>
* 知识库内容交互记录 服务类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@Component
public class InteractionRecordService extends BaseService<KnowledgeInteractionRecordModel, KnowledgeInteractionRecord, InteractionRecordMapper> {
public void createInteractionRecord(KnowledgeInteractionRecordModel interactionRecordModel) {
interactionRecordModel.setRecDate(new Date());
this.createWithModel(interactionRecordModel);
}
public void deleteInteractionRecord(KnowledgeInteractionRecordModel interactionRecordModel) {
this.deleteBySeq(interactionRecordModel.getSequenceNbr());
}
public KnowledgeInteractionRecordModel queryUniqueModel(String userId, String entityType, String entityId, String operateType) {
return this.queryModelByParams(userId, entityType, entityId, operateType);
}
/**
* 获取用户对某类对象的操作记录列表
*
* @param userId 用户名
* @param operateType 操作类型
* @param entityType 操作对象
* @param agencyCode
* @return
*/
public List<KnowledgeInteractionRecordModel> queryListByUser(String userId, String operateType, String entityType, String agencyCode) {
return this.queryForList(null, false, userId, operateType, entityType, agencyCode);
}
/**
* 某个对象被操作的数量统计
*
* @param operateType 操作类型
* @param entityType 操作对象
* @param entityId 对象Id
* @return
*/
public int countByInstance(String operateType, String entityType, String entityId) {
return this.queryCount(operateType, entityType, entityId);
}
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment