完善了订单接口

This commit is contained in:
chen-xin-zhi 2024-11-03 14:58:39 +08:00
parent 6cf376c0d2
commit fa25bd5031
2 changed files with 11 additions and 8 deletions

View File

@ -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");
}

View File

@ -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<User> 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);
}