From 92de3d4da4cd7b7dd4eb254983f92349edd188fe Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Mon, 4 Nov 2024 12:45:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/address/AddressController.java | 6 +++- .../controller/good/GoodController.java | 5 ++- .../controller/user/UserController.java | 33 ++++++++++++++----- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/address/AddressController.java b/src/main/java/com/cultural/heritage/controller/address/AddressController.java index dadcc5b..c6acb51 100644 --- a/src/main/java/com/cultural/heritage/controller/address/AddressController.java +++ b/src/main/java/com/cultural/heritage/controller/address/AddressController.java @@ -10,6 +10,7 @@ import com.cultural.heritage.model.dto.address.AddressAddRequest; import com.cultural.heritage.model.dto.address.AddressUpdateRequest; import com.cultural.heritage.model.entity.Address; import com.cultural.heritage.service.address.AddressService; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -24,7 +25,7 @@ import java.util.List; @RestController @RequestMapping("/address") @Slf4j -@Tag(name = "地址接口") +@Tag(name = "地址管理模块") public class AddressController { @@ -38,6 +39,7 @@ public class AddressController { * @return 是否添加成功 */ @PostMapping("/add") + @Operation(summary = "小程序端用户添加地址信息", description = "参数:地址添加请求体,权限:所有人,方法名:addAddress") public BaseResponse addAddress(@RequestBody AddressAddRequest addressAddRequest) { if (addressAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -58,6 +60,7 @@ public class AddressController { * @return 是否成功删除 */ @PostMapping("/delete") + @Operation(summary = "小程序端用户删除地址信息", description = "参数:地址删除请求体,权限:所有人,方法名:delAddress") public BaseResponse delAddress(@RequestBody CommonRequest deleteRequest) { if (deleteRequest == null || deleteRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -77,6 +80,7 @@ public class AddressController { * @return 是否更新成功 */ @PostMapping("/update") +// @Operation(summary = "小程序端用户更新地址信息", ) public BaseResponse updateAddress(@RequestBody AddressUpdateRequest addressUpdateRequest) { if (addressUpdateRequest == null || addressUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); diff --git a/src/main/java/com/cultural/heritage/controller/good/GoodController.java b/src/main/java/com/cultural/heritage/controller/good/GoodController.java index e22eb29..c316f9b 100644 --- a/src/main/java/com/cultural/heritage/controller/good/GoodController.java +++ b/src/main/java/com/cultural/heritage/controller/good/GoodController.java @@ -20,7 +20,10 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; -import org.springframework.web.bind.annotation.*; +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 java.util.List; diff --git a/src/main/java/com/cultural/heritage/controller/user/UserController.java b/src/main/java/com/cultural/heritage/controller/user/UserController.java index c1ddc02..561f874 100644 --- a/src/main/java/com/cultural/heritage/controller/user/UserController.java +++ b/src/main/java/com/cultural/heritage/controller/user/UserController.java @@ -5,10 +5,12 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.config.WxOpenConfig; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; @@ -16,6 +18,7 @@ import com.cultural.heritage.model.dto.user.*; import com.cultural.heritage.model.entity.User; import com.cultural.heritage.model.vo.UserVO; import com.cultural.heritage.service.user.UserService; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; @@ -36,7 +39,7 @@ import static com.cultural.heritage.constant.UserConstant.SALT; */ @Slf4j @RestController -@Tag(name = "用户接口") +@Tag(name = "用户管理模块") @RequestMapping("/user") public class UserController { @@ -56,6 +59,8 @@ public class UserController { * @return 登录用户信息 */ @PostMapping("/login") + @Operation(summary = "Web端用户登录", description = "参数:{账号,密码}, 权限:管理员(admin, boss), 方法名:userLogin") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse userLogin(@RequestBody UserLoginRequest userLoginRequest, HttpServletRequest request){ if(userLoginRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -79,6 +84,7 @@ public class UserController { * @return 用户登录信息 */ @GetMapping("/login/wx_open") + @Operation(summary = "微信小程序用户登录", description = "参数:code(用户登录凭证), 权限:所有人, 方法名:userLoginByWxOpen") public BaseResponse userLoginByWxOpen(@RequestParam("code") String code, HttpServletRequest request) { WxMaJscode2SessionResult sessionInfo; try { @@ -103,6 +109,8 @@ public class UserController { * @return 是否退出登录成功 */ @PostMapping("/logout") + @Operation(summary = "Web端管理员退出登录", description = "参数:无,权限:管理员(admin, boss),方法名:userLogout") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse userLogout(HttpServletRequest request) { boolean result = userService.userLogout(request); return ResultUtils.success(result); @@ -114,6 +122,7 @@ public class UserController { * @return 用户登录信息 */ @GetMapping("/get/login") + @Operation(summary = "小程序端获取登录信息", description = "参数:无,权限:所有人, 方法名:getLoginUser") public BaseResponse getLoginUser(HttpServletRequest request) { User user = userService.getLoginUser(request); return ResultUtils.success(userService.getUserVO(user)); @@ -128,6 +137,7 @@ public class UserController { * @return 是否更新成功 */ @PostMapping("/update/my") + @Operation(summary = "小程序端更新用户信息", description = "参数:用户更新请求体,权限:所有人, 方法名:updateMyUser") public BaseResponse updateMyUser(@RequestBody UserUpdateMyRequest userUpdateMyRequest, HttpServletRequest request) { if (userUpdateMyRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -148,7 +158,8 @@ public class UserController { * @return 添加用户的信息 */ @PostMapping("/add") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员创建用户", description = "参数:用户添加请求体, 权限:管理员(admin, boss), 方法名:addUser") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse addUser(@RequestBody UserAddRequest userAddRequest) { if (userAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -171,7 +182,8 @@ public class UserController { * @return 是否删除 */ @PostMapping("/delete") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员删除用户", description = "参数:用户删除请求体, 权限:管理员(admin, boss), 方法名:deleteUser") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse deleteUser(@RequestBody CommonRequest deleteRequest) { if (deleteRequest == null || deleteRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -188,7 +200,8 @@ public class UserController { * @return 是否更新成功 */ @PostMapping("/update") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员更新用户", description = "参数:用户更新请求体, 权限:管理员(admin, boss), 方法名:updateUser") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse updateUser(@RequestBody UserUpdateRequest userUpdateRequest) { if (userUpdateRequest == null || userUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -207,7 +220,8 @@ public class UserController { * @return 用户信息 */ @GetMapping("/get") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员根据id获取用户信息", description = "参数:用户id, 权限:管理员(admin, boss), 方法名:getUserById") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse getUserById(long id) { if (id <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -222,7 +236,8 @@ public class UserController { * 获取用户数量 */ @GetMapping("/count") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员获取用户数量", description = "参数:无, 权限:管理员(admin, boss), 方法名:getUserCount") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse getUserCount() { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("userRole", "user"); @@ -238,7 +253,8 @@ public class UserController { * @return 用户信息列表 */ @PostMapping("/list/page") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员分页获取用户信息", description = "参数:用户查询请求体, 权限:管理员(admin, boss), 方法名:listUserByPage") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listUserByPage(@RequestBody UserQueryRequest userQueryRequest) { long current = userQueryRequest.getCurrent(); long pageSize = userQueryRequest.getPageSize(); @@ -256,7 +272,8 @@ public class UserController { * @return 脱敏用户信息列表 */ @PostMapping("/list/page/vo") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @Operation(summary = "Web端管理员分页获取脱敏用户信息", description = "参数:用户查询请求体, 权限:管理员(admin, boss), 方法名:listUserVOByPage") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listUserVOByPage(@RequestBody UserQueryRequest userQueryRequest) { if (userQueryRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR);