diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuConsultationFormsController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuConsultationFormsController.java index 9256d78..3c034d9 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuConsultationFormsController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuConsultationFormsController.java @@ -101,4 +101,16 @@ public class MuhuConsultationFormsController extends BaseController { return toAjax(muhuConsultationFormsService.deleteMuhuConsultationFormsByFormIds(formIds)); } + + /** + * 查询今日问诊单列表 + */ + @PreAuthorize("@ss.hasPermi('muhu:consultation:list') or @ss.hasRole('muhu')") + @GetMapping("/today") + public TableDataInfo todayList(MuhuConsultationForms muhuConsultationForms) + { + startPage(); + List list = muhuConsultationFormsService.selectTodayConsultationFormsList(muhuConsultationForms); + return getDataTable(list); + } } diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuFeedbackController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuFeedbackController.java new file mode 100644 index 0000000..b875bf9 --- /dev/null +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuFeedbackController.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.MuhuFeedback; +import com.chenhai.muhu.service.IMuhuFeedbackService; +import com.chenhai.common.utils.poi.ExcelUtil; +import com.chenhai.common.core.page.TableDataInfo; + +/** + * 反馈建议Controller + * + * @author ruoyi + * @date 2026-02-10 + */ +@RestController +@RequestMapping("/muhu/feedback") +public class MuhuFeedbackController extends BaseController +{ + @Autowired + private IMuhuFeedbackService muhuFeedbackService; + + /** + * 查询反馈建议列表 + */ + @PreAuthorize("@ss.hasPermi('muhu:feedback:list') or @ss.hasRole('muhu')") + @GetMapping("/list") + public TableDataInfo list(MuhuFeedback muhuFeedback) + { + startPage(); + List list = muhuFeedbackService.selectMuhuFeedbackList(muhuFeedback); + return getDataTable(list); + } + + /** + * 导出反馈建议列表 + */ + @PreAuthorize("@ss.hasPermi('muhu:feedback:export') or @ss.hasRole('muhu')") + @Log(title = "反馈建议", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MuhuFeedback muhuFeedback) + { + List list = muhuFeedbackService.selectMuhuFeedbackList(muhuFeedback); + ExcelUtil util = new ExcelUtil(MuhuFeedback.class); + util.exportExcel(response, list, "反馈建议数据"); + } + + /** + * 获取反馈建议详细信息 + */ + @PreAuthorize("@ss.hasPermi('muhu:feedback:query') or @ss.hasRole('muhu')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(muhuFeedbackService.selectMuhuFeedbackById(id)); + } + + /** + * 新增反馈建议 + */ + @PreAuthorize("@ss.hasPermi('muhu:feedback:add') or @ss.hasRole('muhu')") + @Log(title = "反馈建议", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MuhuFeedback muhuFeedback) + { + return toAjax(muhuFeedbackService.insertMuhuFeedback(muhuFeedback)); + } + + /** + * 修改反馈建议 + */ + @PreAuthorize("@ss.hasPermi('muhu:feedback:edit') or @ss.hasRole('muhu')") + @Log(title = "反馈建议", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MuhuFeedback muhuFeedback) + { + return toAjax(muhuFeedbackService.updateMuhuFeedback(muhuFeedback)); + } + + /** + * 删除反馈建议 + */ + @PreAuthorize("@ss.hasPermi('muhu:feedback:remove') or @ss.hasRole('muhu')") + @Log(title = "反馈建议", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(muhuFeedbackService.deleteMuhuFeedbackByIds(ids)); + } +} diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java index 126f46f..6ef10a1 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java @@ -1,27 +1,49 @@ package com.chenhai.web.controller.muhu; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.chenhai.common.utils.DictUtils; +import com.chenhai.common.utils.StringUtils; +import com.chenhai.framework.web.service.TokenService; +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.RequestParam; +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.core.domain.entity.SysArea; import com.chenhai.common.core.domain.entity.SysUser; import com.chenhai.common.core.domain.model.LoginUser; +import com.chenhai.common.enums.BusinessType; +import com.chenhai.system.domain.SysMuhuUser; +import com.chenhai.system.service.ISysMuhuUserService; import com.chenhai.system.service.ISysAreaService; import com.chenhai.system.service.ISysUserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.List; +import com.chenhai.common.utils.poi.ExcelUtil; +import com.chenhai.common.core.page.TableDataInfo; /** * @author : mazhongxu * @date : 2026-01-14 17:08 - * @modyified By : + * @modified By : */ @RestController @RequestMapping("/muhu/user") public class MuhuUserController extends BaseController { + @Autowired + private ISysMuhuUserService sysMuhuUserService; @Autowired private ISysAreaService sysAreaService; @@ -29,6 +51,196 @@ public class MuhuUserController extends BaseController @Autowired private ISysUserService sysUserService; + @Autowired + private TokenService tokenService; + + /** + * 查询牧户用户列表 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:list') or @ss.hasRole('muhu')") + @GetMapping("/list") + public TableDataInfo list(SysMuhuUser sysMuhuUser) + { + startPage(); + List list = sysMuhuUserService.selectSysMuhuUserList(sysMuhuUser); + return getDataTable(list); + } + + /** + * 导出牧户用户列表 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:export') or @ss.hasRole('muhu')") + @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') or @ss.hasRole('muhu')") + @GetMapping(value = "/{userId}") + public AjaxResult getInfo(@PathVariable("userId") Long userId) + { + return success(sysMuhuUserService.selectSysMuhuUserByUserId(userId)); + } + + /** + * 新增牧户用户 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:add') or @ss.hasRole('muhu')") + @Log(title = "牧户用户", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysMuhuUser sysMuhuUser) + { + try { + // 自动设置当前登录用户的ID + Long currentUserId = getUserId(); + if (currentUserId == null) { + return error("用户未登录,无法创建牧户信息"); + } + + // 设置当前用户ID + sysMuhuUser.setUserId(currentUserId); + + return toAjax(sysMuhuUserService.insertSysMuhuUser(sysMuhuUser)); + } catch (IllegalArgumentException e) { + return error(e.getMessage()); + } catch (Exception e) { + return error("新增失败:" + e.getMessage()); + } + } + + /** + * 修改牧户用户 + */ + @PreAuthorize("@ss.hasRole('muhu')") + @Log(title = "牧户个人信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult updateProfile(@RequestBody SysUser user) { + LoginUser loginUser = getLoginUser(); + if (loginUser == null) { + return error("用户未登录"); + } + + SysUser currentUser = loginUser.getUser(); + boolean hasUpdate = false; + + // 验证昵称 + if (StringUtils.isNotEmpty(user.getNickName())) { + // 昵称长度验证 + if (user.getNickName().length() < 2 || user.getNickName().length() > 20) { + return error("昵称长度应在2-20个字符之间"); + } + currentUser.setNickName(user.getNickName()); + hasUpdate = true; + } + + // 验证头像URL + if (StringUtils.isNotEmpty(user.getAvatar())) { + currentUser.setAvatar(user.getAvatar()); + hasUpdate = true; + } + + // 如果昵称和头像都为空,直接返回成功 + if (!hasUpdate) { + return success(); + } + + // 检查手机号是否唯一(如果需要) + if (StringUtils.isNotEmpty(user.getPhonenumber())) { + currentUser.setPhonenumber(user.getPhonenumber()); + if (!sysUserService.checkPhoneUnique(currentUser)) { + return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在"); + } + } + + // 检查邮箱是否唯一(如果需要) + if (StringUtils.isNotEmpty(user.getEmail())) { + currentUser.setEmail(user.getEmail()); + if (!sysUserService.checkEmailUnique(currentUser)) { + return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在"); + } + } + + // 更新用户信息 + if (sysUserService.updateUserProfile(currentUser) > 0) { + // 更新缓存用户信息 + tokenService.setLoginUser(loginUser); + return success(); + } + + return error("修改个人信息异常,请联系管理员"); + } + + /** + * 删除牧户用户 + */ + @PreAuthorize("@ss.hasPermi('system:muhuuser:remove') or @ss.hasRole('muhu')") + @Log(title = "牧户用户", businessType = BusinessType.DELETE) + @DeleteMapping("/{userIds}") + public AjaxResult remove(@PathVariable Long[] userIds) + { + return toAjax(sysMuhuUserService.deleteSysMuhuUserByUserIds(userIds)); + } + + /** + * 提交实名认证(新增) + */ + @PreAuthorize("@ss.hasRole('muhu')") + @PostMapping("/auth/submit") + public AjaxResult submitAuth(@RequestBody AuthRequest request) + { + try { + Long userId = getUserId(); // 获取当前登录用户ID + + boolean result = sysMuhuUserService.submitRealNameAuth( + userId, + request.getRealName(), + request.getIdCard() + ); + + if (result) { + return success("实名认证成功"); + } else { + return error("实名认证失败"); + } + } catch (RuntimeException e) { + return error(e.getMessage()); + } + } + + /** + * 实名认证请求对象 + */ + public static class AuthRequest { + private String realName; + private String idCard; + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + } + + /** + * 获取区域子节点 + */ @PreAuthorize("@ss.hasRole('muhu')") @GetMapping("/areaChildren") public AjaxResult getAreaChildren(@RequestParam(value = "parentCode", required = false, defaultValue = "152900") String parentCode) { @@ -39,18 +251,64 @@ public class MuhuUserController extends BaseController return success(list); } + /** + * 获取用户信息 + */ @PreAuthorize("@ss.hasRole('muhu')") @GetMapping("/getUserInfo") - public AjaxResult checkUserAreaCode() { - LoginUser loginUser = getLoginUser(); - SysUser user = loginUser.getUser(); - return success(user); + public AjaxResult getUserInfo() { + try { + LoginUser loginUser = getLoginUser(); + SysUser user = loginUser.getUser(); + + // 添加认证状态信息 + Map result = new HashMap<>(); + result.put("user", user); + + // 查询实名认证状态 + Long userId = user.getUserId(); + if (userId != null) { + // 方法1:直接查询牧户用户表 + SysMuhuUser muhuUser = sysMuhuUserService.selectSysMuhuUserByUserId(userId); + + if (muhuUser != null && muhuUser.getAuthStatus() != null) { + // 获取认证状态 + String authStatus = muhuUser.getAuthStatus(); + String statusLabel = DictUtils.getDictLabel("auth_status", authStatus, "未认证"); + + // 根据状态判断是否已认证 + boolean isAuthenticated = "1".equals(authStatus); // 假设1表示已认证 + + result.put("authStatus", authStatus); + + // 如果需要,可以添加认证的详细信息 + if (isAuthenticated) { + Map authInfo = new HashMap<>(); + authInfo.put("realName", muhuUser.getRealName()); + authInfo.put("authTime", muhuUser.getAuthTime()); + result.put("authInfo", authInfo); + } + } else { + // 没有认证记录 + result.put("authStatus", "未认证"); + } + } else { + result.put("authStatus", "未认证"); + } + + return success(result); + } catch (Exception e) { + return error("获取用户信息失败: " + e.getMessage()); + } } + /** + * 保存用户区域代码 + */ @PreAuthorize("@ss.hasRole('muhu')") @PutMapping("/saveUserAreaCode/{areaCode}") public AjaxResult getArea(@PathVariable("areaCode") String areaCode) { Long userId = getUserId(); return toAjax(sysUserService.updateUserAreaCode(userId, areaCode)); } -} +} \ No newline at end of file diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysLoginController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysLoginController.java index 8be440c..070a430 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysLoginController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/system/SysLoginController.java @@ -48,8 +48,6 @@ public class SysLoginController @Autowired private ISysConfigService configService; - @Autowired // 添加这行 - private IVetExpertsService vetExpertsService; /** * 登录方法 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 index f871930..5dfcedf 100644 --- 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 @@ -1,6 +1,10 @@ package com.chenhai.web.controller.system; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import com.chenhai.common.utils.DictUtils; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -37,7 +41,7 @@ public class SysMuhuUserController extends BaseController /** * 查询牧户用户列表 */ - @PreAuthorize("@ss.hasPermi('system:muhuuser:list')") + @PreAuthorize("@ss.hasPermi('system:muhuuser:list') or @ss.hasRole('muhu')") @GetMapping("/list") public TableDataInfo list(SysMuhuUser sysMuhuUser) { @@ -49,7 +53,7 @@ public class SysMuhuUserController extends BaseController /** * 导出牧户用户列表 */ - @PreAuthorize("@ss.hasPermi('system:muhuuser:export')") + @PreAuthorize("@ss.hasPermi('system:muhuuser:export') or @ss.hasRole('muhu')") @Log(title = "牧户用户", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SysMuhuUser sysMuhuUser) @@ -62,7 +66,7 @@ public class SysMuhuUserController extends BaseController /** * 获取牧户用户详细信息 */ - @PreAuthorize("@ss.hasPermi('system:muhuuser:query')") + @PreAuthorize("@ss.hasPermi('system:muhuuser:query') or @ss.hasRole('muhu')") @GetMapping(value = "/{userId}") public AjaxResult getInfo(@PathVariable("userId") Long userId) { @@ -72,18 +76,33 @@ public class SysMuhuUserController extends BaseController /** * 新增牧户用户 */ - @PreAuthorize("@ss.hasPermi('system:muhuuser:add')") + @PreAuthorize("@ss.hasPermi('system:muhuuser:add') or @ss.hasRole('muhu')") @Log(title = "牧户用户", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SysMuhuUser sysMuhuUser) { - return toAjax(sysMuhuUserService.insertSysMuhuUser(sysMuhuUser)); + try { + // 自动设置当前登录用户的ID + Long currentUserId = getUserId(); + if (currentUserId == null) { + return error("用户未登录,无法创建牧户信息"); + } + + // 设置当前用户ID + sysMuhuUser.setUserId(currentUserId); + + return toAjax(sysMuhuUserService.insertSysMuhuUser(sysMuhuUser)); + } catch (IllegalArgumentException e) { + return error(e.getMessage()); + } catch (Exception e) { + return error("新增失败:" + e.getMessage()); + } } /** * 修改牧户用户 */ - @PreAuthorize("@ss.hasPermi('system:muhuuser:edit')") + @PreAuthorize("@ss.hasPermi('system:muhuuser:edit') or @ss.hasRole('muhu')") @Log(title = "牧户用户", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SysMuhuUser sysMuhuUser) @@ -94,11 +113,133 @@ public class SysMuhuUserController extends BaseController /** * 删除牧户用户 */ - @PreAuthorize("@ss.hasPermi('system:muhuuser:remove')") + @PreAuthorize("@ss.hasPermi('system:muhuuser:remove') or @ss.hasRole('muhu')") @Log(title = "牧户用户", businessType = BusinessType.DELETE) @DeleteMapping("/{userIds}") public AjaxResult remove(@PathVariable Long[] userIds) { return toAjax(sysMuhuUserService.deleteSysMuhuUserByUserIds(userIds)); } + + /** + * 提交实名认证(新增) + */ + @PreAuthorize("@ss.hasRole('muhu')") + @PostMapping("/auth/submit") + public AjaxResult submitAuth(@RequestBody AuthRequest request) + { + try { + Long userId = getUserId(); // 获取当前登录用户ID + + boolean result = sysMuhuUserService.submitRealNameAuth( + userId, + request.getRealName(), + request.getIdCard() + ); + + if (result) { + return success("实名认证成功"); + } else { + return error("实名认证失败"); + } + } catch (RuntimeException e) { + return error(e.getMessage()); + } + } + + /** + * 实名认证请求对象 + */ + public static class AuthRequest { + private String realName; + private String idCard; + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + } + + /** + * 获取当前用户的实名认证状态 + */ + @PreAuthorize("@ss.hasRole('muhu')") + @GetMapping("/auth/status") + public AjaxResult getAuthStatus() { + try { + Long userId = getUserId(); // 获取当前登录用户ID + if (userId == null) { + return error("用户未登录"); + } + + String authStatus = sysMuhuUserService.getAuthStatusByUserId(userId); + + // 使用字典工具获取状态标签 + String statusLabel = DictUtils.getDictLabel("auth_status", authStatus, "未认证"); + + Map result = new HashMap<>(); + result.put("userId", userId); + result.put("authStatus", authStatus); + result.put("statusLabel", statusLabel); + + return success(result); + } catch (Exception e) { + return error("获取认证状态失败: " + e.getMessage()); + } + } + + /** + * 获取实名认证状态详情 + */ + @PreAuthorize("@ss.hasRole('muhu')") + @GetMapping("/auth/detail") + public AjaxResult getAuthDetail() { + try { + Long userId = getUserId(); + if (userId == null) { + return error("用户未登录"); + } + + SysMuhuUser user = sysMuhuUserService.selectSysMuhuUserByUserId(userId); + + Map result = new HashMap<>(); + + if (user == null) { + // 用户不存在,返回默认状态 + result.put("userId", userId); + result.put("authStatus", "0"); + result.put("statusLabel", "未认证"); + result.put("hasRecord", false); + } else { + // 使用字典转换状态码为标签 + String statusLabel = DictUtils.getDictLabel("auth_status", user.getAuthStatus(), "未认证"); + + result.put("userId", user.getUserId()); + result.put("realName", user.getRealName()); + result.put("idCard", user.getIdCard()); + result.put("authStatus", user.getAuthStatus()); + result.put("statusLabel", statusLabel); + result.put("authTime", user.getAuthTime()); + result.put("authFailReason", user.getAuthFailReason()); + result.put("hasRecord", true); + } + + return success(result); + } catch (Exception e) { + return error("获取认证详情失败: " + e.getMessage()); + } + } + + } diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCommentsController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCommentsController.java index 8c59456..c728617 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCommentsController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCommentsController.java @@ -37,7 +37,7 @@ public class VetCommentsController extends BaseController /** * 查询兽医回复列表 */ - @PreAuthorize("@ss.hasPermi('vet:comments:list') or @ss.hasRole('vetnotshenhe')") + @PreAuthorize("@ss.hasPermi('vet:comments:list') or @ss.hasRole('vetnotshenhe') or @ss.hasRole('vet')") @GetMapping("/list") public TableDataInfo list(VetComments vetComments) { @@ -49,7 +49,7 @@ public class VetCommentsController extends BaseController /** * 导出兽医回复列表 */ - @PreAuthorize("@ss.hasPermi('vet:comments:export') or @ss.hasRole('vetnotshenhe')") + @PreAuthorize("@ss.hasPermi('vet:comments:export') or @ss.hasRole('vetnotshenhe') or @ss.hasRole('vet')") @Log(title = "兽医回复", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, VetComments vetComments) @@ -62,7 +62,7 @@ public class VetCommentsController extends BaseController /** * 获取兽医回复详细信息 */ - @PreAuthorize("@ss.hasPermi('vet:comments:query') or @ss.hasRole('vetnotshenhe')") + @PreAuthorize("@ss.hasPermi('vet:comments:query') or @ss.hasRole('vetnotshenhe') or @ss.hasRole('vet')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -72,7 +72,7 @@ public class VetCommentsController extends BaseController /** * 新增兽医回复 */ - @PreAuthorize("@ss.hasPermi('vet:comments:add') or @ss.hasRole('vetnotshenhe')") + @PreAuthorize("@ss.hasPermi('vet:comments:add') or @ss.hasRole('vetnotshenhe') or @ss.hasRole('vet')") @Log(title = "兽医回复", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody VetComments vetComments) @@ -83,7 +83,7 @@ public class VetCommentsController extends BaseController /** * 修改兽医回复 */ - @PreAuthorize("@ss.hasPermi('vet:comments:edit') or @ss.hasRole('vetnotshenhe')") + @PreAuthorize("@ss.hasPermi('vet:comments:edit') or @ss.hasRole('vetnotshenhe') or @ss.hasRole('vet')") @Log(title = "兽医回复", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody VetComments vetComments) @@ -94,7 +94,7 @@ public class VetCommentsController extends BaseController /** * 删除兽医回复 */ - @PreAuthorize("@ss.hasPermi('vet:comments:remove') or @ss.hasRole('vetnotshenhe')") + @PreAuthorize("@ss.hasPermi('vet:comments:remove') or @ss.hasRole('vetnotshenhe') or @ss.hasRole('vet')") @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/MuhuConsultationForms.java b/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuConsultationForms.java index 99b9f31..6988149 100644 --- a/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuConsultationForms.java +++ b/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuConsultationForms.java @@ -83,6 +83,9 @@ public class MuhuConsultationForms extends BaseEntity @Excel(name = "头像") private String avatar; + /** 今日回复总数(非数据库字段,用于统计) */ + private Long todayReplyCount; + public void setFormId(Long formId) { this.formId = formId; @@ -243,6 +246,14 @@ public class MuhuConsultationForms extends BaseEntity return avatar; } + public Long getTodayReplyCount() { + return todayReplyCount; + } + + public void setTodayReplyCount(Long todayReplyCount) { + this.todayReplyCount = todayReplyCount; + } + @Override public String toString() { @@ -263,6 +274,7 @@ public class MuhuConsultationForms extends BaseEntity .append("replyCount", getReplyCount()) .append("createdTime", getCreatedTime()) .append("avatar", getAvatar()) + .append("todayReplyCount", getTodayReplyCount()) .toString(); } } diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuFeedback.java b/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuFeedback.java new file mode 100644 index 0000000..1413d53 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/domain/MuhuFeedback.java @@ -0,0 +1,237 @@ +package com.chenhai.muhu.domain; + +import java.util.Date; + +import com.chenhai.common.core.domain.entity.SysUser; +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_feedback + * + * @author ruoyi + * @date 2026-02-10 + */ +public class MuhuFeedback extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 反馈ID */ + private Long id; + + /** 用户ID */ + @Excel(name = "用户ID") + private Long userId; + + /** 反馈类型 */ + @Excel(name = "反馈类型") + private String type; + + /** 反馈标题 */ + @Excel(name = "反馈标题") + private String title; + + /** 反馈内容 */ + @Excel(name = "反馈内容") + private String content; + + /** 联系方式 */ + @Excel(name = "联系方式") + private String contactInfo; + + /** 状态 */ + @Excel(name = "状态") + private String status; + + /** 优先级 */ + @Excel(name = "优先级") + private String priority; + + /** 平台来源 */ + @Excel(name = "平台来源") + private String platform; + + /** 应用版本号 */ + @Excel(name = "应用版本号") + private String version; + + /** 图片地址 */ + @Excel(name = "图片地址") + private String images; + + /** 创建时间 */ + @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; + + /** 用户昵称 */ + private String nickName; + + 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 setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + + 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 setContactInfo(String contactInfo) + { + this.contactInfo = contactInfo; + } + + public String getContactInfo() + { + return contactInfo; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + public void setPriority(String priority) + { + this.priority = priority; + } + + public String getPriority() + { + return priority; + } + + public void setPlatform(String platform) + { + this.platform = platform; + } + + public String getPlatform() + { + return platform; + } + + public void setVersion(String version) + { + this.version = version; + } + + public String getVersion() + { + return version; + } + + public void setImages(String images) + { + this.images = images; + } + + public String getImages() + { + return images; + } + + 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 setNickName(String nickName) + { + this.nickName = nickName; + } + + public String getNickName() + { + return nickName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("userId", getUserId()) + .append("type", getType()) + .append("title", getTitle()) + .append("content", getContent()) + .append("contactInfo", getContactInfo()) + .append("status", getStatus()) + .append("priority", getPriority()) + .append("platform", getPlatform()) + .append("version", getVersion()) + .append("images", getImages()) + .append("createdAt", getCreatedAt()) + .append("updatedAt", getUpdatedAt()) + .append("nickName", getNickName()) + .toString(); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuConsultationFormsMapper.java b/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuConsultationFormsMapper.java index a887b21..80d3542 100644 --- a/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuConsultationFormsMapper.java +++ b/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuConsultationFormsMapper.java @@ -58,4 +58,12 @@ public interface MuhuConsultationFormsMapper * @return 结果 */ public int deleteMuhuConsultationFormsByFormIds(Long[] formIds); + + /** + * 查询今日问诊单列表 + * + * @param muhuConsultationForms 问诊单 + * @return 问诊单集合 + */ + public List selectTodayConsultationFormsList(MuhuConsultationForms muhuConsultationForms); } diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuFeedbackMapper.java b/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuFeedbackMapper.java new file mode 100644 index 0000000..23565a7 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/mapper/MuhuFeedbackMapper.java @@ -0,0 +1,61 @@ +package com.chenhai.muhu.mapper; + +import java.util.List; +import com.chenhai.muhu.domain.MuhuFeedback; + +/** + * 反馈建议Mapper接口 + * + * @author ruoyi + * @date 2026-02-10 + */ +public interface MuhuFeedbackMapper +{ + /** + * 查询反馈建议 + * + * @param id 反馈建议主键 + * @return 反馈建议 + */ + public MuhuFeedback selectMuhuFeedbackById(Long id); + + /** + * 查询反馈建议列表 + * + * @param muhuFeedback 反馈建议 + * @return 反馈建议集合 + */ + public List selectMuhuFeedbackList(MuhuFeedback muhuFeedback); + + /** + * 新增反馈建议 + * + * @param muhuFeedback 反馈建议 + * @return 结果 + */ + public int insertMuhuFeedback(MuhuFeedback muhuFeedback); + + /** + * 修改反馈建议 + * + * @param muhuFeedback 反馈建议 + * @return 结果 + */ + public int updateMuhuFeedback(MuhuFeedback muhuFeedback); + + /** + * 删除反馈建议 + * + * @param id 反馈建议主键 + * @return 结果 + */ + public int deleteMuhuFeedbackById(Long id); + + /** + * 批量删除反馈建议 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMuhuFeedbackByIds(Long[] ids); +} diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuConsultationFormsService.java b/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuConsultationFormsService.java index 3e56502..bc91bfe 100644 --- a/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuConsultationFormsService.java +++ b/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuConsultationFormsService.java @@ -58,4 +58,12 @@ public interface IMuhuConsultationFormsService * @return 结果 */ public int deleteMuhuConsultationFormsByFormId(Long formId); + + /** + * 查询今日问诊单列表 + * + * @param muhuConsultationForms 问诊单 + * @return 问诊单集合 + */ + public List selectTodayConsultationFormsList(MuhuConsultationForms muhuConsultationForms); } diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuFeedbackService.java b/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuFeedbackService.java new file mode 100644 index 0000000..463824f --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/service/IMuhuFeedbackService.java @@ -0,0 +1,61 @@ +package com.chenhai.muhu.service; + +import java.util.List; +import com.chenhai.muhu.domain.MuhuFeedback; + +/** + * 反馈建议Service接口 + * + * @author ruoyi + * @date 2026-02-10 + */ +public interface IMuhuFeedbackService +{ + /** + * 查询反馈建议 + * + * @param id 反馈建议主键 + * @return 反馈建议 + */ + public MuhuFeedback selectMuhuFeedbackById(Long id); + + /** + * 查询反馈建议列表 + * + * @param muhuFeedback 反馈建议 + * @return 反馈建议集合 + */ + public List selectMuhuFeedbackList(MuhuFeedback muhuFeedback); + + /** + * 新增反馈建议 + * + * @param muhuFeedback 反馈建议 + * @return 结果 + */ + public int insertMuhuFeedback(MuhuFeedback muhuFeedback); + + /** + * 修改反馈建议 + * + * @param muhuFeedback 反馈建议 + * @return 结果 + */ + public int updateMuhuFeedback(MuhuFeedback muhuFeedback); + + /** + * 批量删除反馈建议 + * + * @param ids 需要删除的反馈建议主键集合 + * @return 结果 + */ + public int deleteMuhuFeedbackByIds(Long[] ids); + + /** + * 删除反馈建议信息 + * + * @param id 反馈建议主键 + * @return 结果 + */ + public int deleteMuhuFeedbackById(Long id); +} diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuConsultationFormsServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuConsultationFormsServiceImpl.java index 32a3889..02cd234 100644 --- a/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuConsultationFormsServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuConsultationFormsServiceImpl.java @@ -35,7 +35,10 @@ public class MuhuConsultationFormsServiceImpl implements IMuhuConsultationFormsS @Override public MuhuConsultationForms selectMuhuConsultationFormsByFormId(Long formId) { MuhuConsultationForms form = muhuConsultationFormsMapper.selectMuhuConsultationFormsByFormId(formId); + + // 检查用户是否有权限查看该问诊单 if (form != null) { + checkViewPermission(form); // 修复回复数量 fixReplyCountAndStatus(form); } @@ -54,16 +57,33 @@ public class MuhuConsultationFormsServiceImpl implements IMuhuConsultationFormsS // 检查是否有admin权限 boolean isAdmin = SecurityUtils.hasRole("admin") || SecurityUtils.hasPermi("*:*:*"); - if (SecurityUtils.hasRole("muhu") && !isAdmin && SecurityUtils.hasRole("vetnotshenhe")) { - LoginUser loginUser = SecurityUtils.getLoginUser(); - if (loginUser != null) { - // 如果是muhu用户且不是admin,只能查看自己的问诊单 + // 检查是否是兽医角色 + boolean isVet = SecurityUtils.hasRole("vet"); + boolean isVetNotShenhe = SecurityUtils.hasRole("vetnotshenhe"); + + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + // 如果是普通用户(muhu),且不是管理员,只能查看自己的问诊单 + if (SecurityUtils.hasRole("muhu") && !isAdmin) { muhuConsultationForms.setUserId(loginUser.getUserId()); } + // 如果是兽医,但未审核,不能查看任何问诊单(或者只能查看自己回复的) + else if (isVetNotShenhe && !isAdmin) { + // 未审核的兽医不能查看问诊单,返回空列表 + // 或者可以设置一个不可能的条件,如userId = -1 + muhuConsultationForms.setUserId(-1L); + return muhuConsultationFormsMapper.selectMuhuConsultationFormsList(muhuConsultationForms); + } + // 如果是已审核的兽医,可以查看所有问诊单,不需要设置userId } List list = muhuConsultationFormsMapper.selectMuhuConsultationFormsList(muhuConsultationForms); + // 对于普通用户,还需要在返回前再次过滤,确保只返回自己的问诊单 + if (loginUser != null && SecurityUtils.hasRole("muhu") && !isAdmin) { + list.removeIf(form -> !form.getUserId().equals(loginUser.getUserId())); + } + // 修复每个问诊单的回复数量和状态 for (MuhuConsultationForms form : list) { fixReplyCountAndStatus(form); @@ -234,4 +254,85 @@ public class MuhuConsultationFormsServiceImpl implements IMuhuConsultationFormsS return 0L; } } + + /** + * 检查用户是否有权限查看问诊单 + * @param form 问诊单 + */ + private void checkViewPermission(MuhuConsultationForms form) { + if (form == null) { + return; + } + + boolean isAdmin = SecurityUtils.hasRole("admin") || SecurityUtils.hasPermi("*:*:*"); + LoginUser loginUser = SecurityUtils.getLoginUser(); + + // 如果是管理员,可以查看所有 + if (isAdmin) { + return; + } + + // 如果是普通用户,只能查看自己的问诊单 + if (SecurityUtils.hasRole("muhu") && loginUser != null) { + if (!form.getUserId().equals(loginUser.getUserId())) { + throw new RuntimeException("您没有权限查看此问诊单"); + } + } + + // 如果是未审核的兽医,不能查看 + if (SecurityUtils.hasRole("vetnotshenhe")) { + throw new RuntimeException("未审核的兽医不能查看问诊单"); + } + + // 已审核的兽医可以查看所有问诊单 + if (SecurityUtils.hasRole("vet")) { + return; + } + } + + /** + * 查询今日问诊单列表 + * + * @param muhuConsultationForms 问诊单 + * @return 问诊单 + */ + @Override + public List selectTodayConsultationFormsList(MuhuConsultationForms muhuConsultationForms) + { + // 检查是否有admin权限 + boolean isAdmin = SecurityUtils.hasRole("admin") || SecurityUtils.hasPermi("*:*:*"); + + // 检查是否是兽医角色 + boolean isVet = SecurityUtils.hasRole("vet"); + boolean isVetNotShenhe = SecurityUtils.hasRole("vetnotshenhe"); + + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + // 如果是普通用户(muhu),且不是管理员,只能查看自己的问诊单 + if (SecurityUtils.hasRole("muhu") && !isAdmin) { + muhuConsultationForms.setUserId(loginUser.getUserId()); + } + // 如果是兽医,但未审核,不能查看任何问诊单 + else if (isVetNotShenhe && !isAdmin) { + // 未审核的兽医不能查看问诊单,返回空列表 + muhuConsultationForms.setUserId(-1L); + return muhuConsultationFormsMapper.selectTodayConsultationFormsList(muhuConsultationForms); + } + // 如果是已审核的兽医,可以查看所有问诊单,不需要设置userId + } + + List list = muhuConsultationFormsMapper.selectTodayConsultationFormsList(muhuConsultationForms); + + // 对于普通用户,还需要在返回前再次过滤,确保只返回自己的问诊单 + if (loginUser != null && SecurityUtils.hasRole("muhu") && !isAdmin) { + list.removeIf(form -> !form.getUserId().equals(loginUser.getUserId())); + } + + // 修复每个问诊单的回复数量和状态 + for (MuhuConsultationForms form : list) { + fixReplyCountAndStatus(form); + } + + return list; + } } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuFeedbackServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuFeedbackServiceImpl.java new file mode 100644 index 0000000..e79e8d3 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/muhu/service/impl/MuhuFeedbackServiceImpl.java @@ -0,0 +1,117 @@ +package com.chenhai.muhu.service.impl; + +import java.util.Date; +import java.util.List; + +import com.chenhai.common.core.domain.entity.SysUser; +import com.chenhai.common.core.domain.model.LoginUser; +import com.chenhai.common.utils.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chenhai.muhu.mapper.MuhuFeedbackMapper; +import com.chenhai.muhu.domain.MuhuFeedback; +import com.chenhai.muhu.service.IMuhuFeedbackService; + +/** + * 反馈建议Service业务层处理 + * + * @author ruoyi + * @date 2026-02-10 + */ +@Service +public class MuhuFeedbackServiceImpl implements IMuhuFeedbackService +{ + @Autowired + private MuhuFeedbackMapper muhuFeedbackMapper; + + /** + * 查询反馈建议 + * + * @param id 反馈建议主键 + * @return 反馈建议 + */ + @Override + public MuhuFeedback selectMuhuFeedbackById(Long id) + { + return muhuFeedbackMapper.selectMuhuFeedbackById(id); + } + + /** + * 查询反馈建议列表 + * + * @param muhuFeedback 反馈建议 + * @return 反馈建议 + */ + @Override + public List selectMuhuFeedbackList(MuhuFeedback muhuFeedback) + { + return muhuFeedbackMapper.selectMuhuFeedbackList(muhuFeedback); + } + + /** + * 新增反馈建议 + * + * @param muhuFeedback 反馈建议 + * @return 结果 + */ + @Override + public int insertMuhuFeedback(MuhuFeedback muhuFeedback) + { + // 获取当前登录用户信息 + LoginUser loginUser = SecurityUtils.getLoginUser(); + + if (loginUser != null && loginUser.getUser() != null) { + SysUser user = loginUser.getUser(); + // 自动设置用户ID和昵称 + muhuFeedback.setUserId(user.getUserId()); + muhuFeedback.setNickName(user.getNickName()); + } else { + // 如果没有登录用户,可以根据需要设置默认值或抛出异常 + throw new RuntimeException("用户未登录,无法提交反馈"); + } + + // 设置时间 + Date now = new Date(); + muhuFeedback.setCreatedAt(now); + muhuFeedback.setUpdatedAt(now); + + return muhuFeedbackMapper.insertMuhuFeedback(muhuFeedback); + } + + + /** + * 修改反馈建议 + * + * @param muhuFeedback 反馈建议 + * @return 结果 + */ + @Override + public int updateMuhuFeedback(MuhuFeedback muhuFeedback) + { + return muhuFeedbackMapper.updateMuhuFeedback(muhuFeedback); + } + + /** + * 批量删除反馈建议 + * + * @param ids 需要删除的反馈建议主键 + * @return 结果 + */ + @Override + public int deleteMuhuFeedbackByIds(Long[] ids) + { + return muhuFeedbackMapper.deleteMuhuFeedbackByIds(ids); + } + + /** + * 删除反馈建议信息 + * + * @param id 反馈建议主键 + * @return 结果 + */ + @Override + public int deleteMuhuFeedbackById(Long id) + { + return muhuFeedbackMapper.deleteMuhuFeedbackById(id); + } +} 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 index 249beff..9772183 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/domain/SysMuhuUser.java +++ b/chenhai-system/src/main/java/com/chenhai/system/domain/SysMuhuUser.java @@ -1,6 +1,8 @@ package com.chenhai.system.domain; import java.util.Date; + +import com.chenhai.common.core.domain.entity.SysUser; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -9,7 +11,7 @@ import com.chenhai.common.core.domain.BaseEntity; /** * 牧户用户对象 sys_muhu_user - * + * * @author ruoyi * @date 2026-02-03 */ @@ -41,7 +43,7 @@ public class SysMuhuUser extends BaseEntity private String faceImage; /** 认证状态(0未认证 1已认证 2审核中 3认证失败) */ - @Excel(name = "认证状态", readConverterExp = "0=未认证,1=已认证,2=审核中,3=认证失败") + @Excel(name = "认证状态") private String authStatus; /** 认证时间 */ @@ -70,136 +72,147 @@ public class SysMuhuUser extends BaseEntity @Excel(name = "最后登录IP") private String lastLoginIp; - public void setUserId(Long userId) + /** 关联的系统用户对象 */ + private SysUser sysUser; + + public void setUserId(Long userId) { this.userId = userId; } - public Long getUserId() + public Long getUserId() { return userId; } - public void setRealName(String realName) + public void setRealName(String realName) { this.realName = realName; } - public String getRealName() + public String getRealName() { return realName; } - public void setIdCard(String idCard) + public void setIdCard(String idCard) { this.idCard = idCard; } - public String getIdCard() + public String getIdCard() { return idCard; } - public void setIdCardFront(String idCardFront) + public void setIdCardFront(String idCardFront) { this.idCardFront = idCardFront; } - public String getIdCardFront() + public String getIdCardFront() { return idCardFront; } - public void setIdCardBack(String idCardBack) + public void setIdCardBack(String idCardBack) { this.idCardBack = idCardBack; } - public String getIdCardBack() + public String getIdCardBack() { return idCardBack; } - public void setFaceImage(String faceImage) + public void setFaceImage(String faceImage) { this.faceImage = faceImage; } - public String getFaceImage() + public String getFaceImage() { return faceImage; } - public void setAuthStatus(String authStatus) + public void setAuthStatus(String authStatus) { this.authStatus = authStatus; } - public String getAuthStatus() + public String getAuthStatus() { return authStatus; } - public void setAuthTime(Date authTime) + public void setAuthTime(Date authTime) { this.authTime = authTime; } - public Date getAuthTime() + public Date getAuthTime() { return authTime; } - public void setAuthFailReason(String authFailReason) + public void setAuthFailReason(String authFailReason) { this.authFailReason = authFailReason; } - public String getAuthFailReason() + public String getAuthFailReason() { return authFailReason; } - public void setSecurityQuestion(String securityQuestion) + public void setSecurityQuestion(String securityQuestion) { this.securityQuestion = securityQuestion; } - public String getSecurityQuestion() + public String getSecurityQuestion() { return securityQuestion; } - public void setSecurityAnswer(String securityAnswer) + public void setSecurityAnswer(String securityAnswer) { this.securityAnswer = securityAnswer; } - public String getSecurityAnswer() + public String getSecurityAnswer() { return securityAnswer; } - public void setLastLoginTime(Date lastLoginTime) + public void setLastLoginTime(Date lastLoginTime) { this.lastLoginTime = lastLoginTime; } - public Date getLastLoginTime() + public Date getLastLoginTime() { return lastLoginTime; } - public void setLastLoginIp(String lastLoginIp) + public void setLastLoginIp(String lastLoginIp) { this.lastLoginIp = lastLoginIp; } - public String getLastLoginIp() + public String getLastLoginIp() { return lastLoginIp; } + public SysUser getSysUser() { + return sysUser; + } + + public void setSysUser(SysUser sysUser) { + this.sysUser = sysUser; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -217,6 +230,7 @@ public class SysMuhuUser extends BaseEntity .append("lastLoginTime", getLastLoginTime()) .append("lastLoginIp", getLastLoginIp()) .append("updateTime", getUpdateTime()) + .append("sysUser", getSysUser()) .toString(); } } 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 index 455f5bc..db0b051 100644 --- a/chenhai-system/src/main/java/com/chenhai/system/service/ISysMuhuUserService.java +++ b/chenhai-system/src/main/java/com/chenhai/system/service/ISysMuhuUserService.java @@ -58,4 +58,22 @@ public interface ISysMuhuUserService * @return 结果 */ public int deleteSysMuhuUserByUserId(Long userId); + + /** + * 提交实名认证(新增) + * + * @param userId 用户ID + * @param realName 真实姓名 + * @param idCard 身份证号 + * @return 认证结果 + */ + public boolean submitRealNameAuth(Long userId, String realName, String idCard); + + /** + * 获取当前用户的实名认证状态 + * + * @param userId 用户ID + * @return 认证状态 + */ + public String getAuthStatusByUserId(Long userId); } 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 index 81b7dfb..c3d1d2c 100644 --- 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 @@ -7,60 +7,86 @@ import org.springframework.stereotype.Service; import com.chenhai.system.mapper.SysMuhuUserMapper; import com.chenhai.system.domain.SysMuhuUser; import com.chenhai.system.service.ISysMuhuUserService; +import org.springframework.transaction.annotation.Transactional; /** * 牧户用户Service业务层处理 - * + * * @author ruoyi * @date 2026-02-03 */ @Service -public class SysMuhuUserServiceImpl implements ISysMuhuUserService +public class SysMuhuUserServiceImpl implements ISysMuhuUserService { @Autowired private SysMuhuUserMapper sysMuhuUserMapper; /** * 查询牧户用户 - * - * @param userId 牧户用户主键 - * @return 牧户用户 */ @Override public SysMuhuUser selectSysMuhuUserByUserId(Long userId) { - return sysMuhuUserMapper.selectSysMuhuUserByUserId(userId); + SysMuhuUser user = sysMuhuUserMapper.selectSysMuhuUserByUserId(userId); + // 确保返回的用户对象状态不为null + if (user != null && (user.getAuthStatus() == null || user.getAuthStatus().trim().isEmpty())) { + user.setAuthStatus("未认证"); + } + return user; } /** * 查询牧户用户列表 - * - * @param sysMuhuUser 牧户用户 - * @return 牧户用户 */ @Override public List selectSysMuhuUserList(SysMuhuUser sysMuhuUser) { - return sysMuhuUserMapper.selectSysMuhuUserList(sysMuhuUser); + List list = sysMuhuUserMapper.selectSysMuhuUserList(sysMuhuUser); + // 确保列表中所有用户的状态不为null + for (SysMuhuUser user : list) { + if (user.getAuthStatus() == null || user.getAuthStatus().trim().isEmpty()) { + user.setAuthStatus("未认证"); + } + } + return list; } /** - * 新增牧户用户 - * - * @param sysMuhuUser 牧户用户 - * @return 结果 + * 新增牧户用户 - 确保默认状态为"未认证" */ @Override public int insertSysMuhuUser(SysMuhuUser sysMuhuUser) { + // 验证 userId 不能为空 + if (sysMuhuUser.getUserId() == null) { + throw new IllegalArgumentException("用户ID不能为空"); + } + + // 检查是否已存在该用户的记录 + SysMuhuUser existingUser = selectSysMuhuUserByUserId(sysMuhuUser.getUserId()); + if (existingUser != null) { + // 如果已存在,抛出明确的异常 + throw new IllegalArgumentException("用户ID " + sysMuhuUser.getUserId() + " 已存在牧户记录,请使用更新操作"); + } + + // 确保新增用户默认状态为"未认证"(统一使用字典值) + if (sysMuhuUser.getAuthStatus() == null || sysMuhuUser.getAuthStatus().trim().isEmpty()) { + sysMuhuUser.setAuthStatus("未认证"); // 使用字典值,0表示未认证 + } + + // 设置创建时间和更新时间 + sysMuhuUser.setCreateTime(DateUtils.getNowDate()); + sysMuhuUser.setUpdateTime(DateUtils.getNowDate()); + + // 记录日志 + System.out.println("新增牧户用户,用户ID:" + sysMuhuUser.getUserId() + + ",真实姓名:" + sysMuhuUser.getRealName()); + return sysMuhuUserMapper.insertSysMuhuUser(sysMuhuUser); } /** * 修改牧户用户 - * - * @param sysMuhuUser 牧户用户 - * @return 结果 */ @Override public int updateSysMuhuUser(SysMuhuUser sysMuhuUser) @@ -71,9 +97,6 @@ public class SysMuhuUserServiceImpl implements ISysMuhuUserService /** * 批量删除牧户用户 - * - * @param userIds 需要删除的牧户用户主键 - * @return 结果 */ @Override public int deleteSysMuhuUserByUserIds(Long[] userIds) @@ -83,13 +106,110 @@ public class SysMuhuUserServiceImpl implements ISysMuhuUserService /** * 删除牧户用户信息 - * - * @param userId 牧户用户主键 - * @return 结果 */ @Override public int deleteSysMuhuUserByUserId(Long userId) { return sysMuhuUserMapper.deleteSysMuhuUserByUserId(userId); } -} + + /** + * 提交实名认证 + */ + @Override + @Transactional + public boolean submitRealNameAuth(Long userId, String realName, String idCard) { + // 1. 参数验证 + if (userId == null) { + throw new RuntimeException("用户ID不能为空"); + } + + if (realName == null || realName.trim().isEmpty()) { + throw new RuntimeException("真实姓名不能为空"); + } + + if (idCard == null || idCard.trim().isEmpty()) { + throw new RuntimeException("身份证号不能为空"); + } + + // 清理输入 + realName = realName.trim(); + idCard = idCard.trim().toUpperCase(); + + // 2. 验证姓名格式(2-20个汉字) + if (!realName.matches("^[\\u4e00-\\u9fa5]{2,20}$")) { + throw new RuntimeException("姓名必须是2-20个汉字"); + } + + // 3. 验证身份证格式 + if (!isValidIdCard(idCard)) { + throw new RuntimeException("身份证号格式不正确"); + } + + // 4. 检查是否已认证 + SysMuhuUser existingUser = sysMuhuUserMapper.selectSysMuhuUserByUserId(userId); + if (existingUser != null && "已认证".equals(existingUser.getAuthStatus())) { + throw new RuntimeException("该用户已认证,无需重复认证"); + } + + // 5. 检查身份证是否已被使用 + SysMuhuUser query = new SysMuhuUser(); + query.setIdCard(idCard); + List idCardUsers = sysMuhuUserMapper.selectSysMuhuUserList(query); + if (!idCardUsers.isEmpty()) { + for (SysMuhuUser user : idCardUsers) { + if (!user.getUserId().equals(userId)) { + throw new RuntimeException("该身份证号已被其他用户使用"); + } + } + } + + // 6. 保存认证信息 + if (existingUser == null) { + // 新增记录 + SysMuhuUser newUser = new SysMuhuUser(); + newUser.setUserId(userId); + newUser.setRealName(realName); + newUser.setIdCard(idCard); + newUser.setAuthStatus("已认证"); // 设置为"已认证" + newUser.setAuthTime(DateUtils.getNowDate()); + return sysMuhuUserMapper.insertSysMuhuUser(newUser) > 0; + } else { + // 更新记录 + existingUser.setRealName(realName); + existingUser.setIdCard(idCard); + existingUser.setAuthStatus("已认证"); // 设置为"已认证" + existingUser.setAuthTime(DateUtils.getNowDate()); + existingUser.setUpdateTime(DateUtils.getNowDate()); + return sysMuhuUserMapper.updateSysMuhuUser(existingUser) > 0; + } + } + + /** + * 验证身份证号格式 + */ + private boolean isValidIdCard(String idCard) { + // 18位身份证正则 + String regex = "^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9X]$"; + return idCard.matches(regex); + } + + /** + * 获取当前用户的实名认证状态 + */ + @Override + public String getAuthStatusByUserId(Long userId) { + if (userId == null) { + return "未认证"; // 默认返回"未认证" + } + + SysMuhuUser user = sysMuhuUserMapper.selectSysMuhuUserByUserId(userId); + if (user == null) { + return "未认证"; // 用户不存在,返回"未认证" + } + + String authStatus = user.getAuthStatus(); + // 确保返回有效的认证状态,默认为"未认证" + return (authStatus != null && !authStatus.trim().isEmpty()) ? authStatus : "未认证"; + } +} \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/muhu/MuhuConsultationFormsMapper.xml b/chenhai-system/src/main/resources/mapper/muhu/MuhuConsultationFormsMapper.xml index 106bce4..7805698 100644 --- a/chenhai-system/src/main/resources/mapper/muhu/MuhuConsultationFormsMapper.xml +++ b/chenhai-system/src/main/resources/mapper/muhu/MuhuConsultationFormsMapper.xml @@ -21,6 +21,8 @@ + + @@ -30,7 +32,8 @@ SELECT - cf.*, - (SELECT COUNT(*) FROM vet_comments vc WHERE vc.consultation_id = cf.form_id) as reply_count + cf.*, + (SELECT COUNT(*) FROM vet_comments vc WHERE vc.consultation_id = cf.form_id) as reply_count, + 0 as today_reply_count FROM muhu_consultation_forms cf WHERE cf.form_id = #{formId} + + + insert into muhu_consultation_forms diff --git a/chenhai-system/src/main/resources/mapper/muhu/MuhuFeedbackMapper.xml b/chenhai-system/src/main/resources/mapper/muhu/MuhuFeedbackMapper.xml new file mode 100644 index 0000000..569d6a5 --- /dev/null +++ b/chenhai-system/src/main/resources/mapper/muhu/MuhuFeedbackMapper.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + select + f.id, + f.user_id, + f.type, + f.title, + f.content, + f.contact_info, + f.status, + f.priority, + f.platform, + f.version, + f.images, + f.created_at, + f.updated_at, + u.nick_name + from muhu_feedback f + left join sys_user u on f.user_id = u.user_id + + + + + + + + insert into muhu_feedback + + user_id, + type, + title, + content, + contact_info, + status, + priority, + platform, + version, + images, + created_at, + updated_at, + + + #{userId}, + #{type}, + #{title}, + #{content}, + #{contactInfo}, + #{status}, + #{priority}, + #{platform}, + #{version}, + #{images}, + #{createdAt}, + #{updatedAt}, + + + + + update muhu_feedback + + user_id = #{userId}, + type = #{type}, + title = #{title}, + content = #{content}, + contact_info = #{contactInfo}, + status = #{status}, + priority = #{priority}, + platform = #{platform}, + version = #{version}, + images = #{images}, + created_at = #{createdAt}, + updated_at = #{updatedAt}, + + where id = #{id} + + + + delete from muhu_feedback where id = #{id} + + + + delete from muhu_feedback where id in + + #{id} + + + \ 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 index 5260b47..07ced53 100644 --- a/chenhai-system/src/main/resources/mapper/system/SysMuhuUserMapper.xml +++ b/chenhai-system/src/main/resources/mapper/system/SysMuhuUserMapper.xml @@ -1,9 +1,10 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + @@ -19,35 +20,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + - 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 + select + m.user_id, + m.real_name, + + case + when m.id_card is not null and length(m.id_card) >= 15 then + concat( + substr(m.id_card, 1, 6), + '********', + substr(m.id_card, -4) + ) + else m.id_card + end as id_card, + m.id_card_front, + m.id_card_back, + m.face_image, + m.auth_status, + m.auth_time, + m.auth_fail_reason, + m.security_question, + m.security_answer, + m.last_login_time, + m.last_login_ip, + m.update_time, + u.user_id as sys_user_id, + u.user_name, + u.nick_name, + u.email, + u.phonenumber, + u.avatar + + from sys_muhu_user m + left join sys_user u on m.user_id = u.user_id - + + insert into sys_muhu_user @@ -65,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" last_login_time, last_login_ip, update_time, - + #{userId}, #{realName}, @@ -81,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{lastLoginTime}, #{lastLoginIp}, #{updateTime}, - + @@ -109,7 +150,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from sys_muhu_user where user_id in + delete from sys_muhu_user where user_id in #{userId} diff --git a/chenhai-ui/src/api/muhu/feedback.js b/chenhai-ui/src/api/muhu/feedback.js new file mode 100644 index 0000000..549ff59 --- /dev/null +++ b/chenhai-ui/src/api/muhu/feedback.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询反馈建议列表 +export function listFeedback(query) { + return request({ + url: '/muhu/feedback/list', + method: 'get', + params: query + }) +} + +// 查询反馈建议详细 +export function getFeedback(id) { + return request({ + url: '/muhu/feedback/' + id, + method: 'get' + }) +} + +// 新增反馈建议 +export function addFeedback(data) { + return request({ + url: '/muhu/feedback', + method: 'post', + data: data + }) +} + +// 修改反馈建议 +export function updateFeedback(data) { + return request({ + url: '/muhu/feedback', + method: 'put', + data: data + }) +} + +// 删除反馈建议 +export function delFeedback(id) { + return request({ + url: '/muhu/feedback/' + id, + method: 'delete' + }) +} diff --git a/chenhai-ui/src/api/system/muhuuser.js b/chenhai-ui/src/api/system/muhuuser.js index 7b117d1..1893622 100644 --- a/chenhai-ui/src/api/system/muhuuser.js +++ b/chenhai-ui/src/api/system/muhuuser.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询牧户用户列表 export function listMuhuuser(query) { return request({ - url: '/system/muhuuser/list', + url: '/muhu/user/list', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listMuhuuser(query) { // 查询牧户用户详细 export function getMuhuuser(userId) { return request({ - url: '/system/muhuuser/' + userId, + url: '/muhu/user/' + userId, method: 'get' }) } @@ -20,7 +20,7 @@ export function getMuhuuser(userId) { // 新增牧户用户 export function addMuhuuser(data) { return request({ - url: '/system/muhuuser', + url: '/muhu/user', method: 'post', data: data }) @@ -29,16 +29,68 @@ export function addMuhuuser(data) { // 修改牧户用户 export function updateMuhuuser(data) { return request({ - url: '/system/muhuuser', + url: '/muhu/user', method: 'put', data: data }) } // 删除牧户用户 -export function delMuhuuser(userId) { +export function delMuhuuser(userIds) { return request({ - url: '/system/muhuuser/' + userId, + url: '/muhu/user/' + userIds, method: 'delete' }) } + +// ============ 实名认证相关接口 ============ +// 提交实名认证 +export function submitRealNameAuth(data) { + return request({ + url: '/muhu/user/auth/submit', + method: 'post', + data: data + }) +} + +// 获取实名认证状态 +export function getAuthStatus() { + return request({ + url: '/muhu/user/auth/status', + method: 'get' + }) +} + +// 获取实名认证详情 +export function getAuthDetail() { + return request({ + url: '/muhu/user/auth/detail', + method: 'get' + }) +} + +// ============ 区域和用户信息相关接口 ============ +// 获取区域子节点 +export function getAreaChildren(parentCode) { + return request({ + url: '/muhu/user/areaChildren', + method: 'get', + params: { parentCode } + }) +} + +// 获取用户信息 +export function getUserInfo() { + return request({ + url: '/muhu/user/getUserInfo', + method: 'get' + }) +} + +// 保存用户区域代码 +export function saveUserAreaCode(areaCode) { + return request({ + url: '/muhu/user/saveUserAreaCode/' + areaCode, + method: 'put' + }) +} diff --git a/chenhai-ui/src/views/muhu/feedback/index.vue b/chenhai-ui/src/views/muhu/feedback/index.vue new file mode 100644 index 0000000..03b66be --- /dev/null +++ b/chenhai-ui/src/views/muhu/feedback/index.vue @@ -0,0 +1,272 @@ + + + diff --git a/chenhai-ui/src/views/system/muhuuser/index.vue b/chenhai-ui/src/views/system/muhuuser/index.vue index 268c005..202f2ca 100644 --- a/chenhai-ui/src/views/system/muhuuser/index.vue +++ b/chenhai-ui/src/views/system/muhuuser/index.vue @@ -58,13 +58,6 @@ - - - - -