hanfucheng 1 rok temu
rodzic
commit
eef6400ed1
17 zmienionych plików z 779 dodań i 8 usunięć
  1. 114 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbAnswerController.java
  2. 11 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbAskTypeController.java
  3. 121 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbQuestionCollectController.java
  4. 13 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbQuestionController.java
  5. 25 1
      sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbAnswer.java
  6. 65 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbQuestionCollect.java
  7. 69 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/mapper/JnbQuestionCollectMapper.java
  8. 8 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbAnswerService.java
  9. 78 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbQuestionCollectService.java
  10. 16 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbQuestionService.java
  11. 8 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbQuestionTypeService.java
  12. 15 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbAnswerServiceImpl.java
  13. 121 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionCollectServiceImpl.java
  14. 35 4
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionServiceImpl.java
  15. 11 0
      sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionTypeServiceImpl.java
  16. 67 0
      sooka-jnb/src/main/resources/mapper/asking/JnbQuestionCollectMapper.xml
  17. 2 2
      sooka-jnb/src/main/resources/mapper/asking/JnbQuestionMapper.xml

+ 114 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbAnswerController.java

@@ -0,0 +1,114 @@
+package com.ruoyi.web.controller.asking;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.sooka.jnb.asking.domain.JnbAnswer;
+import com.sooka.jnb.asking.service.IJnbAnswerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 问答列-答案Controller
+ *
+ * @author ruoyi
+ * @date 2024-03-13
+ */
+@RestController
+@RequestMapping("/asking/answer")
+public class JnbAnswerController extends BaseController {
+    @Autowired
+    private IJnbAnswerService jnbAnswerService;
+
+    /**
+     * 查询问答列-答案列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:answer:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(JnbAnswer jnbAnswer) {
+        startPage();
+        List<JnbAnswer> list = jnbAnswerService.selectJnbAnswerList(jnbAnswer);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出问答列-答案列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:answer:export')")
+    @Log(title = "问答列-答案", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, JnbAnswer jnbAnswer) {
+        List<JnbAnswer> list = jnbAnswerService.selectJnbAnswerList(jnbAnswer);
+        ExcelUtil<JnbAnswer> util = new ExcelUtil<JnbAnswer>(JnbAnswer.class);
+        util.exportExcel(response, list, "问答列-答案数据");
+    }
+
+    /**
+     * 获取问答列-答案详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:answer:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id) {
+        return success(jnbAnswerService.selectJnbAnswerById(id));
+    }
+
+    /**
+     * 新增问答列-答案
+     */
+    @PreAuthorize("@ss.hasPermi('system:answer:add')")
+    @Log(title = "问答列-答案", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody JnbAnswer jnbAnswer) {
+        return toAjax(jnbAnswerService.insertJnbAnswer(jnbAnswer));
+    }
+
+    /**
+     * 修改问答列-答案
+     */
+    @PreAuthorize("@ss.hasPermi('system:answer:edit')")
+    @Log(title = "问答列-答案", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody JnbAnswer jnbAnswer) {
+        return toAjax(jnbAnswerService.updateJnbAnswer(jnbAnswer));
+    }
+
+    /**
+     * 删除问答列-答案
+     */
+    @PreAuthorize("@ss.hasPermi('system:answer:remove')")
+    @Log(title = "问答列-答案", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable String[] ids) {
+        return toAjax(jnbAnswerService.deleteJnbAnswerByIds(ids));
+    }
+
+    /*
+    * 小程序-添加答案
+    *
+    * @author 韩福成
+    * @date 2024/3/13 14:27
+    */
+    @PostMapping("/addAnswer")
+    public AjaxResult addAnswer(@RequestBody JnbAnswer jnbAnswer) {
+        return toAjax(jnbAnswerService.addAnswer(jnbAnswer));
+    }
+
+    /*
+    * 小程序-答案采纳
+    *
+    * @author 韩福成
+    * @date 2024/3/13 15:00
+    */
+    @GetMapping("/adoptAnswer")
+    public AjaxResult adoptAnswer(JnbAnswer jnbAnswer) {
+        jnbAnswer.setAdopt("1");
+        return toAjax(jnbAnswerService.updateJnbAnswer(jnbAnswer));
+    }
+}

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbAskTypeController.java

@@ -88,6 +88,17 @@ public class JnbAskTypeController extends BaseController {
         return R.ok(jnbQuestionTypeService.updateJnbQuestionType(jnbQuestionType));
     }
 
+    /*
+    * 修改是否展示
+    *
+    * @author 韩福成
+    * @date 2024/3/14 10:15
+    */
+    @PutMapping("/updateAskType")
+    public R updataType(@RequestBody JnbQuestionType jnbQuestionType) {
+        return R.ok(jnbQuestionTypeService.updataType(jnbQuestionType));
+    }
+
     /**
      * 删除类型配置
      */

+ 121 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbQuestionCollectController.java

@@ -0,0 +1,121 @@
+package com.ruoyi.web.controller.asking;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.common.core.domain.R;
+import com.sooka.jnb.asking.domain.JnbQuestionCollect;
+import com.sooka.jnb.asking.service.IJnbQuestionCollectService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 问题收藏Controller
+ *
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+@RestController
+@RequestMapping("/asking/collect")
+public class JnbQuestionCollectController extends BaseController {
+    @Autowired
+    private IJnbQuestionCollectService jnbQuestionCollectService;
+
+    /**
+     * 查询问题收藏列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:collect:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(JnbQuestionCollect jnbQuestionCollect) {
+        startPage();
+        List<JnbQuestionCollect> list = jnbQuestionCollectService.selectJnbQuestionCollectList(jnbQuestionCollect);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出问题收藏列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:collect:export')")
+    @Log(title = "问题收藏", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, JnbQuestionCollect jnbQuestionCollect) {
+        List<JnbQuestionCollect> list = jnbQuestionCollectService.selectJnbQuestionCollectList(jnbQuestionCollect);
+        ExcelUtil<JnbQuestionCollect> util = new ExcelUtil<JnbQuestionCollect>(JnbQuestionCollect.class);
+        util.exportExcel(response, list, "问题收藏数据");
+    }
+
+    /**
+     * 获取问题收藏详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:collect:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id) {
+        return success(jnbQuestionCollectService.selectJnbQuestionCollectById(id));
+    }
+
+    /**
+     * 新增问题收藏
+     */
+    @PreAuthorize("@ss.hasPermi('system:collect:add')")
+    @Log(title = "问题收藏", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody JnbQuestionCollect jnbQuestionCollect) {
+        return toAjax(jnbQuestionCollectService.insertJnbQuestionCollect(jnbQuestionCollect));
+    }
+
+    /**
+     * 修改问题收藏
+     */
+    @PreAuthorize("@ss.hasPermi('system:collect:edit')")
+    @Log(title = "问题收藏", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody JnbQuestionCollect jnbQuestionCollect) {
+        return toAjax(jnbQuestionCollectService.updateJnbQuestionCollect(jnbQuestionCollect));
+    }
+
+    /**
+     * 删除问题收藏
+     */
+    @PreAuthorize("@ss.hasPermi('system:collect:remove')")
+    @Log(title = "问题收藏", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable String[] ids) {
+        return toAjax(jnbQuestionCollectService.deleteJnbQuestionCollectByIds(ids));
+    }
+
+    /*
+     * 小程序-添加(取消)收藏
+     *
+     * @author 韩福成
+     * @date 2024/3/13 14:22
+     */
+    @GetMapping("/addCollect")
+    public AjaxResult addCollect(JnbQuestionCollect jnbQuestionCollect) {
+        return toAjax(jnbQuestionCollectService.addCollect(jnbQuestionCollect));
+    }
+
+    /*
+    * 小程序-判断是否收藏
+    *
+    * @author 韩福成
+    * @date 2024/3/14 9:05
+    */
+    @GetMapping("/selectCollect")
+    public R selectCollect(JnbQuestionCollect jnbQuestionCollect) {
+        return R.ok(jnbQuestionCollectService.selectCollect(jnbQuestionCollect));
+    }
+}

+ 13 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbQuestionController.java

@@ -87,6 +87,17 @@ public class JnbQuestionController extends BaseController {
         return toAjax(jnbQuestionService.updateJnbQuestion(jnbQuestion));
     }
 
+    /*
+    * 修改是否展示
+    *
+    * @author 韩福成
+    * @date 2024/3/14 10:21
+    */
+    @PutMapping("/updateWhetherShow")
+    public R updateWhetherShow(@RequestBody JnbQuestion jnbQuestion) {
+        return R.ok(jnbQuestionService.updateWhetherShow(jnbQuestion));
+    }
+
     /**
      * 删除问答列-问题
      */
@@ -193,6 +204,7 @@ public class JnbQuestionController extends BaseController {
     */
     @GetMapping(value = "/getDetailById")
     public AjaxResult getDetailById(JnbQuestion jnbQuestion) {
-        return success(jnbQuestionService.selectJnbQuestionById(jnbQuestion.getId()));
+        return success(jnbQuestionService.getDetailById(jnbQuestion.getId()));
     }
+
 }

+ 25 - 1
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbAnswer.java

@@ -43,7 +43,31 @@ public class JnbAnswer extends BaseEntity
     //头像
     private String headImg;
 
-    public void setId(String id) 
+    public String getWechatName() {
+        return wechatName;
+    }
+
+    public void setWechatName(String wechatName) {
+        this.wechatName = wechatName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getHeadImg() {
+        return headImg;
+    }
+
+    public void setHeadImg(String headImg) {
+        this.headImg = headImg;
+    }
+
+    public void setId(String id)
     {
         this.id = id;
     }

+ 65 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbQuestionCollect.java

@@ -0,0 +1,65 @@
+package com.sooka.jnb.asking.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 问题收藏对象 jnb_question_collect
+ * 
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+public class JnbQuestionCollect extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private String id;
+
+    /** 问题id */
+    @Excel(name = "问题id")
+    private String questionId;
+
+    /** 创建人 */
+    @Excel(name = "创建人")
+    private Long userId;
+
+    public void setId(String id) 
+    {
+        this.id = id;
+    }
+
+    public String getId() 
+    {
+        return id;
+    }
+    public void setQuestionId(String questionId) 
+    {
+        this.questionId = questionId;
+    }
+
+    public String getQuestionId() 
+    {
+        return questionId;
+    }
+    public void setUserId(Long userId) 
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId() 
+    {
+        return userId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("questionId", getQuestionId())
+            .append("userId", getUserId())
+            .toString();
+    }
+}

+ 69 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/mapper/JnbQuestionCollectMapper.java

@@ -0,0 +1,69 @@
+package com.sooka.jnb.asking.mapper;
+
+import com.sooka.jnb.asking.domain.JnbQuestionCollect;
+
+import java.util.List;
+
+/**
+ * 问题收藏Mapper接口
+ *
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+public interface JnbQuestionCollectMapper {
+    /**
+     * 查询问题收藏
+     *
+     * @param id 问题收藏主键
+     * @return 问题收藏
+     */
+    public JnbQuestionCollect selectJnbQuestionCollectById(String id);
+
+    /**
+     * 查询问题收藏列表
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 问题收藏集合
+     */
+    public List<JnbQuestionCollect> selectJnbQuestionCollectList(JnbQuestionCollect jnbQuestionCollect);
+
+    /**
+     * 新增问题收藏
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 结果
+     */
+    public int insertJnbQuestionCollect(JnbQuestionCollect jnbQuestionCollect);
+
+    /**
+     * 修改问题收藏
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 结果
+     */
+    public int updateJnbQuestionCollect(JnbQuestionCollect jnbQuestionCollect);
+
+    /**
+     * 删除问题收藏
+     *
+     * @param id 问题收藏主键
+     * @return 结果
+     */
+    public int deleteJnbQuestionCollectById(String id);
+
+    /**
+     * 批量删除问题收藏
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteJnbQuestionCollectByIds(String[] ids);
+
+    /*
+    * 按问题id删除
+    *
+    * @author 韩福成
+    * @date 2024/3/14 8:56
+    */
+    public int deleteJnbQuestionCollect(String questionId);
+}

+ 8 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbAnswerService.java

@@ -58,4 +58,12 @@ public interface IJnbAnswerService {
      * @return 结果
      */
     public int deleteJnbAnswerById(String id);
+
+    /*
+    * 小程序-添加答案
+    *
+    * @author 韩福成
+    * @date 2024/3/13 14:50
+    */
+    public int addAnswer(JnbAnswer jnbAnswer);
 }

+ 78 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbQuestionCollectService.java

@@ -0,0 +1,78 @@
+package com.sooka.jnb.asking.service;
+
+
+import com.sooka.jnb.asking.domain.JnbQuestionCollect;
+
+import java.util.List;
+
+/**
+ * 问题收藏Service接口
+ *
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+public interface IJnbQuestionCollectService {
+    /**
+     * 查询问题收藏
+     *
+     * @param id 问题收藏主键
+     * @return 问题收藏
+     */
+    public JnbQuestionCollect selectJnbQuestionCollectById(String id);
+
+    /**
+     * 查询问题收藏列表
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 问题收藏集合
+     */
+    public List<JnbQuestionCollect> selectJnbQuestionCollectList(JnbQuestionCollect jnbQuestionCollect);
+
+    /**
+     * 新增问题收藏
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 结果
+     */
+    public int insertJnbQuestionCollect(JnbQuestionCollect jnbQuestionCollect);
+
+    /**
+     * 修改问题收藏
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 结果
+     */
+    public int updateJnbQuestionCollect(JnbQuestionCollect jnbQuestionCollect);
+
+    /**
+     * 批量删除问题收藏
+     *
+     * @param ids 需要删除的问题收藏主键集合
+     * @return 结果
+     */
+    public int deleteJnbQuestionCollectByIds(String[] ids);
+
+    /**
+     * 删除问题收藏信息
+     *
+     * @param id 问题收藏主键
+     * @return 结果
+     */
+    public int deleteJnbQuestionCollectById(String id);
+
+    /*
+    * 小程序-添加(取消)收藏
+    *
+    * @author 韩福成
+    * @date 2024/3/14 8:46
+    */
+    public int addCollect(JnbQuestionCollect jnbQuestionCollect);
+
+    /*
+    * 小程序-判断是否收藏
+    *
+    * @author 韩福成
+    * @date 2024/3/14 9:08
+    */
+    public List<JnbQuestionCollect> selectCollect(JnbQuestionCollect jnbQuestionCollect);
+}

+ 16 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbQuestionService.java

@@ -44,6 +44,14 @@ public interface IJnbQuestionService {
      */
     public int updateJnbQuestion(JnbQuestion jnbQuestion);
 
+    /*
+    * 修改是否展示
+    *
+    * @author 韩福成
+    * @date 2024/3/14 10:23
+    */
+    public int updateWhetherShow(JnbQuestion jnbQuestion);
+
     /**
      * 批量删除问答列-问题
      *
@@ -93,6 +101,14 @@ public interface IJnbQuestionService {
     public List<JnbQuestion> getExcitingAnswersList(JnbQuestion jnbQuestion);
 
     /*
+    * 小程序-获取问题详情
+    *
+    * @author 韩福成
+    * @date 2024/3/13 14:09
+    */
+    public JnbQuestion getDetailById(String id);
+
+    /*
     * 小程序-按类型查询最多悬赏问题列表
     *
     * @author 韩福成

+ 8 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/IJnbQuestionTypeService.java

@@ -43,6 +43,14 @@ public interface IJnbQuestionTypeService {
      */
     public int updateJnbQuestionType(JnbQuestionType jnbQuestionType);
 
+    /*
+    * 修改是否展示
+    *
+    * @author 韩福成
+    * @date 2024/3/14 10:17
+    */
+    public int updataType(JnbQuestionType jnbQuestionType);
+
     /**
      * 批量删除类型配置
      *

+ 15 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbAnswerServiceImpl.java

@@ -3,6 +3,7 @@ package com.sooka.jnb.asking.service.impl;
 import java.util.List;
 
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
 import com.sooka.jnb.asking.domain.JnbAnswer;
 import com.sooka.jnb.asking.mapper.JnbAnswerMapper;
 import com.sooka.jnb.asking.service.IJnbAnswerService;
@@ -87,4 +88,18 @@ public class JnbAnswerServiceImpl implements IJnbAnswerService {
     public int deleteJnbAnswerById(String id) {
         return jnbAnswerMapper.deleteJnbAnswerById(id);
     }
+
+    /*
+    * 小程序-添加答案
+    *
+    * @author 韩福成
+    * @date 2024/3/13 14:50
+    */
+    @Override
+    public int addAnswer(JnbAnswer jnbAnswer) {
+        jnbAnswer.setId(IdUtils.simpleUUID());
+        jnbAnswer.setCreateTime(DateUtils.getNowDate());
+        jnbAnswer.setDataStatus("1");
+        return jnbAnswerMapper.insertJnbAnswer(jnbAnswer);
+    }
 }

+ 121 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionCollectServiceImpl.java

@@ -0,0 +1,121 @@
+package com.sooka.jnb.asking.service.impl;
+
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import com.sooka.jnb.asking.domain.JnbQuestionCollect;
+import com.sooka.jnb.asking.mapper.JnbQuestionCollectMapper;
+import com.sooka.jnb.asking.service.IJnbQuestionCollectService;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 问题收藏Service业务层处理
+ *
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+@Service
+public class JnbQuestionCollectServiceImpl implements IJnbQuestionCollectService {
+    @Autowired
+    private JnbQuestionCollectMapper jnbQuestionCollectMapper;
+
+    /**
+     * 查询问题收藏
+     *
+     * @param id 问题收藏主键
+     * @return 问题收藏
+     */
+    @Override
+    public JnbQuestionCollect selectJnbQuestionCollectById(String id) {
+        return jnbQuestionCollectMapper.selectJnbQuestionCollectById(id);
+    }
+
+    /**
+     * 查询问题收藏列表
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 问题收藏
+     */
+    @Override
+    public List<JnbQuestionCollect> selectJnbQuestionCollectList(JnbQuestionCollect jnbQuestionCollect) {
+        return jnbQuestionCollectMapper.selectJnbQuestionCollectList(jnbQuestionCollect);
+    }
+
+    /**
+     * 新增问题收藏
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 结果
+     */
+    @Override
+    public int insertJnbQuestionCollect(JnbQuestionCollect jnbQuestionCollect) {
+        jnbQuestionCollect.setId(IdUtils.simpleUUID());
+        return jnbQuestionCollectMapper.insertJnbQuestionCollect(jnbQuestionCollect);
+    }
+
+    /**
+     * 修改问题收藏
+     *
+     * @param jnbQuestionCollect 问题收藏
+     * @return 结果
+     */
+    @Override
+    public int updateJnbQuestionCollect(JnbQuestionCollect jnbQuestionCollect) {
+        return jnbQuestionCollectMapper.updateJnbQuestionCollect(jnbQuestionCollect);
+    }
+
+    /**
+     * 批量删除问题收藏
+     *
+     * @param ids 需要删除的问题收藏主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJnbQuestionCollectByIds(String[] ids) {
+        return jnbQuestionCollectMapper.deleteJnbQuestionCollectByIds(ids);
+    }
+
+    /**
+     * 删除问题收藏信息
+     *
+     * @param id 问题收藏主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJnbQuestionCollectById(String id) {
+        return jnbQuestionCollectMapper.deleteJnbQuestionCollectById(id);
+    }
+
+    /*
+    * 小程序-添加(取消)收藏
+    *
+    * @author 韩福成
+    * @date 2024/3/14 8:47
+    */
+    @Override
+    public int addCollect(JnbQuestionCollect jnbQuestionCollect) {
+        List<JnbQuestionCollect> jnbQuestionCollects = jnbQuestionCollectMapper.selectJnbQuestionCollectList(jnbQuestionCollect);
+        if (jnbQuestionCollects.isEmpty()){
+            //添加收藏
+            jnbQuestionCollect.setId(IdUtils.simpleUUID());
+            return jnbQuestionCollectMapper.insertJnbQuestionCollect(jnbQuestionCollect);
+        }else {
+            //取消收藏
+            return jnbQuestionCollectMapper.deleteJnbQuestionCollect(jnbQuestionCollect.getQuestionId());
+        }
+    }
+
+    /*
+    * 小程序-判断是否收藏
+    *
+    * @author 韩福成
+    * @date 2024/3/14 9:09
+    */
+    @Override
+    public List<JnbQuestionCollect> selectCollect(JnbQuestionCollect jnbQuestionCollect) {
+        return jnbQuestionCollectMapper.selectJnbQuestionCollectList(jnbQuestionCollect);
+    }
+}

+ 35 - 4
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionServiceImpl.java

@@ -51,10 +51,6 @@ public class JnbQuestionServiceImpl implements IJnbQuestionService {
     @Override
     public JnbQuestion selectJnbQuestionById(String id) {
         JnbQuestion question = jnbQuestionMapper.selectJnbQuestionById(id);
-        JnbQuestion jnbQuestion = new JnbQuestion();
-        jnbQuestion.setId(id);
-        jnbQuestion.setBrowse(question.getBrowse()+1);
-        jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
         if (StringUtils.isNotEmpty(question.getPath())){
             String[] split = question.getPath().split(",");
             question.setPaths(split);
@@ -128,6 +124,17 @@ public class JnbQuestionServiceImpl implements IJnbQuestionService {
         return jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
     }
 
+    /*
+    * 修改是否展示
+    *
+    * @author 韩福成
+    * @date 2024/3/14 10:23
+    */
+    @Override
+    public int updateWhetherShow(JnbQuestion jnbQuestion) {
+        return jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
+    }
+
     /**
      * 批量删除问答列-问题
      *
@@ -238,4 +245,28 @@ public class JnbQuestionServiceImpl implements IJnbQuestionService {
         }
         return list;
     }
+
+    /*
+    * 小程序-获取问题详情
+    *
+    * @author 韩福成
+    * @date 2024/3/13 14:10
+    */
+    @Override
+    public JnbQuestion getDetailById(String id) {
+        JnbQuestion question = jnbQuestionMapper.selectJnbQuestionById(id);
+        JnbQuestion jnbQuestion = new JnbQuestion();
+        jnbQuestion.setId(id);
+        jnbQuestion.setBrowse(question.getBrowse()+1);
+        jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
+        if (StringUtils.isNotEmpty(question.getPath())){
+            String[] split = question.getPath().split(",");
+            question.setPaths(split);
+        }
+        JnbAnswer jnbAnswer = new JnbAnswer();
+        jnbAnswer.setQuestionId(id);
+        List<JnbAnswer> answerList = jnbAnswerService.selectJnbAnswerList(jnbAnswer);
+        question.setAnswerList(answerList);
+        return question;
+    }
 }

+ 11 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionTypeServiceImpl.java

@@ -76,6 +76,17 @@ public class JnbQuestionTypeServiceImpl implements IJnbQuestionTypeService {
         return jnbQuestionTypeMapper.updateJnbQuestionType(jnbQuestionType);
     }
 
+    /*
+    * 修改是否展示
+    *
+    * @author 韩福成
+    * @date 2024/3/14 10:17
+    */
+    @Override
+    public int updataType(JnbQuestionType jnbQuestionType) {
+        return jnbQuestionTypeMapper.updateJnbQuestionType(jnbQuestionType);
+    }
+
     /**
      * 批量删除类型配置
      *

+ 67 - 0
sooka-jnb/src/main/resources/mapper/asking/JnbQuestionCollectMapper.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sooka.jnb.asking.mapper.JnbQuestionCollectMapper">
+    
+    <resultMap type="JnbQuestionCollect" id="JnbQuestionCollectResult">
+        <result property="id"    column="id"    />
+        <result property="questionId"    column="question_id"    />
+        <result property="userId"    column="user_id"    />
+    </resultMap>
+
+    <sql id="selectJnbQuestionCollectVo">
+        select id, question_id, user_id from jnb_question_collect
+    </sql>
+
+    <select id="selectJnbQuestionCollectList" parameterType="JnbQuestionCollect" resultMap="JnbQuestionCollectResult">
+        <include refid="selectJnbQuestionCollectVo"/>
+        <where>  
+            <if test="questionId != null  and questionId != ''"> and question_id = #{questionId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+        </where>
+    </select>
+    
+    <select id="selectJnbQuestionCollectById" parameterType="String" resultMap="JnbQuestionCollectResult">
+        <include refid="selectJnbQuestionCollectVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertJnbQuestionCollect" parameterType="JnbQuestionCollect">
+        insert into jnb_question_collect
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="questionId != null">question_id,</if>
+            <if test="userId != null">user_id,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="questionId != null">#{questionId},</if>
+            <if test="userId != null">#{userId},</if>
+         </trim>
+    </insert>
+
+    <update id="updateJnbQuestionCollect" parameterType="JnbQuestionCollect">
+        update jnb_question_collect
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="questionId != null">question_id = #{questionId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteJnbQuestionCollectById" parameterType="String">
+        delete from jnb_question_collect where id = #{id}
+    </delete>
+
+    <delete id="deleteJnbQuestionCollectByIds" parameterType="String">
+        delete from jnb_question_collect where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <delete id="deleteJnbQuestionCollect" parameterType="String">
+        delete from jnb_question_collect where question_id = #{questionId}
+    </delete>
+</mapper>

+ 2 - 2
sooka-jnb/src/main/resources/mapper/asking/JnbQuestionMapper.xml

@@ -161,8 +161,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.type,
             a.score,
             a.browse,
-            count(b.id) comment,
-            count(c.id) collect
+            count(DISTINCT b.id) comment,
+            count(DISTINCT c.id) collect
         FROM
             jnb_question a
             LEFT JOIN jnb_answer b on a.id = b.question_id and b.data_status = 1