|
@@ -1,24 +1,39 @@
|
|
|
package com.jeeplus.modules.knowledgeSharing.service;
|
|
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.jeeplus.common.config.Global;
|
|
|
+import com.jeeplus.common.oss.OSSClientUtil;
|
|
|
import com.jeeplus.common.persistence.Page;
|
|
|
import com.jeeplus.common.service.CrudService;
|
|
|
+import com.jeeplus.common.utils.MyBeanUtils;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
|
import com.jeeplus.modules.knowledgeSharing.dao.KnowledgeSharingDetailsDao;
|
|
|
-import com.jeeplus.modules.knowledgeSharing.entity.KnowledgeSharingComment;
|
|
|
-import com.jeeplus.modules.knowledgeSharing.entity.KnowledgeSharingInfo;
|
|
|
-import com.jeeplus.modules.knowledgeSharing.entity.KnowledgeSharingView;
|
|
|
+import com.jeeplus.modules.knowledgeSharing.dify.DifyApiClient;
|
|
|
+import com.jeeplus.modules.knowledgeSharing.entity.*;
|
|
|
import com.jeeplus.modules.sys.entity.Workattachment;
|
|
|
import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
+import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 知识分享Service
|
|
|
+ *
|
|
|
* @author 徐滕
|
|
|
* @create 2022-4-11 9:17
|
|
|
*/
|
|
@@ -41,10 +56,11 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
|
|
|
/**
|
|
|
* 获取附件信息
|
|
|
+ *
|
|
|
* @param knowledgeSharingInfo
|
|
|
*/
|
|
|
- public void queryDetails(KnowledgeSharingInfo knowledgeSharingInfo) {
|
|
|
- if(knowledgeSharingInfo==null)return;
|
|
|
+ public void queryDetails(KnowledgeSharingInfo knowledgeSharingInfo) throws Exception {
|
|
|
+ if (knowledgeSharingInfo == null) return;
|
|
|
Workattachment attchment = new Workattachment();
|
|
|
attchment.setAttachmentId(knowledgeSharingInfo.getId());
|
|
|
attchment.setAttachmentFlag("183");
|
|
@@ -52,11 +68,29 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
attchment.setAttachmentFlag("79");
|
|
|
List<Workattachment> attachmentTwos = workattachmentService.findList(attchment);
|
|
|
attachments.addAll(attachmentTwos);
|
|
|
+ String columnId = knowledgeSharingInfo.getColumnId();
|
|
|
+ String datasetId = getTypeIdByColumnId(columnId);
|
|
|
knowledgeSharingInfo.setWorkAttachments(attachments);
|
|
|
- for (Workattachment clientAttachment:attachments){
|
|
|
- if (clientAttachment.getCollectFlag().equals("1")){
|
|
|
- for (Workattachment workattachment:knowledgeSharingInfo.getWorkAttachments()){
|
|
|
- if (clientAttachment.getId().equals(workattachment.getId())){
|
|
|
+ for (Workattachment clientAttachment : attachments) {
|
|
|
+ boolean allowedFileType = isAllowedFileType(clientAttachment.getAttachmentName());
|
|
|
+ if(!allowedFileType){
|
|
|
+ clientAttachment.setSyncDifySync("2");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //判断文件是否同步至dify
|
|
|
+ String nameOnly = clientAttachment.getAttachmentName().substring(0, clientAttachment.getAttachmentName().lastIndexOf("."));
|
|
|
+ JSONObject docItem = DifyApiClient.findKnowledgeBaseById(1, 999, datasetId, nameOnly);
|
|
|
+ JSONArray data = docItem.getJSONArray("data");
|
|
|
+ List<KnowledgeBaseDoc> knowledgeBaseDocArrayList = JSON.parseArray(data.toString(), KnowledgeBaseDoc.class);
|
|
|
+ if (knowledgeBaseDocArrayList != null && !knowledgeBaseDocArrayList.isEmpty()) {
|
|
|
+ clientAttachment.setSyncDifySync("1");
|
|
|
+ } else {
|
|
|
+ clientAttachment.setSyncDifySync("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (clientAttachment.getCollectFlag().equals("1")) {
|
|
|
+ for (Workattachment workattachment : knowledgeSharingInfo.getWorkAttachments()) {
|
|
|
+ if (clientAttachment.getId().equals(workattachment.getId())) {
|
|
|
workattachment.setCollectFlag("1");
|
|
|
break;
|
|
|
}
|
|
@@ -68,7 +102,7 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
|
|
|
public Page<KnowledgeSharingInfo> findPage(Page<KnowledgeSharingInfo> page, KnowledgeSharingInfo knowledgeSharingInfo) {
|
|
|
//处理登记人信息
|
|
|
- if (knowledgeSharingInfo!=null && StringUtils.isNotBlank(knowledgeSharingInfo.getJordanswId())){
|
|
|
+ if (knowledgeSharingInfo != null && StringUtils.isNotBlank(knowledgeSharingInfo.getJordanswId())) {
|
|
|
knowledgeSharingInfo.setJordanswName(UserUtils.get(knowledgeSharingInfo.getJordanswId()).getName());
|
|
|
}
|
|
|
int count = dao.queryCount(knowledgeSharingInfo);
|
|
@@ -88,17 +122,225 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
super.save(knowledgeSharingInfo);
|
|
|
//保存附件
|
|
|
this.saveAttachments(knowledgeSharingInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id获取dify的分类id
|
|
|
+ */
|
|
|
+ public String getTypeIdByColumnId(String columnId) throws Exception {
|
|
|
+ String columnName;
|
|
|
+ switch (columnId) {
|
|
|
+ case "1":
|
|
|
+ columnName = "学习园地";
|
|
|
+ break;
|
|
|
+ case "9":
|
|
|
+ columnName = "国家标准及规范";
|
|
|
+ break;
|
|
|
+ case "7":
|
|
|
+ columnName = "行业标准及规范";
|
|
|
+ break;
|
|
|
+ case "8":
|
|
|
+ columnName = "公司内部发文和通知";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ columnName = "请教专家";
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ columnName = "案例讨论";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ columnName = "学习园地";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ KnowledgeBase knowledgeBase = new KnowledgeBase();
|
|
|
+ knowledgeBase.setName(columnName);
|
|
|
+ JSONObject jsonObject = DifyApiClient.selectKnowledgeBaseList(1, 999, knowledgeBase);
|
|
|
+ JSONArray data = jsonObject.getJSONArray("data");
|
|
|
+ List<KnowledgeBase> knowledgeBaseList = JSON.parseArray(data.toString(), KnowledgeBase.class);
|
|
|
+ return knowledgeBaseList.isEmpty() ? null : knowledgeBaseList.get(0).getId();
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断文件类型
|
|
|
+ *
|
|
|
+ * @param fileName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean isAllowedFileType(String fileName) {
|
|
|
+ // 允许的后缀名
|
|
|
+ List<String> allowedExtensions = Arrays.asList(
|
|
|
+ "txt", "markdown", "mdx", "pdf", "html", "xlsx", "xls",
|
|
|
+ "docx", "csv", "vtt", "properties", "md", "htm"
|
|
|
+ ); // 获取文件后缀
|
|
|
+ if (fileName == null || !fileName.contains(".")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String extension = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
+ return allowedExtensions.contains(extension);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将附件同步至dify
|
|
|
+ *
|
|
|
+ * @param knowledgeSharingInfo1
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ @Async
|
|
|
+ public void saveToDify(KnowledgeSharingInfo knowledgeSharingInfo1, String saveFlag) throws Exception {
|
|
|
+ try {
|
|
|
+ KnowledgeSharingInfo knowledgeSharingInfo = new KnowledgeSharingInfo();
|
|
|
+ knowledgeSharingInfo.setId(knowledgeSharingInfo1.getId());
|
|
|
+ knowledgeSharingInfo.setColumnId(knowledgeSharingInfo1.getColumnId());
|
|
|
+ List<Workattachment> workattachments = knowledgeSharingInfo1.getWorkAttachments();
|
|
|
+ //如果没有附件,默认同步成功,无需执行同步
|
|
|
+ if (workattachments.isEmpty()) {
|
|
|
+ knowledgeSharingInfo1.setIsSync("1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //找到对应的分类名称
|
|
|
+ String typeId = getTypeIdByColumnId(knowledgeSharingInfo.getColumnId());
|
|
|
+ //处理附件,转为输入流
|
|
|
+ String aliyunUrl = Global.getAliyunUrl();
|
|
|
+ String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
+ // 判断文件是否完全同步的状态
|
|
|
+ String allSyncStatus = "1";
|
|
|
+ for (Workattachment attachment : workattachments) {
|
|
|
+ String file = attachment.getUrl();
|
|
|
+ String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
+ // 文件类型不合法的话,跳过当前文件
|
|
|
+ if (!isAllowedFileType(fileName)) {
|
|
|
+ allSyncStatus = "0";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String cons = "";
|
|
|
+ byte[] fileBytes;
|
|
|
+ if ("1".equals(saveFlag)) {
|
|
|
+ //String key = file.split(cons + "/")[1];
|
|
|
+ if (file.startsWith("/")) {
|
|
|
+ file = file.substring(1); // 去掉最前面的 "/"
|
|
|
+ }
|
|
|
+ // 转为 byte[] 数组
|
|
|
+ fileBytes = new OSSClientUtil().downBytesByStream(file, fileName);
|
|
|
+ } else {
|
|
|
+ if (file.contains(aliyunUrl)) {
|
|
|
+ cons = aliyunUrl;
|
|
|
+ } else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
|
|
|
+ cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
+ } else {
|
|
|
+ cons = aliDownloadUrl;
|
|
|
+ }
|
|
|
+ String key = file.split(cons + "/")[1];
|
|
|
+ fileBytes = new OSSClientUtil().downBytesByStream(key, fileName);
|
|
|
+ }
|
|
|
+ try (InputStream inputStream = new ByteArrayInputStream(fileBytes)) {
|
|
|
+ DifyApiClient.createByFileDifyApi(inputStream, attachment.getAttachmentName(), typeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ knowledgeSharingInfo1.setIsSync(allSyncStatus);
|
|
|
+ } catch (Exception e) {
|
|
|
+ knowledgeSharingInfo1.setIsSync("0");
|
|
|
+ }
|
|
|
+ KnowledgeSharingInfo t = get(knowledgeSharingInfo1.getId());//从数据库取出记录的值
|
|
|
+ MyBeanUtils.copyBeanNotNull2Bean(knowledgeSharingInfo1, t);//将编辑表单中的非NULL值覆盖数据库记录中的值
|
|
|
+ t.setOffice(UserUtils.getSelectOffice());
|
|
|
+ t.setCompany(UserUtils.getSelectCompany());
|
|
|
+ t.setModerator("系统管理员");
|
|
|
+ //添加信息
|
|
|
+ super.save(t);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将附件同步至dify
|
|
|
+ *
|
|
|
+ * @param knowledgeSharingInfo
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ @Async
|
|
|
+ public void updateToDify(KnowledgeSharingInfo knowledgeSharingInfo) throws Exception {
|
|
|
+ try {
|
|
|
+ KnowledgeSharingInfo knowledgeSharingInfo1 = new KnowledgeSharingInfo();
|
|
|
+ knowledgeSharingInfo1.setColumnId(knowledgeSharingInfo.getColumnId());
|
|
|
+ knowledgeSharingInfo1.setId(knowledgeSharingInfo.getId());
|
|
|
+ //查询附件
|
|
|
+ queryDetails(knowledgeSharingInfo1);
|
|
|
+ //删除附件重新上传
|
|
|
+ List<Workattachment> workattachments = knowledgeSharingInfo1.getWorkAttachments();
|
|
|
+ //如果没有附件,默认同步成功,无需执行同步
|
|
|
+ if (workattachments.isEmpty()) {
|
|
|
+ knowledgeSharingInfo.setIsSync("1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //找到对应的分类名称
|
|
|
+ String typeId = getTypeIdByColumnId(knowledgeSharingInfo.getColumnId());
|
|
|
+ String allSyncStatus = "1";
|
|
|
+ String aliyunUrl = Global.getAliyunUrl();
|
|
|
+ String aliDownloadUrl = Global.getAliDownloadUrl();
|
|
|
+ //处理附件,转为输入流
|
|
|
+ for (Workattachment attachment : workattachments) {
|
|
|
+ // 转为 byte[] 数组
|
|
|
+ String file = attachment.getUrl();
|
|
|
+ String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
|
|
|
+ String cons = "";
|
|
|
+ // 文件类型不合法的话,跳过当前文件
|
|
|
+ if (!isAllowedFileType(fileName)) {
|
|
|
+ allSyncStatus = "0";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (file.contains(aliyunUrl)) {
|
|
|
+ cons = aliyunUrl;
|
|
|
+ } else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")) {
|
|
|
+ cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
|
|
|
+ } else {
|
|
|
+ cons = aliDownloadUrl;
|
|
|
+ }
|
|
|
+ String key = file.split(cons + "/")[1];
|
|
|
+ byte[] fileBytes = new OSSClientUtil().downBytesByStream(key, fileName);
|
|
|
+ try (InputStream inputStream = new ByteArrayInputStream(fileBytes)) {
|
|
|
+ DifyApiClient.createByFileDifyApi(inputStream, attachment.getAttachmentName(), typeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ knowledgeSharingInfo.setIsSync(allSyncStatus);
|
|
|
+ } catch (Exception e) {
|
|
|
+ knowledgeSharingInfo.setIsSync("0");
|
|
|
+ }
|
|
|
+ //更新
|
|
|
+ KnowledgeSharingInfo dbInfo = get(knowledgeSharingInfo.getId());
|
|
|
+ MyBeanUtils.copyBeanNotNull2Bean(knowledgeSharingInfo, dbInfo);
|
|
|
+ knowledgeSharingInfo.setOffice(UserUtils.getSelectOffice());
|
|
|
+ knowledgeSharingInfo.setCompany(UserUtils.getSelectCompany());
|
|
|
+ knowledgeSharingInfo.setModerator("系统管理员");
|
|
|
+ super.save(knowledgeSharingInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将附件同步至dify
|
|
|
+ *
|
|
|
+ * @param knowledgeSharingInfo
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ @Async
|
|
|
+ public void syncToDify(KnowledgeSharingInfo knowledgeSharingInfo) {
|
|
|
+ try {
|
|
|
+ //查询附件
|
|
|
+ queryDetails(knowledgeSharingInfo);
|
|
|
+ //同步
|
|
|
+ saveToDify(knowledgeSharingInfo, "2");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("同步失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加附件信息
|
|
|
+ *
|
|
|
* @param knowledgeSharingInfo
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
public void saveAttachments(KnowledgeSharingInfo knowledgeSharingInfo) {
|
|
|
List<Workattachment> workattachments = knowledgeSharingInfo.getWorkAttachments();
|
|
|
- if (workattachments!=null && workattachments.size()!=0) {
|
|
|
+ if (workattachments != null && workattachments.size() != 0) {
|
|
|
for (Workattachment workattachment : workattachments) {
|
|
|
if (workattachment.getId() == null) {
|
|
|
continue;
|
|
@@ -121,32 +363,89 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
|
|
|
/**
|
|
|
* 删除方法
|
|
|
+ *
|
|
|
* @param knowledgeSharingInfo
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
- public void delete (KnowledgeSharingInfo knowledgeSharingInfo){
|
|
|
+ public void delete(KnowledgeSharingInfo knowledgeSharingInfo) {
|
|
|
+ //同步删除dify的附件
|
|
|
+ deleteToDify(knowledgeSharingInfo);
|
|
|
dao.deleteByLogic(knowledgeSharingInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 同步删除dify中的附件
|
|
|
+ *
|
|
|
+ * @param knowledgeSharingInfo1
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void deleteToDify(KnowledgeSharingInfo knowledgeSharingInfo1) {
|
|
|
+ try {
|
|
|
+ KnowledgeSharingInfo knowledgeSharingInfo = new KnowledgeSharingInfo();
|
|
|
+ knowledgeSharingInfo.setId(knowledgeSharingInfo1.getId());
|
|
|
+ knowledgeSharingInfo.setColumnId(knowledgeSharingInfo1.getColumnId());
|
|
|
+ queryDetails(knowledgeSharingInfo);
|
|
|
+ //获取附件
|
|
|
+ List<Workattachment> workAttachments = knowledgeSharingInfo.getWorkAttachments();
|
|
|
+ if (workAttachments.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //获取dify的知识库id
|
|
|
+ String typeIdByColumnId = getTypeIdByColumnId(knowledgeSharingInfo.getColumnId());
|
|
|
+ // 获取文档id
|
|
|
+ for (Workattachment workAttachment : workAttachments) {
|
|
|
+ JSONObject jsonObject = DifyApiClient.findKnowledgeBaseById(1, 999, typeIdByColumnId, workAttachment.getAttachmentName());
|
|
|
+ JSONArray data = jsonObject.getJSONArray("data");
|
|
|
+ List<KnowledgeBase> knowledgeBaseList = JSON.parseArray(data.toString(), KnowledgeBase.class);
|
|
|
+ if (!knowledgeBaseList.isEmpty()) {
|
|
|
+ DifyApiClient.deleteDocument(typeIdByColumnId, knowledgeBaseList.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除单个dify中的文件
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void deleteToDifyByOne(String attachmentName, String columnId) {
|
|
|
+ try {
|
|
|
+ //获取dify的知识库id
|
|
|
+ String typeIdByColumnId = getTypeIdByColumnId(columnId);
|
|
|
+ JSONObject jsonObject = DifyApiClient.findKnowledgeBaseById(1, 999, typeIdByColumnId, attachmentName);
|
|
|
+ JSONArray data = jsonObject.getJSONArray("data");
|
|
|
+ List<KnowledgeBase> knowledgeBaseList = JSON.parseArray(data.toString(), KnowledgeBase.class);
|
|
|
+ if (!knowledgeBaseList.isEmpty()) {
|
|
|
+ DifyApiClient.deleteDocument(typeIdByColumnId, knowledgeBaseList.get(0).getId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据知识分享id和用户id查询查看知识分享信息数据
|
|
|
+ *
|
|
|
* @param knowledgeSharingId
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
- public KnowledgeSharingView getOaNotifyView(String knowledgeSharingId, String userId){
|
|
|
+ public KnowledgeSharingView getOaNotifyView(String knowledgeSharingId, String userId) {
|
|
|
return dao.getKnowledgeSharingView(knowledgeSharingId, userId);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存修改知识分享阅读数据
|
|
|
+ *
|
|
|
* @param knowledgeSharingView
|
|
|
*/
|
|
|
@Transactional(readOnly = false)
|
|
|
- public void saveKnowledgeSharingView(KnowledgeSharingView knowledgeSharingView,String knowledgeSharingId){
|
|
|
+ public void saveKnowledgeSharingView(KnowledgeSharingView knowledgeSharingView, String knowledgeSharingId) {
|
|
|
//判断是否为空,若为空则该知识分享没看过 则对该知识分享进行添加基本数据
|
|
|
- if(null == knowledgeSharingView){
|
|
|
+ if (null == knowledgeSharingView) {
|
|
|
KnowledgeSharingView newKnowledgeSharingView = new KnowledgeSharingView();
|
|
|
newKnowledgeSharingView.setKnowledgeSharingId(knowledgeSharingId);
|
|
|
newKnowledgeSharingView.setUserId(UserUtils.getUser().getId());
|
|
@@ -155,7 +454,7 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
newKnowledgeSharingView.setLastVisitTime(new Date());
|
|
|
newKnowledgeSharingView.preInsert();
|
|
|
dao.saveKnowledgeSharingView(newKnowledgeSharingView);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//如果已经有查看记录则修改最后一次查看记录时间并修改查看次数
|
|
|
knowledgeSharingView.setLastVisitTime(new Date());
|
|
|
knowledgeSharingView.preUpdate();
|
|
@@ -165,21 +464,24 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
|
|
|
/**
|
|
|
* 根据知识分享id查询查看知识分享记录信息
|
|
|
+ *
|
|
|
* @param knowledgeSharingId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<KnowledgeSharingView> getKnowledgeSharingViewList(String knowledgeSharingId){
|
|
|
+ public List<KnowledgeSharingView> getKnowledgeSharingViewList(String knowledgeSharingId) {
|
|
|
return dao.getKnowledgeSharingViewList(knowledgeSharingId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据知识分享id查询知识分享评论信息
|
|
|
+ *
|
|
|
* @param knowledgeSharingId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<KnowledgeSharingComment> getKnowledgeSharingCommentList(String knowledgeSharingId){
|
|
|
+ public List<KnowledgeSharingComment> getKnowledgeSharingCommentList(String knowledgeSharingId) {
|
|
|
return dao.getKnowledgeSharingCommentList(knowledgeSharingId);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 根据知识分享id 新增评论
|
|
|
*/
|
|
@@ -188,6 +490,7 @@ public class KnowledgeSharingDetailsService extends CrudService<KnowledgeSharing
|
|
|
knowledgeSharingComment.preInsert();
|
|
|
dao.saveComment(knowledgeSharingComment);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 根据评论id 删除评论
|
|
|
*/
|