浏览代码

Merge branch 'master' of http://192.168.1.222:3000/hnsh-smart-steward/smart-steward-api

duhongyu 3 周之前
父节点
当前提交
ca4398f200
共有 32 个文件被更改,包括 1949 次插入129 次删除
  1. 30 13
      smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeCategoryController.java
  2. 154 22
      smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeContentController.java
  3. 100 0
      smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeDraftController.java
  4. 100 0
      smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgePublishRecordController.java
  5. 62 0
      smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeViewRecordController.java
  6. 47 0
      smart-steward-common/src/main/java/com/smartSteward/common/enums/knowledge/PublicStatus.java
  7. 2 0
      smart-steward-entity/src/main/java/com/smartSteward/entity/database/comm/CommComments.java
  8. 6 1
      smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeCategory.java
  9. 78 30
      smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeContent.java
  10. 66 0
      smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeDraft.java
  11. 69 0
      smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgePublishRecord.java
  12. 53 0
      smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeViewRecord.java
  13. 9 0
      smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeCategoryMapper.java
  14. 14 14
      smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeContentMapper.java
  15. 60 0
      smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeDraftMapper.java
  16. 60 0
      smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgePublishRecordMapper.java
  17. 60 0
      smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeViewRecordMapper.java
  18. 16 6
      smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeCategoryMapper.xml
  19. 41 9
      smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeContentMapper.xml
  20. 90 0
      smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeDraftMapper.xml
  21. 87 0
      smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgePublishRecordMapper.xml
  22. 84 0
      smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeViewRecordMapper.xml
  23. 21 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeCategoryService.java
  24. 26 15
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeContentService.java
  25. 60 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeDraftService.java
  26. 60 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgePublishRecordService.java
  27. 60 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeViewRecordService.java
  28. 34 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeCategoryServiceImpl.java
  29. 111 19
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeContentServiceImpl.java
  30. 98 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeDraftServiceImpl.java
  31. 95 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgePublishRecordServiceImpl.java
  32. 96 0
      smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeViewRecordServiceImpl.java

+ 30 - 13
smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeCategoryController.java

@@ -1,5 +1,6 @@
1 1
 package com.smartSteward.web.controller.knowledge;;
2 2
 
3
+import java.util.Arrays;
3 4
 import java.util.List;
4 5
 import io.swagger.annotations.Api;
5 6
 import io.swagger.annotations.ApiOperation;
@@ -43,23 +44,13 @@ public class KnowledgeCategoryController extends BaseController
43 44
     public TableDataInfo list(KnowledgeCategory knowledgeCategory)
44 45
     {
45 46
         startPage();
46
-        List<KnowledgeCategory> list = knowledgeCategoryService.selectKnowledgeCategoryList(knowledgeCategory);
47
-        return getDataTable(list);
48
-    }
47
+        // TODO: 可见范围判断
49 48
 
50
-
51
-    @ApiOperation("导出知识库分类列表")
52
-    @PreAuthorize("@ss.hasPermi('knowledgeCategory:category:export')")
53
-    @Log(title = "知识库分类", businessType = BusinessType.EXPORT)
54
-    @PostMapping("/export")
55
-    public void export(HttpServletResponse response, KnowledgeCategory knowledgeCategory)
56
-    {
49
+        knowledgeCategory.setDelFlag("0");
57 50
         List<KnowledgeCategory> list = knowledgeCategoryService.selectKnowledgeCategoryList(knowledgeCategory);
58
-        ExcelUtil<KnowledgeCategory> util = new ExcelUtil<KnowledgeCategory>(KnowledgeCategory.class);
59
-        util.exportExcel(response, list, "知识库分类数据");
51
+        return getDataTable(list);
60 52
     }
61 53
 
62
-
63 54
     @ApiOperation("获取知识库分类详细信息")
64 55
     @PreAuthorize("@ss.hasPermi('knowledgeCategory:category:query')")
65 56
     @GetMapping(value = "/{id}")
@@ -75,6 +66,11 @@ public class KnowledgeCategoryController extends BaseController
75 66
     @PostMapping
76 67
     public AjaxResult add(@RequestBody KnowledgeCategory knowledgeCategory)
77 68
     {
69
+        knowledgeCategory.setCreateBy(getLoginUser().getUsername());
70
+        if (knowledgeCategory.getSortOrder() == null)
71
+        {
72
+            knowledgeCategory.setSortOrder(0L);
73
+        }
78 74
         return toAjax(knowledgeCategoryService.insertKnowledgeCategory(knowledgeCategory));
79 75
     }
80 76
 
@@ -85,6 +81,15 @@ public class KnowledgeCategoryController extends BaseController
85 81
     @PutMapping
86 82
     public AjaxResult edit(@RequestBody KnowledgeCategory knowledgeCategory)
87 83
     {
84
+        knowledgeCategory.setUpdateBy(getLoginUser().getUsername());
85
+        if (knowledgeCategory.getSortOrder() == null)
86
+        {
87
+            knowledgeCategory.setSortOrder(0L);
88
+        }
89
+        if (knowledgeCategory.getDelFlag() == null || knowledgeCategory.getDelFlag() == "")
90
+        {
91
+            knowledgeCategory.setDelFlag("0");
92
+        }
88 93
         return toAjax(knowledgeCategoryService.updateKnowledgeCategory(knowledgeCategory));
89 94
     }
90 95
 
@@ -95,6 +100,18 @@ public class KnowledgeCategoryController extends BaseController
95 100
 	@DeleteMapping("/{ids}")
96 101
     public AjaxResult remove(@PathVariable Long[] ids)
97 102
     {
103
+        // 获取详情,判断是否有权限删除
104
+        List<KnowledgeCategory> list = knowledgeCategoryService.selectKnowledgeCategoryListByIds(ids);
105
+
106
+        // 检查是否有子分类
107
+        for (KnowledgeCategory category : list)
108
+        {
109
+            if (category.getManagePermission()!="" && category.getManagePermission().contains(getUserId().toString()))
110
+            {
111
+                return AjaxResult.error("无权限操作");
112
+            }
113
+        }
114
+
98 115
         return toAjax(knowledgeCategoryService.deleteKnowledgeCategoryByIds(ids));
99 116
     }
100 117
 }

+ 154 - 22
smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeContentController.java

@@ -1,6 +1,15 @@
1 1
 package com.smartSteward.web.controller.knowledge;;
2 2
 
3 3
 import java.util.List;
4
+
5
+import com.smartSteward.common.enums.knowledge.PublicStatus;
6
+import com.smartSteward.common.utils.DateUtils;
7
+import com.smartSteward.entity.database.knowledge.KnowledgeCategory;
8
+import com.smartSteward.entity.database.knowledge.KnowledgeDraft;
9
+import com.smartSteward.entity.database.knowledge.KnowledgePublishRecord;
10
+import com.smartSteward.service.knowledge.IKnowledgeCategoryService;
11
+import com.smartSteward.service.knowledge.IKnowledgeDraftService;
12
+import com.smartSteward.service.knowledge.IKnowledgePublishRecordService;
4 13
 import io.swagger.annotations.Api;
5 14
 import io.swagger.annotations.ApiOperation;
6 15
 import javax.servlet.http.HttpServletResponse;
@@ -36,29 +45,25 @@ public class KnowledgeContentController extends BaseController
36 45
     @Autowired
37 46
     private IKnowledgeContentService knowledgeContentService;
38 47
 
48
+    @Autowired
49
+    private IKnowledgeCategoryService knowledgeCategoryService;
39 50
 
40
-    @ApiOperation("查询知识库内容列表")
41
-    @PreAuthorize("@ss.hasPermi('knowledgeContent:content:list')")
42
-    @GetMapping("/list")
43
-    public TableDataInfo list(KnowledgeContent knowledgeContent)
44
-    {
45
-        startPage();
46
-        List<KnowledgeContent> list = knowledgeContentService.selectKnowledgeContentList(knowledgeContent);
47
-        return getDataTable(list);
48
-    }
51
+    @Autowired
52
+    private IKnowledgeDraftService knowledgeDraftService;
49 53
 
54
+    @Autowired
55
+    private IKnowledgePublishRecordService knowledgePublishRecordService;
50 56
 
51
-    @ApiOperation("导出知识库内容列表")
52
-    @PreAuthorize("@ss.hasPermi('knowledgeContent:content:export')")
53
-    @Log(title = "知识库内容", businessType = BusinessType.EXPORT)
54
-    @PostMapping("/export")
55
-    public void export(HttpServletResponse response, KnowledgeContent knowledgeContent)
57
+    @ApiOperation("获取知识库内容目录列表")
58
+    @PreAuthorize("@ss.hasPermi('knowledgeContent:content:list')")
59
+    @GetMapping("/list/{categoryId}")
60
+    public AjaxResult list(@PathVariable("categoryId") Long categoryId)
56 61
     {
57
-        List<KnowledgeContent> list = knowledgeContentService.selectKnowledgeContentList(knowledgeContent);
58
-        ExcelUtil<KnowledgeContent> util = new ExcelUtil<KnowledgeContent>(KnowledgeContent.class);
59
-        util.exportExcel(response, list, "知识库内容数据");
60
-    }
62
+        boolean isAdmin = knowledgeCategoryService.isAdmin(categoryId, getLoginUser());
61 63
 
64
+        List<KnowledgeContent> list = knowledgeContentService.selectCommCommentsTree(categoryId, isAdmin);
65
+        return success(list);
66
+    }
62 67
 
63 68
     @ApiOperation("获取知识库内容详细信息")
64 69
     @PreAuthorize("@ss.hasPermi('knowledgeContent:content:query')")
@@ -75,6 +80,26 @@ public class KnowledgeContentController extends BaseController
75 80
     @PostMapping
76 81
     public AjaxResult add(@RequestBody KnowledgeContent knowledgeContent)
77 82
     {
83
+
84
+        // 获取分类信息,看是否有权限操作
85
+        KnowledgeCategory knowledgeCategory = knowledgeCategoryService.selectKnowledgeCategoryById(knowledgeContent.getCategoryId());
86
+        if (knowledgeCategory == null)
87
+        {
88
+            return AjaxResult.error("分类不存在");
89
+        }
90
+
91
+        boolean isAdmin = knowledgeCategoryService.isAdmin(knowledgeCategory.getId(), getLoginUser());
92
+        if (!isAdmin) {
93
+            return AjaxResult.error("您没有权限操作该分类");
94
+        }
95
+
96
+        if (knowledgeContent.getParentId() == null) {
97
+            knowledgeContent.setParentId(0L);
98
+        }
99
+
100
+        knowledgeContent.setStatus(PublicStatus.UNPUBLISHED.getStatus());
101
+        knowledgeContent.setCreateBy(getUserId().toString());
102
+
78 103
         return toAjax(knowledgeContentService.insertKnowledgeContent(knowledgeContent));
79 104
     }
80 105
 
@@ -85,16 +110,123 @@ public class KnowledgeContentController extends BaseController
85 110
     @PutMapping
86 111
     public AjaxResult edit(@RequestBody KnowledgeContent knowledgeContent)
87 112
     {
88
-        return toAjax(knowledgeContentService.updateKnowledgeContent(knowledgeContent));
113
+
114
+        // 判断是否修改内容
115
+        if (knowledgeContent.getContent() == null || knowledgeContent.getContent().isEmpty()) {
116
+            return AjaxResult.error("内容不能为空");
117
+        }
118
+
119
+        KnowledgeContent oldKnowledgeContent = knowledgeContentService.selectKnowledgeContentById(knowledgeContent.getId());
120
+        if (oldKnowledgeContent == null) {
121
+            return AjaxResult.error("内容不存在");
122
+        }
123
+
124
+
125
+        boolean isAdmin = knowledgeCategoryService.isAdmin(oldKnowledgeContent.getCategoryId(), getLoginUser());
126
+        if (!isAdmin) {
127
+            return AjaxResult.error("您没有权限操作该分类");
128
+        }
129
+
130
+        // 修改对应信息
131
+        KnowledgeContent newKnowledgeContent = new KnowledgeContent();
132
+        newKnowledgeContent.setId(knowledgeContent.getId());
133
+
134
+        boolean contentChanged = false;
135
+
136
+        if (knowledgeContent.getContent() != null && !knowledgeContent.getContent().isEmpty() && knowledgeContent.getContent() != oldKnowledgeContent.getContent()) {
137
+            newKnowledgeContent.setContent(knowledgeContent.getContent());
138
+            contentChanged = true;
139
+        }
140
+
141
+        if (knowledgeContent.getTitle() != null && !knowledgeContent.getTitle().isEmpty() && knowledgeContent.getTitle() != oldKnowledgeContent.getTitle()) {
142
+            newKnowledgeContent.setTitle(knowledgeContent.getTitle());
143
+        }
144
+
145
+        if (knowledgeContent.getParentId() != null && !knowledgeContent.getParentId().equals(oldKnowledgeContent.getParentId())) {
146
+            newKnowledgeContent.setParentId(knowledgeContent.getParentId());
147
+        }
148
+
149
+        if (knowledgeContent.getAttachment() != null && !knowledgeContent.getAttachment().isEmpty() && knowledgeContent.getAttachment() != oldKnowledgeContent.getAttachment()) {
150
+            newKnowledgeContent.setAttachment(knowledgeContent.getAttachment());
151
+            contentChanged = true;
152
+        }
153
+
154
+        // 如果内容改变,需要更新状态
155
+        if (contentChanged) {
156
+            if (knowledgeContent.getStatus().equals(PublicStatus.UNPUBLISHED.getStatus())) {
157
+                newKnowledgeContent.setStatus(PublicStatus.UNPUBLISHED.getStatus());
158
+
159
+                // 获取最后一次草稿信息
160
+                KnowledgeDraft lastDraft = new KnowledgeDraft();
161
+                if (oldKnowledgeContent.getLastDraftId() != null) {
162
+                    lastDraft = knowledgeDraftService.selectKnowledgeDraftById(oldKnowledgeContent.getLastDraftId());
163
+                }
164
+
165
+                if (lastDraft.getContent() != null && !lastDraft.getContent().isEmpty() && (lastDraft.getContent() != oldKnowledgeContent.getContent() || lastDraft.getAttachment() != knowledgeContent.getAttachment())) {
166
+                    // 记录草稿信息
167
+                    KnowledgeDraft knowledgeDraft = new KnowledgeDraft();
168
+                    knowledgeDraft.setContentId(newKnowledgeContent.getId());
169
+                    knowledgeDraft.setContent(newKnowledgeContent.getContent());
170
+                    knowledgeDraft.setTitle(knowledgeContent.getTitle());
171
+                    knowledgeDraft.setAttachment(knowledgeContent.getAttachment());
172
+                    knowledgeDraft.setDelFlag("0");
173
+
174
+                    knowledgeDraft.setCreateBy(getUserId().toString());
175
+
176
+                    int draftId = knowledgeDraftService.insertKnowledgeDraft(knowledgeDraft);
177
+
178
+                    newKnowledgeContent.setLastDraftId((long) draftId);
179
+                }
180
+
181
+            } else if (knowledgeContent.getStatus().equals(PublicStatus.PUBLISHED.getStatus()) && oldKnowledgeContent.getStatus().equals(PublicStatus.PUBLISHED.getStatus())) {
182
+
183
+                return AjaxResult.error("已发布不允许操作");
184
+            }
185
+        }
186
+
187
+        // 如果当前状态跟之前不一样,需要记录发布状态
188
+        if (!knowledgeContent.getStatus().equals(oldKnowledgeContent.getStatus()) && knowledgeContent.getStatus().equals(PublicStatus.PUBLISHED.getStatus())) {
189
+            // 版本格式为年月日字符串加三位数字
190
+            String version = DateUtils.dateTimeNow().replaceAll("[-:.]", "") + "001";
191
+            // 如果历史版本时间跟现在一样,累加后三位
192
+            if (oldKnowledgeContent.getVersion().startsWith(version.substring(0, 8))) {
193
+                version = version.substring(0, 8) + (Integer.parseInt(oldKnowledgeContent.getVersion().substring(8)) + 1);
194
+            }
195
+
196
+            KnowledgePublishRecord knowledgePublishRecord = new KnowledgePublishRecord();
197
+            knowledgePublishRecord.setContentId(newKnowledgeContent.getId());
198
+            knowledgePublishRecord.setVersion(version);
199
+            knowledgePublishRecord.setTitle(knowledgeContent.getTitle());
200
+            knowledgePublishRecord.setContent(newKnowledgeContent.getContent());
201
+            knowledgePublishRecord.setPublishBy(getUserId().toString());
202
+            knowledgePublishRecord.setCreateTime(DateUtils.getNowDate());
203
+            knowledgePublishRecord.setAttachment(knowledgeContent.getAttachment());
204
+            knowledgePublishRecord.setDelFlag("0");
205
+
206
+            knowledgePublishRecordService.insertKnowledgePublishRecord(knowledgePublishRecord);
207
+            knowledgeContent.setVersion(version);
208
+        }
209
+
210
+        return toAjax(knowledgeContentService.updateKnowledgeContent(newKnowledgeContent));
89 211
     }
90 212
 
91 213
 
92 214
     @ApiOperation("删除知识库内容")
93 215
     @PreAuthorize("@ss.hasPermi('knowledgeContent:content:remove')")
94 216
     @Log(title = "知识库内容", businessType = BusinessType.DELETE)
95
-	@DeleteMapping("/{ids}")
96
-    public AjaxResult remove(@PathVariable Long[] ids)
217
+	@DeleteMapping("/{id}")
218
+    public AjaxResult remove(@PathVariable Long id)
97 219
     {
98
-        return toAjax(knowledgeContentService.deleteKnowledgeContentByIds(ids));
220
+        KnowledgeContent oldKnowledgeContent = knowledgeContentService.selectKnowledgeContentById(id);
221
+        if (oldKnowledgeContent == null) {
222
+            return AjaxResult.error("内容不存在");
223
+        }
224
+
225
+        boolean isAdmin = knowledgeCategoryService.isAdmin(oldKnowledgeContent.getCategoryId(), getLoginUser());
226
+        if (!isAdmin) {
227
+            return AjaxResult.error("您没有权限删除该分类");
228
+        }
229
+
230
+        return toAjax(knowledgeContentService.deleteKnowledgeContentByIds(new Long[]{id}));
99 231
     }
100 232
 }

+ 100 - 0
smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeDraftController.java

@@ -0,0 +1,100 @@
1
+package com.smartSteward.web.controller.knowledge;;
2
+
3
+import java.util.List;
4
+import io.swagger.annotations.Api;
5
+import io.swagger.annotations.ApiOperation;
6
+import javax.servlet.http.HttpServletResponse;
7
+import org.springframework.security.access.prepost.PreAuthorize;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.GetMapping;
10
+import org.springframework.web.bind.annotation.PostMapping;
11
+import org.springframework.web.bind.annotation.PutMapping;
12
+import org.springframework.web.bind.annotation.DeleteMapping;
13
+import org.springframework.web.bind.annotation.PathVariable;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RestController;
17
+import com.smartSteward.common.annotation.Log;
18
+import com.smartSteward.web.controller.BaseController;
19
+import com.smartSteward.common.core.AjaxResult;
20
+import com.smartSteward.common.enums.BusinessType;
21
+import com.smartSteward.entity.database.knowledge.KnowledgeDraft;
22
+import com.smartSteward.service.knowledge.IKnowledgeDraftService;
23
+import com.smartSteward.common.utils.poi.ExcelUtil;
24
+import com.smartSteward.common.core.page.TableDataInfo;
25
+
26
+/**
27
+ * 知识库草稿Controller
28
+ * 
29
+ * @author smart-steward
30
+ */
31
+@RestController
32
+@Api(value = "知识库草稿",tags = "知识库草稿")
33
+@RequestMapping("/knowledgeDraft/draft")
34
+public class KnowledgeDraftController extends BaseController
35
+{
36
+    @Autowired
37
+    private IKnowledgeDraftService knowledgeDraftService;
38
+
39
+
40
+    @ApiOperation("查询知识库草稿列表")
41
+    @PreAuthorize("@ss.hasPermi('knowledgeDraft:draft:list')")
42
+    @GetMapping("/list")
43
+    public TableDataInfo list(KnowledgeDraft knowledgeDraft)
44
+    {
45
+        startPage();
46
+        List<KnowledgeDraft> list = knowledgeDraftService.selectKnowledgeDraftList(knowledgeDraft);
47
+        return getDataTable(list);
48
+    }
49
+
50
+
51
+//    @ApiOperation("导出知识库草稿列表")
52
+//    @PreAuthorize("@ss.hasPermi('knowledgeDraft:draft:export')")
53
+//    @Log(title = "知识库草稿", businessType = BusinessType.EXPORT)
54
+//    @PostMapping("/export")
55
+//    public void export(HttpServletResponse response, KnowledgeDraft knowledgeDraft)
56
+//    {
57
+//        List<KnowledgeDraft> list = knowledgeDraftService.selectKnowledgeDraftList(knowledgeDraft);
58
+//        ExcelUtil<KnowledgeDraft> util = new ExcelUtil<KnowledgeDraft>(KnowledgeDraft.class);
59
+//        util.exportExcel(response, list, "知识库草稿数据");
60
+//    }
61
+//
62
+//
63
+//    @ApiOperation("获取知识库草稿详细信息")
64
+//    @PreAuthorize("@ss.hasPermi('knowledgeDraft:draft:query')")
65
+//    @GetMapping(value = "/{id}")
66
+//    public AjaxResult getInfo(@PathVariable("id") Long id)
67
+//    {
68
+//        return success(knowledgeDraftService.selectKnowledgeDraftById(id));
69
+//    }
70
+//
71
+//
72
+//    @ApiOperation("新增知识库草稿")
73
+//    @PreAuthorize("@ss.hasPermi('knowledgeDraft:draft:add')")
74
+//    @Log(title = "知识库草稿", businessType = BusinessType.INSERT)
75
+//    @PostMapping
76
+//    public AjaxResult add(@RequestBody KnowledgeDraft knowledgeDraft)
77
+//    {
78
+//        return toAjax(knowledgeDraftService.insertKnowledgeDraft(knowledgeDraft));
79
+//    }
80
+//
81
+//
82
+//    @ApiOperation("修改知识库草稿")
83
+//    @PreAuthorize("@ss.hasPermi('knowledgeDraft:draft:edit')")
84
+//    @Log(title = "知识库草稿", businessType = BusinessType.UPDATE)
85
+//    @PutMapping
86
+//    public AjaxResult edit(@RequestBody KnowledgeDraft knowledgeDraft)
87
+//    {
88
+//        return toAjax(knowledgeDraftService.updateKnowledgeDraft(knowledgeDraft));
89
+//    }
90
+//
91
+//
92
+//    @ApiOperation("删除知识库草稿")
93
+//    @PreAuthorize("@ss.hasPermi('knowledgeDraft:draft:remove')")
94
+//    @Log(title = "知识库草稿", businessType = BusinessType.DELETE)
95
+//	@DeleteMapping("/{ids}")
96
+//    public AjaxResult remove(@PathVariable Long[] ids)
97
+//    {
98
+//        return toAjax(knowledgeDraftService.deleteKnowledgeDraftByIds(ids));
99
+//    }
100
+}

+ 100 - 0
smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgePublishRecordController.java

@@ -0,0 +1,100 @@
1
+package com.smartSteward.web.controller.knowledge;;
2
+
3
+import java.util.List;
4
+import io.swagger.annotations.Api;
5
+import io.swagger.annotations.ApiOperation;
6
+import javax.servlet.http.HttpServletResponse;
7
+import org.springframework.security.access.prepost.PreAuthorize;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.GetMapping;
10
+import org.springframework.web.bind.annotation.PostMapping;
11
+import org.springframework.web.bind.annotation.PutMapping;
12
+import org.springframework.web.bind.annotation.DeleteMapping;
13
+import org.springframework.web.bind.annotation.PathVariable;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RestController;
17
+import com.smartSteward.common.annotation.Log;
18
+import com.smartSteward.web.controller.BaseController;
19
+import com.smartSteward.common.core.AjaxResult;
20
+import com.smartSteward.common.enums.BusinessType;
21
+import com.smartSteward.entity.database.knowledge.KnowledgePublishRecord;
22
+import com.smartSteward.service.knowledge.IKnowledgePublishRecordService;
23
+import com.smartSteward.common.utils.poi.ExcelUtil;
24
+import com.smartSteward.common.core.page.TableDataInfo;
25
+
26
+/**
27
+ * 知识库发布记录Controller
28
+ * 
29
+ * @author smart-steward
30
+ */
31
+@RestController
32
+@Api(value = "知识库发布记录",tags = "知识库发布记录")
33
+@RequestMapping("/knowledgePublishRecord/record")
34
+public class KnowledgePublishRecordController extends BaseController
35
+{
36
+    @Autowired
37
+    private IKnowledgePublishRecordService knowledgePublishRecordService;
38
+
39
+
40
+    @ApiOperation("查询知识库发布记录列表")
41
+    @PreAuthorize("@ss.hasPermi('knowledgePublishRecord:record:list')")
42
+    @GetMapping("/list")
43
+    public TableDataInfo list(KnowledgePublishRecord knowledgePublishRecord)
44
+    {
45
+        startPage();
46
+        List<KnowledgePublishRecord> list = knowledgePublishRecordService.selectKnowledgePublishRecordList(knowledgePublishRecord);
47
+        return getDataTable(list);
48
+    }
49
+
50
+
51
+//    @ApiOperation("导出知识库发布记录列表")
52
+//    @PreAuthorize("@ss.hasPermi('knowledgePublishRecord:record:export')")
53
+//    @Log(title = "知识库发布记录", businessType = BusinessType.EXPORT)
54
+//    @PostMapping("/export")
55
+//    public void export(HttpServletResponse response, KnowledgePublishRecord knowledgePublishRecord)
56
+//    {
57
+//        List<KnowledgePublishRecord> list = knowledgePublishRecordService.selectKnowledgePublishRecordList(knowledgePublishRecord);
58
+//        ExcelUtil<KnowledgePublishRecord> util = new ExcelUtil<KnowledgePublishRecord>(KnowledgePublishRecord.class);
59
+//        util.exportExcel(response, list, "知识库发布记录数据");
60
+//    }
61
+//
62
+//
63
+//    @ApiOperation("获取知识库发布记录详细信息")
64
+//    @PreAuthorize("@ss.hasPermi('knowledgePublishRecord:record:query')")
65
+//    @GetMapping(value = "/{id}")
66
+//    public AjaxResult getInfo(@PathVariable("id") Long id)
67
+//    {
68
+//        return success(knowledgePublishRecordService.selectKnowledgePublishRecordById(id));
69
+//    }
70
+//
71
+//
72
+//    @ApiOperation("新增知识库发布记录")
73
+//    @PreAuthorize("@ss.hasPermi('knowledgePublishRecord:record:add')")
74
+//    @Log(title = "知识库发布记录", businessType = BusinessType.INSERT)
75
+//    @PostMapping
76
+//    public AjaxResult add(@RequestBody KnowledgePublishRecord knowledgePublishRecord)
77
+//    {
78
+//        return toAjax(knowledgePublishRecordService.insertKnowledgePublishRecord(knowledgePublishRecord));
79
+//    }
80
+//
81
+//
82
+//    @ApiOperation("修改知识库发布记录")
83
+//    @PreAuthorize("@ss.hasPermi('knowledgePublishRecord:record:edit')")
84
+//    @Log(title = "知识库发布记录", businessType = BusinessType.UPDATE)
85
+//    @PutMapping
86
+//    public AjaxResult edit(@RequestBody KnowledgePublishRecord knowledgePublishRecord)
87
+//    {
88
+//        return toAjax(knowledgePublishRecordService.updateKnowledgePublishRecord(knowledgePublishRecord));
89
+//    }
90
+//
91
+//
92
+//    @ApiOperation("删除知识库发布记录")
93
+//    @PreAuthorize("@ss.hasPermi('knowledgePublishRecord:record:remove')")
94
+//    @Log(title = "知识库发布记录", businessType = BusinessType.DELETE)
95
+//	@DeleteMapping("/{ids}")
96
+//    public AjaxResult remove(@PathVariable Long[] ids)
97
+//    {
98
+//        return toAjax(knowledgePublishRecordService.deleteKnowledgePublishRecordByIds(ids));
99
+//    }
100
+}

+ 62 - 0
smart-steward-api/src/main/java/com/smartSteward/web/controller/knowledge/KnowledgeViewRecordController.java

@@ -0,0 +1,62 @@
1
+package com.smartSteward.web.controller.knowledge;;
2
+
3
+import java.util.List;
4
+import io.swagger.annotations.Api;
5
+import io.swagger.annotations.ApiOperation;
6
+import javax.servlet.http.HttpServletResponse;
7
+import org.springframework.security.access.prepost.PreAuthorize;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.GetMapping;
10
+import org.springframework.web.bind.annotation.PostMapping;
11
+import org.springframework.web.bind.annotation.PutMapping;
12
+import org.springframework.web.bind.annotation.DeleteMapping;
13
+import org.springframework.web.bind.annotation.PathVariable;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RestController;
17
+import com.smartSteward.common.annotation.Log;
18
+import com.smartSteward.web.controller.BaseController;
19
+import com.smartSteward.common.core.AjaxResult;
20
+import com.smartSteward.common.enums.BusinessType;
21
+import com.smartSteward.entity.database.knowledge.KnowledgeViewRecord;
22
+import com.smartSteward.service.knowledge.IKnowledgeViewRecordService;
23
+import com.smartSteward.common.utils.poi.ExcelUtil;
24
+import com.smartSteward.common.core.page.TableDataInfo;
25
+
26
+/**
27
+ * 知识库查看记录Controller
28
+ * 
29
+ * @author smart-steward
30
+ */
31
+@RestController
32
+@Api(value = "知识库查看记录",tags = "知识库查看记录")
33
+@RequestMapping("/knowledgeViewRecord/record")
34
+public class KnowledgeViewRecordController extends BaseController
35
+{
36
+    @Autowired
37
+    private IKnowledgeViewRecordService knowledgeViewRecordService;
38
+
39
+
40
+    @ApiOperation("查询知识库查看记录列表")
41
+    @PreAuthorize("@ss.hasPermi('knowledgeViewRecord:record:list')")
42
+    @GetMapping("/list")
43
+    public TableDataInfo list(KnowledgeViewRecord knowledgeViewRecord)
44
+    {
45
+        startPage();
46
+        List<KnowledgeViewRecord> list = knowledgeViewRecordService.selectKnowledgeViewRecordList(knowledgeViewRecord);
47
+        return getDataTable(list);
48
+    }
49
+
50
+    @ApiOperation("新增知识库查看记录")
51
+    @PreAuthorize("@ss.hasPermi('knowledgeViewRecord:record:add')")
52
+    @Log(title = "知识库查看记录", businessType = BusinessType.INSERT)
53
+    @PostMapping
54
+    public AjaxResult add(@RequestBody KnowledgeViewRecord knowledgeViewRecord)
55
+    {
56
+        knowledgeViewRecord.setUserId(getUserId().toString());
57
+        knowledgeViewRecord.setUserName(getUsername());
58
+        knowledgeViewRecord.setUserAvatar(getUserAvatar());
59
+        knowledgeViewRecord.setCreateBy(getUserId().toString());
60
+        return toAjax(knowledgeViewRecordService.insertKnowledgeViewRecord(knowledgeViewRecord));
61
+    }
62
+}

+ 47 - 0
smart-steward-common/src/main/java/com/smartSteward/common/enums/knowledge/PublicStatus.java

@@ -0,0 +1,47 @@
1
+package com.smartSteward.common.enums.knowledge;
2
+
3
+/**
4
+ * 工单延时状态枚举类
5
+ * @author smartSteward
6
+ */
7
+
8
+public enum PublicStatus {
9
+    /**
10
+     * 已发布
11
+     */
12
+    PUBLISHED(1L, "已发布"),
13
+    /**
14
+     * 未发布
15
+     */
16
+    UNPUBLISHED(2L, "未发布");
17
+
18
+    /**
19
+     * 延时状态
20
+     */
21
+    private final Long status;
22
+    /**
23
+     * 描述
24
+     */
25
+    private final String desc;
26
+
27
+    PublicStatus(Long status, String desc) {
28
+        this.status = status;
29
+        this.desc = desc;
30
+    }
31
+
32
+    /**
33
+     * 获取延时状态
34
+     * @return 延时状态
35
+     */
36
+    public Long getStatus() {
37
+        return status;
38
+    }
39
+
40
+    /**
41
+     * 获取描述
42
+     * @return 描述
43
+     */
44
+    public String getDesc() {
45
+        return desc;
46
+    }
47
+}

+ 2 - 0
smart-steward-entity/src/main/java/com/smartSteward/entity/database/comm/CommComments.java

@@ -1,5 +1,6 @@
1 1
 package com.smartSteward.entity.database.comm;
2 2
 
3
+import com.smartSteward.common.annotation.FilePathField;
3 4
 import io.swagger.annotations.ApiModel;
4 5
 import io.swagger.annotations.ApiModelProperty;
5 6
 import lombok.Data;
@@ -76,6 +77,7 @@ public class CommComments extends BaseEntity
76 77
     /** 评论图片(图片路径,多个逗号分割) */
77 78
     @Excel(name = "评论图片", readConverterExp = "图=片路径,多个逗号分割")
78 79
     @ApiModelProperty("评论图片")
80
+    @FilePathField()
79 81
     private String attachments;
80 82
 
81 83
 

+ 6 - 1
smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeCategory.java

@@ -1,5 +1,6 @@
1 1
 package com.smartSteward.entity.database.knowledge;;
2 2
 
3
+import com.smartSteward.common.annotation.FilePathField;
3 4
 import io.swagger.annotations.ApiModel;
4 5
 import io.swagger.annotations.ApiModelProperty;
5 6
 import lombok.Data;
@@ -7,6 +8,8 @@ import lombok.EqualsAndHashCode;
7 8
 import com.smartSteward.common.annotation.Excel;
8 9
 import com.smartSteward.common.core.BaseEntity;
9 10
 
11
+import javax.validation.constraints.NotBlank;
12
+
10 13
 /**
11 14
  * 知识库分类对象 knowledge_category
12 15
  *
@@ -26,6 +29,7 @@ public class KnowledgeCategory extends BaseEntity
26 29
     /** 知识库名称 */
27 30
     @Excel(name = "知识库名称")
28 31
     @ApiModelProperty("知识库名称")
32
+    @NotBlank
29 33
     private String name;
30 34
 
31 35
     /** 知识库描述 */
@@ -36,6 +40,7 @@ public class KnowledgeCategory extends BaseEntity
36 40
     /** 知识库图标 */
37 41
     @Excel(name = "知识库图标")
38 42
     @ApiModelProperty("知识库图标")
43
+    @FilePathField()
39 44
     private String icon;
40 45
 
41 46
     /** 管理权限 */
@@ -66,7 +71,7 @@ public class KnowledgeCategory extends BaseEntity
66 71
     /** 删除标记(0:正常 1:删除) */
67 72
     @Excel(name = "删除标记(0:正常 1:删除)")
68 73
     @ApiModelProperty("删除标记(0:正常 1:删除)")
69
-    private Long isDeleted;
74
+    private String delFlag;
70 75
 
71 76
 
72 77
 }

+ 78 - 30
smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeContent.java

@@ -1,5 +1,10 @@
1
-package com.smartSteward.entity.database.knowledge;;
1
+package com.smartSteward.entity.database.knowledge;
2 2
 
3
+import java.util.Date;
4
+import java.util.List;
5
+
6
+import com.fasterxml.jackson.annotation.JsonFormat;
7
+import com.smartSteward.common.annotation.FilePathField;
3 8
 import io.swagger.annotations.ApiModel;
4 9
 import io.swagger.annotations.ApiModelProperty;
5 10
 import lombok.Data;
@@ -7,45 +12,88 @@ import lombok.EqualsAndHashCode;
7 12
 import com.smartSteward.common.annotation.Excel;
8 13
 import com.smartSteward.common.core.BaseEntity;
9 14
 
15
+import javax.validation.constraints.*;
16
+
10 17
 /**
11
- * 知识库内容对象 knowledge_content
12
- *
13
- * @author smart-steward
14
- */
18
+* 知识库内容(已发布内容)对象 knowledge_content
19
+*
20
+* @author smart-steward
21
+*/
15 22
 @Data
16 23
 @EqualsAndHashCode(callSuper = true)
17
-@ApiModel("知识库内容")
24
+@ApiModel("知识库内容(已发布内容)")
18 25
 public class KnowledgeContent extends BaseEntity
19 26
 {
20
-    private static final long serialVersionUID = 1L;
27
+   private static final long serialVersionUID = 1L;
28
+
29
+   /** 主键ID */
30
+   @ApiModelProperty(value = "主键id")
31
+   private Long id;
32
+
33
+   /** 知识库分类ID */
34
+   @Excel(name = "知识库分类ID")
35
+   @ApiModelProperty("知识库分类ID")
36
+   @NotNull(message = "知识库分类ID不能为空")
37
+   private Long categoryId;
38
+
39
+   /** 父级ID(0:根目录) */
40
+   @Excel(name = "父级ID(0:根目录)")
41
+   @ApiModelProperty("父级ID(0:根目录)")
42
+   private Long parentId;
43
+
44
+   /** 内容标题 */
45
+   @Excel(name = "内容标题")
46
+   @ApiModelProperty("内容标题")
47
+   @NotBlank(message = "内容标题不能为空")
48
+   private String title;
49
+
50
+   /** 内容 */
51
+   @Excel(name = "内容")
52
+   @ApiModelProperty("内容")
53
+   private String content;
54
+
55
+   /** 版本号 */
56
+   @Excel(name = "版本号")
57
+   @ApiModelProperty("版本号")
58
+   private String version;
59
+
60
+   /** 状态: 1-已发布 2-已下线 */
61
+   @Excel(name = "状态: 1-已发布 2-未发布")
62
+   @ApiModelProperty("状态: 1-已发布 2-未发布")
63
+   @NotNull(message = "状态: 1-已发布 2-未发布不能为空")
64
+   private Long status;
21 65
 
22
-    /** 主键ID */
23
-    @ApiModelProperty(value = "主键id")
24
-    private Long id;
66
+   /** 发布时间 */
67
+   @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
68
+   @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
69
+   @ApiModelProperty("发布时间")
70
+   private Date publishTime;
25 71
 
26
-    /** 知识库分类ID */
27
-    @Excel(name = "知识库分类ID")
28
-    @ApiModelProperty("知识库分类ID")
29
-    private Long categoryId;
72
+   /** 发布人 */
73
+   @Excel(name = "发布人")
74
+   @ApiModelProperty("发布人")
75
+   private String publishBy;
30 76
 
31
-    /** 父级ID(0:根目录) */
32
-    @Excel(name = "父级ID(0:根目录)")
33
-    @ApiModelProperty("父级ID(0:根目录)")
34
-    private Long parentId;
77
+   /** 最后一次草稿ID */
78
+   @Excel(name = "最后一次草稿ID")
79
+   @ApiModelProperty("最后一次草稿ID")
80
+   private Long lastDraftId;
35 81
 
36
-    /** 内容标题 */
37
-    @Excel(name = "内容标题")
38
-    @ApiModelProperty("内容标题")
39
-    private String title;
82
+   /** 浏览次数 */
83
+   @Excel(name = "浏览次数")
84
+   @ApiModelProperty("浏览次数")
85
+   private Long viewCount;
40 86
 
41
-    /** 内容 */
42
-    @Excel(name = "内容")
43
-    @ApiModelProperty("内容")
44
-    private String content;
87
+   /** 知识库附件 */
88
+   @Excel(name = "知识库附件")
89
+   @ApiModelProperty("知识库附件")
90
+   @FilePathField()
91
+   private String attachment;
45 92
 
46
-    /** 删除标记(0:正常 1:删除) */
47
-    @Excel(name = "删除标记(0:正常 1:删除)")
48
-    @ApiModelProperty("删除标记(0:正常 1:删除)")
49
-    private Long isDeleted;
93
+   /** 删除标记(0:正常 1:删除) */
94
+   @Excel(name = "删除标记(0:正常 1:删除)")
95
+   @ApiModelProperty("删除标记(0:正常 1:删除)")
96
+   private String delFlag;
50 97
 
98
+   private List<KnowledgeContent> children;
51 99
 }

+ 66 - 0
smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeDraft.java

@@ -0,0 +1,66 @@
1
+package com.smartSteward.entity.database.knowledge;
2
+
3
+import com.smartSteward.common.annotation.FilePathField;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import com.smartSteward.common.annotation.Excel;
9
+import com.smartSteward.common.core.BaseEntity;
10
+
11
+import javax.validation.constraints.*;
12
+
13
+/**
14
+* 知识库草稿对象 knowledge_draft
15
+*
16
+* @author smart-steward
17
+*/
18
+@Data
19
+@EqualsAndHashCode(callSuper = true)
20
+@ApiModel("知识库草稿")
21
+public class KnowledgeDraft extends BaseEntity
22
+{
23
+   private static final long serialVersionUID = 1L;
24
+
25
+   /** 主键ID */
26
+   @ApiModelProperty(value = "主键id")
27
+   private Long id;
28
+
29
+   /** 关联的内容ID(新建时为null) */
30
+   @Excel(name = "关联的内容ID(新建时为null)")
31
+   @ApiModelProperty("关联的内容ID(新建时为null)")
32
+   private Long contentId;
33
+
34
+   /** 知识库分类ID */
35
+   @Excel(name = "知识库分类ID")
36
+   @ApiModelProperty("知识库分类ID")
37
+   @NotNull(message = "知识库分类ID不能为空")
38
+   private Long categoryId;
39
+
40
+   /** 父级ID(0:根目录) */
41
+   @Excel(name = "父级ID(0:根目录)")
42
+   @ApiModelProperty("父级ID(0:根目录)")
43
+   private Long parentId;
44
+
45
+   /** 草稿标题 */
46
+   @Excel(name = "草稿标题")
47
+   @ApiModelProperty("草稿标题")
48
+   @NotBlank(message = "草稿标题不能为空")
49
+   private String title;
50
+
51
+   /** 草稿内容 */
52
+   @Excel(name = "草稿内容")
53
+   @ApiModelProperty("草稿内容")
54
+   private String content;
55
+
56
+   /** 知识库附件 */
57
+   @Excel(name = "知识库附件")
58
+   @ApiModelProperty("知识库附件")
59
+   @FilePathField()
60
+   private String attachment;
61
+
62
+   /** 删除标记(0:正常 1:删除) */
63
+   @Excel(name = "删除标记(0:正常 1:删除)")
64
+   @ApiModelProperty("删除标记(0:正常 1:删除)")
65
+   private String delFlag;
66
+}

+ 69 - 0
smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgePublishRecord.java

@@ -0,0 +1,69 @@
1
+package com.smartSteward.entity.database.knowledge;
2
+
3
+import java.util.Date;
4
+import com.fasterxml.jackson.annotation.JsonFormat;
5
+import com.smartSteward.common.annotation.FilePathField;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import com.smartSteward.common.annotation.Excel;
11
+import com.smartSteward.common.core.BaseEntity;
12
+
13
+import javax.validation.constraints.*;
14
+
15
+/**
16
+* 知识库发布记录对象 knowledge_publish_record
17
+*
18
+* @author smart-steward
19
+*/
20
+@Data
21
+@EqualsAndHashCode(callSuper = true)
22
+@ApiModel("知识库发布记录")
23
+public class KnowledgePublishRecord extends BaseEntity
24
+{
25
+   private static final long serialVersionUID = 1L;
26
+
27
+   /** 主键ID */
28
+   @ApiModelProperty(value = "主键id")
29
+   private Long id;
30
+
31
+   /** 内容ID */
32
+   @Excel(name = "内容ID")
33
+   @ApiModelProperty("内容ID")
34
+   @NotNull(message = "内容ID不能为空")
35
+   private Long contentId;
36
+
37
+   /** 内容标题 */
38
+   @Excel(name = "内容标题")
39
+   @ApiModelProperty("内容标题")
40
+   @NotBlank(message = "内容标题不能为空")
41
+   private String title;
42
+
43
+   /** 内容 */
44
+   @Excel(name = "内容")
45
+   @ApiModelProperty("内容")
46
+   private String content;
47
+
48
+   /** 发布版本号 */
49
+   @Excel(name = "发布版本号")
50
+   @ApiModelProperty("发布版本号")
51
+   @NotNull(message = "发布版本号不能为空")
52
+   private String version;
53
+
54
+   /** 发布人 */
55
+   @Excel(name = "发布人")
56
+   @ApiModelProperty("发布人")
57
+   private String publishBy;
58
+
59
+   /** 知识库附件 */
60
+   @Excel(name = "知识库附件")
61
+   @ApiModelProperty("知识库附件")
62
+   @FilePathField()
63
+   private String attachment;
64
+
65
+   /** 删除标记(0:正常 1:删除) */
66
+   @Excel(name = "删除标记(0:正常 1:删除)")
67
+   @ApiModelProperty("删除标记(0:正常 1:删除)")
68
+   private String delFlag;
69
+}

+ 53 - 0
smart-steward-entity/src/main/java/com/smartSteward/entity/database/knowledge/KnowledgeViewRecord.java

@@ -0,0 +1,53 @@
1
+package com.smartSteward.entity.database.knowledge;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+import lombok.EqualsAndHashCode;
7
+import com.smartSteward.common.annotation.Excel;
8
+import com.smartSteward.common.core.BaseEntity;
9
+
10
+import javax.validation.constraints.*;
11
+
12
+/**
13
+* 知识库查看记录对象 knowledge_view_record
14
+*
15
+* @author smart-steward
16
+*/
17
+@Data
18
+@EqualsAndHashCode(callSuper = true)
19
+@ApiModel("知识库查看记录")
20
+public class KnowledgeViewRecord extends BaseEntity
21
+{
22
+   private static final long serialVersionUID = 1L;
23
+
24
+   /** 主键ID */
25
+   @ApiModelProperty(value = "主键id")
26
+   private Long id;
27
+
28
+   /** 知识内容ID */
29
+   @Excel(name = "知识内容ID")
30
+   @ApiModelProperty("知识内容ID")
31
+   @NotNull(message = "知识内容ID不能为空")
32
+   private Long contentId;
33
+
34
+   /** 用户ID */
35
+   @Excel(name = "用户ID")
36
+   @ApiModelProperty("用户ID")
37
+   @NotBlank(message = "用户ID不能为空")
38
+   private String userId;
39
+
40
+   /** 用户名 */
41
+   @Excel(name = "用户名")
42
+   @ApiModelProperty("用户名")
43
+   private String userName;
44
+
45
+   /** 用户头像 */
46
+   @Excel(name = "用户头像")
47
+   @ApiModelProperty("用户头像")
48
+   private String userAvatar;
49
+
50
+   /** 删除标记(0:正常 1:删除) */
51
+   @ApiModelProperty("删除标记(0:正常 1:删除)")
52
+   private String delFlag;
53
+}

+ 9 - 0
smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeCategoryMapper.java

@@ -57,4 +57,13 @@ public interface KnowledgeCategoryMapper
57 57
      * @return 结果
58 58
      */
59 59
     public int deleteKnowledgeCategoryByIds(Long[] ids);
60
+
61
+
62
+    /**
63
+     * 根据ID查询知识库分类列表
64
+     *
65
+     * @param ids 知识库分类主键集合
66
+     * @return 知识库分类集合
67
+     */
68
+    public List<KnowledgeCategory> selectKnowledgeCategoryListByIds(Long[] ids);
60 69
 }

+ 14 - 14
smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeContentMapper.java

@@ -4,54 +4,54 @@ import java.util.List;
4 4
 import com.smartSteward.entity.database.knowledge.KnowledgeContent;
5 5
 
6 6
 /**
7
- * 知识库内容Mapper接口
7
+ * 知识库内容(已发布内容)Mapper接口
8 8
  * 
9 9
  * @author smart-steward
10 10
  */
11 11
 public interface KnowledgeContentMapper 
12 12
 {
13 13
     /**
14
-     * 查询知识库内容
14
+     * 查询知识库内容(已发布内容)
15 15
      * 
16
-     * @param id 知识库内容主键
17
-     * @return 知识库内容
16
+     * @param id 知识库内容(已发布内容)主键
17
+     * @return 知识库内容(已发布内容)
18 18
      */
19 19
     public KnowledgeContent selectKnowledgeContentById(Long id);
20 20
 
21 21
     /**
22
-     * 查询知识库内容列表
22
+     * 查询知识库内容(已发布内容)列表
23 23
      * 
24
-     * @param knowledgeContent 知识库内容
25
-     * @return 知识库内容集合
24
+     * @param knowledgeContent 知识库内容(已发布内容)
25
+     * @return 知识库内容(已发布内容)集合
26 26
      */
27 27
     public List<KnowledgeContent> selectKnowledgeContentList(KnowledgeContent knowledgeContent);
28 28
 
29 29
     /**
30
-     * 新增知识库内容
30
+     * 新增知识库内容(已发布内容)
31 31
      * 
32
-     * @param knowledgeContent 知识库内容
32
+     * @param knowledgeContent 知识库内容(已发布内容)
33 33
      * @return 结果
34 34
      */
35 35
     public int insertKnowledgeContent(KnowledgeContent knowledgeContent);
36 36
 
37 37
     /**
38
-     * 修改知识库内容
38
+     * 修改知识库内容(已发布内容)
39 39
      * 
40
-     * @param knowledgeContent 知识库内容
40
+     * @param knowledgeContent 知识库内容(已发布内容)
41 41
      * @return 结果
42 42
      */
43 43
     public int updateKnowledgeContent(KnowledgeContent knowledgeContent);
44 44
 
45 45
     /**
46
-     * 删除知识库内容
46
+     * 删除知识库内容(已发布内容)
47 47
      * 
48
-     * @param id 知识库内容主键
48
+     * @param id 知识库内容(已发布内容)主键
49 49
      * @return 结果
50 50
      */
51 51
     public int deleteKnowledgeContentById(Long id);
52 52
 
53 53
     /**
54
-     * 批量删除知识库内容
54
+     * 批量删除知识库内容(已发布内容)
55 55
      * 
56 56
      * @param ids 需要删除的数据主键集合
57 57
      * @return 结果

+ 60 - 0
smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeDraftMapper.java

@@ -0,0 +1,60 @@
1
+package com.smartSteward.mapper.knowledge;
2
+
3
+import java.util.List;
4
+import com.smartSteward.entity.database.knowledge.KnowledgeDraft;
5
+
6
+/**
7
+ * 知识库草稿Mapper接口
8
+ * 
9
+ * @author smart-steward
10
+ */
11
+public interface KnowledgeDraftMapper 
12
+{
13
+    /**
14
+     * 查询知识库草稿
15
+     * 
16
+     * @param id 知识库草稿主键
17
+     * @return 知识库草稿
18
+     */
19
+    public KnowledgeDraft selectKnowledgeDraftById(Long id);
20
+
21
+    /**
22
+     * 查询知识库草稿列表
23
+     * 
24
+     * @param knowledgeDraft 知识库草稿
25
+     * @return 知识库草稿集合
26
+     */
27
+    public List<KnowledgeDraft> selectKnowledgeDraftList(KnowledgeDraft knowledgeDraft);
28
+
29
+    /**
30
+     * 新增知识库草稿
31
+     * 
32
+     * @param knowledgeDraft 知识库草稿
33
+     * @return 结果
34
+     */
35
+    public int insertKnowledgeDraft(KnowledgeDraft knowledgeDraft);
36
+
37
+    /**
38
+     * 修改知识库草稿
39
+     * 
40
+     * @param knowledgeDraft 知识库草稿
41
+     * @return 结果
42
+     */
43
+    public int updateKnowledgeDraft(KnowledgeDraft knowledgeDraft);
44
+
45
+    /**
46
+     * 删除知识库草稿
47
+     * 
48
+     * @param id 知识库草稿主键
49
+     * @return 结果
50
+     */
51
+    public int deleteKnowledgeDraftById(Long id);
52
+
53
+    /**
54
+     * 批量删除知识库草稿
55
+     * 
56
+     * @param ids 需要删除的数据主键集合
57
+     * @return 结果
58
+     */
59
+    public int deleteKnowledgeDraftByIds(Long[] ids);
60
+}

+ 60 - 0
smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgePublishRecordMapper.java

@@ -0,0 +1,60 @@
1
+package com.smartSteward.mapper.knowledge;
2
+
3
+import java.util.List;
4
+import com.smartSteward.entity.database.knowledge.KnowledgePublishRecord;
5
+
6
+/**
7
+ * 知识库发布记录Mapper接口
8
+ * 
9
+ * @author smart-steward
10
+ */
11
+public interface KnowledgePublishRecordMapper 
12
+{
13
+    /**
14
+     * 查询知识库发布记录
15
+     * 
16
+     * @param id 知识库发布记录主键
17
+     * @return 知识库发布记录
18
+     */
19
+    public KnowledgePublishRecord selectKnowledgePublishRecordById(Long id);
20
+
21
+    /**
22
+     * 查询知识库发布记录列表
23
+     * 
24
+     * @param knowledgePublishRecord 知识库发布记录
25
+     * @return 知识库发布记录集合
26
+     */
27
+    public List<KnowledgePublishRecord> selectKnowledgePublishRecordList(KnowledgePublishRecord knowledgePublishRecord);
28
+
29
+    /**
30
+     * 新增知识库发布记录
31
+     * 
32
+     * @param knowledgePublishRecord 知识库发布记录
33
+     * @return 结果
34
+     */
35
+    public int insertKnowledgePublishRecord(KnowledgePublishRecord knowledgePublishRecord);
36
+
37
+    /**
38
+     * 修改知识库发布记录
39
+     * 
40
+     * @param knowledgePublishRecord 知识库发布记录
41
+     * @return 结果
42
+     */
43
+    public int updateKnowledgePublishRecord(KnowledgePublishRecord knowledgePublishRecord);
44
+
45
+    /**
46
+     * 删除知识库发布记录
47
+     * 
48
+     * @param id 知识库发布记录主键
49
+     * @return 结果
50
+     */
51
+    public int deleteKnowledgePublishRecordById(Long id);
52
+
53
+    /**
54
+     * 批量删除知识库发布记录
55
+     * 
56
+     * @param ids 需要删除的数据主键集合
57
+     * @return 结果
58
+     */
59
+    public int deleteKnowledgePublishRecordByIds(Long[] ids);
60
+}

+ 60 - 0
smart-steward-mapper/src/main/java/com/smartSteward/mapper/knowledge/KnowledgeViewRecordMapper.java

@@ -0,0 +1,60 @@
1
+package com.smartSteward.mapper.knowledge;
2
+
3
+import java.util.List;
4
+import com.smartSteward.entity.database.knowledge.KnowledgeViewRecord;
5
+
6
+/**
7
+ * 知识库查看记录Mapper接口
8
+ * 
9
+ * @author smart-steward
10
+ */
11
+public interface KnowledgeViewRecordMapper 
12
+{
13
+    /**
14
+     * 查询知识库查看记录
15
+     * 
16
+     * @param id 知识库查看记录主键
17
+     * @return 知识库查看记录
18
+     */
19
+    public KnowledgeViewRecord selectKnowledgeViewRecordById(Long id);
20
+
21
+    /**
22
+     * 查询知识库查看记录列表
23
+     * 
24
+     * @param knowledgeViewRecord 知识库查看记录
25
+     * @return 知识库查看记录集合
26
+     */
27
+    public List<KnowledgeViewRecord> selectKnowledgeViewRecordList(KnowledgeViewRecord knowledgeViewRecord);
28
+
29
+    /**
30
+     * 新增知识库查看记录
31
+     * 
32
+     * @param knowledgeViewRecord 知识库查看记录
33
+     * @return 结果
34
+     */
35
+    public int insertKnowledgeViewRecord(KnowledgeViewRecord knowledgeViewRecord);
36
+
37
+    /**
38
+     * 修改知识库查看记录
39
+     * 
40
+     * @param knowledgeViewRecord 知识库查看记录
41
+     * @return 结果
42
+     */
43
+    public int updateKnowledgeViewRecord(KnowledgeViewRecord knowledgeViewRecord);
44
+
45
+    /**
46
+     * 删除知识库查看记录
47
+     * 
48
+     * @param id 知识库查看记录主键
49
+     * @return 结果
50
+     */
51
+    public int deleteKnowledgeViewRecordById(Long id);
52
+
53
+    /**
54
+     * 批量删除知识库查看记录
55
+     * 
56
+     * @param ids 需要删除的数据主键集合
57
+     * @return 结果
58
+     */
59
+    public int deleteKnowledgeViewRecordByIds(Long[] ids);
60
+}

+ 16 - 6
smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeCategoryMapper.xml

@@ -18,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
18 18
         <result property="updateTime"    column="update_time"    />
19 19
         <result property="createBy"    column="create_by"    />
20 20
         <result property="updateBy"    column="update_by"    />
21
-        <result property="isDeleted"    column="is_deleted"    />
21
+        <result property="delFlag"    column="is_deleted"    />
22 22
     </resultMap>
23 23
 
24 24
     <sql id="selectKnowledgeCategoryVo">
@@ -36,7 +36,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
36 36
             <if test="visibleRole != null  and visibleRole != ''"> and visible_role = #{visibleRole}</if>
37 37
             <if test="associationIds != null  and associationIds != ''"> and association_ids = #{associationIds}</if>
38 38
             <if test="sortOrder != null "> and sort_order = #{sortOrder}</if>
39
-            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
39
+            <if test="delFlag != null "> and is_deleted = #{delFlag}</if>
40
+        </where>
41
+    </select>
42
+
43
+    <select id="selectKnowledgeCategoryListByIds" parameterType="KnowledgeCategory" resultMap="KnowledgeCategoryResult">
44
+        <include refid="selectKnowledgeCategoryVo"/>
45
+        <where>
46
+            id in
47
+            <foreach collection="ids" item="id" open="(" close=")" separator=",">
48
+                #{id}
49
+            </foreach>
40 50
         </where>
41 51
     </select>
42 52
     
@@ -60,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
60 70
             <if test="updateTime != null">update_time,</if>
61 71
             <if test="createBy != null">create_by,</if>
62 72
             <if test="updateBy != null">update_by,</if>
63
-            <if test="isDeleted != null">is_deleted,</if>
73
+            <if test="delFlag != null">is_deleted,</if>
64 74
          </trim>
65 75
         <trim prefix="values (" suffix=")" suffixOverrides=",">
66 76
             <if test="name != null and name != ''">#{name},</if>
@@ -75,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
75 85
             <if test="updateTime != null">#{updateTime},</if>
76 86
             <if test="createBy != null">#{createBy},</if>
77 87
             <if test="updateBy != null">#{updateBy},</if>
78
-            <if test="isDeleted != null">#{isDeleted},</if>
88
+            <if test="delFlag != null">#{delFlag},</if>
79 89
          </trim>
80 90
     </insert>
81 91
 
@@ -94,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
94 104
             <if test="updateTime != null">update_time = #{updateTime},</if>
95 105
             <if test="createBy != null">create_by = #{createBy},</if>
96 106
             <if test="updateBy != null">update_by = #{updateBy},</if>
97
-            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
107
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
98 108
         </trim>
99 109
         where id = #{id}
100 110
     </update>
@@ -104,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
104 114
     </delete>
105 115
 
106 116
     <delete id="deleteKnowledgeCategoryByIds" parameterType="String">
107
-        delete from knowledge_category where id in 
117
+        update knowledge_category set del_flag = '1' where id in
108 118
         <foreach item="id" collection="array" open="(" separator="," close=")">
109 119
             #{id}
110 120
         </foreach>

+ 41 - 9
smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeContentMapper.xml

@@ -10,25 +10,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
10 10
         <result property="parentId"    column="parent_id"    />
11 11
         <result property="title"    column="title"    />
12 12
         <result property="content"    column="content"    />
13
+        <result property="version"    column="version"    />
14
+        <result property="status"    column="status"    />
15
+        <result property="publishTime"    column="publish_time"    />
16
+        <result property="publishBy"    column="publish_by"    />
17
+        <result property="lastDraftId"    column="last_draft_id"    />
18
+        <result property="viewCount"    column="view_count"    />
13 19
         <result property="createTime"    column="create_time"    />
14 20
         <result property="updateTime"    column="update_time"    />
15 21
         <result property="createBy"    column="create_by"    />
16 22
         <result property="updateBy"    column="update_by"    />
17
-        <result property="isDeleted"    column="is_deleted"    />
23
+        <result property="delFlag"    column="is_deleted"    />
24
+        <result property="attachment"    column="attachment"    />
18 25
     </resultMap>
19 26
 
20 27
     <sql id="selectKnowledgeContentVo">
21
-        select id, category_id, parent_id, title, content, create_time, update_time, create_by, update_by, is_deleted from knowledge_content
28
+        select id, category_id, parent_id, title, content, version, status, publish_time, publish_by, last_draft_id, view_count, attachment, create_time, update_time, create_by, update_by, is_deleted from knowledge_content
22 29
     </sql>
23 30
 
24 31
     <select id="selectKnowledgeContentList" parameterType="KnowledgeContent" resultMap="KnowledgeContentResult">
25 32
         <include refid="selectKnowledgeContentVo"/>
26
-        <where>  
33
+        <where>
27 34
             <if test="categoryId != null "> and category_id = #{categoryId}</if>
28 35
             <if test="parentId != null "> and parent_id = #{parentId}</if>
29 36
             <if test="title != null  and title != ''"> and title = #{title}</if>
30 37
             <if test="content != null  and content != ''"> and content = #{content}</if>
31
-            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
38
+            <if test="version != null "> and version = #{version}</if>
39
+            <if test="status != null "> and status = #{status}</if>
40
+            <if test="publishTime != null "> and publish_time = #{publishTime}</if>
41
+            <if test="publishBy != null  and publishBy != ''"> and publish_by = #{publishBy}</if>
42
+            <if test="lastDraftId != null "> and last_draft_id = #{lastDraftId}</if>
43
+            <if test="viewCount != null "> and view_count = #{viewCount}</if>
44
+            <if test="delFlag != null "> and is_deleted = #{delFlag}</if>
45
+            <!-- 如果有station_id字段,则增加站点集合查询条件 -->
32 46
         </where>
33 47
     </select>
34 48
     
@@ -44,22 +58,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
44 58
             <if test="parentId != null">parent_id,</if>
45 59
             <if test="title != null and title != ''">title,</if>
46 60
             <if test="content != null">content,</if>
61
+            <if test="version != null">version,</if>
62
+            <if test="status != null">status,</if>
63
+            <if test="publishTime != null">publish_time,</if>
64
+            <if test="publishBy != null">publish_by,</if>
65
+            <if test="lastDraftId != null">last_draft_id,</if>
66
+            <if test="viewCount != null">view_count,</if>
47 67
             <if test="createTime != null">create_time,</if>
48 68
             <if test="updateTime != null">update_time,</if>
49 69
             <if test="createBy != null">create_by,</if>
50 70
             <if test="updateBy != null">update_by,</if>
51
-            <if test="isDeleted != null">is_deleted,</if>
71
+            <if test="delFlag != null">is_deleted,</if>
52 72
          </trim>
53 73
         <trim prefix="values (" suffix=")" suffixOverrides=",">
54 74
             <if test="categoryId != null">#{categoryId},</if>
55 75
             <if test="parentId != null">#{parentId},</if>
56 76
             <if test="title != null and title != ''">#{title},</if>
57 77
             <if test="content != null">#{content},</if>
78
+            <if test="version != null">#{version},</if>
79
+            <if test="status != null">#{status},</if>
80
+            <if test="publishTime != null">#{publishTime},</if>
81
+            <if test="publishBy != null">#{publishBy},</if>
82
+            <if test="lastDraftId != null">#{lastDraftId},</if>
83
+            <if test="viewCount != null">#{viewCount},</if>
58 84
             <if test="createTime != null">#{createTime},</if>
59 85
             <if test="updateTime != null">#{updateTime},</if>
60 86
             <if test="createBy != null">#{createBy},</if>
61 87
             <if test="updateBy != null">#{updateBy},</if>
62
-            <if test="isDeleted != null">#{isDeleted},</if>
88
+            <if test="delFlag != null">#{delFlag},</if>
63 89
          </trim>
64 90
     </insert>
65 91
 
@@ -70,21 +96,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
70 96
             <if test="parentId != null">parent_id = #{parentId},</if>
71 97
             <if test="title != null and title != ''">title = #{title},</if>
72 98
             <if test="content != null">content = #{content},</if>
99
+            <if test="version != null">version = #{version},</if>
100
+            <if test="status != null">status = #{status},</if>
101
+            <if test="publishTime != null">publish_time = #{publishTime},</if>
102
+            <if test="publishBy != null">publish_by = #{publishBy},</if>
103
+            <if test="lastDraftId != null">last_draft_id = #{lastDraftId},</if>
104
+            <if test="viewCount != null">view_count = #{viewCount},</if>
73 105
             <if test="createTime != null">create_time = #{createTime},</if>
74 106
             <if test="updateTime != null">update_time = #{updateTime},</if>
75 107
             <if test="createBy != null">create_by = #{createBy},</if>
76 108
             <if test="updateBy != null">update_by = #{updateBy},</if>
77
-            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
109
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
78 110
         </trim>
79 111
         where id = #{id}
80 112
     </update>
81 113
 
82 114
     <delete id="deleteKnowledgeContentById" parameterType="Long">
83
-        delete from knowledge_content where id = #{id}
115
+        update knowledge_content set del_flag = '1' where id = #{id}
84 116
     </delete>
85 117
 
86 118
     <delete id="deleteKnowledgeContentByIds" parameterType="String">
87
-        delete from knowledge_content where id in 
119
+        update knowledge_content set del_flag = '1' where id in
88 120
         <foreach item="id" collection="array" open="(" separator="," close=")">
89 121
             #{id}
90 122
         </foreach>

+ 90 - 0
smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeDraftMapper.xml

@@ -0,0 +1,90 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.smartSteward.mapper.knowledge.KnowledgeDraftMapper">
6
+    
7
+    <resultMap type="KnowledgeDraft" id="KnowledgeDraftResult">
8
+        <result property="id"    column="id"    />
9
+        <result property="contentId"    column="content_id"    />
10
+        <result property="title"    column="title"    />
11
+        <result property="content"    column="content"    />
12
+        <result property="createTime"    column="create_time"    />
13
+        <result property="updateTime"    column="update_time"    />
14
+        <result property="createBy"    column="create_by"    />
15
+        <result property="updateBy"    column="update_by"    />
16
+        <result property="delFlag"    column="is_deleted"    />
17
+        <result column="attachment" property="attachment" />
18
+    </resultMap>
19
+
20
+    <sql id="selectKnowledgeDraftVo">
21
+        select id, content_id, title, content, create_time, update_time, create_by, update_by, del_flag, attachment from knowledge_draft
22
+    </sql>
23
+
24
+    <select id="selectKnowledgeDraftList" parameterType="KnowledgeDraft" resultMap="KnowledgeDraftResult">
25
+        <include refid="selectKnowledgeDraftVo"/>
26
+        <where>
27
+            <if test="contentId != null "> and content_id = #{contentId}</if>
28
+            <if test="title != null  and title != ''"> and title = #{title}</if>
29
+            <if test="content != null  and content != ''"> and content = #{content}</if>
30
+            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
31
+            <!-- 如果有station_id字段,则增加站点集合查询条件 -->
32
+        </where>
33
+    </select>
34
+    
35
+    <select id="selectKnowledgeDraftById" parameterType="Long" resultMap="KnowledgeDraftResult">
36
+        <include refid="selectKnowledgeDraftVo"/>
37
+        where id = #{id}
38
+    </select>
39
+
40
+    <insert id="insertKnowledgeDraft" parameterType="KnowledgeDraft" useGeneratedKeys="true" keyProperty="id">
41
+        insert into knowledge_draft
42
+        <trim prefix="(" suffix=")" suffixOverrides=",">
43
+            <if test="contentId != null">content_id,</if>
44
+            <if test="title != null and title != ''">title,</if>
45
+            <if test="content != null">content,</if>
46
+            <if test="createTime != null">create_time,</if>
47
+            <if test="updateTime != null">update_time,</if>
48
+            <if test="createBy != null">create_by,</if>
49
+            <if test="updateBy != null">update_by,</if>
50
+            <if test="delFlag != null">del_flag,</if>
51
+            <if test="attachment != null">attachment,</if>
52
+         </trim>
53
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
54
+            <if test="contentId != null">#{contentId},</if>
55
+            <if test="title != null and title != ''">#{title},</if>
56
+            <if test="content != null">#{content},</if>
57
+            <if test="createTime != null">#{createTime},</if>
58
+            <if test="updateTime != null">#{updateTime},</if>
59
+            <if test="createBy != null">#{createBy},</if>
60
+            <if test="updateBy != null">#{updateBy},</if>
61
+            <if test="delFlag != null">#{delFlag},</if>
62
+         </trim>
63
+    </insert>
64
+
65
+    <update id="updateKnowledgeDraft" parameterType="KnowledgeDraft">
66
+        update knowledge_draft
67
+        <trim prefix="SET" suffixOverrides=",">
68
+            <if test="contentId != null">content_id = #{contentId},</if>
69
+            <if test="title != null and title != ''">title = #{title},</if>
70
+            <if test="content != null">content = #{content},</if>
71
+            <if test="createTime != null">create_time = #{createTime},</if>
72
+            <if test="updateTime != null">update_time = #{updateTime},</if>
73
+            <if test="createBy != null">create_by = #{createBy},</if>
74
+            <if test="updateBy != null">update_by = #{updateBy},</if>
75
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
76
+        </trim>
77
+        where id = #{id}
78
+    </update>
79
+
80
+    <delete id="deleteKnowledgeDraftById" parameterType="Long">
81
+        update knowledge_draft set del_flag = '1' where id = #{id}
82
+    </delete>
83
+
84
+    <delete id="deleteKnowledgeDraftByIds" parameterType="String">
85
+        update knowledge_draft set del_flag = '1' where id in
86
+        <foreach item="id" collection="array" open="(" separator="," close=")">
87
+            #{id}
88
+        </foreach>
89
+    </delete>
90
+</mapper>

+ 87 - 0
smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgePublishRecordMapper.xml

@@ -0,0 +1,87 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.smartSteward.mapper.knowledge.KnowledgePublishRecordMapper">
6
+    
7
+    <resultMap type="KnowledgePublishRecord" id="KnowledgePublishRecordResult">
8
+        <result property="id"    column="id"    />
9
+        <result property="contentId"    column="content_id"    />
10
+        <result property="title"    column="title"    />
11
+        <result property="content"    column="content"    />
12
+        <result property="version"    column="version"    />
13
+        <result property="publishBy"    column="publish_by"    />
14
+        <result property="createTime"    column="create_time"    />
15
+        <result property="delFlag"    column="del_flag"    />
16
+        <result property="attachment"    column="attachment"    />
17
+    </resultMap>
18
+
19
+    <sql id="selectKnowledgePublishRecordVo">
20
+        select id, content_id, title, content, version, publish_by, create_time, del_flag, attachment from knowledge_publish_record
21
+    </sql>
22
+
23
+    <select id="selectKnowledgePublishRecordList" parameterType="KnowledgePublishRecord" resultMap="KnowledgePublishRecordResult">
24
+        <include refid="selectKnowledgePublishRecordVo"/>
25
+        <where>
26
+            <if test="contentId != null "> and content_id = #{contentId}</if>
27
+            <if test="publishBy != null  and publishBy != ''"> and publish_by = #{publishBy}</if>
28
+            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
29
+            <!-- 如果有station_id字段,则增加站点集合查询条件 -->
30
+        </where>
31
+    </select>
32
+    
33
+    <select id="selectKnowledgePublishRecordById" parameterType="Long" resultMap="KnowledgePublishRecordResult">
34
+        <include refid="selectKnowledgePublishRecordVo"/>
35
+        where id = #{id}
36
+    </select>
37
+
38
+    <insert id="insertKnowledgePublishRecord" parameterType="KnowledgePublishRecord" useGeneratedKeys="true" keyProperty="id">
39
+        insert into knowledge_publish_record
40
+        <trim prefix="(" suffix=")" suffixOverrides=",">
41
+            <if test="contentId != null">content_id,</if>
42
+            <if test="version != null">version,</if>
43
+            <if test="title != null">title,</if>
44
+            <if test="content != null">content,</if>
45
+            <if test="publishBy != null">publish_by,</if>
46
+            <if test="createTime != null">create_time,</if>
47
+            <if test="delFlag != null">del_flag,</if>
48
+            <if test="attachment != null">attachment,</if>
49
+         </trim>
50
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
51
+            <if test="contentId != null">#{contentId},</if>
52
+            <if test="version != null">#{version},</if>
53
+            <if test="title != null">#{title},</if>
54
+            <if test="content != null">#{content},</if>
55
+            <if test="publishBy != null">#{publishBy},</if>
56
+            <if test="createTime != null">#{createTime},</if>
57
+            <if test="delFlag != null">#{delFlag},</if>
58
+            <if test="attachment != null">#{attachment},</if>
59
+         </trim>
60
+    </insert>
61
+
62
+    <update id="updateKnowledgePublishRecord" parameterType="KnowledgePublishRecord">
63
+        update knowledge_publish_record
64
+        <trim prefix="SET" suffixOverrides=",">
65
+            <if test="contentId != null">content_id = #{contentId},</if>
66
+            <if test="version != null">version = #{version},</if>
67
+            <if test="title != null">title = #{title},</if>
68
+            <if test="content != null">content = #{content},</if>
69
+            <if test="publishBy != null">publish_by = #{publishBy},</if>
70
+            <if test="createTime != null">create_time = #{createTime},</if>
71
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
72
+            <if test="attachment != null">attachment = #{attachment},</if>
73
+        </trim>
74
+        where id = #{id}
75
+    </update>
76
+
77
+    <delete id="deleteKnowledgePublishRecordById" parameterType="Long">
78
+        update knowledge_publish_record set del_flag = '1' where id = #{id}
79
+    </delete>
80
+
81
+    <delete id="deleteKnowledgePublishRecordByIds" parameterType="String">
82
+        update knowledge_publish_record set del_flag = '1' where id in
83
+        <foreach item="id" collection="array" open="(" separator="," close=")">
84
+            #{id}
85
+        </foreach>
86
+    </delete>
87
+</mapper>

+ 84 - 0
smart-steward-mapper/src/main/resources/mapper/knowledge/KnowledgeViewRecordMapper.xml

@@ -0,0 +1,84 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.smartSteward.mapper.knowledge.KnowledgeViewRecordMapper">
6
+    
7
+    <resultMap type="KnowledgeViewRecord" id="KnowledgeViewRecordResult">
8
+        <result property="id"    column="id"    />
9
+        <result property="contentId"    column="content_id"    />
10
+        <result property="userId"    column="user_id"    />
11
+        <result property="userName"    column="user_name"    />
12
+        <result property="userAvatar"    column="user_avatar"    />
13
+        <result property="createTime"    column="create_time"    />
14
+        <result property="updateTime"    column="update_time"    />
15
+        <result property="delFlag"    column="del_flag"    />
16
+    </resultMap>
17
+
18
+    <sql id="selectKnowledgeViewRecordVo">
19
+        select id, content_id, user_id, user_name, user_avatar, create_time, update_time, del_flag from knowledge_view_record
20
+    </sql>
21
+
22
+    <select id="selectKnowledgeViewRecordList" parameterType="KnowledgeViewRecord" resultMap="KnowledgeViewRecordResult">
23
+        <include refid="selectKnowledgeViewRecordVo"/>
24
+        <where>
25
+            <if test="contentId != null "> and content_id = #{contentId}</if>
26
+            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
27
+            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
28
+            <if test="userAvatar != null  and userAvatar != ''"> and user_avatar = #{userAvatar}</if>
29
+            <!-- 如果有station_id字段,则增加站点集合查询条件 -->
30
+        </where>
31
+    </select>
32
+    
33
+    <select id="selectKnowledgeViewRecordById" parameterType="Long" resultMap="KnowledgeViewRecordResult">
34
+        <include refid="selectKnowledgeViewRecordVo"/>
35
+        where id = #{id}
36
+    </select>
37
+
38
+    <insert id="insertKnowledgeViewRecord" parameterType="KnowledgeViewRecord" useGeneratedKeys="true" keyProperty="id">
39
+        insert into knowledge_view_record
40
+        <trim prefix="(" suffix=")" suffixOverrides=",">
41
+            <if test="contentId != null">content_id,</if>
42
+            <if test="userId != null and userId != ''">user_id,</if>
43
+            <if test="userName != null">user_name,</if>
44
+            <if test="userAvatar != null">user_avatar,</if>
45
+            <if test="createTime != null">create_time,</if>
46
+            <if test="updateTime != null">update_time,</if>
47
+            <if test="delFlag != null">del_flag,</if>
48
+         </trim>
49
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
50
+            <if test="contentId != null">#{contentId},</if>
51
+            <if test="userId != null and userId != ''">#{userId},</if>
52
+            <if test="userName != null">#{userName},</if>
53
+            <if test="userAvatar != null">#{userAvatar},</if>
54
+            <if test="createTime != null">#{createTime},</if>
55
+            <if test="updateTime != null">#{updateTime},</if>
56
+            <if test="delFlag != null">#{delFlag},</if>
57
+         </trim>
58
+    </insert>
59
+
60
+    <update id="updateKnowledgeViewRecord" parameterType="KnowledgeViewRecord">
61
+        update knowledge_view_record
62
+        <trim prefix="SET" suffixOverrides=",">
63
+            <if test="contentId != null">content_id = #{contentId},</if>
64
+            <if test="userId != null and userId != ''">user_id = #{userId},</if>
65
+            <if test="userName != null">user_name = #{userName},</if>
66
+            <if test="userAvatar != null">user_avatar = #{userAvatar},</if>
67
+            <if test="createTime != null">create_time = #{createTime},</if>
68
+            <if test="updateTime != null">update_time = #{updateTime},</if>
69
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
70
+        </trim>
71
+        where id = #{id}
72
+    </update>
73
+
74
+    <delete id="deleteKnowledgeViewRecordById" parameterType="Long">
75
+        delete from knowledge_view_record where id = #{id}
76
+    </delete>
77
+
78
+    <delete id="deleteKnowledgeViewRecordByIds" parameterType="String">
79
+        delete from knowledge_view_record where id in 
80
+        <foreach item="id" collection="array" open="(" separator="," close=")">
81
+            #{id}
82
+        </foreach>
83
+    </delete>
84
+</mapper>

+ 21 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeCategoryService.java

@@ -1,6 +1,8 @@
1 1
 package com.smartSteward.service.knowledge;
2 2
 
3 3
 import java.util.List;
4
+
5
+import com.smartSteward.common.core.model.LoginUser;
4 6
 import com.smartSteward.entity.database.knowledge.KnowledgeCategory;
5 7
 
6 8
 /**
@@ -57,4 +59,23 @@ public interface IKnowledgeCategoryService
57 59
      * @return 结果
58 60
      */
59 61
     public int deleteKnowledgeCategoryById(Long id);
62
+
63
+     /**
64
+      * 根据ID查询知识库分类列表
65
+      *
66
+      * @param ids 知识库分类主键集合
67
+      * @return 知识库分类集合
68
+      */
69
+    public List<KnowledgeCategory> selectKnowledgeCategoryListByIds(Long[] ids);
70
+
71
+
72
+    /**
73
+     * 判断是否为管理员
74
+     *
75
+     * @param categoryId 知识库分类主键
76
+     * @param loginUser 登录用户
77
+     * @return 是否为管理员
78
+     */
79
+    public boolean isAdmin(Long categoryId, LoginUser  loginUser);
80
+
60 81
 }

+ 26 - 15
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeContentService.java

@@ -1,60 +1,71 @@
1 1
 package com.smartSteward.service.knowledge;
2 2
 
3 3
 import java.util.List;
4
+
5
+import com.smartSteward.common.core.model.LoginUser;
4 6
 import com.smartSteward.entity.database.knowledge.KnowledgeContent;
5 7
 
6 8
 /**
7
- * 知识库内容Service接口
9
+ * 知识库内容(已发布内容)Service接口
8 10
  * 
9 11
  * @author smart-steward
10 12
  */
11 13
 public interface IKnowledgeContentService 
12 14
 {
13 15
     /**
14
-     * 查询知识库内容
16
+     * 查询知识库内容(已发布内容)
15 17
      * 
16
-     * @param id 知识库内容主键
17
-     * @return 知识库内容
18
+     * @param id 知识库内容(已发布内容)主键
19
+     * @return 知识库内容(已发布内容)
18 20
      */
19 21
     public KnowledgeContent selectKnowledgeContentById(Long id);
20 22
 
21 23
     /**
22
-     * 查询知识库内容列表
24
+     * 查询知识库内容(已发布内容)列表
23 25
      * 
24
-     * @param knowledgeContent 知识库内容
25
-     * @return 知识库内容集合
26
+     * @param knowledgeContent 知识库内容(已发布内容)
27
+     * @return 知识库内容(已发布内容)集合
26 28
      */
27 29
     public List<KnowledgeContent> selectKnowledgeContentList(KnowledgeContent knowledgeContent);
28 30
 
29 31
     /**
30
-     * 新增知识库内容
32
+     * 新增知识库内容(已发布内容)
31 33
      * 
32
-     * @param knowledgeContent 知识库内容
34
+     * @param knowledgeContent 知识库内容(已发布内容)
33 35
      * @return 结果
34 36
      */
35 37
     public int insertKnowledgeContent(KnowledgeContent knowledgeContent);
36 38
 
37 39
     /**
38
-     * 修改知识库内容
40
+     * 修改知识库内容(已发布内容)
39 41
      * 
40
-     * @param knowledgeContent 知识库内容
42
+     * @param knowledgeContent 知识库内容(已发布内容)
41 43
      * @return 结果
42 44
      */
43 45
     public int updateKnowledgeContent(KnowledgeContent knowledgeContent);
44 46
 
45 47
     /**
46
-     * 批量删除知识库内容
48
+     * 批量删除知识库内容(已发布内容)
47 49
      * 
48
-     * @param ids 需要删除的知识库内容主键集合
50
+     * @param ids 需要删除的知识库内容(已发布内容)主键集合
49 51
      * @return 结果
50 52
      */
51 53
     public int deleteKnowledgeContentByIds(Long[] ids);
52 54
 
53 55
     /**
54
-     * 删除知识库内容信息
56
+     * 删除知识库内容(已发布内容)信息
55 57
      * 
56
-     * @param id 知识库内容主键
58
+     * @param id 知识库内容(已发布内容)主键
57 59
      * @return 结果
58 60
      */
59 61
     public int deleteKnowledgeContentById(Long id);
62
+
63
+     /**
64
+     * 查询知识库分类下的所有内容(已发布内容)
65
+     *
66
+     * @param categoryId 知识库分类主键
67
+     * @return 知识库内容(已发布内容)集合
68
+     */
69
+    public List<KnowledgeContent> selectCommCommentsTree(Long categoryId, boolean isAdmin);
70
+
60 71
 }

+ 60 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeDraftService.java

@@ -0,0 +1,60 @@
1
+package com.smartSteward.service.knowledge;
2
+
3
+import java.util.List;
4
+import com.smartSteward.entity.database.knowledge.KnowledgeDraft;
5
+
6
+/**
7
+ * 知识库草稿Service接口
8
+ * 
9
+ * @author smart-steward
10
+ */
11
+public interface IKnowledgeDraftService 
12
+{
13
+    /**
14
+     * 查询知识库草稿
15
+     * 
16
+     * @param id 知识库草稿主键
17
+     * @return 知识库草稿
18
+     */
19
+    public KnowledgeDraft selectKnowledgeDraftById(Long id);
20
+
21
+    /**
22
+     * 查询知识库草稿列表
23
+     * 
24
+     * @param knowledgeDraft 知识库草稿
25
+     * @return 知识库草稿集合
26
+     */
27
+    public List<KnowledgeDraft> selectKnowledgeDraftList(KnowledgeDraft knowledgeDraft);
28
+
29
+    /**
30
+     * 新增知识库草稿
31
+     * 
32
+     * @param knowledgeDraft 知识库草稿
33
+     * @return 结果
34
+     */
35
+    public int insertKnowledgeDraft(KnowledgeDraft knowledgeDraft);
36
+
37
+    /**
38
+     * 修改知识库草稿
39
+     * 
40
+     * @param knowledgeDraft 知识库草稿
41
+     * @return 结果
42
+     */
43
+    public int updateKnowledgeDraft(KnowledgeDraft knowledgeDraft);
44
+
45
+    /**
46
+     * 批量删除知识库草稿
47
+     * 
48
+     * @param ids 需要删除的知识库草稿主键集合
49
+     * @return 结果
50
+     */
51
+    public int deleteKnowledgeDraftByIds(Long[] ids);
52
+
53
+    /**
54
+     * 删除知识库草稿信息
55
+     * 
56
+     * @param id 知识库草稿主键
57
+     * @return 结果
58
+     */
59
+    public int deleteKnowledgeDraftById(Long id);
60
+}

+ 60 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgePublishRecordService.java

@@ -0,0 +1,60 @@
1
+package com.smartSteward.service.knowledge;
2
+
3
+import java.util.List;
4
+import com.smartSteward.entity.database.knowledge.KnowledgePublishRecord;
5
+
6
+/**
7
+ * 知识库发布记录Service接口
8
+ * 
9
+ * @author smart-steward
10
+ */
11
+public interface IKnowledgePublishRecordService 
12
+{
13
+    /**
14
+     * 查询知识库发布记录
15
+     * 
16
+     * @param id 知识库发布记录主键
17
+     * @return 知识库发布记录
18
+     */
19
+    public KnowledgePublishRecord selectKnowledgePublishRecordById(Long id);
20
+
21
+    /**
22
+     * 查询知识库发布记录列表
23
+     * 
24
+     * @param knowledgePublishRecord 知识库发布记录
25
+     * @return 知识库发布记录集合
26
+     */
27
+    public List<KnowledgePublishRecord> selectKnowledgePublishRecordList(KnowledgePublishRecord knowledgePublishRecord);
28
+
29
+    /**
30
+     * 新增知识库发布记录
31
+     * 
32
+     * @param knowledgePublishRecord 知识库发布记录
33
+     * @return 结果
34
+     */
35
+    public int insertKnowledgePublishRecord(KnowledgePublishRecord knowledgePublishRecord);
36
+
37
+    /**
38
+     * 修改知识库发布记录
39
+     * 
40
+     * @param knowledgePublishRecord 知识库发布记录
41
+     * @return 结果
42
+     */
43
+    public int updateKnowledgePublishRecord(KnowledgePublishRecord knowledgePublishRecord);
44
+
45
+    /**
46
+     * 批量删除知识库发布记录
47
+     * 
48
+     * @param ids 需要删除的知识库发布记录主键集合
49
+     * @return 结果
50
+     */
51
+    public int deleteKnowledgePublishRecordByIds(Long[] ids);
52
+
53
+    /**
54
+     * 删除知识库发布记录信息
55
+     * 
56
+     * @param id 知识库发布记录主键
57
+     * @return 结果
58
+     */
59
+    public int deleteKnowledgePublishRecordById(Long id);
60
+}

+ 60 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/IKnowledgeViewRecordService.java

@@ -0,0 +1,60 @@
1
+package com.smartSteward.service.knowledge;
2
+
3
+import java.util.List;
4
+import com.smartSteward.entity.database.knowledge.KnowledgeViewRecord;
5
+
6
+/**
7
+ * 知识库查看记录Service接口
8
+ * 
9
+ * @author smart-steward
10
+ */
11
+public interface IKnowledgeViewRecordService 
12
+{
13
+    /**
14
+     * 查询知识库查看记录
15
+     * 
16
+     * @param id 知识库查看记录主键
17
+     * @return 知识库查看记录
18
+     */
19
+    public KnowledgeViewRecord selectKnowledgeViewRecordById(Long id);
20
+
21
+    /**
22
+     * 查询知识库查看记录列表
23
+     * 
24
+     * @param knowledgeViewRecord 知识库查看记录
25
+     * @return 知识库查看记录集合
26
+     */
27
+    public List<KnowledgeViewRecord> selectKnowledgeViewRecordList(KnowledgeViewRecord knowledgeViewRecord);
28
+
29
+    /**
30
+     * 新增知识库查看记录
31
+     * 
32
+     * @param knowledgeViewRecord 知识库查看记录
33
+     * @return 结果
34
+     */
35
+    public int insertKnowledgeViewRecord(KnowledgeViewRecord knowledgeViewRecord);
36
+
37
+    /**
38
+     * 修改知识库查看记录
39
+     * 
40
+     * @param knowledgeViewRecord 知识库查看记录
41
+     * @return 结果
42
+     */
43
+    public int updateKnowledgeViewRecord(KnowledgeViewRecord knowledgeViewRecord);
44
+
45
+    /**
46
+     * 批量删除知识库查看记录
47
+     * 
48
+     * @param ids 需要删除的知识库查看记录主键集合
49
+     * @return 结果
50
+     */
51
+    public int deleteKnowledgeViewRecordByIds(Long[] ids);
52
+
53
+    /**
54
+     * 删除知识库查看记录信息
55
+     * 
56
+     * @param id 知识库查看记录主键
57
+     * @return 结果
58
+     */
59
+    public int deleteKnowledgeViewRecordById(Long id);
60
+}

+ 34 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeCategoryServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.List;
5 5
 
6 6
 import com.smartSteward.common.core.SecurityUtils;
7 7
 
8
+import com.smartSteward.common.core.model.LoginUser;
8 9
 import com.smartSteward.common.utils.DateUtils;
9 10
 
10 11
 import org.springframework.beans.factory.annotation.Autowired;
@@ -99,6 +100,39 @@ public class KnowledgeCategoryServiceImpl implements IKnowledgeCategoryService
99 100
     {
100 101
         return knowledgeCategoryMapper.deleteKnowledgeCategoryById(id);
101 102
     }
103
+    /**
104
+     * 根据ID查询知识库分类列表
105
+     *
106
+     * @param ids 知识库分类主键集合
107
+     * @return 知识库分类集合
108
+     */
109
+    @Override
110
+    public List<KnowledgeCategory> selectKnowledgeCategoryListByIds(Long[] ids)
111
+    {
112
+        return knowledgeCategoryMapper.selectKnowledgeCategoryListByIds(ids);
113
+    }
114
+
115
+    /**
116
+     * 判断是否为知识库管理员
117
+     *
118
+     * @param categoryId 知识库分类主键
119
+     * @param loginUser 登录用户
120
+     * @return 是否为管理员
121
+     */
122
+    @Override
123
+    public boolean isAdmin(Long categoryId, LoginUser loginUser)
124
+    {
125
+       KnowledgeCategory knowledgeCategory = knowledgeCategoryMapper.selectKnowledgeCategoryById(categoryId);
126
+       if (knowledgeCategory == null){
127
+           return false;
128
+       }
129
+
130
+//       if (knowledgeCategory.getManagePermission().equals(loginUser.getUser())){
131
+//           return true;
132
+//       }
133
+
134
+       return true;
135
+    }
102 136
 
103 137
 
104 138
 }

+ 111 - 19
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeContentServiceImpl.java

@@ -1,7 +1,17 @@
1 1
 package com.smartSteward.service.knowledge.impl;
2
+import java.util.ArrayList;
3
+import java.util.Date;
4
+import java.util.Iterator;
2 5
 import java.util.List;
6
+import java.util.stream.Collectors;
7
+
3 8
 import com.smartSteward.common.core.SecurityUtils;
9
+import com.smartSteward.common.core.model.LoginUser;
10
+import com.smartSteward.common.enums.knowledge.PublicStatus;
4 11
 import com.smartSteward.common.utils.DateUtils;
12
+import com.smartSteward.common.utils.StringUtils;
13
+import com.smartSteward.entity.database.comm.CommComments;
14
+import com.smartSteward.entity.input.comm.CommentInput;
5 15
 import org.springframework.beans.factory.annotation.Autowired;
6 16
 import org.springframework.stereotype.Service;
7 17
 import com.smartSteward.mapper.knowledge.KnowledgeContentMapper;
@@ -9,21 +19,21 @@ import com.smartSteward.entity.database.knowledge.KnowledgeContent;
9 19
 import com.smartSteward.service.knowledge.IKnowledgeContentService;
10 20
 
11 21
 /**
12
- * 知识库内容Service业务层处理
13
- * 
22
+ * 知识库内容(已发布内容)Service业务层处理
23
+ *
14 24
  * @author smart-steward
15 25
  */
16 26
 @Service
17
-public class KnowledgeContentServiceImpl implements IKnowledgeContentService 
27
+public class KnowledgeContentServiceImpl implements IKnowledgeContentService
18 28
 {
19 29
     @Autowired
20 30
     private KnowledgeContentMapper knowledgeContentMapper;
21 31
 
22 32
     /**
23
-     * 查询知识库内容
24
-     * 
25
-     * @param id 知识库内容主键
26
-     * @return 知识库内容
33
+     * 查询知识库内容(已发布内容)
34
+     *
35
+     * @param id 知识库内容(已发布内容)主键
36
+     * @return 知识库内容(已发布内容)
27 37
      */
28 38
     @Override
29 39
     public KnowledgeContent selectKnowledgeContentById(Long id)
@@ -32,10 +42,10 @@ public class KnowledgeContentServiceImpl implements IKnowledgeContentService
32 42
     }
33 43
 
34 44
     /**
35
-     * 查询知识库内容列表
36
-     * 
37
-     * @param knowledgeContent 知识库内容
38
-     * @return 知识库内容
45
+     * 查询知识库内容(已发布内容)列表
46
+     *
47
+     * @param knowledgeContent 知识库内容(已发布内容)
48
+     * @return 知识库内容(已发布内容)
39 49
      */
40 50
     @Override
41 51
     public List<KnowledgeContent> selectKnowledgeContentList(KnowledgeContent knowledgeContent)
@@ -44,9 +54,91 @@ public class KnowledgeContentServiceImpl implements IKnowledgeContentService
44 54
     }
45 55
 
46 56
     /**
47
-     * 新增知识库内容
57
+     * 查询公共评论列表
58
+     *
59
+     * @return 公共评论
60
+     */
61
+    @Override
62
+    public List<KnowledgeContent> selectCommCommentsTree(Long categoryId, boolean isAdmin)
63
+    {
64
+        // 获取到所有数据
65
+        KnowledgeContent query = new KnowledgeContent();
66
+        query.setCategoryId(categoryId);
67
+        query.setDelFlag("0");
68
+        if (!isAdmin) {
69
+            query.setStatus(PublicStatus.PUBLISHED.getStatus());
70
+        }
71
+        List<KnowledgeContent> list = knowledgeContentMapper.selectKnowledgeContentList(query);
72
+        return buildTree(list);
73
+    }
74
+
75
+    public List<KnowledgeContent> buildTree(List<KnowledgeContent> list)
76
+    {
77
+        List<KnowledgeContent> returnList = new ArrayList<KnowledgeContent>();
78
+        List<Long> tempList = list.stream().map(KnowledgeContent::getId).collect(Collectors.toList());
79
+        for (KnowledgeContent info : list)
80
+        {
81
+            // 如果是顶级节点, 遍历该父节点的所有子节点
82
+            if (!tempList.contains(info.getParentId()))
83
+            {
84
+                recursionFn(list, info);
85
+                returnList.add(info);
86
+            }
87
+        }
88
+        if (returnList.isEmpty())
89
+        {
90
+            returnList = list;
91
+        }
92
+        return returnList;
93
+    }
94
+
95
+    /**
96
+     * 递归列表
97
+     */
98
+    private void recursionFn(List<KnowledgeContent> list, KnowledgeContent t)
99
+    {
100
+        // 得到子节点列表
101
+        List<KnowledgeContent> childList = getChildList(list, t);
102
+        t.setChildren(childList);
103
+        for (KnowledgeContent tChild : childList)
104
+        {
105
+            if (hasChild(list, tChild))
106
+            {
107
+                recursionFn(list, tChild);
108
+            }
109
+        }
110
+    }
111
+
112
+    /**
113
+     * 得到子节点列表
114
+     */
115
+    private List<KnowledgeContent> getChildList(List<KnowledgeContent> list, KnowledgeContent t)
116
+    {
117
+        List<KnowledgeContent> tlist = new ArrayList<KnowledgeContent>();
118
+        Iterator<KnowledgeContent> it = list.iterator();
119
+        while (it.hasNext())
120
+        {
121
+            KnowledgeContent n = (KnowledgeContent) it.next();
122
+            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue())
123
+            {
124
+                tlist.add(n);
125
+            }
126
+        }
127
+        return tlist;
128
+    }
129
+
130
+    /**
131
+     * 判断是否有子节点
132
+     */
133
+    private boolean hasChild(List<KnowledgeContent> list, KnowledgeContent t)
134
+    {
135
+        return getChildList(list, t).size() > 0;
136
+    }
137
+
138
+    /**
139
+     * 新增知识库内容(已发布内容)
48 140
      * 
49
-     * @param knowledgeContent 知识库内容
141
+     * @param knowledgeContent 知识库内容(已发布内容)
50 142
      * @return 结果
51 143
      */
52 144
     @Override
@@ -58,9 +150,9 @@ public class KnowledgeContentServiceImpl implements IKnowledgeContentService
58 150
     }
59 151
 
60 152
     /**
61
-     * 修改知识库内容
153
+     * 修改知识库内容(已发布内容)
62 154
      * 
63
-     * @param knowledgeContent 知识库内容
155
+     * @param knowledgeContent 知识库内容(已发布内容)
64 156
      * @return 结果
65 157
      */
66 158
     @Override
@@ -72,9 +164,9 @@ public class KnowledgeContentServiceImpl implements IKnowledgeContentService
72 164
     }
73 165
 
74 166
     /**
75
-     * 批量删除知识库内容
167
+     * 批量删除知识库内容(已发布内容)
76 168
      * 
77
-     * @param ids 需要删除的知识库内容主键
169
+     * @param ids 需要删除的知识库内容(已发布内容)主键
78 170
      * @return 结果
79 171
      */
80 172
     @Override
@@ -84,9 +176,9 @@ public class KnowledgeContentServiceImpl implements IKnowledgeContentService
84 176
     }
85 177
 
86 178
     /**
87
-     * 删除知识库内容信息
179
+     * 删除知识库内容(已发布内容)信息
88 180
      * 
89
-     * @param id 知识库内容主键
181
+     * @param id 知识库内容(已发布内容)主键
90 182
      * @return 结果
91 183
      */
92 184
     @Override

+ 98 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeDraftServiceImpl.java

@@ -0,0 +1,98 @@
1
+package com.smartSteward.service.knowledge.impl;
2
+import java.util.Date;
3
+import java.util.List;
4
+import com.smartSteward.common.core.SecurityUtils;
5
+import com.smartSteward.common.utils.DateUtils;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+import com.smartSteward.mapper.knowledge.KnowledgeDraftMapper;
9
+import com.smartSteward.entity.database.knowledge.KnowledgeDraft;
10
+import com.smartSteward.service.knowledge.IKnowledgeDraftService;
11
+
12
+/**
13
+ * 知识库草稿Service业务层处理
14
+ * 
15
+ * @author smart-steward
16
+ */
17
+@Service
18
+public class KnowledgeDraftServiceImpl implements IKnowledgeDraftService 
19
+{
20
+    @Autowired
21
+    private KnowledgeDraftMapper knowledgeDraftMapper;
22
+
23
+    /**
24
+     * 查询知识库草稿
25
+     * 
26
+     * @param id 知识库草稿主键
27
+     * @return 知识库草稿
28
+     */
29
+    @Override
30
+    public KnowledgeDraft selectKnowledgeDraftById(Long id)
31
+    {
32
+        return knowledgeDraftMapper.selectKnowledgeDraftById(id);
33
+    }
34
+
35
+    /**
36
+     * 查询知识库草稿列表
37
+     * 
38
+     * @param knowledgeDraft 知识库草稿
39
+     * @return 知识库草稿
40
+     */
41
+    @Override
42
+    public List<KnowledgeDraft> selectKnowledgeDraftList(KnowledgeDraft knowledgeDraft)
43
+    {
44
+        return knowledgeDraftMapper.selectKnowledgeDraftList(knowledgeDraft);
45
+    }
46
+
47
+    /**
48
+     * 新增知识库草稿
49
+     * 
50
+     * @param knowledgeDraft 知识库草稿
51
+     * @return 结果
52
+     */
53
+    @Override
54
+    public int insertKnowledgeDraft(KnowledgeDraft knowledgeDraft)
55
+    {
56
+        knowledgeDraft.setCreateTime(DateUtils.getNowDate());
57
+        knowledgeDraft.setCreateBy(SecurityUtils.getUsername());
58
+        return knowledgeDraftMapper.insertKnowledgeDraft(knowledgeDraft);
59
+    }
60
+
61
+    /**
62
+     * 修改知识库草稿
63
+     * 
64
+     * @param knowledgeDraft 知识库草稿
65
+     * @return 结果
66
+     */
67
+    @Override
68
+    public int updateKnowledgeDraft(KnowledgeDraft knowledgeDraft)
69
+    {
70
+        knowledgeDraft.setUpdateTime(DateUtils.getNowDate());
71
+        knowledgeDraft.setUpdateBy(SecurityUtils.getUsername());
72
+        return knowledgeDraftMapper.updateKnowledgeDraft(knowledgeDraft);
73
+    }
74
+
75
+    /**
76
+     * 批量删除知识库草稿
77
+     * 
78
+     * @param ids 需要删除的知识库草稿主键
79
+     * @return 结果
80
+     */
81
+    @Override
82
+    public int deleteKnowledgeDraftByIds(Long[] ids)
83
+    {
84
+        return knowledgeDraftMapper.deleteKnowledgeDraftByIds(ids);
85
+    }
86
+
87
+    /**
88
+     * 删除知识库草稿信息
89
+     * 
90
+     * @param id 知识库草稿主键
91
+     * @return 结果
92
+     */
93
+    @Override
94
+    public int deleteKnowledgeDraftById(Long id)
95
+    {
96
+        return knowledgeDraftMapper.deleteKnowledgeDraftById(id);
97
+    }
98
+}

+ 95 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgePublishRecordServiceImpl.java

@@ -0,0 +1,95 @@
1
+package com.smartSteward.service.knowledge.impl;
2
+import java.util.Date;
3
+import java.util.List;
4
+import com.smartSteward.common.core.SecurityUtils;
5
+import com.smartSteward.common.utils.DateUtils;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+import com.smartSteward.mapper.knowledge.KnowledgePublishRecordMapper;
9
+import com.smartSteward.entity.database.knowledge.KnowledgePublishRecord;
10
+import com.smartSteward.service.knowledge.IKnowledgePublishRecordService;
11
+
12
+/**
13
+ * 知识库发布记录Service业务层处理
14
+ * 
15
+ * @author smart-steward
16
+ */
17
+@Service
18
+public class KnowledgePublishRecordServiceImpl implements IKnowledgePublishRecordService 
19
+{
20
+    @Autowired
21
+    private KnowledgePublishRecordMapper knowledgePublishRecordMapper;
22
+
23
+    /**
24
+     * 查询知识库发布记录
25
+     * 
26
+     * @param id 知识库发布记录主键
27
+     * @return 知识库发布记录
28
+     */
29
+    @Override
30
+    public KnowledgePublishRecord selectKnowledgePublishRecordById(Long id)
31
+    {
32
+        return knowledgePublishRecordMapper.selectKnowledgePublishRecordById(id);
33
+    }
34
+
35
+    /**
36
+     * 查询知识库发布记录列表
37
+     * 
38
+     * @param knowledgePublishRecord 知识库发布记录
39
+     * @return 知识库发布记录
40
+     */
41
+    @Override
42
+    public List<KnowledgePublishRecord> selectKnowledgePublishRecordList(KnowledgePublishRecord knowledgePublishRecord)
43
+    {
44
+        return knowledgePublishRecordMapper.selectKnowledgePublishRecordList(knowledgePublishRecord);
45
+    }
46
+
47
+    /**
48
+     * 新增知识库发布记录
49
+     * 
50
+     * @param knowledgePublishRecord 知识库发布记录
51
+     * @return 结果
52
+     */
53
+    @Override
54
+    public int insertKnowledgePublishRecord(KnowledgePublishRecord knowledgePublishRecord)
55
+    {
56
+        knowledgePublishRecord.setCreateTime(DateUtils.getNowDate());
57
+        return knowledgePublishRecordMapper.insertKnowledgePublishRecord(knowledgePublishRecord);
58
+    }
59
+
60
+    /**
61
+     * 修改知识库发布记录
62
+     * 
63
+     * @param knowledgePublishRecord 知识库发布记录
64
+     * @return 结果
65
+     */
66
+    @Override
67
+    public int updateKnowledgePublishRecord(KnowledgePublishRecord knowledgePublishRecord)
68
+    {
69
+        return knowledgePublishRecordMapper.updateKnowledgePublishRecord(knowledgePublishRecord);
70
+    }
71
+
72
+    /**
73
+     * 批量删除知识库发布记录
74
+     * 
75
+     * @param ids 需要删除的知识库发布记录主键
76
+     * @return 结果
77
+     */
78
+    @Override
79
+    public int deleteKnowledgePublishRecordByIds(Long[] ids)
80
+    {
81
+        return knowledgePublishRecordMapper.deleteKnowledgePublishRecordByIds(ids);
82
+    }
83
+
84
+    /**
85
+     * 删除知识库发布记录信息
86
+     * 
87
+     * @param id 知识库发布记录主键
88
+     * @return 结果
89
+     */
90
+    @Override
91
+    public int deleteKnowledgePublishRecordById(Long id)
92
+    {
93
+        return knowledgePublishRecordMapper.deleteKnowledgePublishRecordById(id);
94
+    }
95
+}

+ 96 - 0
smart-steward-service/src/main/java/com/smartSteward/service/knowledge/impl/KnowledgeViewRecordServiceImpl.java

@@ -0,0 +1,96 @@
1
+package com.smartSteward.service.knowledge.impl;
2
+import java.util.Date;
3
+import java.util.List;
4
+import com.smartSteward.common.core.SecurityUtils;
5
+import com.smartSteward.common.utils.DateUtils;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.stereotype.Service;
8
+import com.smartSteward.mapper.knowledge.KnowledgeViewRecordMapper;
9
+import com.smartSteward.entity.database.knowledge.KnowledgeViewRecord;
10
+import com.smartSteward.service.knowledge.IKnowledgeViewRecordService;
11
+
12
+/**
13
+ * 知识库查看记录Service业务层处理
14
+ * 
15
+ * @author smart-steward
16
+ */
17
+@Service
18
+public class KnowledgeViewRecordServiceImpl implements IKnowledgeViewRecordService 
19
+{
20
+    @Autowired
21
+    private KnowledgeViewRecordMapper knowledgeViewRecordMapper;
22
+
23
+    /**
24
+     * 查询知识库查看记录
25
+     * 
26
+     * @param id 知识库查看记录主键
27
+     * @return 知识库查看记录
28
+     */
29
+    @Override
30
+    public KnowledgeViewRecord selectKnowledgeViewRecordById(Long id)
31
+    {
32
+        return knowledgeViewRecordMapper.selectKnowledgeViewRecordById(id);
33
+    }
34
+
35
+    /**
36
+     * 查询知识库查看记录列表
37
+     * 
38
+     * @param knowledgeViewRecord 知识库查看记录
39
+     * @return 知识库查看记录
40
+     */
41
+    @Override
42
+    public List<KnowledgeViewRecord> selectKnowledgeViewRecordList(KnowledgeViewRecord knowledgeViewRecord)
43
+    {
44
+        return knowledgeViewRecordMapper.selectKnowledgeViewRecordList(knowledgeViewRecord);
45
+    }
46
+
47
+    /**
48
+     * 新增知识库查看记录
49
+     * 
50
+     * @param knowledgeViewRecord 知识库查看记录
51
+     * @return 结果
52
+     */
53
+    @Override
54
+    public int insertKnowledgeViewRecord(KnowledgeViewRecord knowledgeViewRecord)
55
+    {
56
+        knowledgeViewRecord.setCreateTime(DateUtils.getNowDate());
57
+        return knowledgeViewRecordMapper.insertKnowledgeViewRecord(knowledgeViewRecord);
58
+    }
59
+
60
+    /**
61
+     * 修改知识库查看记录
62
+     * 
63
+     * @param knowledgeViewRecord 知识库查看记录
64
+     * @return 结果
65
+     */
66
+    @Override
67
+    public int updateKnowledgeViewRecord(KnowledgeViewRecord knowledgeViewRecord)
68
+    {
69
+        knowledgeViewRecord.setUpdateTime(DateUtils.getNowDate());
70
+        return knowledgeViewRecordMapper.updateKnowledgeViewRecord(knowledgeViewRecord);
71
+    }
72
+
73
+    /**
74
+     * 批量删除知识库查看记录
75
+     * 
76
+     * @param ids 需要删除的知识库查看记录主键
77
+     * @return 结果
78
+     */
79
+    @Override
80
+    public int deleteKnowledgeViewRecordByIds(Long[] ids)
81
+    {
82
+        return knowledgeViewRecordMapper.deleteKnowledgeViewRecordByIds(ids);
83
+    }
84
+
85
+    /**
86
+     * 删除知识库查看记录信息
87
+     * 
88
+     * @param id 知识库查看记录主键
89
+     * @return 结果
90
+     */
91
+    @Override
92
+    public int deleteKnowledgeViewRecordById(Long id)
93
+    {
94
+        return knowledgeViewRecordMapper.deleteKnowledgeViewRecordById(id);
95
+    }
96
+}