|
@@ -0,0 +1,132 @@
|
|
|
+package com.caimei365.user.controller;
|
|
|
+
|
|
|
+import com.caimei365.user.model.ResponseJson;
|
|
|
+import com.caimei365.user.model.dto.AvatarDto;
|
|
|
+import com.caimei365.user.model.dto.MessageDto;
|
|
|
+import com.caimei365.user.model.vo.HelpPageVo;
|
|
|
+import com.caimei365.user.model.vo.PaginationVo;
|
|
|
+import com.caimei365.user.service.UserCenterService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Description
|
|
|
+ *
|
|
|
+ * @author : Charles
|
|
|
+ * @date : 2021/10/22
|
|
|
+ */
|
|
|
+@Api(tags = "用户中心API")
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping("/user/center")
|
|
|
+public class UserCenterApi {
|
|
|
+
|
|
|
+ private final UserCenterService userCenterService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看帮助页信息(注册协议)
|
|
|
+ * @param helpPageId 帮助页Id
|
|
|
+ */
|
|
|
+ @ApiOperation("查看帮助页信息(注册协议)(旧:/club/protocol)")
|
|
|
+ @ApiImplicitParam(required = true, name = "helpPageId", value = "帮助页Id")
|
|
|
+ @GetMapping("/protocol")
|
|
|
+ public ResponseJson<HelpPageVo> getUserProtocol(Integer helpPageId) {
|
|
|
+ if (null == helpPageId) {
|
|
|
+ return ResponseJson.error("参数异常:帮助页Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return userCenterService.getUserProtocol(helpPageId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存用户头像
|
|
|
+ * @param avatarDto {
|
|
|
+ * userId 用户id
|
|
|
+ * image 头像图片
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @ApiOperation("保存用户头像(旧:/user/uploadAvatar)")
|
|
|
+ @PostMapping("/avatar/save")
|
|
|
+ public ResponseJson<Void> uploadAvatar(AvatarDto avatarDto) {
|
|
|
+ if (null == avatarDto.getUserId()) {
|
|
|
+ return ResponseJson.error("参数异常:用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(avatarDto.getImage())) {
|
|
|
+ return ResponseJson.error("参数异常:用户头像不能为空!", null);
|
|
|
+ }
|
|
|
+ return userCenterService.saveUserAvatar(avatarDto.getUserId(), avatarDto.getImage());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 我的站内消息
|
|
|
+ */
|
|
|
+ @ApiOperation("我的站内消息(旧:/user/messageList)")
|
|
|
+ @GetMapping("/messages")
|
|
|
+ public ResponseJson<PaginationVo<Map<String, Object>>> getMessageList(Integer userId,
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数异常:用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return userCenterService.getMessageList(userId, pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站内消息-标为已读
|
|
|
+ * @param messageDto {
|
|
|
+ * messageIds 站内消息Id集合
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @ApiOperation("站内消息-标为已读(旧:/user/markAsRead)")
|
|
|
+ @PostMapping("/messages/read")
|
|
|
+ public ResponseJson<Void> markMessageAsRead(MessageDto messageDto) {
|
|
|
+ if (StringUtils.isBlank(messageDto.getMessageIds())) {
|
|
|
+ return ResponseJson.error("参数异常:消息Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return userCenterService.markMessageAsRead(messageDto.getMessageIds());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 站内消息-删除
|
|
|
+ * @param messageDto {
|
|
|
+ * messageIds 站内消息Id集合
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ @ApiOperation("站内消息-删除(旧:/user/deleteMessage)")
|
|
|
+ @PostMapping("/messages/delete")
|
|
|
+ public ResponseJson<Void> deleteMessages(MessageDto messageDto) {
|
|
|
+ if (StringUtils.isBlank(messageDto.getMessageIds())) {
|
|
|
+ return ResponseJson.error("参数异常:消息Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return userCenterService.deleteMessages(messageDto.getMessageIds());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 我的账户余额明细
|
|
|
+ */
|
|
|
+ @ApiOperation("账户余额明细(旧:/personalCenter/touchBalance)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
|
|
|
+ @ApiImplicitParam(required = false, name = "year", value = "年份"),
|
|
|
+ @ApiImplicitParam(required = false, name = "month", value = "月份"),
|
|
|
+ @ApiImplicitParam(required = false, name = "type", value = "收支类型:1收入,2支出"),
|
|
|
+ @ApiImplicitParam(required = false, name = "pageNum", value = "第几页"),
|
|
|
+ @ApiImplicitParam(required = false, name = "pageSize", value = "一页多少条")
|
|
|
+ })
|
|
|
+ @GetMapping("/balance")
|
|
|
+ public ResponseJson<Map<String, Object>> getBalanceRecord(Integer userId, String type, Integer year, Integer month,
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数异常:用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return userCenterService.getBalanceRecord(userId, type, year, month, pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|