From fa25bd50316f219937124c4af40aa34c014b1473 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Sun, 3 Nov 2024 14:58:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=86=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heritage/controller/file/FileController.java | 10 +++++----- .../heritage/controller/user/WeChatController.java | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/file/FileController.java b/src/main/java/com/cultural/heritage/controller/file/FileController.java index c0f0f1e..e03cefe 100644 --- a/src/main/java/com/cultural/heritage/controller/file/FileController.java +++ b/src/main/java/com/cultural/heritage/controller/file/FileController.java @@ -14,16 +14,16 @@ import com.cultural.heritage.service.user.UserService; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; -import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import java.io.File; -import java.io.IOException; import java.util.Arrays; -import java.util.Random; @RestController @RequestMapping("/file") @@ -122,7 +122,7 @@ public class FileController { long fileSize = multipartFile.getSize(); //文件后缀 String fileSuffix = FileUtil.getSuffix(multipartFile.getOriginalFilename()); - final long LIMIT = 512 * 1024L; + final long LIMIT = 2 * 1024 * 1024L; if (fileSize > LIMIT) { throw new BusinessException(ErrorCode.PARAMS_ERROR, "文件大小不能超过512K"); } diff --git a/src/main/java/com/cultural/heritage/controller/user/WeChatController.java b/src/main/java/com/cultural/heritage/controller/user/WeChatController.java index 97188ed..b5886f9 100644 --- a/src/main/java/com/cultural/heritage/controller/user/WeChatController.java +++ b/src/main/java/com/cultural/heritage/controller/user/WeChatController.java @@ -6,6 +6,9 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.cultural.heritage.common.BaseResponse; +import com.cultural.heritage.common.ErrorCode; +import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.vo.UserVO; import com.cultural.heritage.service.user.UserService; @@ -48,7 +51,7 @@ public class WeChatController { // 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey) String signature2 = DigestUtils.sha1Hex(rawData + sessionKey); if (!signature.equals(signature2)) { -// return ResultUtils.success(ErrorCode.PARAMS_ERROR, "签名校验失败"); + throw new BusinessException(ErrorCode.PARAMS_ERROR, "签名校验失败"); } // 5.根据返回的User实体类,判断用户是否是新用户,是的话,将用户信息存到数据库; LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); @@ -64,8 +67,8 @@ public class WeChatController { user.setUserName(nickName); userService.save(user); } -// return R.ok().data(user); - return null; + UserVO userVO = userService.getUserVO(user); + return ResultUtils.success(userVO); }