From 44057267ea795060cfb61e5b3464af6659d01bbf Mon Sep 17 00:00:00 2001 From: menxipeng Date: Fri, 22 Aug 2025 17:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/ClientShopUserController.java | 83 +++++++++++++++++-- .../common/core/domain/entity/ShopUser.java | 3 + .../system/service/IShopUserService.java | 10 ++- .../service/impl/ShopUserServiceImpl.java | 14 +++- .../mapper/system/ShopUserMapper.xml | 11 ++- ruoyi-ui/src/api/feedback/clientFeedback.js | 31 +++++++ 6 files changed, 143 insertions(+), 9 deletions(-) create mode 100644 ruoyi-ui/src/api/feedback/clientFeedback.js diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java index e363286..fc1ff36 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ClientShopUserController.java @@ -4,14 +4,17 @@ import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.ShopUser; import com.ruoyi.common.core.domain.entity.ShopUserResq; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.web.service.SysLoginService; +import com.ruoyi.system.config.AliConfig; import com.ruoyi.system.service.AliConfigService; +import com.ruoyi.system.service.IShopUserService; import com.ruoyi.system.service.ShopUserService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; @RequestMapping("/client") @RestController @@ -23,7 +26,8 @@ public class ClientShopUserController { private AliConfigService aliConfigService; @Autowired private ShopUserService shopUserService; - + @Autowired + private IShopUserService iShopUserService; /** * 获取验证码 @@ -65,10 +69,77 @@ public class ClientShopUserController { */ @PostMapping("/updateUser") public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser){ + Long userId = SecurityUtils.getUserId(); + if (userId == null) { + return AjaxResult.error("用户未登录"); + } + shopUser.setUserId(userId); return AjaxResult.success(shopUserService.modifyUser(shopUser)); } + /** + * 获取个人信息 + * @return 个人信息 + */ + @GetMapping("/getUserInfo") + public AjaxResult getUserInfo() { + // 获取当前登录用户名 + Long userId = SecurityUtils.getUserId(); + if (userId == null) { + return AjaxResult.error("用户未登录"); + } + + // 根据用户ID查询完整的用户信息 + ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId); + if (shopUser == null) { + return AjaxResult.error("未找到用户信息"); + } + + // 出于安全考虑,清除敏感信息 + shopUser.setPassword(null); + + return AjaxResult.success(shopUser); + } + + /** + * 根据用户ID获取个人信息 + * @param userId 用户ID + * @return 个人信息 + */ + @GetMapping("/getUserInfoById/{userId}") + public AjaxResult getUserInfoById(@PathVariable("userId") Long userId) { + if (userId == null) { + return AjaxResult.error("用户ID不能为空"); + } + + // 根据用户ID查询完整的用户信息 + ShopUser shopUser = iShopUserService.selectShopUserByUserId(userId); + if (shopUser == null) { + return AjaxResult.error("未找到用户信息"); + } + + // 出于安全考虑,清除敏感信息 + shopUser.setPassword(null); + + return AjaxResult.success(shopUser); + } + @PostMapping("/user/file") + public AjaxResult addConfigFile( + @RequestParam("file") MultipartFile file + ) throws IOException { + // 检查是否已经登录 + Long userId = SecurityUtils.getUserId(); + if (userId == null) { + return AjaxResult.error("用户未登录"); + } + // 1. 处理文件上传 + if (file != null && !file.isEmpty()) { + // 保存文件逻辑 + return AjaxResult.success("请求成功", AliConfig.ossUp("user/", file.getOriginalFilename(), file.getInputStream())); + } + return AjaxResult.error("文件不能为空"); + } -} +} \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java index ec6e87a..f434eab 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java @@ -91,4 +91,7 @@ public class ShopUser { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date vipEndTime; + + // 简介 + private String descinfo; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IShopUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IShopUserService.java index 4c5280f..92a336d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IShopUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IShopUserService.java @@ -22,6 +22,14 @@ public interface IShopUserService */ public ShopUser selectShopUserById(String id); + /** + * 根据用户ID查询用户信息 + * + * @param userId 用户ID + * @return 用户信息 + */ + public ShopUser selectShopUserByUserId(Long userId); + /** * 查询用户管理列表 * @@ -77,4 +85,4 @@ public interface IShopUserService * @return 用户标签列表(以分号分隔的字符串) */ public String getUserTags(String userId); -} +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java index 14a9de9..b4f928f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java @@ -38,6 +38,18 @@ public class ShopUserServiceImpl implements IShopUserService return shopUserMapper.selectShopUserById(id); } + /** + * 根据用户ID查询用户信息 + * + * @param userId 用户ID + * @return 用户信息 + */ + @Override + public ShopUser selectShopUserByUserId(Long userId) + { + return shopUserMapper.selectShopUserByUserId(userId); + } + /** * 查询用户管理列表 * @@ -190,4 +202,4 @@ public class ShopUserServiceImpl implements IShopUserService return tags.toString(); } -} +} \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml index ef36af5..0688cc5 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml @@ -24,6 +24,7 @@ head_img, vip_start_time, vip_end_time, + descinfo, #{userId}, @@ -43,6 +44,7 @@ #{headImg}, #{vipStartTime}, #{vipEndTime}, + #{descinfo}, @@ -66,10 +68,11 @@ + - select id, user_id, username, password,device_type,device_id, phone, nickname, sex, birthday, addr, register_time, status, vip, online, create_time, update_time, is_del,head_img,vip_end_time,vip_start_time from shop_user + select id, user_id, `descinfo`,username, password,device_type,device_id, phone, nickname, sex, birthday, addr, register_time, status, vip, online, create_time, update_time, is_del,head_img,vip_end_time,vip_start_time from shop_user @@ -130,6 +135,8 @@ create_time, update_time, is_del, + descinfo, + #{userId}, @@ -147,6 +154,7 @@ #{createTime}, #{updateTime}, #{isDel}, + #{descinfo}, @@ -170,6 +178,7 @@ is_del = #{isDel}, vip_start_time = #{vipStartTime}, vip_end_time = #{vipEndTime}, + vip_end_time = #{descinfo}, where shop_user.user_id = #{userId} diff --git a/ruoyi-ui/src/api/feedback/clientFeedback.js b/ruoyi-ui/src/api/feedback/clientFeedback.js new file mode 100644 index 0000000..18303bd --- /dev/null +++ b/ruoyi-ui/src/api/feedback/clientFeedback.js @@ -0,0 +1,31 @@ +import request from '@/utils/request' + +/** + * 提交用户反馈 + * @param {Object} data 反馈数据 + * @param {String} data.feedbackContent 反馈内容 (必填) + * @param {String} data.userName 用户姓名 + * @param {String} data.contactType 联系方式类型 (例如: "email", "phone", "wechat") + * @param {String} data.contactInfo 联系方式信息 + * @param {String} data.attachmentPath 附件路径 + * @returns {Promise} + */ +export function submitFeedback(data) { + return request({ + url: '/client/feedback/submit', + method: 'post', + data: data + }) +} + +/** + * 查询用户反馈详情 + * @param {String} id 反馈ID + * @returns {Promise} + */ +export function getFeedbackDetail(id) { + return request({ + url: '/client/feedback/detail/' + id, + method: 'get' + }) +} \ No newline at end of file