|
@@ -1,11 +1,17 @@
|
|
|
package com.cyksj.web.controller.sys;
|
|
package com.cyksj.web.controller.sys;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
|
|
+import com.cyksj.mapper.manage.help.HelpQuestionClassificationMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.help.HelpQuestionMapper;
|
|
|
|
|
+import com.cyksj.model.entity.HelpQuestion;
|
|
|
|
|
+import com.cyksj.model.entity.HelpQuestionClassification;
|
|
|
import com.cyksj.model.entity.SysConfig;
|
|
import com.cyksj.model.entity.SysConfig;
|
|
|
import com.cyksj.service.sys.SysConfigService;
|
|
import com.cyksj.service.sys.SysConfigService;
|
|
|
|
|
+import com.cyksj.service.sys.SysHelpService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -22,6 +28,12 @@ public class SysConfigController {
|
|
|
|
|
|
|
|
private final SysConfigService sysConfigService;
|
|
private final SysConfigService sysConfigService;
|
|
|
|
|
|
|
|
|
|
+ private final SysHelpService sysHelpService;
|
|
|
|
|
+
|
|
|
|
|
+ private final HelpQuestionClassificationMapper classificationMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final HelpQuestionMapper helpQuestionMapper;
|
|
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
|
public Result<SysConfig> get(String key){
|
|
public Result<SysConfig> get(String key){
|
|
|
SysConfig sysConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, key).last(" limit 1"));
|
|
SysConfig sysConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, key).last(" limit 1"));
|
|
@@ -54,4 +66,125 @@ public class SysConfigController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增问题分类
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/help/question/classification")
|
|
|
|
|
+ public Result<String> saveHelpQuestionClassification(@RequestBody HelpQuestionClassification helpQuestionClassification) {
|
|
|
|
|
+ sysHelpService.postQuestionClassification(helpQuestionClassification);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("新增问题分类成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除问题分类
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/help/question/classification/{id}")
|
|
|
|
|
+ public Result<String> deleteHelpQuestionClassificationById(@PathVariable Long id) {
|
|
|
|
|
+ HelpQuestionClassification helpQuestionClassification = classificationMapper.selectById(id);
|
|
|
|
|
+ if (helpQuestionClassification != null) {
|
|
|
|
|
+ helpQuestionClassification.setDeleted(false);
|
|
|
|
|
+ classificationMapper.updateById(helpQuestionClassification);
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("删除问题分类成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑问题分类
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/help/question/classification")
|
|
|
|
|
+ public Result<String> editHelpQuestionClassification(@RequestBody HelpQuestionClassification helpQuestionClassification) {
|
|
|
|
|
+ sysHelpService.editQuestionClassification(helpQuestionClassification);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("新增问题分类成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 问题分类列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/help/question/classification")
|
|
|
|
|
+ public Result<Page<HelpQuestionClassification>> saveHelpQuestionClassification(@RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
|
|
|
|
|
+ Page<HelpQuestionClassification> page = classificationMapper.selectPage(new Page<>(start, limit), Wrappers.lambdaQuery(HelpQuestionClassification.class)
|
|
|
|
|
+ .eq(HelpQuestionClassification::getDeleted, true)
|
|
|
|
|
+ .orderByDesc(HelpQuestionClassification::getSort));
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上下架分类
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/help/question/classification/status/{id}")
|
|
|
|
|
+ public Result<String> updateHelpQuestionClassificationStatus(@PathVariable Long id) {
|
|
|
|
|
+ HelpQuestionClassification classification = classificationMapper.selectById(id);
|
|
|
|
|
+ if (classification == null || !classification.getDeleted()) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("分类不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ classification.setStatus(!classification.getStatus());
|
|
|
|
|
+ classificationMapper.updateById(classification);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("操作成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/help/question")
|
|
|
|
|
+ public Result<String> saveHelpQuestion(@RequestBody HelpQuestion helpQuestion) {
|
|
|
|
|
+ sysHelpService.saveHelpQuestion(helpQuestion);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("新增问题成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/help/question/{id}")
|
|
|
|
|
+ public Result<String> deleteHelpQuestionById(@PathVariable Long id) {
|
|
|
|
|
+ HelpQuestion helpQuestion = helpQuestionMapper.selectById(id);
|
|
|
|
|
+ if (helpQuestion == null || !helpQuestion.getDeleted()) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("问题不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ helpQuestion.setDeleted(false);
|
|
|
|
|
+ helpQuestionMapper.updateById(helpQuestion);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("删除问题成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/help/question")
|
|
|
|
|
+ public Result<String> editHelpQuestion(@RequestBody HelpQuestion helpQuestion) {
|
|
|
|
|
+ sysHelpService.editHelpQuestion(helpQuestion);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("编辑问题成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 问题列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/help/question")
|
|
|
|
|
+ public Result<Page<HelpQuestion>> saveHelpQuestion(Long classificationId, @RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
|
|
|
|
|
+ if (classificationId == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("问题分类id为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ HelpQuestionClassification helpQuestionClassification = classificationMapper.selectById(classificationId);
|
|
|
|
|
+ if (helpQuestionClassification == null || !helpQuestionClassification.getDeleted()) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该分类已被删除");
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<HelpQuestion> page = helpQuestionMapper.selectPage(new Page<>(start, limit),
|
|
|
|
|
+ Wrappers.lambdaQuery(HelpQuestion.class)
|
|
|
|
|
+ .eq(HelpQuestion::getClassificationId, classificationId)
|
|
|
|
|
+ .eq(HelpQuestion::getDeleted, true)
|
|
|
|
|
+ .orderByDesc(HelpQuestion::getSort));
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上下架问题
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/help/question/status/{id}")
|
|
|
|
|
+ public Result<String> saveHelpQuestion(@PathVariable Long id) {
|
|
|
|
|
+ HelpQuestion helpQuestion = helpQuestionMapper.selectById(id);
|
|
|
|
|
+ if (helpQuestion == null || !helpQuestion.getDeleted()) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("问题不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ helpQuestion.setStatus(!helpQuestion.getStatus());
|
|
|
|
|
+ helpQuestionMapper.updateById(helpQuestion);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("操作成功");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|