hanfucheng 1 год назад
Родитель
Сommit
1522c9e6e6

+ 198 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/asking/JnbQuestionController.java

@@ -0,0 +1,198 @@
+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.domain.R;
+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.JnbQuestion;
+import com.sooka.jnb.asking.domain.JnbQuestionType;
+import com.sooka.jnb.asking.service.IJnbQuestionService;
+import com.sooka.jnb.asking.service.IJnbQuestionTypeService;
+import com.sooka.jnb.my.domain.ScoreOperate;
+import com.sooka.jnb.my.service.IScoreService;
+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 韩福成
+ * @date 2024-03-11
+ */
+@RestController
+@RequestMapping("/asking/question")
+public class JnbQuestionController extends BaseController {
+    @Autowired
+    private IJnbQuestionService jnbQuestionService;
+
+    @Autowired
+    private IJnbQuestionTypeService jnbQuestionTypeService;
+
+    /**
+     * 查询问答列-问题列表
+     */
+    @PreAuthorize("@ss.hasPermi('asking:question:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(JnbQuestion jnbQuestion) {
+        startPage();
+        List<JnbQuestion> list = jnbQuestionService.selectJnbQuestionList(jnbQuestion);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出问答列-问题列表
+     */
+    @PreAuthorize("@ss.hasPermi('asking:question:export')")
+    @Log(title = "导出问答列", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, JnbQuestion jnbQuestion) {
+        List<JnbQuestion> list = jnbQuestionService.selectJnbQuestionList(jnbQuestion);
+        ExcelUtil<JnbQuestion> util = new ExcelUtil<JnbQuestion>(JnbQuestion.class);
+        util.exportExcel(response, list, "问答列-问题数据");
+    }
+
+    /**
+     * 获取问答列-问题详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('asking:question:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id) {
+        return success(jnbQuestionService.selectJnbQuestionById(id));
+    }
+
+    /**
+     * 新增问答列-问题
+     */
+    @PreAuthorize("@ss.hasPermi('asking:question:add')")
+    @Log(title = "新增问答列", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody JnbQuestion jnbQuestion) {
+        return toAjax(jnbQuestionService.insertJnbQuestion(jnbQuestion));
+    }
+
+    /**
+     * 修改问答列-问题
+     */
+    @PreAuthorize("@ss.hasPermi('asking:question:edit')")
+    @Log(title = "修改问答列", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody JnbQuestion jnbQuestion) {
+        return toAjax(jnbQuestionService.updateJnbQuestion(jnbQuestion));
+    }
+
+    /**
+     * 删除问答列-问题
+     */
+    @PreAuthorize("@ss.hasPermi('asking:question:remove')")
+    @Log(title = "删除问答列", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable String[] ids) {
+        return toAjax(jnbQuestionService.deleteJnbQuestionByIds(ids));
+    }
+
+    /*
+    * 审核问题
+    *
+    * @author 韩福成
+    * @date 2024/3/11 10:20
+    */
+    @PreAuthorize("@ss.hasPermi('asking:question:examine')")
+    @Log(title = "审核问题", businessType = BusinessType.UPDATE)
+    @PutMapping("/through")
+    public AjaxResult through(@RequestBody JnbQuestion jnbQuestion) {
+        return toAjax(jnbQuestionService.through(jnbQuestion));
+    }
+
+    /*
+    * 查询类型配置列表
+    *
+    * @author 韩福成
+    * @date 2024/3/11 10:44
+    */
+    @GetMapping("/typeList")
+    public R typeList(JnbQuestionType jnbQuestionType) {
+        return R.ok(jnbQuestionTypeService.selectJnbQuestionTypeList(jnbQuestionType));
+    }
+
+    /*
+    * 小程序-获取热门问答列表
+    *
+    * @author 韩福成
+    * @date 2024/3/11 11:21
+    */
+    @GetMapping("/getHotQuestionList")
+    public TableDataInfo getHotQuestionList(JnbQuestion jnbQuestion) {
+        startPage();
+        List<JnbQuestion> list = jnbQuestionService.getHotQuestionList(jnbQuestion);
+        return getDataTable(list);
+    }
+
+    /*
+    * 小程序-新增问题
+    *
+    * @author 韩福成
+    * @date 2024/3/12 10:32
+    */
+    @Log(title = "新增问题", businessType = BusinessType.INSERT)
+    @PostMapping("addQuestion")
+    public AjaxResult addQuestion(@RequestBody JnbQuestion jnbQuestion) {
+        return toAjax(jnbQuestionService.insertJnbQuestion(jnbQuestion));
+    }
+
+    /*
+    * 小程序-按类型查询全部列表问题
+    *
+    * @author 韩福成
+    * @date 2024/3/12 13:02
+    */
+    @GetMapping("/getAllQuestionByType")
+    public TableDataInfo getQuestionByType(JnbQuestion jnbQuestion) {
+        startPage();
+        List<JnbQuestion> list = jnbQuestionService.getQuestionByType(jnbQuestion);
+        return getDataTable(list);
+    }
+
+    /*
+    * 小程序-按类型查询精彩回答问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:48
+    */
+    @GetMapping("/getExcitingAnswersList")
+    public TableDataInfo getExcitingAnswersList(JnbQuestion jnbQuestion) {
+        startPage();
+        List<JnbQuestion> list = jnbQuestionService.getExcitingAnswersList(jnbQuestion);
+        return getDataTable(list);
+    }
+
+    /*
+    *小程序-按类型查询最多悬赏问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:49
+    */
+    @GetMapping("/getMaxScoreList")
+    public TableDataInfo getMaxScoreList(JnbQuestion jnbQuestion) {
+        startPage();
+        List<JnbQuestion> list = jnbQuestionService.getMaxScoreList(jnbQuestion);
+        return getDataTable(list);
+    }
+
+    /*
+    * 小程序-获取问题详情
+    *
+    * @author 韩福成
+    * @date 2024/3/13 8:54
+    */
+    @GetMapping(value = "/getDetailById")
+    public AjaxResult getDetailById(JnbQuestion jnbQuestion) {
+        return success(jnbQuestionService.selectJnbQuestionById(jnbQuestion.getId()));
+    }
+}

+ 106 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbAnswer.java

@@ -0,0 +1,106 @@
+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_answer
+ * 
+ * @author ruoyi
+ * @date 2024-03-13
+ */
+public class JnbAnswer extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private String id;
+
+    /** 问题id */
+    @Excel(name = "问题id")
+    private String questionId;
+
+    /** 答案 */
+    @Excel(name = "答案")
+    private String answer;
+
+    /** 是否被采纳 */
+    @Excel(name = "是否被采纳")
+    private String adopt;
+
+    /** 数据状态 */
+    @Excel(name = "数据状态")
+    private String dataStatus;
+
+    //微信名
+    private String wechatName;
+
+    //真实姓名
+    private String name;
+
+    //头像
+    private String headImg;
+
+    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 setAnswer(String answer) 
+    {
+        this.answer = answer;
+    }
+
+    public String getAnswer() 
+    {
+        return answer;
+    }
+    public void setAdopt(String adopt) 
+    {
+        this.adopt = adopt;
+    }
+
+    public String getAdopt() 
+    {
+        return adopt;
+    }
+    public void setDataStatus(String dataStatus) 
+    {
+        this.dataStatus = dataStatus;
+    }
+
+    public String getDataStatus() 
+    {
+        return dataStatus;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("questionId", getQuestionId())
+            .append("answer", getAnswer())
+            .append("adopt", getAdopt())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("dataStatus", getDataStatus())
+            .toString();
+    }
+}

+ 232 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbQuestion.java

@@ -0,0 +1,232 @@
+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;
+
+import java.util.List;
+
+/**
+ * 问答列-问题对象 jnb_question
+ * 
+ * @author 韩福成
+ * @date 2024-03-11
+ */
+public class JnbQuestion extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private String id;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String title;
+
+    /** 正文 */
+    @Excel(name = "正文")
+    private String text;
+
+    /** 是否首页展示 */
+    @Excel(name = "是否首页展示")
+    private String whetherShow;
+
+    /** 类型配置id */
+    @Excel(name = "类型配置id")
+    private String typeId;
+
+    /** 类型名称 */
+    private String type;
+
+    /** 悬赏积分 */
+    @Excel(name = "悬赏积分")
+    private String score;
+
+    /** 审核状态(3-待审核;1-审核通过;2-审核未通过) */
+    @Excel(name = "审核状态", readConverterExp = "3=-待审核;1-审核通过;2-审核未通过")
+    private String status;
+
+    /** 浏览数 */
+    @Excel(name = "浏览数")
+    private Long browse;
+
+    /** 评论数 */
+    private Long comment;
+
+    /** 收藏数 */
+    private Long collect;
+
+    /** 数据状态 */
+    @Excel(name = "数据状态")
+    private String dataStatus;
+
+    /**
+     * 图片路径
+     */
+    private String path;
+
+    private String[] paths;
+
+    private String tab;
+
+    //答案
+    private List<JnbAnswer> answerList;
+
+    public List<JnbAnswer> getAnswerList() {
+        return answerList;
+    }
+
+    public void setAnswerList(List<JnbAnswer> answerList) {
+        this.answerList = answerList;
+    }
+
+    public String getTab() {
+        return tab;
+    }
+
+    public void setTab(String tab) {
+        this.tab = tab;
+    }
+
+    public String[] getPaths() {
+        return paths;
+    }
+
+    public void setPaths(String[] paths) {
+        this.paths = paths;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public Long getCollect() {
+        return collect;
+    }
+
+    public void setCollect(Long collect) {
+        this.collect = collect;
+    }
+
+    public Long getComment() {
+        return comment;
+    }
+
+    public void setComment(Long comment) {
+        this.comment = comment;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setId(String id)
+    {
+        this.id = id;
+    }
+
+    public String getId() 
+    {
+        return id;
+    }
+    public void setTitle(String title) 
+    {
+        this.title = title;
+    }
+
+    public String getTitle() 
+    {
+        return title;
+    }
+    public void setText(String text) 
+    {
+        this.text = text;
+    }
+
+    public String getText() 
+    {
+        return text;
+    }
+    public void setWhetherShow(String whetherShow) 
+    {
+        this.whetherShow = whetherShow;
+    }
+
+    public String getWhetherShow() 
+    {
+        return whetherShow;
+    }
+    public void setTypeId(String typeId) 
+    {
+        this.typeId = typeId;
+    }
+
+    public String getTypeId() 
+    {
+        return typeId;
+    }
+    public void setScore(String score) 
+    {
+        this.score = score;
+    }
+
+    public String getScore() 
+    {
+        return score;
+    }
+    public void setStatus(String status) 
+    {
+        this.status = status;
+    }
+
+    public String getStatus() 
+    {
+        return status;
+    }
+    public void setBrowse(Long browse) 
+    {
+        this.browse = browse;
+    }
+
+    public Long getBrowse() 
+    {
+        return browse;
+    }
+    public void setDataStatus(String dataStatus) 
+    {
+        this.dataStatus = dataStatus;
+    }
+
+    public String getDataStatus() 
+    {
+        return dataStatus;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("title", getTitle())
+            .append("text", getText())
+            .append("whetherShow", getWhetherShow())
+            .append("typeId", getTypeId())
+            .append("score", getScore())
+            .append("status", getStatus())
+            .append("browse", getBrowse())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("dataStatus", getDataStatus())
+            .toString();
+    }
+}

+ 52 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbQuestionImg.java

@@ -0,0 +1,52 @@
+package com.sooka.jnb.asking.domain;
+
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 问题图片
+ *
+ * @author 韩福成
+ * @date 2024-03-02
+ */
+public class JnbQuestionImg extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    private String id;
+
+    /**
+     * 关联id
+     */
+    private String questionId;
+
+    /**
+     * 图片
+     */
+    private String path;
+
+    public String getQuestionId() {
+        return questionId;
+    }
+
+    public void setQuestionId(String questionId) {
+        this.questionId = questionId;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+}

+ 13 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/domain/JnbQuestionType.java

@@ -51,6 +51,19 @@ public class JnbQuestionType extends BaseEntity {
      */
     private String dataStatus;
 
+    /*
+    * 问题数
+    */
+    private Long questionNum;
+
+    public Long getQuestionNum() {
+        return questionNum;
+    }
+
+    public void setQuestionNum(Long questionNum) {
+        this.questionNum = questionNum;
+    }
+
     public String getTypeId() {
         return typeId;
     }

+ 63 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/mapper/JnbAnswerMapper.java

@@ -0,0 +1,63 @@
+package com.sooka.jnb.asking.mapper;
+
+import com.sooka.jnb.asking.domain.JnbAnswer;
+
+import java.util.List;
+
+/**
+ * 问答列-答案Mapper接口
+ *
+ * @author 韩福成
+ * @date 2024-03-11
+ */
+public interface JnbAnswerMapper {
+
+    /**
+     * 查询问答列-答案
+     *
+     * @param id 问答列-答案主键
+     * @return 问答列-答案
+     */
+    public JnbAnswer selectJnbAnswerById(String id);
+
+    /**
+     * 查询问答列-答案列表
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 问答列-答案集合
+     */
+    public List<JnbAnswer> selectJnbAnswerList(JnbAnswer jnbAnswer);
+
+    /**
+     * 新增问答列-答案
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 结果
+     */
+    public int insertJnbAnswer(JnbAnswer jnbAnswer);
+
+    /**
+     * 修改问答列-答案
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 结果
+     */
+    public int updateJnbAnswer(JnbAnswer jnbAnswer);
+
+    /**
+     * 删除问答列-答案
+     *
+     * @param id 问答列-答案主键
+     * @return 结果
+     */
+    public int deleteJnbAnswerById(String id);
+
+    /**
+     * 批量删除问答列-答案
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteJnbAnswerByIds(String[] ids);
+
+}

+ 110 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/mapper/JnbQuestionMapper.java

@@ -0,0 +1,110 @@
+package com.sooka.jnb.asking.mapper;
+
+import com.sooka.jnb.asking.domain.JnbQuestion;
+import com.sooka.jnb.asking.domain.JnbQuestionImg;
+
+import java.util.List;
+
+/**
+ * 问答列-问题Mapper接口
+ *
+ * @author 韩福成
+ * @date 2024-03-11
+ */
+public interface JnbQuestionMapper {
+    /**
+     * 查询问答列-问题
+     *
+     * @param id 问答列-问题主键
+     * @return 问答列-问题
+     */
+    public JnbQuestion selectJnbQuestionById(String id);
+
+    /**
+     * 查询问答列-问题列表
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 问答列-问题集合
+     */
+    public List<JnbQuestion> selectJnbQuestionList(JnbQuestion jnbQuestion);
+
+    /**
+     * 新增问答列-问题
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 结果
+     */
+    public int insertJnbQuestion(JnbQuestion jnbQuestion);
+
+    /**
+     * 修改问答列-问题
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 结果
+     */
+    public int updateJnbQuestion(JnbQuestion jnbQuestion);
+
+    /**
+     * 删除问答列-问题
+     *
+     * @param id 问答列-问题主键
+     * @return 结果
+     */
+    public int deleteJnbQuestionById(String id);
+
+    /**
+     * 批量删除问答列-问题
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteJnbQuestionByIds(String[] ids);
+
+    /*
+    * 新增问题图片
+    *
+    * @author 韩福成
+    * @date 2024/3/11 16:12
+    */
+    public int insertJnbQuestionImg(JnbQuestionImg jnbQuestionImg);
+
+    /*
+    * 按问题id删除图片
+    *
+    * @author 韩福成
+    * @date 2024/3/11 16:43
+    */
+    public int deleteQuestionImg(String id);
+
+    /*
+    * 小程序-获取热门问答列表
+    *
+    * @author 韩福成
+    * @date 2024/3/11 14:31
+    */
+    public List<JnbQuestion> getHotQuestionList(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-按类型查询问题
+    *
+    * @author 韩福成
+    * @date 2024/3/12 13:06
+    */
+    public List<JnbQuestion> getQuestionByType(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-按类型查询精彩回答问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:54
+    */
+    public List<JnbQuestion> getExcitingAnswersList(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-按类型查询最多悬赏问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:54
+    */
+    public List<JnbQuestion> getMaxScoreList(JnbQuestion jnbQuestion);
+}

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

@@ -0,0 +1,61 @@
+package com.sooka.jnb.asking.service;
+
+import com.sooka.jnb.asking.domain.JnbAnswer;
+
+import java.util.List;
+
+/**
+ * 问答列-答案Service接口
+ *
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+public interface IJnbAnswerService {
+    /**
+     * 查询问答列-答案
+     *
+     * @param id 问答列-答案主键
+     * @return 问答列-答案
+     */
+    public JnbAnswer selectJnbAnswerById(String id);
+
+    /**
+     * 查询问答列-答案列表
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 问答列-答案集合
+     */
+    public List<JnbAnswer> selectJnbAnswerList(JnbAnswer jnbAnswer);
+
+    /**
+     * 新增问答列-答案
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 结果
+     */
+    public int insertJnbAnswer(JnbAnswer jnbAnswer);
+
+    /**
+     * 修改问答列-答案
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 结果
+     */
+    public int updateJnbAnswer(JnbAnswer jnbAnswer);
+
+    /**
+     * 批量删除问答列-答案
+     *
+     * @param ids 需要删除的问答列-答案主键集合
+     * @return 结果
+     */
+    public int deleteJnbAnswerByIds(String[] ids);
+
+    /**
+     * 删除问答列-答案信息
+     *
+     * @param id 问答列-答案主键
+     * @return 结果
+     */
+    public int deleteJnbAnswerById(String id);
+}

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

@@ -0,0 +1,102 @@
+package com.sooka.jnb.asking.service;
+
+import com.sooka.jnb.asking.domain.JnbQuestion;
+import com.sooka.jnb.my.domain.JnbNameAuthentication;
+
+import java.util.List;
+
+/**
+ * 问答列-问题Service接口
+ *
+ * @author 韩福成
+ * @date 2024-03-11
+ */
+public interface IJnbQuestionService {
+    /**
+     * 查询问答列-问题
+     *
+     * @param id 问答列-问题主键
+     * @return 问答列-问题
+     */
+    public JnbQuestion selectJnbQuestionById(String id);
+
+    /**
+     * 查询问答列-问题列表
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 问答列-问题集合
+     */
+    public List<JnbQuestion> selectJnbQuestionList(JnbQuestion jnbQuestion);
+
+    /**
+     * 新增问答列-问题
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 结果
+     */
+    public int insertJnbQuestion(JnbQuestion jnbQuestion);
+
+    /**
+     * 修改问答列-问题
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 结果
+     */
+    public int updateJnbQuestion(JnbQuestion jnbQuestion);
+
+    /**
+     * 批量删除问答列-问题
+     *
+     * @param ids 需要删除的问答列-问题主键集合
+     * @return 结果
+     */
+    public int deleteJnbQuestionByIds(String[] ids);
+
+    /**
+     * 删除问答列-问题信息
+     *
+     * @param id 问答列-问题主键
+     * @return 结果
+     */
+    public int deleteJnbQuestionById(String id);
+
+    /**
+    * 问答审核
+    *
+    * @author 韩福成
+    * @date 2024/3/11 11:24
+    */
+    public int through(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-获取热门问答列表
+    *
+    * @author 韩福成
+    * @date 2024/3/11 14:27
+    */
+    public List<JnbQuestion> getHotQuestionList(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-按类型查询问题
+    *
+    * @author 韩福成
+    * @date 2024/3/12 13:04
+    */
+    public List<JnbQuestion> getQuestionByType(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-按类型查询精彩回答问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:52
+    */
+    public List<JnbQuestion> getExcitingAnswersList(JnbQuestion jnbQuestion);
+
+    /*
+    * 小程序-按类型查询最多悬赏问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:52
+    */
+    public List<JnbQuestion> getMaxScoreList(JnbQuestion jnbQuestion);
+}

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

@@ -0,0 +1,90 @@
+package com.sooka.jnb.asking.service.impl;
+
+import java.util.List;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.sooka.jnb.asking.domain.JnbAnswer;
+import com.sooka.jnb.asking.mapper.JnbAnswerMapper;
+import com.sooka.jnb.asking.service.IJnbAnswerService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 问答列-答案Service业务层处理
+ *
+ * @author 韩福成
+ * @date 2024-03-13
+ */
+@Service
+public class JnbAnswerServiceImpl implements IJnbAnswerService {
+    @Autowired
+    private JnbAnswerMapper jnbAnswerMapper;
+
+    /**
+     * 查询问答列-答案
+     *
+     * @param id 问答列-答案主键
+     * @return 问答列-答案
+     */
+    @Override
+    public JnbAnswer selectJnbAnswerById(String id) {
+        return jnbAnswerMapper.selectJnbAnswerById(id);
+    }
+
+    /**
+     * 查询问答列-答案列表
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 问答列-答案
+     */
+    @Override
+    public List<JnbAnswer> selectJnbAnswerList(JnbAnswer jnbAnswer) {
+        return jnbAnswerMapper.selectJnbAnswerList(jnbAnswer);
+    }
+
+    /**
+     * 新增问答列-答案
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 结果
+     */
+    @Override
+    public int insertJnbAnswer(JnbAnswer jnbAnswer) {
+        jnbAnswer.setCreateTime(DateUtils.getNowDate());
+        return jnbAnswerMapper.insertJnbAnswer(jnbAnswer);
+    }
+
+    /**
+     * 修改问答列-答案
+     *
+     * @param jnbAnswer 问答列-答案
+     * @return 结果
+     */
+    @Override
+    public int updateJnbAnswer(JnbAnswer jnbAnswer) {
+        jnbAnswer.setUpdateTime(DateUtils.getNowDate());
+        return jnbAnswerMapper.updateJnbAnswer(jnbAnswer);
+    }
+
+    /**
+     * 批量删除问答列-答案
+     *
+     * @param ids 需要删除的问答列-答案主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJnbAnswerByIds(String[] ids) {
+        return jnbAnswerMapper.deleteJnbAnswerByIds(ids);
+    }
+
+    /**
+     * 删除问答列-答案信息
+     *
+     * @param id 问答列-答案主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJnbAnswerById(String id) {
+        return jnbAnswerMapper.deleteJnbAnswerById(id);
+    }
+}

+ 241 - 0
sooka-jnb/src/main/java/com/sooka/jnb/asking/service/impl/JnbQuestionServiceImpl.java

@@ -0,0 +1,241 @@
+package com.sooka.jnb.asking.service.impl;
+
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.DictUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import com.sooka.jnb.asking.domain.JnbAnswer;
+import com.sooka.jnb.asking.domain.JnbQuestion;
+import com.sooka.jnb.asking.domain.JnbQuestionImg;
+import com.sooka.jnb.asking.mapper.JnbQuestionMapper;
+import com.sooka.jnb.asking.service.IJnbAnswerService;
+import com.sooka.jnb.asking.service.IJnbQuestionService;
+import com.sooka.jnb.my.domain.Announcement;
+import com.sooka.jnb.my.service.IAnnouncementService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import static com.ruoyi.common.constant.CacheConstants.SYS_CONFIG_KEY;
+
+/**
+ * 问答列-问题Service业务层处理
+ *
+ * @author 韩福成
+ * @date 2024-03-11
+ */
+@Service
+public class JnbQuestionServiceImpl implements IJnbQuestionService {
+    @Autowired
+    private JnbQuestionMapper jnbQuestionMapper;
+
+    @Autowired
+    private IAnnouncementService announcementService;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    @Autowired
+    private IJnbAnswerService jnbAnswerService;
+
+    /**
+     * 查询问答列-问题
+     *
+     * @param id 问答列-问题主键
+     * @return 问答列-问题
+     */
+    @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);
+        }
+        JnbAnswer jnbAnswer = new JnbAnswer();
+        jnbAnswer.setQuestionId(id);
+        List<JnbAnswer> answerList = jnbAnswerService.selectJnbAnswerList(jnbAnswer);
+        question.setAnswerList(answerList);
+        return question;
+    }
+
+    /**
+     * 查询问答列-问题列表
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 问答列-问题
+     */
+    @Override
+    public List<JnbQuestion> selectJnbQuestionList(JnbQuestion jnbQuestion) {
+        return jnbQuestionMapper.selectJnbQuestionList(jnbQuestion);
+    }
+
+    /**
+     * 新增问答列-问题
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 结果
+     */
+    @Override
+    public int insertJnbQuestion(JnbQuestion jnbQuestion) {
+        jnbQuestion.setId(IdUtils.simpleUUID());
+        jnbQuestion.setCreateBy(SecurityUtils.getUserId().toString());
+        jnbQuestion.setCreateTime(DateUtils.getNowDate());
+        jnbQuestion.setDataStatus("1");
+        jnbQuestion.setStatus("3");
+        jnbQuestion.setWhetherShow("N");
+        if (jnbQuestion.getPath()!=null){
+            String[] paths = jnbQuestion.getPath().split(",");
+            for (String path : paths) {
+                JnbQuestionImg img = new JnbQuestionImg();
+                img.setId(IdUtils.simpleUUID());
+                img.setQuestionId(jnbQuestion.getId());
+                img.setPath(path);
+                jnbQuestionMapper.insertJnbQuestionImg(img);
+            }
+        }
+        return jnbQuestionMapper.insertJnbQuestion(jnbQuestion);
+    }
+
+    /**
+     * 修改问答列-问题
+     *
+     * @param jnbQuestion 问答列-问题
+     * @return 结果
+     */
+    @Override
+    public int updateJnbQuestion(JnbQuestion jnbQuestion) {
+        jnbQuestion.setUpdateBy(SecurityUtils.getUserId().toString());
+        jnbQuestion.setUpdateTime(DateUtils.getNowDate());
+        jnbQuestionMapper.deleteQuestionImg(jnbQuestion.getId());
+        if (jnbQuestion.getPath()!=null){
+            String[] paths = jnbQuestion.getPath().split(",");
+            for (String path : paths) {
+                JnbQuestionImg img = new JnbQuestionImg();
+                img.setId(IdUtils.simpleUUID());
+                img.setQuestionId(jnbQuestion.getId());
+                img.setPath(path);
+                jnbQuestionMapper.insertJnbQuestionImg(img);
+            }
+        }
+        return jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
+    }
+
+    /**
+     * 批量删除问答列-问题
+     *
+     * @param ids 需要删除的问答列-问题主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJnbQuestionByIds(String[] ids) {
+        return jnbQuestionMapper.deleteJnbQuestionByIds(ids);
+    }
+
+    /**
+     * 删除问答列-问题信息
+     *
+     * @param id 问答列-问题主键
+     * @return 结果
+     */
+    @Override
+    public int deleteJnbQuestionById(String id) {
+        return jnbQuestionMapper.deleteJnbQuestionById(id);
+    }
+
+    /*
+    * 审核
+    *
+    * @author 韩福成
+    * @date 2024/3/11 11:25
+    */
+    @Override
+    public int through(JnbQuestion jnbQuestion) {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String data = simpleDateFormat.format(jnbQuestion.getCreateTime());
+        Announcement announcement = new Announcement();
+        announcement.setUserId(IdUtils.simpleUUID());
+        announcement.setCreateBy(SecurityUtils.getUserId().toString());
+        String type = DictUtils.getDictLabel("examine_state",jnbQuestion.getStatus());
+        announcement.setAnnouncementTitle(type+":[问答]");
+        announcement.setAnnouncementBody("您在"+data+"发起的[问答]信息已["+type+"]");
+        announcement.setAnnoType("jnb_question");
+        announcement.setBindId(jnbQuestion.getId());
+        announcementService.insertAnnouncement(announcement);
+        return jnbQuestionMapper.updateJnbQuestion(jnbQuestion);
+    }
+
+    /*
+    * 小程序-获取热门问答列表
+    *
+    * @author 韩福成
+    * @date 2024/3/11 14:28
+    */
+    @Override
+    public List<JnbQuestion> getHotQuestionList(JnbQuestion jnbQuestion) {
+        Long hotNum = Long.valueOf(redisCache.getCacheObject(SYS_CONFIG_KEY + "init_socre").toString());
+        jnbQuestion.setBrowse(hotNum);
+        return jnbQuestionMapper.getHotQuestionList(jnbQuestion);
+    }
+
+    /*
+    * 小程序-按类型查询问题
+    *
+    * @author 韩福成
+    * @date 2024/3/12 13:04
+    */
+    @Override
+    public List<JnbQuestion> getQuestionByType(JnbQuestion jnbQuestion) {
+        List<JnbQuestion> list = jnbQuestionMapper.getQuestionByType(jnbQuestion);
+        for (JnbQuestion ques : list){
+            if (StringUtils.isNotEmpty(ques.getPath())){
+                String[] split = ques.getPath().split(",");
+                ques.setPaths(split);
+            }
+        }
+        return list;
+    }
+
+    /*
+    * 小程序-按类型查询精彩回答问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:53
+    */
+    @Override
+    public List<JnbQuestion> getExcitingAnswersList(JnbQuestion jnbQuestion) {
+        List<JnbQuestion> list = jnbQuestionMapper.getExcitingAnswersList(jnbQuestion);
+        for (JnbQuestion ques : list){
+            if (StringUtils.isNotEmpty(ques.getPath())){
+                String[] split = ques.getPath().split(",");
+                ques.setPaths(split);
+            }
+        }
+        return list;
+    }
+
+    /*
+    * 小程序-按类型查询最多悬赏问题列表
+    *
+    * @author 韩福成
+    * @date 2024/3/12 15:53
+    */
+    @Override
+    public List<JnbQuestion> getMaxScoreList(JnbQuestion jnbQuestion) {
+        List<JnbQuestion> list = jnbQuestionMapper.getMaxScoreList(jnbQuestion);
+        for (JnbQuestion ques : list){
+            if (StringUtils.isNotEmpty(ques.getPath())){
+                String[] split = ques.getPath().split(",");
+                ques.setPaths(split);
+            }
+        }
+        return list;
+    }
+}

+ 106 - 0
sooka-jnb/src/main/resources/mapper/asking/JnbAnswerMapper.xml

@@ -0,0 +1,106 @@
+<?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.JnbAnswerMapper">
+
+    <resultMap type="JnbAnswer" id="JnbAnswerResult">
+        <result property="id"    column="id"    />
+        <result property="questionId"    column="question_id"    />
+        <result property="answer"    column="answer"    />
+        <result property="adopt"    column="adopt"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="dataStatus"    column="data_status"    />
+        <result property="wechatName"    column="wechat_name"    />
+        <result property="name"    column="name"    />
+        <result property="headImg"    column="head_img"    />
+    </resultMap>
+
+    <sql id="selectJnbAnswerVo">
+        select id, question_id, answer, adopt, create_by, create_time, update_by, update_time, data_status from jnb_answer
+    </sql>
+
+    <select id="selectJnbAnswerList" parameterType="JnbAnswer" resultMap="JnbAnswerResult">
+        select
+            a.id,
+            a.question_id,
+            a.answer,
+            a.adopt,
+            a.create_by,
+            a.create_time,
+            a.update_by,
+            a.update_time,
+            a.data_status,
+            b.wechat_name,
+            b.`name`,
+            b.head_img
+        from jnb_answer a
+        left join jnb_wx_user b on a.create_by = b.id
+        where a.data_status =1
+            <if test="questionId != null  and questionId != ''"> and question_id = #{questionId}</if>
+            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
+            <if test="adopt != null  and adopt != ''"> and adopt = #{adopt}</if>
+            <if test="dataStatus != null  and dataStatus != ''"> and data_status = #{dataStatus}</if>
+             order by a.adopt desc ,a.create_time
+    </select>
+
+    <select id="selectJnbAnswerById" parameterType="String" resultMap="JnbAnswerResult">
+        <include refid="selectJnbAnswerVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertJnbAnswer" parameterType="JnbAnswer">
+        insert into jnb_answer
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="questionId != null">question_id,</if>
+            <if test="answer != null">answer,</if>
+            <if test="adopt != null">adopt,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="dataStatus != null">data_status,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="questionId != null">#{questionId},</if>
+            <if test="answer != null">#{answer},</if>
+            <if test="adopt != null">#{adopt},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="dataStatus != null">#{dataStatus},</if>
+        </trim>
+    </insert>
+
+    <update id="updateJnbAnswer" parameterType="JnbAnswer">
+        update jnb_answer
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="questionId != null">question_id = #{questionId},</if>
+            <if test="answer != null">answer = #{answer},</if>
+            <if test="adopt != null">adopt = #{adopt},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="dataStatus != null">data_status = #{dataStatus},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteJnbAnswerById" parameterType="String">
+        delete from jnb_answer where id = #{id}
+    </delete>
+
+    <delete id="deleteJnbAnswerByIds" parameterType="String">
+        delete from jnb_answer where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

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

@@ -0,0 +1,252 @@
+<?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.JnbQuestionMapper">
+    
+    <resultMap type="JnbQuestion" id="JnbQuestionResult">
+        <result property="id"    column="id"    />
+        <result property="title"    column="title"    />
+        <result property="text"    column="text"    />
+        <result property="whetherShow"    column="whether_show"    />
+        <result property="typeId"    column="type_id"    />
+        <result property="type"    column="type"    />
+        <result property="score"    column="score"    />
+        <result property="status"    column="status"    />
+        <result property="browse"    column="browse"    />
+        <result property="comment"    column="comment"    />
+        <result property="comment"    column="comment"    />
+        <result property="collect"    column="collect"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="dataStatus"    column="data_status"    />
+        <result property="path"    column="path"    />
+    </resultMap>
+
+    <sql id="selectJnbQuestionVo">
+        select id, title, text, whether_show, type_id,type, score, status, browse, create_by, create_time, update_by, update_time, data_status from jnb_question
+    </sql>
+
+    <select id="selectJnbQuestionList" parameterType="JnbQuestion" resultMap="JnbQuestionResult">
+        <include refid="selectJnbQuestionVo"/>
+        where data_status = 1
+            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
+            <if test="text != null  and text != ''"> and text = #{text}</if>
+            <if test="whetherShow != null  and whetherShow != ''"> and whether_show = #{whetherShow}</if>
+            <if test="typeId != null  and typeId != ''"> and type_id = #{typeId}</if>
+            <if test="score != null  and score != ''"> and score = #{score}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="browse != null "> and browse = #{browse}</if>
+            <if test="dataStatus != null  and dataStatus != ''"> and data_status = #{dataStatus}</if>
+        order by create_time desc
+    </select>
+
+    <select id="selectJnbQuestionById" parameterType="String" resultMap="JnbQuestionResult">
+        SELECT
+            a.id,
+            a.title,
+            a.text,
+            a.whether_show,
+            a.type_id,
+            a.type,
+            a.score,
+            a.STATUS,
+            a.browse,
+            a.create_by,
+            a.create_time,
+            a.update_by,
+            a.update_time,
+            a.data_status,
+            GROUP_CONCAT(b.path) path,
+			count(c.id) collect
+        FROM
+            jnb_question a
+            left join jnb_question_img b on a.id = b.question_id
+			left join jnb_question_collect c on a.id = c.question_id
+        where a.id = #{id}
+    </select>
+        
+    <insert id="insertJnbQuestion" parameterType="JnbQuestion">
+        insert into jnb_question
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="title != null">title,</if>
+            <if test="text != null">text,</if>
+            <if test="whetherShow != null">whether_show,</if>
+            <if test="typeId != null">type_id,</if>
+            <if test="type != null">type,</if>
+            <if test="score != null">score,</if>
+            <if test="status != null">status,</if>
+            <if test="browse != null">browse,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="dataStatus != null">data_status,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="title != null">#{title},</if>
+            <if test="text != null">#{text},</if>
+            <if test="whetherShow != null">#{whetherShow},</if>
+            <if test="typeId != null">#{typeId},</if>
+            <if test="type != null">#{type},</if>
+            <if test="score != null">#{score},</if>
+            <if test="status != null">#{status},</if>
+            <if test="browse != null">#{browse},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="dataStatus != null">#{dataStatus},</if>
+         </trim>
+    </insert>
+
+    <insert id="insertJnbQuestionImg" parameterType="JnbQuestionImg">
+        insert into jnb_question_img
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="questionId != null">question_id,</if>
+            <if test="path != null">path,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="questionId != null">#{questionId},</if>
+            <if test="path != null">#{path},</if>
+        </trim>
+    </insert>
+
+    <update id="updateJnbQuestion" parameterType="JnbQuestion">
+        update jnb_question
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="title != null">title = #{title},</if>
+            <if test="text != null">text = #{text},</if>
+            <if test="whetherShow != null">whether_show = #{whetherShow},</if>
+            <if test="typeId != null">type_id = #{typeId},</if>
+            <if test="type != null">type = #{type},</if>
+            <if test="score != null">score = #{score},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="browse != null">browse = #{browse},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="dataStatus != null">data_status = #{dataStatus},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteJnbQuestionById" parameterType="String">
+        delete from jnb_question where id = #{id}
+    </delete>
+
+    <delete id="deleteQuestionImg" parameterType="String">
+        delete from jnb_question_img where question_id = #{id}
+    </delete>
+
+    <update id="deleteJnbQuestionByIds" parameterType="String">
+        update jnb_question set data_status = 2
+        where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+    <select id="getHotQuestionList" parameterType="JnbQuestion" resultMap="JnbQuestionResult">
+        SELECT
+            a.id,
+            a.title,
+            a.type,
+            a.score,
+            a.browse,
+            count(b.id) comment,
+            count(c.id) collect
+        FROM
+            jnb_question a
+            LEFT JOIN jnb_answer b on a.id = b.question_id and b.data_status = 1
+            LEFT JOIN jnb_question_collect c on a.id = c.question_id
+        WHERE
+            a.data_status = 1
+            and a.status = 1
+            and a.whether_show = 'Y'
+            and a.browse >= #{browse}
+            GROUP BY a.id
+    </select>
+
+    <select id="getQuestionByType" parameterType="JnbQuestion" resultMap="JnbQuestionResult">
+        SELECT
+            a.id,
+            a.title,
+            a.text,
+            a.score,
+            a.browse,
+            GROUP_CONCAT(b.path) path,
+            a.create_by,
+            count(c.id) comment,
+	        count(d.id)  collect
+        FROM
+            jnb_question a
+            left join jnb_question_img b on a.id = b.question_id
+            left join jnb_answer c on a.id = c.question_id and c.data_status = 1
+	        left join jnb_question_collect d on a.id = d.question_id
+        WHERE
+            a.data_status = 1
+            and a.`status` = 1
+            and a.whether_show = 'Y'
+            and a.type_id = #{id}
+            GROUP BY a.id
+            order by a.create_time desc
+    </select>
+
+    <select id="getExcitingAnswersList" parameterType="JnbQuestion" resultMap="JnbQuestionResult">
+        SELECT
+            a.id,
+            a.title,
+            a.text,
+            a.score,
+            a.browse,
+            GROUP_CONCAT(b.path) path,
+            a.create_by,
+            count(c.id) comment,
+	        count(d.id)  collect
+        FROM
+            jnb_question a
+            left join jnb_question_img b on a.id = b.question_id
+            left join jnb_answer c on a.id = c.question_id and c.data_status = 1
+	        left join jnb_question_collect d on a.id = d.question_id
+        WHERE
+            a.data_status = 1
+            and a.`status` = 1
+            and a.whether_show = 'Y'
+            and a.type_id = #{id}
+            GROUP BY a.id
+            order by count(d.id) desc,comment desc,a.browse desc,a.create_time desc
+    </select>
+
+    <select id="getMaxScoreList" parameterType="JnbQuestion" resultMap="JnbQuestionResult">
+        SELECT
+            a.id,
+            a.title,
+            a.text,
+            a.score,
+            a.browse,
+            GROUP_CONCAT(b.path) path,
+            a.create_by,
+            count(c.id) comment,
+	        count(d.id)  collect
+        FROM
+            jnb_question a
+            left join jnb_question_img b on a.id = b.question_id
+            left join jnb_answer c on a.id = c.question_id and c.data_status = 1
+	        left join jnb_question_collect d on a.id = d.question_id
+        WHERE
+            a.data_status = 1
+            and a.`status` = 1
+            and a.whether_show = 'Y'
+            and a.type_id = #{id}
+            GROUP BY a.id
+            order by a.score desc
+    </select>
+</mapper>

+ 4 - 1
sooka-jnb/src/main/resources/mapper/asking/JnbQuestionTypeMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="whetherShow"    column="whether_show"    />
         <result property="path"    column="path"    />
         <result property="imgId"    column="imgId"    />
+        <result property="questionNum"    column="questionNum"    />
     </resultMap>
 
     <sql id="selectJnbQuestionTypeVo">
@@ -17,11 +18,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectJnbQuestionTypeList" parameterType="JnbQuestionType" resultMap="JnbQuestionTypeResult">
-        select a.id, a.type, a.whether_show, b.path from jnb_question_type a
+        select a.id, a.type, a.whether_show, b.path,count(c.id) questionNum from jnb_question_type a
         left join jnb_question_type_img b on a.id = b.type_id
+        LEFT JOIN jnb_question c ON a.id = c.type_id AND c.data_status = 1 and c.whether_show = 'Y' and c.status =1
         where a.data_status =1
             <if test="type != null  and type != ''"> and a.type like concat('%', #{type}, '%')</if>
             <if test="whetherShow != null  and whetherShow != ''"> and a.whether_show = #{whetherShow}</if>
+        GROUP BY a.id
         order by a.create_time desc
     </select>