package com.mzl.flower.web.current;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.mzl.flower.base.BaseController;
|
import com.mzl.flower.base.R;
|
import com.mzl.flower.base.ReturnDataDTO;
|
import com.mzl.flower.dto.request.system.SearchMessageDTO;
|
import com.mzl.flower.dto.response.system.UserMessageDTO;
|
import com.mzl.flower.service.system.UserMessageService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
@RestController
|
@RequestMapping("/api/message/user")
|
@Api(value = "个人中心-消息管理", tags = "个人中心-消息管理")
|
@Validated
|
@Slf4j
|
public class UserMessageController extends BaseController {
|
|
@Autowired
|
private UserMessageService messageService;
|
|
@GetMapping("/page")
|
@ApiOperation(value = "获取用户消息列表")
|
public ResponseEntity<ReturnDataDTO<Page<UserMessageDTO>>> selectUserMessage(Page page, SearchMessageDTO dto) {
|
return returnData(R.SUCCESS.getCode(), messageService.selectUserMessage(page, dto));
|
}
|
|
@GetMapping("/detail")
|
@ApiOperation(value = "获取用户消息详情")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "消息ID", required = true, dataType = "String", paramType = "query")
|
})
|
public ResponseEntity<ReturnDataDTO<UserMessageDTO>> detail(String id) {
|
return returnData(R.SUCCESS.getCode(), messageService.detail(id));
|
}
|
|
@GetMapping("/unread/count")
|
@ApiOperation(value = "我的未读消息数量")
|
public ResponseEntity<ReturnDataDTO<Integer>> getUnReadCount() {
|
return returnData(R.SUCCESS.getCode(), messageService.getUnReadCount());
|
}
|
|
@PostMapping({"/read/all"})
|
@ApiOperation(value = "设置已读-所有")
|
public ResponseEntity<ReturnDataDTO> setMsgRead() {
|
messageService.setMsgRead();
|
return returnData(R.SUCCESS.getCode(), null);
|
}
|
|
@PostMapping({"/read"})
|
@ApiOperation(value = "设置已读-单个")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "query", name = "id", dataType = "String", value = "消息id"),
|
})
|
public ResponseEntity<ReturnDataDTO> setMsgRead(String id) {
|
messageService.setMsgRead(id);
|
return returnData(R.SUCCESS.getCode(), null);
|
}
|
}
|