2024-11-01 00:09:11 +08:00
|
|
|
package cn.bunny.services.controller;
|
|
|
|
|
2024-11-03 18:56:38 +08:00
|
|
|
import cn.bunny.dao.dto.system.message.MessageAddDto;
|
2024-11-03 21:33:44 +08:00
|
|
|
import cn.bunny.dao.dto.system.message.MessageDto;
|
2024-11-03 18:56:38 +08:00
|
|
|
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
|
2024-11-03 21:33:44 +08:00
|
|
|
import cn.bunny.dao.entity.system.Message;
|
|
|
|
import cn.bunny.dao.pojo.result.PageResult;
|
2024-11-01 16:40:45 +08:00
|
|
|
import cn.bunny.dao.pojo.result.Result;
|
2024-11-03 18:56:38 +08:00
|
|
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
2024-11-03 21:33:44 +08:00
|
|
|
import cn.bunny.dao.vo.system.message.MessageReceivedWithMessageVo;
|
2024-11-01 16:40:45 +08:00
|
|
|
import cn.bunny.dao.vo.system.message.MessageReceivedWithUserVo;
|
|
|
|
import cn.bunny.services.service.MessageReceivedService;
|
2024-11-03 21:33:44 +08:00
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-11-01 16:40:45 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2024-11-03 21:33:44 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
2024-11-02 17:03:38 +08:00
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2024-11-03 18:56:38 +08:00
|
|
|
import jakarta.validation.Valid;
|
2024-11-01 16:40:45 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-11-03 18:56:38 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2024-11-01 16:40:45 +08:00
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
import java.util.List;
|
2024-11-01 00:09:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <p>
|
2024-11-01 16:40:45 +08:00
|
|
|
* 前端控制器
|
2024-11-01 00:09:11 +08:00
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @author Bunny
|
|
|
|
* @since 2024-10-31
|
|
|
|
*/
|
2024-11-02 17:03:38 +08:00
|
|
|
@Tag(name = "消息接受关系", description = "消息接受关系相关接口")
|
2024-11-01 00:09:11 +08:00
|
|
|
@RestController
|
2024-11-01 16:40:45 +08:00
|
|
|
@RequestMapping("/admin/messageReceived")
|
2024-11-01 00:09:11 +08:00
|
|
|
public class MessageReceivedController {
|
|
|
|
|
2024-11-01 16:40:45 +08:00
|
|
|
@Autowired
|
|
|
|
private MessageReceivedService messageReceivedService;
|
|
|
|
|
2024-11-03 21:33:44 +08:00
|
|
|
@Operation(summary = "管理员管理用户消息接收分页查询", description = "管理员管理用户消息接收分页查询")
|
|
|
|
@GetMapping("getMessageReceivedList/{page}/{limit}")
|
|
|
|
public Mono<Result<PageResult<MessageReceivedWithMessageVo>>> getMessageReceivedList(
|
|
|
|
@Parameter(name = "page", description = "当前页", required = true)
|
|
|
|
@PathVariable("page") Integer page,
|
|
|
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
|
|
|
@PathVariable("limit") Integer limit,
|
|
|
|
MessageDto dto) {
|
|
|
|
Page<Message> pageParams = new Page<>(page, limit);
|
|
|
|
PageResult<MessageReceivedWithMessageVo> pageResult = messageReceivedService.getMessageReceivedList(pageParams, dto);
|
|
|
|
return Mono.just(Result.success(pageResult));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "管理员将用户接受消息标为已读", description = "管理员将用户接受消息标为已读")
|
|
|
|
@PutMapping("markMessageReceivedAsRead")
|
|
|
|
public Mono<Result<String>> markMessageReceivedAsRead(@RequestBody List<Long> ids) {
|
|
|
|
messageReceivedService.markMessageReceivedAsRead(ids);
|
|
|
|
return Mono.just(Result.success());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "管理删除用户接受的消息", description = "管理删除用户接受的消息")
|
|
|
|
@DeleteMapping("deleteMessageReceivedByIds")
|
|
|
|
public Mono<Result<String>> deleteMessageReceivedByIds(@RequestBody List<Long> ids) {
|
|
|
|
messageReceivedService.deleteMessageReceivedByIds(ids);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
|
|
|
}
|
|
|
|
|
2024-11-01 16:40:45 +08:00
|
|
|
@Operation(summary = "根据消息id获取接收人信息", description = "根据消息id获取接收人信息")
|
|
|
|
@GetMapping("noManage/getReceivedUserinfoByMessageId")
|
|
|
|
public Mono<Result<List<MessageReceivedWithUserVo>>> getReceivedUserinfoByMessageId(Long messageId) {
|
|
|
|
List<MessageReceivedWithUserVo> voList = messageReceivedService.getReceivedUserinfoByMessageId(messageId);
|
|
|
|
return Mono.just(Result.success(voList));
|
|
|
|
}
|
2024-11-03 18:56:38 +08:00
|
|
|
|
2024-11-03 21:33:44 +08:00
|
|
|
@Operation(summary = "用户将消息标为已读", description = "用户将消息标为已读")
|
|
|
|
@PutMapping("noManage/updateUserMarkAsRead")
|
|
|
|
public Mono<Result<String>> updateUserMarkAsRead(@Valid @RequestBody List<Long> ids) {
|
|
|
|
messageReceivedService.updateUserMarkAsRead(ids);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
|
|
|
}
|
|
|
|
|
2024-11-03 18:56:38 +08:00
|
|
|
@Operation(summary = "添加系统消息", description = "添加系统消息")
|
|
|
|
@PostMapping("addMessage")
|
|
|
|
public Mono<Result<String>> addMessage(@Valid @RequestBody MessageAddDto dto) {
|
|
|
|
messageReceivedService.addMessage(dto);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "更新系统消息", description = "更新系统消息")
|
|
|
|
@PutMapping("updateMessage")
|
|
|
|
public Mono<Result<String>> updateMessage(@Valid @RequestBody MessageUpdateDto dto) {
|
|
|
|
messageReceivedService.updateMessage(dto);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
|
|
|
}
|
|
|
|
|
2024-11-01 00:09:11 +08:00
|
|
|
}
|