From 4277c6658bd3024396ac3a1068872924dda41f5c Mon Sep 17 00:00:00 2001 From: maotiantian Date: Thu, 5 Feb 2026 10:39:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E9=97=AE=E7=AD=94=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../muhu/MuhuExperienceShareController.java | 104 +++ .../system/SysAnswerAgainController.java | 128 ++++ .../system/SysAnswersController.java | 101 ++- .../system/SysMuhuUserController.java | 104 +++ .../system/SysQuestionsController.java | 32 +- .../muhu/domain/MuhuExperienceShare.java | 433 ++++++++++++ .../mapper/MuhuExperienceShareMapper.java | 61 ++ .../service/IMuhuExperienceShareService.java | 61 ++ .../impl/MuhuExperienceShareServiceImpl.java | 93 +++ .../chenhai/system/domain/SysAnswerAgain.java | 155 +++++ .../com/chenhai/system/domain/SysAnswers.java | 169 ++++- .../chenhai/system/domain/SysMuhuUser.java | 222 ++++++ .../chenhai/system/domain/SysQuestions.java | 40 ++ .../system/mapper/SysAnswerAgainMapper.java | 61 ++ .../system/mapper/SysAnswersMapper.java | 51 ++ .../system/mapper/SysMuhuUserMapper.java | 61 ++ .../service/ISysAnswerAgainService.java | 61 ++ .../system/service/ISysAnswersService.java | 57 ++ .../system/service/ISysMuhuUserService.java | 61 ++ .../impl/SysAnswerAgainServiceImpl.java | 121 ++++ .../service/impl/SysAnswersServiceImpl.java | 370 +++++++++- .../service/impl/SysMuhuUserServiceImpl.java | 95 +++ .../service/impl/SysQuestionsServiceImpl.java | 36 +- .../mapper/muhu/MuhuExperienceShareMapper.xml | 181 +++++ .../mapper/system/SysAnswerAgainMapper.xml | 94 +++ .../mapper/system/SysAnswersMapper.xml | 96 ++- .../mapper/system/SysMuhuUserMapper.xml | 117 ++++ .../mapper/system/SysQuestionsMapper.xml | 22 +- chenhai-ui/src/api/muhu/share.js | 44 ++ chenhai-ui/src/api/system/again.js | 44 ++ chenhai-ui/src/api/system/answers.js | 61 ++ chenhai-ui/src/api/system/muhuuser.js | 44 ++ chenhai-ui/src/router/index.js | 66 -- chenhai-ui/src/views/muhu/share/index.vue | 440 ++++++++++++ chenhai-ui/src/views/system/again/index.vue | 275 ++++++++ chenhai-ui/src/views/system/answers/index.vue | 645 ++++++++++++++++-- .../src/views/system/muhuuser/index.vue | 323 +++++++++ .../src/views/system/questions/index.vue | 262 +++---- 38 files changed, 5001 insertions(+), 390 deletions(-) create mode 100644 chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuExperienceShareController.java create mode 100644 chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswerAgainController.java create mode 100644 chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysMuhuUserController.java create mode 100644 chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuExperienceShare.java create mode 100644 chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuExperienceShareMapper.java create mode 100644 chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuExperienceShareService.java create mode 100644 chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuExperienceShareServiceImpl.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswerAgain.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/domain/SysMuhuUser.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswerAgainMapper.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/mapper/SysMuhuUserMapper.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswerAgainService.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/service/ISysMuhuUserService.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswerAgainServiceImpl.java create mode 100644 chenhai-system/src/main/java/com/chenhai/system/service/impl/SysMuhuUserServiceImpl.java create mode 100644 chenhai-system/src/main/resources/mapper/muhu/MuhuExperienceShareMapper.xml create mode 100644 chenhai-system/src/main/resources/mapper/system/SysAnswerAgainMapper.xml create mode 100644 chenhai-system/src/main/resources/mapper/system/SysMuhuUserMapper.xml create mode 100644 chenhai-ui/src/api/muhu/share.js create mode 100644 chenhai-ui/src/api/system/again.js create mode 100644 chenhai-ui/src/api/system/muhuuser.js create mode 100644 chenhai-ui/src/views/muhu/share/index.vue create mode 100644 chenhai-ui/src/views/system/again/index.vue create mode 100644 chenhai-ui/src/views/system/muhuuser/index.vue diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuExperienceShareController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuExperienceShareController.java new file mode 100644 index 0000000..d5cfcdd --- /dev/null +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuExperienceShareController.java @@ -0,0 +1,104 @@ +package com.chenhai.web.controller.muhu; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +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.chenhai.common.annotation.Log; +import com.chenhai.common.core.controller.BaseController; +import com.chenhai.common.core.domain.AjaxResult; +import com.chenhai.common.enums.BusinessType; +import com.chenhai.muhu.domain.MuhuExperienceShare; +import com.chenhai.muhu.service.IMuhuExperienceShareService; +import com.chenhai.common.utils.poi.ExcelUtil; +import com.chenhai.common.core.page.TableDataInfo; + +/** + * 经验分享Controller + * + * @author ruoyi + * @date 2026-01-30 + */ +@RestController +@RequestMapping("/muhu/share") +public class MuhuExperienceShareController extends BaseController +{ + @Autowired + private IMuhuExperienceShareService muhuExperienceShareService; + + /** + * 查询经验分享列表 + */ + @PreAuthorize("@ss.hasPermi('muhu:share:list')") + @GetMapping("/list") + public TableDataInfo list(MuhuExperienceShare muhuExperienceShare) + { + startPage(); + List list = muhuExperienceShareService.selectMuhuExperienceShareList(muhuExperienceShare); + return getDataTable(list); + } + + /** + * 导出经验分享列表 + */ + @PreAuthorize("@ss.hasPermi('muhu:share:export')") + @Log(title = "经验分享", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MuhuExperienceShare muhuExperienceShare) + { + List list = muhuExperienceShareService.selectMuhuExperienceShareList(muhuExperienceShare); + ExcelUtil util = new ExcelUtil(MuhuExperienceShare.class); + util.exportExcel(response, list, "经验分享数据"); + } + + /** + * 获取经验分享详细信息 + */ + @PreAuthorize("@ss.hasPermi('muhu:share:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(muhuExperienceShareService.selectMuhuExperienceShareById(id)); + } + + /** + * 新增经验分享 + */ + @PreAuthorize("@ss.hasPermi('muhu:share:add')") + @Log(title = "经验分享", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MuhuExperienceShare muhuExperienceShare) + { + return toAjax(muhuExperienceShareService.insertMuhuExperienceShare(muhuExperienceShare)); + } + + /** + * 修改经验分享 + */ + @PreAuthorize("@ss.hasPermi('muhu:share:edit')") + @Log(title = "经验分享", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MuhuExperienceShare muhuExperienceShare) + { + return toAjax(muhuExperienceShareService.updateMuhuExperienceShare(muhuExperienceShare)); + } + + /** + * 删除经验分享 + */ + @PreAuthorize("@ss.hasPermi('muhu:share:remove')") + @Log(title = "经验分享", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(muhuExperienceShareService.deleteMuhuExperienceShareByIds(ids)); + } +} diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswerAgainController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswerAgainController.java new file mode 100644 index 0000000..ec5e426 --- /dev/null +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswerAgainController.java @@ -0,0 +1,128 @@ +package com.chenhai.web.controller.system; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +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.chenhai.common.annotation.Log; +import com.chenhai.common.core.controller.BaseController; +import com.chenhai.common.core.domain.AjaxResult; +import com.chenhai.common.enums.BusinessType; +import com.chenhai.common.utils.SecurityUtils; +import com.chenhai.system.domain.SysAnswerAgain; +import com.chenhai.system.service.ISysAnswerAgainService; +import com.chenhai.common.utils.poi.ExcelUtil; +import com.chenhai.common.core.page.TableDataInfo; + +/** + * 回复Controller + * + * @author ruoyi + * @date 2026-02-02 + */ +@RestController +@RequestMapping("/system/again") +public class SysAnswerAgainController extends BaseController +{ + @Autowired + private ISysAnswerAgainService sysAnswerAgainService; + + /** + * 查询回复列表 + */ + @PreAuthorize("@ss.hasPermi('system:again:list') or @ss.hasRole('muhu')") + @GetMapping("/list") + public TableDataInfo list(SysAnswerAgain sysAnswerAgain) + { + startPage(); + List list = sysAnswerAgainService.selectSysAnswerAgainList(sysAnswerAgain); + return getDataTable(list); + } + + /** + * 导出回复列表 + */ + @PreAuthorize("@ss.hasPermi('system:again:export') or @ss.hasRole('muhu')") + @Log(title = "回复", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SysAnswerAgain sysAnswerAgain) + { + List list = sysAnswerAgainService.selectSysAnswerAgainList(sysAnswerAgain); + ExcelUtil util = new ExcelUtil(SysAnswerAgain.class); + util.exportExcel(response, list, "回复数据"); + } + + /** + * 获取回复详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:again:query') or @ss.hasRole('muhu')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sysAnswerAgainService.selectSysAnswerAgainById(id)); + } + + /** + * 新增回复 + */ + @PreAuthorize("@ss.hasPermi('system:again:add') or @ss.hasRole('muhu')") + @Log(title = "回复", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysAnswerAgain sysAnswerAgain) + { + // 可以在这里验证 answerId 是否为空 + if (sysAnswerAgain.getAnswerId() == null) { + return error("对应的回复ID不能为空"); + } + + return toAjax(sysAnswerAgainService.insertSysAnswerAgain(sysAnswerAgain)); + } + + /** + * 修改回复 + */ + @PreAuthorize("@ss.hasPermi('system:again:edit') or @ss.hasRole('muhu')") + @Log(title = "回复", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysAnswerAgain sysAnswerAgain) + { + // 验证权限:只能修改自己的回复 + SysAnswerAgain existing = sysAnswerAgainService.selectSysAnswerAgainById(sysAnswerAgain.getId()); + if (existing != null) { + Long currentUserId = SecurityUtils.getUserId(); + if (!existing.getUserId().equals(currentUserId.toString())) { + return error("只能修改自己的回复"); + } + } + + return toAjax(sysAnswerAgainService.updateSysAnswerAgain(sysAnswerAgain)); + } + + /** + * 删除回复 + */ + @PreAuthorize("@ss.hasPermi('system:again:remove') or @ss.hasRole('muhu')") + @Log(title = "回复", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + // 验证权限:只能删除自己的回复 + Long currentUserId = SecurityUtils.getUserId(); + for (Long id : ids) { + SysAnswerAgain existing = sysAnswerAgainService.selectSysAnswerAgainById(id); + if (existing != null && !existing.getUserId().equals(currentUserId.toString())) { + return error("只能删除自己的回复"); + } + } + + return toAjax(sysAnswerAgainService.deleteSysAnswerAgainByIds(ids)); + } +} \ No newline at end of file diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswersController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswersController.java index bd41d8f..b113014 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswersController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysAnswersController.java @@ -1,6 +1,8 @@ package com.chenhai.web.controller.system; import java.util.List; + +import com.chenhai.common.exception.ServiceException; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +43,7 @@ public class SysAnswersController extends BaseController /** * 查询答复列表 */ - @PreAuthorize("@ss.hasPermi('system:answers:list')") + @PreAuthorize("@ss.hasPermi('system:answers:list') or @ss.hasRole('muhu')") @GetMapping("/list") public TableDataInfo list(SysAnswers sysAnswers) { @@ -50,10 +52,42 @@ public class SysAnswersController extends BaseController return getDataTable(list); } + /** + * 根据问题ID查询顶级答复列表 + */ + @GetMapping("/question/{questionId}/roots") + public TableDataInfo listRootAnswers(@PathVariable("questionId") Long questionId) + { + startPage(); + List list = sysAnswersService.selectRootAnswers(questionId); + return getDataTable(list); + } + + /** + * 根据问题ID查询答复树形结构 + */ + @GetMapping("/question/{questionId}/tree") + public AjaxResult getAnswerTree(@PathVariable("questionId") Long questionId) + { + List tree = sysAnswersService.selectAnswerTree(questionId); + return success(tree); + } + + /** + * 根据父级ID查询子回复列表 + */ + @GetMapping("/parent/{parentId}/children") + public TableDataInfo listChildrenAnswers(@PathVariable("parentId") Long parentId) + { + startPage(); + List list = sysAnswersService.selectChildrenAnswers(parentId); + return getDataTable(list); + } + /** * 根据问题ID查询答复列表 */ - @PreAuthorize("@ss.hasPermi('system:answers:list')") + @PreAuthorize("@ss.hasPermi('system:answers:list') or @ss.hasRole('muhu')") @GetMapping("/question/{questionId}") public TableDataInfo listByQuestionId(@PathVariable("questionId") Long questionId) { @@ -65,7 +99,7 @@ public class SysAnswersController extends BaseController /** * 导出答复列表 */ - @PreAuthorize("@ss.hasPermi('system:answers:export')") + @PreAuthorize("@ss.hasPermi('system:answers:export') or @ss.hasRole('muhu')") @Log(title = "答复", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SysAnswers sysAnswers) @@ -78,7 +112,7 @@ public class SysAnswersController extends BaseController /** * 获取答复详细信息 */ - @PreAuthorize("@ss.hasPermi('system:answers:query')") + @PreAuthorize("@ss.hasPermi('system:answers:query') or @ss.hasRole('muhu')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -88,16 +122,11 @@ public class SysAnswersController extends BaseController /** * 新增答复(使用当前登录用户信息) */ - @PreAuthorize("@ss.hasPermi('system:answers:add')") + @PreAuthorize("@ss.hasPermi('system:answers:add') or @ss.hasRole('muhu')") @Log(title = "答复", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SysAnswers sysAnswers) { - // 验证问题是否存在 - if (sysAnswers.getQuestionId() == null) { - return error("问题ID不能为空"); - } - // 检查问题是否存在 try { sysQuestionsService.selectSysQuestionsById(sysAnswers.getQuestionId()); @@ -109,9 +138,57 @@ public class SysAnswersController extends BaseController } /** - * 修改答复 + * 新增回复 + */ + @PreAuthorize("@ss.hasPermi('system:answers:add') or @ss.hasRole('muhu')") + @Log(title = "回复", businessType = BusinessType.INSERT) + @PostMapping("/reply") + public AjaxResult addReply(@RequestBody SysAnswers sysAnswers) + { + try { + int result = sysAnswersService.insertReply(sysAnswers); + return toAjax(result); + } catch (ServiceException e) { + return error(e.getMessage()); + } + } + + /** + * 点赞答复 + */ + @PreAuthorize("@ss.hasPermi('system:answers:edit')") + @Log(title = "点赞答复", businessType = BusinessType.UPDATE) + @PostMapping("/{id}/like") + public AjaxResult like(@PathVariable("id") Long id) + { + try { + int result = sysAnswersService.likeAnswer(id); + return toAjax(result); + } catch (ServiceException e) { + return error(e.getMessage()); + } + } + + /** + * 取消点赞答复 */ @PreAuthorize("@ss.hasPermi('system:answers:edit')") + @Log(title = "取消点赞答复", businessType = BusinessType.UPDATE) + @PostMapping("/{id}/unlike") + public AjaxResult unlike(@PathVariable("id") Long id) + { + try { + int result = sysAnswersService.unlikeAnswer(id); + return toAjax(result); + } catch (ServiceException e) { + return error(e.getMessage()); + } + } + + /** + * 修改答复 + */ + @PreAuthorize("@ss.hasPermi('system:answers:edit') or @ss.hasRole('muhu')") @Log(title = "答复", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SysAnswers sysAnswers) @@ -122,7 +199,7 @@ public class SysAnswersController extends BaseController /** * 删除答复 */ - @PreAuthorize("@ss.hasPermi('system:answers:remove')") + @PreAuthorize("@ss.hasPermi('system:answers:remove') or @ss.hasRole('muhu')") @Log(title = "答复", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysMuhuUserController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysMuhuUserController.java new file mode 100644 index 0000000..f871930 --- /dev/null +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysMuhuUserController.java @@ -0,0 +1,104 @@ +package com.chenhai.web.controller.system; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +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.chenhai.common.annotation.Log; +import com.chenhai.common.core.controller.BaseController; +import com.chenhai.common.core.domain.AjaxResult; +import com.chenhai.common.enums.BusinessType; +import com.chenhai.system.domain.SysMuhuUser; +import com.chenhai.system.service.ISysMuhuUserService; +import com.chenhai.common.utils.poi.ExcelUtil; +import com.chenhai.common.core.page.TableDataInfo; + +/** + * 牧户用户Controller + * + * @author ruoyi + * @date 2026-02-03 + */ +@RestController +@RequestMapping("/system/muhuuser") +public class SysMuhuUserController extends BaseController +{ + @Autowired + private ISysMuhuUserService sysMuhuUserService; + + /** + * 查询牧户用户列表 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:list')") + @GetMapping("/list") + public TableDataInfo list(SysMuhuUser sysMuhuUser) + { + startPage(); + List list = sysMuhuUserService.selectSysMuhuUserList(sysMuhuUser); + return getDataTable(list); + } + + /** + * 导出牧户用户列表 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:export')") + @Log(title = "牧户用户", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SysMuhuUser sysMuhuUser) + { + List list = sysMuhuUserService.selectSysMuhuUserList(sysMuhuUser); + ExcelUtil util = new ExcelUtil(SysMuhuUser.class); + util.exportExcel(response, list, "牧户用户数据"); + } + + /** + * 获取牧户用户详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:query')") + @GetMapping(value = "/{userId}") + public AjaxResult getInfo(@PathVariable("userId") Long userId) + { + return success(sysMuhuUserService.selectSysMuhuUserByUserId(userId)); + } + + /** + * 新增牧户用户 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:add')") + @Log(title = "牧户用户", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysMuhuUser sysMuhuUser) + { + return toAjax(sysMuhuUserService.insertSysMuhuUser(sysMuhuUser)); + } + + /** + * 修改牧户用户 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:edit')") + @Log(title = "牧户用户", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysMuhuUser sysMuhuUser) + { + return toAjax(sysMuhuUserService.updateSysMuhuUser(sysMuhuUser)); + } + + /** + * 删除牧户用户 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:remove')") + @Log(title = "牧户用户", businessType = BusinessType.DELETE) + @DeleteMapping("/{userIds}") + public AjaxResult remove(@PathVariable Long[] userIds) + { + return toAjax(sysMuhuUserService.deleteSysMuhuUserByUserIds(userIds)); + } +} diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysQuestionsController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysQuestionsController.java index 5614b84..4fd167e 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysQuestionsController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysQuestionsController.java @@ -1,5 +1,6 @@ package com.chenhai.web.controller.system; +import java.util.Date; import java.util.List; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; @@ -47,7 +48,7 @@ public class SysQuestionsController extends BaseController /** * 查询问答列表 */ - @PreAuthorize("@ss.hasPermi('system:questions:list')") + @PreAuthorize("@ss.hasPermi('system:questions:list') or @ss.hasRole('muhu')") @GetMapping("/list") public TableDataInfo list(SysQuestions sysQuestions) { @@ -59,7 +60,7 @@ public class SysQuestionsController extends BaseController /** * 导出问答列表 */ - @PreAuthorize("@ss.hasPermi('system:questions:export')") + @PreAuthorize("@ss.hasPermi('system:questions:export') or @ss.hasRole('muhu')") @Log(title = "问答", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SysQuestions sysQuestions) @@ -72,17 +73,34 @@ public class SysQuestionsController extends BaseController /** * 获取问答详细信息 */ - @PreAuthorize("@ss.hasPermi('system:questions:query')") + @PreAuthorize("@ss.hasPermi('system:questions:query') or @ss.hasRole('muhu')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { - return success(sysQuestionsService.selectSysQuestionsById(id)); + // 先获取问题详情 + SysQuestions question = sysQuestionsService.selectSysQuestionsById(id); + if (question == null) { + return error("问题不存在"); + } + + // 增加观看次数 + Long currentViewCount = question.getViewCount() != null ? question.getViewCount() : 0; + question.setViewCount(currentViewCount + 1); + question.setUpdatedAt(new Date()); + + // 保存更新后的浏览量 + Long currentUserId = getCurrentUserId(); + sysQuestionsService.updateSysQuestions(question, currentUserId); + + // 重新获取更新后的问题详情 + question = sysQuestionsService.selectSysQuestionsById(id); + return success(question); } /** * 新增问答 */ - @PreAuthorize("@ss.hasPermi('system:questions:add')") + @PreAuthorize("@ss.hasPermi('system:questions:add') or @ss.hasRole('muhu')") @Log(title = "问答", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SysQuestions sysQuestions) @@ -94,7 +112,7 @@ public class SysQuestionsController extends BaseController /** * 修改问答 */ - @PreAuthorize("@ss.hasPermi('system:questions:edit')") + @PreAuthorize("@ss.hasPermi('system:questions:edit') or @ss.hasRole('muhu')") @Log(title = "问答", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SysQuestions sysQuestions) @@ -106,7 +124,7 @@ public class SysQuestionsController extends BaseController /** * 删除问答 */ - @PreAuthorize("@ss.hasPermi('system:questions:remove')") + @PreAuthorize("@ss.hasPermi('system:questions:remove') or @ss.hasRole('muhu')") @Log(title = "问答", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuExperienceShare.java b/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuExperienceShare.java new file mode 100644 index 0000000..96d4f6f --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuExperienceShare.java @@ -0,0 +1,433 @@ +package com.chenhai.muhu.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.chenhai.common.annotation.Excel; +import com.chenhai.common.core.domain.BaseEntity; + +/** + * 经验分享对象 muhu_experience_share + * + * @author ruoyi + * @date 2026-01-30 + */ +public class MuhuExperienceShare extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** 发布用户ID */ + @Excel(name = "发布用户ID") + private Long userId; + + /** 发布用户名 */ + @Excel(name = "发布用户名") + private String username; + + /** 用户昵称 */ + @Excel(name = "用户昵称") + private String userNickname; + + /** 用户头像 */ + @Excel(name = "用户头像") + private String userAvatar; + + /** 文章标题 */ + @Excel(name = "文章标题") + private String title; + + /** 文章内容 */ + @Excel(name = "文章内容") + private String content; + + /** 文章摘要 */ + @Excel(name = "文章摘要") + private String summary; + + /** 分类(如:养殖技术、疾病防治等) */ + @Excel(name = "分类", readConverterExp = "如=:养殖技术、疾病防治等") + private String category; + + /** 标签(多个用逗号分隔) */ + @Excel(name = "标签", readConverterExp = "多=个用逗号分隔") + private String tags; + + /** 封面图片 */ + @Excel(name = "封面图片") + private String coverImage; + + /** 文章图片(多个用逗号分隔) */ + @Excel(name = "文章图片", readConverterExp = "多=个用逗号分隔") + private String images; + + /** 附件(多个用逗号分隔) */ + @Excel(name = "附件", readConverterExp = "多=个用逗号分隔") + private String attachments; + + /** 状态(0-待审核,1-已发布,2-审核不通过,3-已下架) */ + @Excel(name = "状态", readConverterExp = "0=-待审核,1-已发布,2-审核不通过,3-已下架") + private Integer status; + + /** 审核备注 */ + @Excel(name = "审核备注") + private String auditRemark; + + /** 审核时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date auditTime; + + /** 审核人ID */ + @Excel(name = "审核人ID") + private Long auditUserId; + + /** 是否包含敏感词(0-否,1-是) */ + @Excel(name = "是否包含敏感词", readConverterExp = "0=-否,1-是") + private Integer hasSensitive; + + /** 敏感词列表(多个用逗号分隔) */ + @Excel(name = "敏感词列表", readConverterExp = "多=个用逗号分隔") + private String sensitiveWords; + + /** 是否已处理敏感词(0-未处理,1-已处理) */ + @Excel(name = "是否已处理敏感词", readConverterExp = "0=-未处理,1-已处理") + private Integer isHandled; + + /** 浏览次数 */ + @Excel(name = "浏览次数") + private Long viewCount; + + /** 点赞数 */ + @Excel(name = "点赞数") + private Long likeCount; + + /** 收藏数 */ + @Excel(name = "收藏数") + private Long collectCount; + + /** 分享数 */ + @Excel(name = "分享数") + private Long shareCount; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdAt; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date updatedAt; + + /** 发布时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date publishedAt; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + + public void setUsername(String username) + { + this.username = username; + } + + public String getUsername() + { + return username; + } + + public void setUserNickname(String userNickname) + { + this.userNickname = userNickname; + } + + public String getUserNickname() + { + return userNickname; + } + + public void setUserAvatar(String userAvatar) + { + this.userAvatar = userAvatar; + } + + public String getUserAvatar() + { + return userAvatar; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getTitle() + { + return title; + } + + public void setContent(String content) + { + this.content = content; + } + + public String getContent() + { + return content; + } + + public void setSummary(String summary) + { + this.summary = summary; + } + + public String getSummary() + { + return summary; + } + + public void setCategory(String category) + { + this.category = category; + } + + public String getCategory() + { + return category; + } + + public void setTags(String tags) + { + this.tags = tags; + } + + public String getTags() + { + return tags; + } + + public void setCoverImage(String coverImage) + { + this.coverImage = coverImage; + } + + public String getCoverImage() + { + return coverImage; + } + + public void setImages(String images) + { + this.images = images; + } + + public String getImages() + { + return images; + } + + public void setAttachments(String attachments) + { + this.attachments = attachments; + } + + public String getAttachments() + { + return attachments; + } + + public void setStatus(Integer status) + { + this.status = status; + } + + public Integer getStatus() + { + return status; + } + + public void setAuditRemark(String auditRemark) + { + this.auditRemark = auditRemark; + } + + public String getAuditRemark() + { + return auditRemark; + } + + public void setAuditTime(Date auditTime) + { + this.auditTime = auditTime; + } + + public Date getAuditTime() + { + return auditTime; + } + + public void setAuditUserId(Long auditUserId) + { + this.auditUserId = auditUserId; + } + + public Long getAuditUserId() + { + return auditUserId; + } + + public void setHasSensitive(Integer hasSensitive) + { + this.hasSensitive = hasSensitive; + } + + public Integer getHasSensitive() + { + return hasSensitive; + } + + public void setSensitiveWords(String sensitiveWords) + { + this.sensitiveWords = sensitiveWords; + } + + public String getSensitiveWords() + { + return sensitiveWords; + } + + public void setIsHandled(Integer isHandled) + { + this.isHandled = isHandled; + } + + public Integer getIsHandled() + { + return isHandled; + } + + public void setViewCount(Long viewCount) + { + this.viewCount = viewCount; + } + + public Long getViewCount() + { + return viewCount; + } + + public void setLikeCount(Long likeCount) + { + this.likeCount = likeCount; + } + + public Long getLikeCount() + { + return likeCount; + } + + public void setCollectCount(Long collectCount) + { + this.collectCount = collectCount; + } + + public Long getCollectCount() + { + return collectCount; + } + + public void setShareCount(Long shareCount) + { + this.shareCount = shareCount; + } + + public Long getShareCount() + { + return shareCount; + } + + public void setCreatedAt(Date createdAt) + { + this.createdAt = createdAt; + } + + public Date getCreatedAt() + { + return createdAt; + } + + public void setUpdatedAt(Date updatedAt) + { + this.updatedAt = updatedAt; + } + + public Date getUpdatedAt() + { + return updatedAt; + } + + public void setPublishedAt(Date publishedAt) + { + this.publishedAt = publishedAt; + } + + public Date getPublishedAt() + { + return publishedAt; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("userId", getUserId()) + .append("username", getUsername()) + .append("userNickname", getUserNickname()) + .append("userAvatar", getUserAvatar()) + .append("title", getTitle()) + .append("content", getContent()) + .append("summary", getSummary()) + .append("category", getCategory()) + .append("tags", getTags()) + .append("coverImage", getCoverImage()) + .append("images", getImages()) + .append("attachments", getAttachments()) + .append("status", getStatus()) + .append("auditRemark", getAuditRemark()) + .append("auditTime", getAuditTime()) + .append("auditUserId", getAuditUserId()) + .append("hasSensitive", getHasSensitive()) + .append("sensitiveWords", getSensitiveWords()) + .append("isHandled", getIsHandled()) + .append("viewCount", getViewCount()) + .append("likeCount", getLikeCount()) + .append("collectCount", getCollectCount()) + .append("shareCount", getShareCount()) + .append("createdAt", getCreatedAt()) + .append("updatedAt", getUpdatedAt()) + .append("publishedAt", getPublishedAt()) + .toString(); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuExperienceShareMapper.java b/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuExperienceShareMapper.java new file mode 100644 index 0000000..ae4c653 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuExperienceShareMapper.java @@ -0,0 +1,61 @@ +package com.chenhai.muhu.mapper; + +import java.util.List; +import com.chenhai.muhu.domain.MuhuExperienceShare; + +/** + * 经验分享Mapper接口 + * + * @author ruoyi + * @date 2026-01-30 + */ +public interface MuhuExperienceShareMapper +{ + /** + * 查询经验分享 + * + * @param id 经验分享主键 + * @return 经验分享 + */ + public MuhuExperienceShare selectMuhuExperienceShareById(Long id); + + /** + * 查询经验分享列表 + * + * @param muhuExperienceShare 经验分享 + * @return 经验分享集合 + */ + public List selectMuhuExperienceShareList(MuhuExperienceShare muhuExperienceShare); + + /** + * 新增经验分享 + * + * @param muhuExperienceShare 经验分享 + * @return 结果 + */ + public int insertMuhuExperienceShare(MuhuExperienceShare muhuExperienceShare); + + /** + * 修改经验分享 + * + * @param muhuExperienceShare 经验分享 + * @return 结果 + */ + public int updateMuhuExperienceShare(MuhuExperienceShare muhuExperienceShare); + + /** + * 删除经验分享 + * + * @param id 经验分享主键 + * @return 结果 + */ + public int deleteMuhuExperienceShareById(Long id); + + /** + * 批量删除经验分享 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMuhuExperienceShareByIds(Long[] ids); +} diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuExperienceShareService.java b/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuExperienceShareService.java new file mode 100644 index 0000000..c89b0ec --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuExperienceShareService.java @@ -0,0 +1,61 @@ +package com.chenhai.muhu.service; + +import java.util.List; +import com.chenhai.muhu.domain.MuhuExperienceShare; + +/** + * 经验分享Service接口 + * + * @author ruoyi + * @date 2026-01-30 + */ +public interface IMuhuExperienceShareService +{ + /** + * 查询经验分享 + * + * @param id 经验分享主键 + * @return 经验分享 + */ + public MuhuExperienceShare selectMuhuExperienceShareById(Long id); + + /** + * 查询经验分享列表 + * + * @param muhuExperienceShare 经验分享 + * @return 经验分享集合 + */ + public List selectMuhuExperienceShareList(MuhuExperienceShare muhuExperienceShare); + + /** + * 新增经验分享 + * + * @param muhuExperienceShare 经验分享 + * @return 结果 + */ + public int insertMuhuExperienceShare(MuhuExperienceShare muhuExperienceShare); + + /** + * 修改经验分享 + * + * @param muhuExperienceShare 经验分享 + * @return 结果 + */ + public int updateMuhuExperienceShare(MuhuExperienceShare muhuExperienceShare); + + /** + * 批量删除经验分享 + * + * @param ids 需要删除的经验分享主键集合 + * @return 结果 + */ + public int deleteMuhuExperienceShareByIds(Long[] ids); + + /** + * 删除经验分享信息 + * + * @param id 经验分享主键 + * @return 结果 + */ + public int deleteMuhuExperienceShareById(Long id); +} diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuExperienceShareServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuExperienceShareServiceImpl.java new file mode 100644 index 0000000..a1b88c9 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuExperienceShareServiceImpl.java @@ -0,0 +1,93 @@ +package com.chenhai.muhu.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chenhai.muhu.mapper.MuhuExperienceShareMapper; +import com.chenhai.muhu.domain.MuhuExperienceShare; +import com.chenhai.muhu.service.IMuhuExperienceShareService; + +/** + * 经验分享Service业务层处理 + * + * @author ruoyi + * @date 2026-01-30 + */ +@Service +public class MuhuExperienceShareServiceImpl implements IMuhuExperienceShareService +{ + @Autowired + private MuhuExperienceShareMapper muhuExperienceShareMapper; + + /** + * 查询经验分享 + * + * @param id 经验分享主键 + * @return 经验分享 + */ + @Override + public MuhuExperienceShare selectMuhuExperienceShareById(Long id) + { + return muhuExperienceShareMapper.selectMuhuExperienceShareById(id); + } + + /** + * 查询经验分享列表 + * + * @param muhuExperienceShare 经验分享 + * @return 经验分享 + */ + @Override + public List selectMuhuExperienceShareList(MuhuExperienceShare muhuExperienceShare) + { + return muhuExperienceShareMapper.selectMuhuExperienceShareList(muhuExperienceShare); + } + + /** + * 新增经验分享 + * + * @param muhuExperienceShare 经验分享 + * @return 结果 + */ + @Override + public int insertMuhuExperienceShare(MuhuExperienceShare muhuExperienceShare) + { + return muhuExperienceShareMapper.insertMuhuExperienceShare(muhuExperienceShare); + } + + /** + * 修改经验分享 + * + * @param muhuExperienceShare 经验分享 + * @return 结果 + */ + @Override + public int updateMuhuExperienceShare(MuhuExperienceShare muhuExperienceShare) + { + return muhuExperienceShareMapper.updateMuhuExperienceShare(muhuExperienceShare); + } + + /** + * 批量删除经验分享 + * + * @param ids 需要删除的经验分享主键 + * @return 结果 + */ + @Override + public int deleteMuhuExperienceShareByIds(Long[] ids) + { + return muhuExperienceShareMapper.deleteMuhuExperienceShareByIds(ids); + } + + /** + * 删除经验分享信息 + * + * @param id 经验分享主键 + * @return 结果 + */ + @Override + public int deleteMuhuExperienceShareById(Long id) + { + return muhuExperienceShareMapper.deleteMuhuExperienceShareById(id); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswerAgain.java b/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswerAgain.java new file mode 100644 index 0000000..65f18f3 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswerAgain.java @@ -0,0 +1,155 @@ +package com.chenhai.system.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.chenhai.common.annotation.Excel; +import com.chenhai.common.core.domain.BaseEntity; + +/** + * 回复对象 sys_answer_again + * + * @author ruoyi + * @date 2026-02-02 + */ +public class SysAnswerAgain extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 对应的回复id */ + @Excel(name = "对应的回复id") + private Long answerId; + + /** 用户id */ + @Excel(name = "用户id") + private String userId; + + /** 用户名 */ + @Excel(name = "用户名") + private String username; + + /** 用户昵称 */ + private String nickName; + + /** 用户头像 */ + private String avatar; + + /** 回复内容 */ + @Excel(name = "回复内容") + private String content; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdAt; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date updatedAt; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setAnswerId(Long answerId) + { + this.answerId = answerId; + } + + public Long getAnswerId() + { + return answerId; + } + + public void setUserId(String userId) + { + this.userId = userId; + } + + public String getUserId() + { + return userId; + } + + public void setUsername(String username) + { + this.username = username; + } + + public String getUsername() + { + return username; + } + + public void setContent(String content) + { + this.content = content; + } + + public String getContent() + { + return content; + } + + public void setCreatedAt(Date createdAt) + { + this.createdAt = createdAt; + } + + public Date getCreatedAt() + { + return createdAt; + } + + public void setUpdatedAt(Date updatedAt) + { + this.updatedAt = updatedAt; + } + + public Date getUpdatedAt() + { + return updatedAt; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("answerId", getAnswerId()) + .append("userId", getUserId()) + .append("username", getUsername()) + .append("content", getContent()) + .append("createdAt", getCreatedAt()) + .append("updatedAt", getUpdatedAt()) + .append("nickName", getNickName()) + .append("avatar", getAvatar()) + .toString(); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswers.java b/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswers.java index b072c5b..60a68bc 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswers.java +++ b/chenhai-system/src/main/java/com/chenhai/system/domain/SysAnswers.java @@ -1,6 +1,7 @@ package com.chenhai.system.domain; import java.util.Date; +import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -33,7 +34,6 @@ public class SysAnswers extends BaseEntity private String username; /** 用户昵称 */ - @Excel(name = "用户昵称") private String nickName; /** 用户头像 */ @@ -53,6 +53,53 @@ public class SysAnswers extends BaseEntity @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") private Date updatedAt; + /** 图片(多个用逗号分隔) */ + @Excel(name = "图片") + private String images; + + /** 父级答复ID(0表示顶级答复) */ + @Excel(name = "父级答复ID") + private Long parentId; + + /** 回复层级(从0开始) */ + @Excel(name = "回复层级") + private Integer level; + + /** 回复路径(用于快速查询子回复) */ + private String path; + + /** 回复数量 */ + @Excel(name = "回复数量") + private Integer replyCount; + + /** 点赞数量 */ + @Excel(name = "点赞数量") + private Integer likeCount; + + /** 是否已点赞(前端展示用) */ + private Boolean liked; + + /** 子回复列表(非数据库字段) */ + private List children; + + /** 父级答复信息(非数据库字段) */ + private SysAnswers parentAnswer; + +// /** 最新回复内容(预览用) */ +// private String latestReplyContent; +// +// /** 最新回复用户昵称 */ +// private String latestReplyNickName; +// +// /** 最新回复用户头像 */ +// private String latestReplyAvatar; +// +// /** 最新回复时间 */ +// private Date latestReplyTime; +// +// /** 是否有更多回复(超过预览数量时) */ +// private Boolean hasMoreReplies; + public void setId(Long id) { this.id = id; @@ -143,6 +190,120 @@ public class SysAnswers extends BaseEntity return updatedAt; } + public void setImages(String images) + { + this.images = images; + } + + public String getImages() + { + return images; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public Integer getReplyCount() { + return replyCount; + } + + public void setReplyCount(Integer replyCount) { + this.replyCount = replyCount; + } + + public Integer getLikeCount() { + return likeCount; + } + + public void setLikeCount(Integer likeCount) { + this.likeCount = likeCount; + } + + public Boolean getLiked() { + return liked; + } + + public void setLiked(Boolean liked) { + this.liked = liked; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public SysAnswers getParentAnswer() { + return parentAnswer; + } + + public void setParentAnswer(SysAnswers parentAnswer) { + this.parentAnswer = parentAnswer; + } + +// public String getLatestReplyContent() { +// return latestReplyContent; +// } +// +// public void setLatestReplyContent(String latestReplyContent) { +// this.latestReplyContent = latestReplyContent; +// } +// +// public String getLatestReplyNickName() { +// return latestReplyNickName; +// } +// +// public void setLatestReplyNickName(String latestReplyNickName) { +// this.latestReplyNickName = latestReplyNickName; +// } +// +// public String getLatestReplyAvatar() { +// return latestReplyAvatar; +// } +// +// public void setLatestReplyAvatar(String latestReplyAvatar) { +// this.latestReplyAvatar = latestReplyAvatar; +// } +// +// public Date getLatestReplyTime() { +// return latestReplyTime; +// } +// +// public void setLatestReplyTime(Date latestReplyTime) { +// this.latestReplyTime = latestReplyTime; +// } +// +// public Boolean getHasMoreReplies() { +// return hasMoreReplies; +// } +// +// public void setHasMoreReplies(Boolean hasMoreReplies) { +// this.hasMoreReplies = hasMoreReplies; +// } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -155,6 +316,12 @@ public class SysAnswers extends BaseEntity .append("content", getContent()) .append("createdAt", getCreatedAt()) .append("updatedAt", getUpdatedAt()) + .append("images", getImages()) + .append("parentId", getParentId()) + .append("level", getLevel()) + .append("path", getPath()) + .append("replyCount", getReplyCount()) + .append("likeCount", getLikeCount()) .toString(); } } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/system/domain/SysMuhuUser.java b/chenhai-system/src/main/java/com/chenhai/system/domain/SysMuhuUser.java new file mode 100644 index 0000000..249beff --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/domain/SysMuhuUser.java @@ -0,0 +1,222 @@ +package com.chenhai.system.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.chenhai.common.annotation.Excel; +import com.chenhai.common.core.domain.BaseEntity; + +/** + * 牧户用户对象 sys_muhu_user + * + * @author ruoyi + * @date 2026-02-03 + */ +public class SysMuhuUser extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 用户ID,关联 sys_user.user_id */ + private Long userId; + + /** 真实姓名 */ + @Excel(name = "真实姓名") + private String realName; + + /** 身份证号 */ + @Excel(name = "身份证号") + private String idCard; + + /** 身份证正面照 */ + @Excel(name = "身份证正面照") + private String idCardFront; + + /** 身份证反面照 */ + @Excel(name = "身份证反面照") + private String idCardBack; + + /** 人脸识别照片 */ + @Excel(name = "人脸识别照片") + private String faceImage; + + /** 认证状态(0未认证 1已认证 2审核中 3认证失败) */ + @Excel(name = "认证状态", readConverterExp = "0=未认证,1=已认证,2=审核中,3=认证失败") + private String authStatus; + + /** 认证时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "认证时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date authTime; + + /** 认证失败原因 */ + @Excel(name = "认证失败原因") + private String authFailReason; + + /** 安全问题 */ + @Excel(name = "安全问题") + private String securityQuestion; + + /** 安全答案 */ + @Excel(name = "安全答案") + private String securityAnswer; + + /** 最后登录时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date lastLoginTime; + + /** 最后登录IP */ + @Excel(name = "最后登录IP") + private String lastLoginIp; + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + + public void setRealName(String realName) + { + this.realName = realName; + } + + public String getRealName() + { + return realName; + } + + public void setIdCard(String idCard) + { + this.idCard = idCard; + } + + public String getIdCard() + { + return idCard; + } + + public void setIdCardFront(String idCardFront) + { + this.idCardFront = idCardFront; + } + + public String getIdCardFront() + { + return idCardFront; + } + + public void setIdCardBack(String idCardBack) + { + this.idCardBack = idCardBack; + } + + public String getIdCardBack() + { + return idCardBack; + } + + public void setFaceImage(String faceImage) + { + this.faceImage = faceImage; + } + + public String getFaceImage() + { + return faceImage; + } + + public void setAuthStatus(String authStatus) + { + this.authStatus = authStatus; + } + + public String getAuthStatus() + { + return authStatus; + } + + public void setAuthTime(Date authTime) + { + this.authTime = authTime; + } + + public Date getAuthTime() + { + return authTime; + } + + public void setAuthFailReason(String authFailReason) + { + this.authFailReason = authFailReason; + } + + public String getAuthFailReason() + { + return authFailReason; + } + + public void setSecurityQuestion(String securityQuestion) + { + this.securityQuestion = securityQuestion; + } + + public String getSecurityQuestion() + { + return securityQuestion; + } + + public void setSecurityAnswer(String securityAnswer) + { + this.securityAnswer = securityAnswer; + } + + public String getSecurityAnswer() + { + return securityAnswer; + } + + public void setLastLoginTime(Date lastLoginTime) + { + this.lastLoginTime = lastLoginTime; + } + + public Date getLastLoginTime() + { + return lastLoginTime; + } + + public void setLastLoginIp(String lastLoginIp) + { + this.lastLoginIp = lastLoginIp; + } + + public String getLastLoginIp() + { + return lastLoginIp; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("realName", getRealName()) + .append("idCard", getIdCard()) + .append("idCardFront", getIdCardFront()) + .append("idCardBack", getIdCardBack()) + .append("faceImage", getFaceImage()) + .append("authStatus", getAuthStatus()) + .append("authTime", getAuthTime()) + .append("authFailReason", getAuthFailReason()) + .append("securityQuestion", getSecurityQuestion()) + .append("securityAnswer", getSecurityAnswer()) + .append("lastLoginTime", getLastLoginTime()) + .append("lastLoginIp", getLastLoginIp()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/domain/SysQuestions.java b/chenhai-system/src/main/java/com/chenhai/system/domain/SysQuestions.java index 718ba90..d130975 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/domain/SysQuestions.java +++ b/chenhai-system/src/main/java/com/chenhai/system/domain/SysQuestions.java @@ -61,6 +61,17 @@ public class SysQuestions extends BaseEntity /** 用户头像 */ private String avatar; + /** 图片(多个用逗号分隔) */ + @Excel(name = "图片") + private String images; + + /** 搜索关键字 - 新增字段 */ + private String searchKey; + + /** 浏览量 */ + @Excel(name = "浏览量") + private Long viewCount; + public void setId(Long id) { this.id = id; @@ -167,6 +178,32 @@ public class SysQuestions extends BaseEntity this.avatar = avatar; } + public void setImages(String images) + { + this.images = images; + } + + public String getImages() + { + return images; + } + + public String getSearchKey() { + return searchKey; + } + + public void setSearchKey(String searchKey) { + this.searchKey = searchKey; + } + + public Long getViewCount() { + return viewCount; + } + + public void setViewCount(Long viewCount) { + this.viewCount = viewCount; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -181,6 +218,9 @@ public class SysQuestions extends BaseEntity .append("updatedAt", getUpdatedAt()) .append("nickName", getNickName()) .append("avatar", getAvatar()) + .append("images", getImages()) + .append("searchKey", getSearchKey()) + .append("viewCount", getViewCount()) .toString(); } } diff --git a/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswerAgainMapper.java b/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswerAgainMapper.java new file mode 100644 index 0000000..fc4c9b4 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswerAgainMapper.java @@ -0,0 +1,61 @@ +package com.chenhai.system.mapper; + +import java.util.List; +import com.chenhai.system.domain.SysAnswerAgain; + +/** + * 回复Mapper接口 + * + * @author ruoyi + * @date 2026-02-02 + */ +public interface SysAnswerAgainMapper +{ + /** + * 查询回复 + * + * @param id 回复主键 + * @return 回复 + */ + public SysAnswerAgain selectSysAnswerAgainById(Long id); + + /** + * 查询回复列表 + * + * @param sysAnswerAgain 回复 + * @return 回复集合 + */ + public List selectSysAnswerAgainList(SysAnswerAgain sysAnswerAgain); + + /** + * 新增回复 + * + * @param sysAnswerAgain 回复 + * @return 结果 + */ + public int insertSysAnswerAgain(SysAnswerAgain sysAnswerAgain); + + /** + * 修改回复 + * + * @param sysAnswerAgain 回复 + * @return 结果 + */ + public int updateSysAnswerAgain(SysAnswerAgain sysAnswerAgain); + + /** + * 删除回复 + * + * @param id 回复主键 + * @return 结果 + */ + public int deleteSysAnswerAgainById(Long id); + + /** + * 批量删除回复 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysAnswerAgainByIds(Long[] ids); +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswersMapper.java b/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswersMapper.java index 9837686..fbd1ef8 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswersMapper.java +++ b/chenhai-system/src/main/java/com/chenhai/system/mapper/SysAnswersMapper.java @@ -75,4 +75,55 @@ public interface SysAnswersMapper * @return 答案数量 */ public Long countAnswersByQuestionId(Long questionId); + + // 以下是新增的回复相关方法 + + /** + * 查询顶级答复列表(parent_id = 0) + * + * @param questionId 问题ID + * @return 答复集合 + */ + public List selectRootAnswers(Long questionId); + + /** + * 查询子回复列表 + * + * @param parentId 父答复ID + * @return 子回复集合 + */ + public List selectChildrenAnswers(Long parentId); + + /** + * 查询答复的完整树结构 + * + * @param questionId 问题ID + * @return 答复集合 + */ + public List selectAnswerTree(Long questionId); + + /** + * 更新答复的回复数量 + * + * @param id 答复ID + * @return 结果 + */ + public int updateReplyCount(Long id); + + /** + * 更新点赞数量 + * + * @param id 答复ID + * @param increment 增量(1或-1) + * @return 结果 + */ + public int updateLikeCount(@Param("id") Long id, @Param("increment") int increment); + + /** + * 查询某个答复的所有后代ID(用于级联删除) + * + * @param id 答复ID + * @return 后代ID集合 + */ + public List selectDescendantIds(Long id); } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/system/mapper/SysMuhuUserMapper.java b/chenhai-system/src/main/java/com/chenhai/system/mapper/SysMuhuUserMapper.java new file mode 100644 index 0000000..341a157 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/mapper/SysMuhuUserMapper.java @@ -0,0 +1,61 @@ +package com.chenhai.system.mapper; + +import java.util.List; +import com.chenhai.system.domain.SysMuhuUser; + +/** + * 牧户用户Mapper接口 + * + * @author ruoyi + * @date 2026-02-03 + */ +public interface SysMuhuUserMapper +{ + /** + * 查询牧户用户 + * + * @param userId 牧户用户主键 + * @return 牧户用户 + */ + public SysMuhuUser selectSysMuhuUserByUserId(Long userId); + + /** + * 查询牧户用户列表 + * + * @param sysMuhuUser 牧户用户 + * @return 牧户用户集合 + */ + public List selectSysMuhuUserList(SysMuhuUser sysMuhuUser); + + /** + * 新增牧户用户 + * + * @param sysMuhuUser 牧户用户 + * @return 结果 + */ + public int insertSysMuhuUser(SysMuhuUser sysMuhuUser); + + /** + * 修改牧户用户 + * + * @param sysMuhuUser 牧户用户 + * @return 结果 + */ + public int updateSysMuhuUser(SysMuhuUser sysMuhuUser); + + /** + * 删除牧户用户 + * + * @param userId 牧户用户主键 + * @return 结果 + */ + public int deleteSysMuhuUserByUserId(Long userId); + + /** + * 批量删除牧户用户 + * + * @param userIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysMuhuUserByUserIds(Long[] userIds); +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswerAgainService.java b/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswerAgainService.java new file mode 100644 index 0000000..f2142ed --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswerAgainService.java @@ -0,0 +1,61 @@ +package com.chenhai.system.service; + +import java.util.List; +import com.chenhai.system.domain.SysAnswerAgain; + +/** + * 回复Service接口 + * + * @author ruoyi + * @date 2026-02-02 + */ +public interface ISysAnswerAgainService +{ + /** + * 查询回复 + * + * @param id 回复主键 + * @return 回复 + */ + public SysAnswerAgain selectSysAnswerAgainById(Long id); + + /** + * 查询回复列表 + * + * @param sysAnswerAgain 回复 + * @return 回复集合 + */ + public List selectSysAnswerAgainList(SysAnswerAgain sysAnswerAgain); + + /** + * 新增回复 + * + * @param sysAnswerAgain 回复 + * @return 结果 + */ + public int insertSysAnswerAgain(SysAnswerAgain sysAnswerAgain); + + /** + * 修改回复 + * + * @param sysAnswerAgain 回复 + * @return 结果 + */ + public int updateSysAnswerAgain(SysAnswerAgain sysAnswerAgain); + + /** + * 批量删除回复 + * + * @param ids 需要删除的回复主键集合 + * @return 结果 + */ + public int deleteSysAnswerAgainByIds(Long[] ids); + + /** + * 删除回复信息 + * + * @param id 回复主键 + * @return 结果 + */ + public int deleteSysAnswerAgainById(Long id); +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswersService.java b/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswersService.java index ed0aaf1..a5fb288 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswersService.java +++ b/chenhai-system/src/main/java/com/chenhai/system/service/ISysAnswersService.java @@ -27,6 +27,30 @@ public interface ISysAnswersService */ public List selectSysAnswersList(SysAnswers sysAnswers); + /** + * 查询顶级答复列表(parent_id = 0) + * + * @param questionId 问题ID + * @return 答复集合 + */ + public List selectRootAnswers(Long questionId); + + /** + * 查询答复的树形结构 + * + * @param questionId 问题ID + * @return 树形答复集合 + */ + public List selectAnswerTree(Long questionId); + + /** + * 查询子回复列表 + * + * @param parentId 父答复ID + * @return 子回复集合 + */ + public List selectChildrenAnswers(Long parentId); + /** * 新增答复 * @@ -43,6 +67,14 @@ public interface ISysAnswersService */ public int insertSysAnswersWithCurrentUser(SysAnswers sysAnswers); + /** + * 新增回复 + * + * @param sysAnswers 回复 + * @return 结果 + */ + public int insertReply(SysAnswers sysAnswers); + /** * 修改答复 * @@ -90,4 +122,29 @@ public interface ISysAnswersService * @return 答案数量 */ public Long countAnswersByQuestionId(Long questionId); + + /** + * 点赞答复 + * + * @param id 答复ID + * @return 结果 + */ + public int likeAnswer(Long id); + + /** + * 取消点赞答复 + * + * @param id 答复ID + * @return 结果 + */ + public int unlikeAnswer(Long id); + + /** + * 检查用户是否点赞 + * + * @param id 答复ID + * @param userId 用户ID + * @return 是否点赞 + */ + public boolean checkUserLike(Long id, String userId); } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/ISysMuhuUserService.java b/chenhai-system/src/main/java/com/chenhai/system/service/ISysMuhuUserService.java new file mode 100644 index 0000000..455f5bc --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/service/ISysMuhuUserService.java @@ -0,0 +1,61 @@ +package com.chenhai.system.service; + +import java.util.List; +import com.chenhai.system.domain.SysMuhuUser; + +/** + * 牧户用户Service接口 + * + * @author ruoyi + * @date 2026-02-03 + */ +public interface ISysMuhuUserService +{ + /** + * 查询牧户用户 + * + * @param userId 牧户用户主键 + * @return 牧户用户 + */ + public SysMuhuUser selectSysMuhuUserByUserId(Long userId); + + /** + * 查询牧户用户列表 + * + * @param sysMuhuUser 牧户用户 + * @return 牧户用户集合 + */ + public List selectSysMuhuUserList(SysMuhuUser sysMuhuUser); + + /** + * 新增牧户用户 + * + * @param sysMuhuUser 牧户用户 + * @return 结果 + */ + public int insertSysMuhuUser(SysMuhuUser sysMuhuUser); + + /** + * 修改牧户用户 + * + * @param sysMuhuUser 牧户用户 + * @return 结果 + */ + public int updateSysMuhuUser(SysMuhuUser sysMuhuUser); + + /** + * 批量删除牧户用户 + * + * @param userIds 需要删除的牧户用户主键集合 + * @return 结果 + */ + public int deleteSysMuhuUserByUserIds(Long[] userIds); + + /** + * 删除牧户用户信息 + * + * @param userId 牧户用户主键 + * @return 结果 + */ + public int deleteSysMuhuUserByUserId(Long userId); +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswerAgainServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswerAgainServiceImpl.java new file mode 100644 index 0000000..5c374a0 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswerAgainServiceImpl.java @@ -0,0 +1,121 @@ +package com.chenhai.system.service.impl; + +import java.util.Date; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chenhai.common.utils.SecurityUtils; +import com.chenhai.system.domain.SysAnswerAgain; +import com.chenhai.system.mapper.SysAnswerAgainMapper; +import com.chenhai.system.mapper.SysUserMapper; +import com.chenhai.system.service.ISysAnswerAgainService; + +/** + * 回复Service业务层处理 + * + * @author ruoyi + * @date 2026-02-02 + */ +@Service +public class SysAnswerAgainServiceImpl implements ISysAnswerAgainService +{ + @Autowired + private SysAnswerAgainMapper sysAnswerAgainMapper; + + @Autowired + private SysUserMapper sysUserMapper; + + /** + * 查询回复 + * + * @param id 回复主键 + * @return 回复 + */ + @Override + public SysAnswerAgain selectSysAnswerAgainById(Long id) + { + return sysAnswerAgainMapper.selectSysAnswerAgainById(id); + } + + /** + * 查询回复列表 + * + * @param sysAnswerAgain 回复 + * @return 回复 + */ + @Override + public List selectSysAnswerAgainList(SysAnswerAgain sysAnswerAgain) + { + return sysAnswerAgainMapper.selectSysAnswerAgainList(sysAnswerAgain); + } + + /** + * 新增回复 + * + * @param sysAnswerAgain 回复 + * @return 结果 + */ + @Override + public int insertSysAnswerAgain(SysAnswerAgain sysAnswerAgain) + { + // 获取当前登录用户信息 + Long userId = SecurityUtils.getUserId(); + com.chenhai.common.core.domain.entity.SysUser currentUser = sysUserMapper.selectUserById(userId); + + if (currentUser != null) { + // 自动设置用户信息 + sysAnswerAgain.setUserId(currentUser.getUserId().toString()); + sysAnswerAgain.setUsername(currentUser.getUserName()); + } + + // 设置创建和更新时间 + Date now = new Date(); + if (sysAnswerAgain.getCreatedAt() == null) { + sysAnswerAgain.setCreatedAt(now); + } + if (sysAnswerAgain.getUpdatedAt() == null) { + sysAnswerAgain.setUpdatedAt(now); + } + + return sysAnswerAgainMapper.insertSysAnswerAgain(sysAnswerAgain); + } + + /** + * 修改回复 + * + * @param sysAnswerAgain 回复 + * @return 结果 + */ + @Override + public int updateSysAnswerAgain(SysAnswerAgain sysAnswerAgain) + { + // 更新时设置更新时间 + sysAnswerAgain.setUpdatedAt(new Date()); + + return sysAnswerAgainMapper.updateSysAnswerAgain(sysAnswerAgain); + } + + /** + * 批量删除回复 + * + * @param ids 需要删除的回复主键 + * @return 结果 + */ + @Override + public int deleteSysAnswerAgainByIds(Long[] ids) + { + return sysAnswerAgainMapper.deleteSysAnswerAgainByIds(ids); + } + + /** + * 删除回复信息 + * + * @param id 回复主键 + * @return 结果 + */ + @Override + public int deleteSysAnswerAgainById(Long id) + { + return sysAnswerAgainMapper.deleteSysAnswerAgainById(id); + } +} \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswersServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswersServiceImpl.java index 55c9fc5..05e6577 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswersServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysAnswersServiceImpl.java @@ -1,6 +1,7 @@ package com.chenhai.system.service.impl; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,6 +14,9 @@ import com.chenhai.system.service.ISysAnswersService; import com.chenhai.system.service.ISysQuestionsService; import com.chenhai.common.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 答复Service业务层处理 * @@ -22,6 +26,8 @@ import com.chenhai.common.exception.ServiceException; @Service public class SysAnswersServiceImpl implements ISysAnswersService { + private static final Logger log = LoggerFactory.getLogger(SysAnswersServiceImpl.class); + @Autowired private SysAnswersMapper sysAnswersMapper; @@ -37,7 +43,20 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Override public SysAnswers selectSysAnswersById(Long id) { - return sysAnswersMapper.selectSysAnswersById(id); + SysAnswers answer = sysAnswersMapper.selectSysAnswersById(id); + if (answer != null) { + if (SecurityUtils.getLoginUser() != null) { + String userId = String.valueOf(SecurityUtils.getUserId()); + answer.setLiked(checkUserLike(id, userId)); + } + + // 如果这个回答有回复,加载前3条回复到children + if (answer.getReplyCount() != null && answer.getReplyCount() > 0) { + List children = selectChildrenAnswers(answer.getId()); + answer.setChildren(children); + } + } + return answer; } /** @@ -49,7 +68,112 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Override public List selectSysAnswersList(SysAnswers sysAnswers) { - return sysAnswersMapper.selectSysAnswersList(sysAnswers); + // 默认只查询顶级回答 + if (sysAnswers.getParentId() == null) { + sysAnswers.setParentId(0L); + } + + // 执行基础查询 + List list = sysAnswersMapper.selectSysAnswersList(sysAnswers); + + if (SecurityUtils.getLoginUser() != null) { + String userId = String.valueOf(SecurityUtils.getUserId()); + list.forEach(answer -> { + answer.setLiked(checkUserLike(answer.getId(), userId)); + + // 如果这个回答有回复,加载前3条回复到children + if (answer.getReplyCount() != null && answer.getReplyCount() > 0) { + List children = selectChildrenAnswers(answer.getId()); + answer.setChildren(children); + } + }); + } + return list; + } + + /** + * 查询顶级答复列表 + * + * @param questionId 问题ID + * @return 答复集合 + */ + @Override + public List selectRootAnswers(Long questionId) + { + List list = sysAnswersMapper.selectRootAnswers(questionId); + if (SecurityUtils.getLoginUser() != null) { + String userId = String.valueOf(SecurityUtils.getUserId()); + list.forEach(answer -> { + answer.setLiked(checkUserLike(answer.getId(), userId)); + // 加载前3条回复 + List children = selectChildrenAnswers(answer.getId()); + answer.setChildren(children); + }); + } + return list; + } + + /** + * 查询答复的树形结构 + * + * @param questionId 问题ID + * @return 树形答复集合 + */ + @Override + public List selectAnswerTree(Long questionId) + { + List allAnswers = sysAnswersMapper.selectAnswerTree(questionId); + + // 构建树形结构 + Map answerMap = new HashMap<>(); + List rootAnswers = new ArrayList<>(); + + // 放入map并设置点赞状态 + String userId = null; + if (SecurityUtils.getLoginUser() != null) { + userId = String.valueOf(SecurityUtils.getUserId()); + } + + for (SysAnswers answer : allAnswers) { + if (userId != null) { + answer.setLiked(checkUserLike(answer.getId(), userId)); + } + answerMap.put(answer.getId(), answer); + } + + // 构建树 + for (SysAnswers answer : allAnswers) { + if (answer.getParentId() == null || answer.getParentId() == 0) { + rootAnswers.add(answer); + } else { + SysAnswers parent = answerMap.get(answer.getParentId()); + if (parent != null) { + if (parent.getChildren() == null) { + parent.setChildren(new ArrayList<>()); + } + parent.getChildren().add(answer); + } + } + } + + return rootAnswers; + } + + /** + * 查询子回复列表 + * + * @param parentId 父答复ID + * @return 子回复集合 + */ + @Override + public List selectChildrenAnswers(Long parentId) + { + List list = sysAnswersMapper.selectChildrenAnswers(parentId); + if (SecurityUtils.getLoginUser() != null) { + String userId = String.valueOf(SecurityUtils.getUserId()); + list.forEach(answer -> answer.setLiked(checkUserLike(answer.getId(), userId))); + } + return list; } /** @@ -62,13 +186,38 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Transactional public int insertSysAnswers(SysAnswers sysAnswers) { - // 验证问题ID是否存在 - if (sysAnswers.getQuestionId() == null) { - throw new ServiceException("问题ID不能为空"); + // 设置默认值 + if (sysAnswers.getParentId() == null) { + sysAnswers.setParentId(0L); + sysAnswers.setLevel(0); + sysAnswers.setPath("0/"); + } + + if (sysAnswers.getReplyCount() == null) { + sysAnswers.setReplyCount(0); + } + + if (sysAnswers.getLikeCount() == null) { + sysAnswers.setLikeCount(0); } int result = sysAnswersMapper.insertSysAnswers(sysAnswers); + // 更新path + if (sysAnswers.getParentId() == 0) { + sysAnswers.setPath("0/" + sysAnswers.getId() + "/"); + } else { + SysAnswers parent = sysAnswersMapper.selectSysAnswersById(sysAnswers.getParentId()); + if (parent != null) { + sysAnswers.setLevel(parent.getLevel() + 1); + sysAnswers.setPath(parent.getPath() + sysAnswers.getId() + "/"); + } + sysAnswersMapper.updateSysAnswers(sysAnswers); + + // 更新父级的回复数量 + sysAnswersMapper.updateReplyCount(sysAnswers.getParentId()); + } + if (result > 0) { // 增加问题的答案数量 sysQuestionsService.increaseAnswerCount(sysAnswers.getQuestionId()); @@ -87,11 +236,6 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Transactional public int insertSysAnswersWithCurrentUser(SysAnswers sysAnswers) { - // 验证问题ID是否存在 - if (sysAnswers.getQuestionId() == null) { - throw new ServiceException("问题ID不能为空"); - } - // 获取当前登录用户信息 SysUser currentUser = SecurityUtils.getLoginUser().getUser(); @@ -105,11 +249,93 @@ public class SysAnswersServiceImpl implements ISysAnswersService // 设置头像 sysAnswers.setAvatar(currentUser.getAvatar()); + return insertSysAnswers(sysAnswers); + } + + /** + * 新增回复 + * + * @param sysAnswers 回复 + * @return 结果 + */ + @Override + @Transactional + public int insertReply(SysAnswers sysAnswers) + { + log.info("开始新增回复,参数: {}", sysAnswers); + + // 检查父级答复是否存在 + SysAnswers parentAnswer = null; + Long parentId = sysAnswers.getParentId(); + + log.info("父级ID: {}", parentId); + + if (parentId == null) { + log.error("父级答复ID为null"); + throw new ServiceException("父级答复ID不能为空"); + } + + if (parentId > 0) { + parentAnswer = sysAnswersMapper.selectSysAnswersById(parentId); + if (parentAnswer == null) { + throw new ServiceException("父级答复不存在"); + } + // 设置问题ID为父级答复的问题ID + sysAnswers.setQuestionId(parentAnswer.getQuestionId()); + } else { + // parentId 为 0,表示这是顶级回答,不是回复 + throw new ServiceException("回复必须有父级答复"); + } + + // 获取当前登录用户信息 + SysUser currentUser = SecurityUtils.getLoginUser().getUser(); + sysAnswers.setUserId(String.valueOf(currentUser.getUserId())); + sysAnswers.setUsername(currentUser.getUserName()); + + // 设置层级和路径 - 修复这里的逻辑! + if (parentAnswer != null) { + Integer parentLevel = parentAnswer.getLevel(); + if (parentLevel == null) { + parentLevel = 0; + } + sysAnswers.setLevel(parentLevel + 1); + + // 修复路径设置逻辑 + // 父级路径应该是父级自己的完整路径,比如父级ID=13,path="0/13/" + // 新回复的path应该是 "0/13/24/" + String parentPath = parentAnswer.getPath(); + if (parentPath == null || "0/".equals(parentPath)) { + // 如果父级路径是根路径,需要修正为包含父级ID的路径 + parentPath = "0/" + parentId + "/"; + } + sysAnswers.setPath(parentPath + "pending/"); + log.info("设置回复路径 - 父级路径: {}, 新回复临时路径: {}", parentPath, sysAnswers.getPath()); + } + + // 确保 replyCount 和 likeCount 不为 null + if (sysAnswers.getReplyCount() == null) { + sysAnswers.setReplyCount(0); + } + if (sysAnswers.getLikeCount() == null) { + sysAnswers.setLikeCount(0); + } + int result = sysAnswersMapper.insertSysAnswers(sysAnswers); - if (result > 0) { - // 增加问题的答案数量 - sysQuestionsService.increaseAnswerCount(sysAnswers.getQuestionId()); + // 更新path - 这里也需要修复 + if (parentAnswer != null) { + String parentPath = parentAnswer.getPath(); + if (parentPath == null || "0/".equals(parentPath)) { + // 修正父级路径 + parentPath = "0/" + parentId + "/"; + } + sysAnswers.setPath(parentPath + sysAnswers.getId() + "/"); + sysAnswersMapper.updateSysAnswers(sysAnswers); + + // 更新父级的回复数量 + sysAnswersMapper.updateReplyCount(parentId); + + log.info("更新回复路径 - 最终路径: {}", sysAnswers.getPath()); } return result; @@ -125,6 +351,15 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Transactional public int updateSysAnswers(SysAnswers sysAnswers) { + // 不允许修改parentId和questionId + if (sysAnswers.getParentId() != null || sysAnswers.getQuestionId() != null) { + SysAnswers oldAnswer = sysAnswersMapper.selectSysAnswersById(sysAnswers.getId()); + if (oldAnswer != null) { + sysAnswers.setParentId(oldAnswer.getParentId()); + sysAnswers.setQuestionId(oldAnswer.getQuestionId()); + } + } + return sysAnswersMapper.updateSysAnswers(sysAnswers); } @@ -138,20 +373,17 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Transactional public int deleteSysAnswersByIds(Long[] ids) { - // 先获取所有要删除的答案,记录对应的问题ID + int totalDeleted = 0; + for (Long id : ids) { - SysAnswers answer = sysAnswersMapper.selectSysAnswersById(id); - if (answer != null) { - // 减少问题的答案数量 - sysQuestionsService.decreaseAnswerCount(answer.getQuestionId()); - } + totalDeleted += deleteSysAnswersById(id); } - return sysAnswersMapper.deleteSysAnswersByIds(ids); + return totalDeleted; } /** - * 删除答复信息 + * 删除答复信息(级联删除所有子回复) * * @param id 答复主键 * @return 结果 @@ -165,12 +397,27 @@ public class SysAnswersServiceImpl implements ISysAnswersService throw new ServiceException("答复不存在"); } - Long questionId = answer.getQuestionId(); - int result = sysAnswersMapper.deleteSysAnswersById(id); + // 获取所有后代ID + List descendantIds = sysAnswersMapper.selectDescendantIds(id); + List allIds = new ArrayList<>(); + allIds.add(id); + allIds.addAll(descendantIds); + + // 删除所有相关答复 + int result = 0; + if (!allIds.isEmpty()) { + Long[] idsArray = allIds.toArray(new Long[0]); + result = sysAnswersMapper.deleteSysAnswersByIds(idsArray); + } if (result > 0) { - // 减少问题的答案数量 - sysQuestionsService.decreaseAnswerCount(questionId); + // 如果是顶级答复,减少问题的答案数量 + if (answer.getParentId() == 0) { + sysQuestionsService.decreaseAnswerCount(answer.getQuestionId()); + } else { + // 如果是子回复,更新父级的回复数量 + sysAnswersMapper.updateReplyCount(answer.getParentId()); + } } return result; @@ -186,10 +433,6 @@ public class SysAnswersServiceImpl implements ISysAnswersService @Transactional public int deleteSysAnswersByQuestionId(Long questionId) { - // 获取该问题的所有答案 - List answers = selectAnswersByQuestionId(questionId); - - // 删除所有答案 int result = sysAnswersMapper.deleteAnswersByQuestionId(questionId); if (result > 0) { @@ -211,7 +454,7 @@ public class SysAnswersServiceImpl implements ISysAnswersService { SysAnswers query = new SysAnswers(); query.setQuestionId(questionId); - return sysAnswersMapper.selectSysAnswersList(query); + return selectSysAnswersList(query); } /** @@ -229,6 +472,71 @@ public class SysAnswersServiceImpl implements ISysAnswersService return (long) answers.size(); } + /** + * 点赞答复 + * + * @param id 答复ID + * @return 结果 + */ + @Override + @Transactional + public int likeAnswer(Long id) + { + // 这里需要实现点赞记录表,这里简化为直接更新点赞数 + // 实际项目中应该有一个 sys_answer_likes 表来记录用户点赞 + + // 检查用户是否已经点赞 + if (SecurityUtils.getLoginUser() != null) { + String userId = String.valueOf(SecurityUtils.getUserId()); + if (checkUserLike(id, userId)) { + throw new ServiceException("已经点赞过了"); + } + + // 记录用户点赞(这里需要实现点赞记录表) + // saveLikeRecord(id, userId); + } + + return sysAnswersMapper.updateLikeCount(id, 1); + } + + /** + * 取消点赞答复 + * + * @param id 答复ID + * @return 结果 + */ + @Override + @Transactional + public int unlikeAnswer(Long id) + { + if (SecurityUtils.getLoginUser() != null) { + String userId = String.valueOf(SecurityUtils.getUserId()); + if (!checkUserLike(id, userId)) { + throw new ServiceException("还没有点赞"); + } + + // 删除点赞记录 + // deleteLikeRecord(id, userId); + } + + return sysAnswersMapper.updateLikeCount(id, -1); + } + + /** + * 检查用户是否点赞 + * + * @param id 答复ID + * @param userId 用户ID + * @return 是否点赞 + */ + @Override + public boolean checkUserLike(Long id, String userId) + { + // 这里需要查询点赞记录表 + // 暂时返回false,实际项目中需要实现 + return false; + } + /** * 重置问题的答案数量为0(私有方法) * diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysMuhuUserServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysMuhuUserServiceImpl.java new file mode 100644 index 0000000..81b7dfb --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysMuhuUserServiceImpl.java @@ -0,0 +1,95 @@ +package com.chenhai.system.service.impl; + +import java.util.List; +import com.chenhai.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chenhai.system.mapper.SysMuhuUserMapper; +import com.chenhai.system.domain.SysMuhuUser; +import com.chenhai.system.service.ISysMuhuUserService; + +/** + * 牧户用户Service业务层处理 + * + * @author ruoyi + * @date 2026-02-03 + */ +@Service +public class SysMuhuUserServiceImpl implements ISysMuhuUserService +{ + @Autowired + private SysMuhuUserMapper sysMuhuUserMapper; + + /** + * 查询牧户用户 + * + * @param userId 牧户用户主键 + * @return 牧户用户 + */ + @Override + public SysMuhuUser selectSysMuhuUserByUserId(Long userId) + { + return sysMuhuUserMapper.selectSysMuhuUserByUserId(userId); + } + + /** + * 查询牧户用户列表 + * + * @param sysMuhuUser 牧户用户 + * @return 牧户用户 + */ + @Override + public List selectSysMuhuUserList(SysMuhuUser sysMuhuUser) + { + return sysMuhuUserMapper.selectSysMuhuUserList(sysMuhuUser); + } + + /** + * 新增牧户用户 + * + * @param sysMuhuUser 牧户用户 + * @return 结果 + */ + @Override + public int insertSysMuhuUser(SysMuhuUser sysMuhuUser) + { + return sysMuhuUserMapper.insertSysMuhuUser(sysMuhuUser); + } + + /** + * 修改牧户用户 + * + * @param sysMuhuUser 牧户用户 + * @return 结果 + */ + @Override + public int updateSysMuhuUser(SysMuhuUser sysMuhuUser) + { + sysMuhuUser.setUpdateTime(DateUtils.getNowDate()); + return sysMuhuUserMapper.updateSysMuhuUser(sysMuhuUser); + } + + /** + * 批量删除牧户用户 + * + * @param userIds 需要删除的牧户用户主键 + * @return 结果 + */ + @Override + public int deleteSysMuhuUserByUserIds(Long[] userIds) + { + return sysMuhuUserMapper.deleteSysMuhuUserByUserIds(userIds); + } + + /** + * 删除牧户用户信息 + * + * @param userId 牧户用户主键 + * @return 结果 + */ + @Override + public int deleteSysMuhuUserByUserId(Long userId) + { + return sysMuhuUserMapper.deleteSysMuhuUserByUserId(userId); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysQuestionsServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysQuestionsServiceImpl.java index 18b609c..0d930f5 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysQuestionsServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/system/service/impl/SysQuestionsServiceImpl.java @@ -94,10 +94,10 @@ public class SysQuestionsServiceImpl implements ISysQuestionsService throw new ServiceException("问题不存在"); } - // 检查权限:只能修改自己的问题 - if (!existingQuestion.getUserId().equals(userId)) { - throw new ServiceException("没有权限修改此问题"); - } +// // 检查权限:只能修改自己的问题 +// if (!existingQuestion.getUserId().equals(userId)) { +// throw new ServiceException("没有权限修改此问题"); +// } // 设置更新时间 sysQuestions.setUpdatedAt(new Date()); @@ -116,16 +116,16 @@ public class SysQuestionsServiceImpl implements ISysQuestionsService @Transactional public int deleteSysQuestionsByIds(Long[] ids, Long userId) { - // 检查权限:只能删除自己的问题 - for (Long id : ids) { - SysQuestions question = sysQuestionsMapper.selectSysQuestionsById(id); - if (question == null) { - throw new ServiceException("问题不存在,ID: " + id); - } - if (!question.getUserId().equals(userId)) { - throw new ServiceException("没有权限删除此问题,ID: " + id); - } - } +// // 检查权限:只能删除自己的问题 +// for (Long id : ids) { +// SysQuestions question = sysQuestionsMapper.selectSysQuestionsById(id); +// if (question == null) { +// throw new ServiceException("问题不存在,ID: " + id); +// } +// if (!question.getUserId().equals(userId)) { +// throw new ServiceException("没有权限删除此问题,ID: " + id); +// } +// } return sysQuestionsMapper.deleteSysQuestionsByIds(ids); } @@ -147,10 +147,10 @@ public class SysQuestionsServiceImpl implements ISysQuestionsService throw new ServiceException("问题不存在"); } - // 检查权限:只能删除自己的问题 - if (!question.getUserId().equals(userId)) { - throw new ServiceException("没有权限删除此问题"); - } +// // 检查权限:只能删除自己的问题 +// if (!question.getUserId().equals(userId)) { +// throw new ServiceException("没有权限删除此问题"); +// } return sysQuestionsMapper.deleteSysQuestionsById(id); } diff --git a/chenhai-system/src/main/resources/mapper/muhu/MuhuExperienceShareMapper.xml b/chenhai-system/src/main/resources/mapper/muhu/MuhuExperienceShareMapper.xml new file mode 100644 index 0000000..ecfa6f1 --- /dev/null +++ b/chenhai-system/src/main/resources/mapper/muhu/MuhuExperienceShareMapper.xml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, user_id, username, user_nickname, user_avatar, title, content, summary, category, tags, cover_image, images, attachments, status, audit_remark, audit_time, audit_user_id, has_sensitive, sensitive_words, is_handled, view_count, like_count, collect_count, share_count, created_at, updated_at, published_at from muhu_experience_share + + + + + + + + insert into muhu_experience_share + + user_id, + username, + user_nickname, + user_avatar, + title, + content, + summary, + category, + tags, + cover_image, + images, + attachments, + status, + audit_remark, + audit_time, + audit_user_id, + has_sensitive, + sensitive_words, + is_handled, + view_count, + like_count, + collect_count, + share_count, + created_at, + updated_at, + published_at, + + + #{userId}, + #{username}, + #{userNickname}, + #{userAvatar}, + #{title}, + #{content}, + #{summary}, + #{category}, + #{tags}, + #{coverImage}, + #{images}, + #{attachments}, + #{status}, + #{auditRemark}, + #{auditTime}, + #{auditUserId}, + #{hasSensitive}, + #{sensitiveWords}, + #{isHandled}, + #{viewCount}, + #{likeCount}, + #{collectCount}, + #{shareCount}, + #{createdAt}, + #{updatedAt}, + #{publishedAt}, + + + + + update muhu_experience_share + + user_id = #{userId}, + username = #{username}, + user_nickname = #{userNickname}, + user_avatar = #{userAvatar}, + title = #{title}, + content = #{content}, + summary = #{summary}, + category = #{category}, + tags = #{tags}, + cover_image = #{coverImage}, + images = #{images}, + attachments = #{attachments}, + status = #{status}, + audit_remark = #{auditRemark}, + audit_time = #{auditTime}, + audit_user_id = #{auditUserId}, + has_sensitive = #{hasSensitive}, + sensitive_words = #{sensitiveWords}, + is_handled = #{isHandled}, + view_count = #{viewCount}, + like_count = #{likeCount}, + collect_count = #{collectCount}, + share_count = #{shareCount}, + created_at = #{createdAt}, + updated_at = #{updatedAt}, + published_at = #{publishedAt}, + + where id = #{id} + + + + delete from muhu_experience_share where id = #{id} + + + + delete from muhu_experience_share where id in + + #{id} + + + \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/system/SysAnswerAgainMapper.xml b/chenhai-system/src/main/resources/mapper/system/SysAnswerAgainMapper.xml new file mode 100644 index 0000000..5213ec1 --- /dev/null +++ b/chenhai-system/src/main/resources/mapper/system/SysAnswerAgainMapper.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + select + a.id, + a.answer_id, + a.user_id, + a.username, + u.nick_name, + u.avatar, + a.content, + a.created_at, + a.updated_at + from sys_answer_again a + left join sys_user u on a.user_id = u.user_id + + + + + + + + insert into sys_answer_again + + answer_id, + user_id, + username, + content, + created_at, + updated_at, + + + #{answerId}, + #{userId}, + #{username}, + #{content}, + #{createdAt}, + #{updatedAt}, + + + + + update sys_answer_again + + answer_id = #{answerId}, + user_id = #{userId}, + username = #{username}, + content = #{content}, + created_at = #{createdAt}, + updated_at = #{updatedAt}, + + where id = #{id} + + + + delete from sys_answer_again where id = #{id} + + + + delete from sys_answer_again where id in + + #{id} + + + \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/system/SysAnswersMapper.xml b/chenhai-system/src/main/resources/mapper/system/SysAnswersMapper.xml index 619b626..f0ff98f 100644 --- a/chenhai-system/src/main/resources/mapper/system/SysAnswersMapper.xml +++ b/chenhai-system/src/main/resources/mapper/system/SysAnswersMapper.xml @@ -14,6 +14,17 @@ + + + + + + + + + + + @@ -26,7 +37,13 @@ u.avatar, a.content, a.created_at, - a.updated_at + a.updated_at, + a.images, + a.parent_id, + a.level, + a.path, + a.reply_count, + a.like_count from sys_answers a left join sys_user u on a.user_id = u.user_id @@ -39,6 +56,8 @@ and a.username like concat('%', #{username}, '%') and u.nick_name like concat('%', #{nickName}, '%') and a.content like concat('%', #{content}, '%') + and a.parent_id = #{parentId} + and a.level = #{level} and date(a.created_at) = date(#{createdAt}) and date_format(a.created_at,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') @@ -46,6 +65,7 @@ and date_format(a.created_at,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') + and a.images like concat('%', #{images}, '%') order by a.created_at desc @@ -55,24 +75,53 @@ where a.id = #{id} + + + + + + + + + insert into sys_answers question_id, user_id, username, - nick_name, - avatar, content, + images, + parent_id, + level, + path, + reply_count, + like_count, created_at, #{questionId}, #{userId}, #{username}, - #{nickName}, - #{avatar}, #{content}, + #{images}, + #{parentId}, + #{level}, + #{path}, + #{replyCount}, + #{likeCount}, sysdate(), @@ -83,14 +132,42 @@ question_id = #{questionId}, user_id = #{userId}, username = #{username}, - nick_name = #{nickName}, - avatar = #{avatar}, + + content = #{content}, + images = #{images}, + parent_id = #{parentId}, + level = #{level}, + path = #{path}, + reply_count = #{replyCount}, + like_count = #{likeCount}, updated_at = sysdate(), where id = #{id} + + + update sys_answers + set reply_count = ( + select cnt from ( + select count(*) as cnt + from sys_answers + where parent_id = #{id} + ) as temp + ), + updated_at = sysdate() + where id = #{id} + + + + + update sys_answers + set like_count = like_count + #{increment}, + updated_at = sysdate() + where id = #{id} + + delete from sys_answers where id = #{id} @@ -109,4 +186,9 @@ + + + \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/system/SysMuhuUserMapper.xml b/chenhai-system/src/main/resources/mapper/system/SysMuhuUserMapper.xml new file mode 100644 index 0000000..5260b47 --- /dev/null +++ b/chenhai-system/src/main/resources/mapper/system/SysMuhuUserMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + select user_id, real_name, id_card, id_card_front, id_card_back, face_image, auth_status, auth_time, auth_fail_reason, security_question, security_answer, last_login_time, last_login_ip, update_time from sys_muhu_user + + + + + + + + insert into sys_muhu_user + + user_id, + real_name, + id_card, + id_card_front, + id_card_back, + face_image, + auth_status, + auth_time, + auth_fail_reason, + security_question, + security_answer, + last_login_time, + last_login_ip, + update_time, + + + #{userId}, + #{realName}, + #{idCard}, + #{idCardFront}, + #{idCardBack}, + #{faceImage}, + #{authStatus}, + #{authTime}, + #{authFailReason}, + #{securityQuestion}, + #{securityAnswer}, + #{lastLoginTime}, + #{lastLoginIp}, + #{updateTime}, + + + + + update sys_muhu_user + + real_name = #{realName}, + id_card = #{idCard}, + id_card_front = #{idCardFront}, + id_card_back = #{idCardBack}, + face_image = #{faceImage}, + auth_status = #{authStatus}, + auth_time = #{authTime}, + auth_fail_reason = #{authFailReason}, + security_question = #{securityQuestion}, + security_answer = #{securityAnswer}, + last_login_time = #{lastLoginTime}, + last_login_ip = #{lastLoginIp}, + update_time = #{updateTime}, + + where user_id = #{userId} + + + + delete from sys_muhu_user where user_id = #{userId} + + + + delete from sys_muhu_user where user_id in + + #{userId} + + + \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/system/SysQuestionsMapper.xml b/chenhai-system/src/main/resources/mapper/system/SysQuestionsMapper.xml index 51c4cf6..eb9cada 100644 --- a/chenhai-system/src/main/resources/mapper/system/SysQuestionsMapper.xml +++ b/chenhai-system/src/main/resources/mapper/system/SysQuestionsMapper.xml @@ -16,6 +16,8 @@ + + @@ -30,7 +32,9 @@ q.tags, q.answer_count, q.created_at, - q.updated_at + q.updated_at, + q.images, + q.view_count FROM sys_questions q LEFT JOIN sys_user u ON q.user_id = u.user_id @@ -47,6 +51,18 @@ and created_at = #{createdAt} and updated_at = #{updatedAt} and u.nick_name like concat('%', #{nickName}, '%') + and images like concat('%', #{images}, '%') + + + and ( + q.title like concat('%', #{searchKey}, '%') + or q.content like concat('%', #{searchKey}, '%') + or q.tags like concat('%', #{searchKey}, '%') + or u.nick_name like concat('%', #{searchKey}, '%') + or u.user_name like concat('%', #{searchKey}, '%') + ) + + and view_count = #{viewCount} order by q.created_at desc @@ -67,6 +83,7 @@ answer_count, created_at, updated_at, + images, #{userId}, @@ -77,6 +94,7 @@ #{answerCount}, #{createdAt}, #{updatedAt}, + #{images}, @@ -91,6 +109,8 @@ answer_count = #{answerCount}, created_at = #{createdAt}, updated_at = #{updatedAt}, + images = #{images}, + view_count = #{viewCount}, where id = #{id} diff --git a/chenhai-ui/src/api/muhu/share.js b/chenhai-ui/src/api/muhu/share.js new file mode 100644 index 0000000..87eaa08 --- /dev/null +++ b/chenhai-ui/src/api/muhu/share.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询经验分享列表 +export function listShare(query) { + return request({ + url: '/muhu/share/list', + method: 'get', + params: query + }) +} + +// 查询经验分享详细 +export function getShare(id) { + return request({ + url: '/muhu/share/' + id, + method: 'get' + }) +} + +// 新增经验分享 +export function addShare(data) { + return request({ + url: '/muhu/share', + method: 'post', + data: data + }) +} + +// 修改经验分享 +export function updateShare(data) { + return request({ + url: '/muhu/share', + method: 'put', + data: data + }) +} + +// 删除经验分享 +export function delShare(id) { + return request({ + url: '/muhu/share/' + id, + method: 'delete' + }) +} diff --git a/chenhai-ui/src/api/system/again.js b/chenhai-ui/src/api/system/again.js new file mode 100644 index 0000000..3b47940 --- /dev/null +++ b/chenhai-ui/src/api/system/again.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询回复列表 +export function listAgain(query) { + return request({ + url: '/system/again/list', + method: 'get', + params: query + }) +} + +// 查询回复详细 +export function getAgain(id) { + return request({ + url: '/system/again/' + id, + method: 'get' + }) +} + +// 新增回复 +export function addAgain(data) { + return request({ + url: '/system/again', + method: 'post', + data: data + }) +} + +// 修改回复 +export function updateAgain(data) { + return request({ + url: '/system/again', + method: 'put', + data: data + }) +} + +// 删除回复 +export function delAgain(id) { + return request({ + url: '/system/again/' + id, + method: 'delete' + }) +} diff --git a/chenhai-ui/src/api/system/answers.js b/chenhai-ui/src/api/system/answers.js index a3e7de1..39d6ad0 100644 --- a/chenhai-ui/src/api/system/answers.js +++ b/chenhai-ui/src/api/system/answers.js @@ -42,3 +42,64 @@ export function delAnswers(id) { method: 'delete' }) } + +// 以下是新增的回复相关API + +// 查询顶级答复列表 +export function listRootAnswers(questionId, query) { + return request({ + url: `/system/answers/question/${questionId}/roots`, + method: 'get', + params: query + }) +} + +// 查询答复树形结构 +export function getAnswerTree(questionId) { + return request({ + url: `/system/answers/question/${questionId}/tree`, + method: 'get' + }) +} + +// 查询子回复列表 +export function listChildrenAnswers(parentId, query) { + return request({ + url: `/system/answers/parent/${parentId}/children`, + method: 'get', + params: query + }) +} + +// 新增回复 +export function addReply(data) { + return request({ + url: '/system/answers/reply', + method: 'post', + data: data + }) +} + +// 点赞答复 +export function likeAnswer(id) { + return request({ + url: `/system/answers/${id}/like`, + method: 'post' + }) +} + +// 取消点赞答复 +export function unlikeAnswer(id) { + return request({ + url: `/system/answers/${id}/unlike`, + method: 'post' + }) +} + +// 获取问题的答案数量 +export function countAnswersByQuestionId(questionId) { + return request({ + url: `/system/answers/count/${questionId}`, + method: 'get' + }) +} diff --git a/chenhai-ui/src/api/system/muhuuser.js b/chenhai-ui/src/api/system/muhuuser.js new file mode 100644 index 0000000..7b117d1 --- /dev/null +++ b/chenhai-ui/src/api/system/muhuuser.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询牧户用户列表 +export function listMuhuuser(query) { + return request({ + url: '/system/muhuuser/list', + method: 'get', + params: query + }) +} + +// 查询牧户用户详细 +export function getMuhuuser(userId) { + return request({ + url: '/system/muhuuser/' + userId, + method: 'get' + }) +} + +// 新增牧户用户 +export function addMuhuuser(data) { + return request({ + url: '/system/muhuuser', + method: 'post', + data: data + }) +} + +// 修改牧户用户 +export function updateMuhuuser(data) { + return request({ + url: '/system/muhuuser', + method: 'put', + data: data + }) +} + +// 删除牧户用户 +export function delMuhuuser(userId) { + return request({ + url: '/system/muhuuser/' + userId, + method: 'delete' + }) +} diff --git a/chenhai-ui/src/router/index.js b/chenhai-ui/src/router/index.js index ae0c866..d41d84a 100644 --- a/chenhai-ui/src/router/index.js +++ b/chenhai-ui/src/router/index.js @@ -30,73 +30,7 @@ import Layout from '@/layout' // 公共路由 export const constantRoutes = [ - // 专家管理路由 - { - path: '/vet/experts', - component: Layout, - children: [ - { - path: 'index', - component: () => import('@/views/vet/experts/index'), - name: 'VetExperts', - meta: { - title: '专家管理', - icon: 'user', - permissions: ['vet:experts:list'] - } - } - ] - }, - // 聊天页面路由 - { - path: '/chat', - component: Layout, - children: [ - { - path: 'index', - component: () => import('@/views/chat/index'), - name: 'ChatIndex', - meta: { - title: '在线咨询', - icon: 'message' - } - } - ] - }, - // 在路由文件中添加以下路由 - { - path: '/vet/experts', - component: Layout, - redirect: '/expert/chat/list', - meta: { - title: '专家中心', - icon: 'expert', - roles: ['vetnotshenhe', 'admin'] - }, - children: [ - { - path: 'chat/list', - component: () => import('@/views/chat/expert'), // 专家会话列表 - name: 'ExpertChatList', - meta: { - title: '我的咨询', - icon: 'list', - roles: ['vetnotshenhe', 'admin'] - } - }, - { - path: 'chat/index', - component: () => import('@/views/chat/expert'), // 专家聊天页面 - name: 'ExpertChat', - meta: { - title: '专家聊天', - icon: 'message', - roles: ['vetnotshenhe', 'admin'] - } - } - ] - }, { path: '/redirect', diff --git a/chenhai-ui/src/views/muhu/share/index.vue b/chenhai-ui/src/views/muhu/share/index.vue new file mode 100644 index 0000000..68f6ac1 --- /dev/null +++ b/chenhai-ui/src/views/muhu/share/index.vue @@ -0,0 +1,440 @@ + + + diff --git a/chenhai-ui/src/views/system/again/index.vue b/chenhai-ui/src/views/system/again/index.vue new file mode 100644 index 0000000..9692937 --- /dev/null +++ b/chenhai-ui/src/views/system/again/index.vue @@ -0,0 +1,275 @@ + + + + diff --git a/chenhai-ui/src/views/system/answers/index.vue b/chenhai-ui/src/views/system/answers/index.vue index e6236f1..31f5dd3 100644 --- a/chenhai-ui/src/views/system/answers/index.vue +++ b/chenhai-ui/src/views/system/answers/index.vue @@ -16,7 +16,7 @@ size="mini" @click="handleAdd" v-hasPermi="['system:answers:add']" - >新增 + >新增回答 - - - - - - - - - - - - + +
+
+ +
+
+ + +
+ + + 回复{{ answer.replyCount > 0 ? `(${answer.replyCount})` : '' }} + + + + {{ answer.showReplies ? '收起回复' : `查看回复(${answer.replyCount})` }} + + 修改 + 删除 +
+
+ +
+ {{ answer.content }} +
+ + +
+
+ + {{ answer.latestReplyNickName || '用户' }} + {{ formatReplyTime(answer.latestReplyTime) }} +
+ +
+ {{ answer.latestReplyContent || '回复内容' }} +
+ +
+ + 查看全部{{ answer.replyCount }}条回复 + + + + 回复 + +
+
+ + +
+ +
+ 提交 + 取消 +
+
+
+ + +
+
+
+ + +
+ 删除 +
+
+
+ {{ reply.content }} +
+
+ + +
+ + 查看更多回复(共{{ answer.replyCount }}条) + +
+
+
+
- + - + @@ -107,31 +209,36 @@ + + diff --git a/chenhai-ui/src/views/system/muhuuser/index.vue b/chenhai-ui/src/views/system/muhuuser/index.vue new file mode 100644 index 0000000..268c005 --- /dev/null +++ b/chenhai-ui/src/views/system/muhuuser/index.vue @@ -0,0 +1,323 @@ + + + diff --git a/chenhai-ui/src/views/system/questions/index.vue b/chenhai-ui/src/views/system/questions/index.vue index c5e2c4b..ad3a37e 100644 --- a/chenhai-ui/src/views/system/questions/index.vue +++ b/chenhai-ui/src/views/system/questions/index.vue @@ -3,49 +3,6 @@
- - - - - - - - - - - - - - - - 搜索 重置 @@ -88,17 +45,6 @@ v-hasPermi="['system:questions:remove']" >删除 - - 查看答案 -
- -
- -
+ +
+
- + + + + - + +