package com.zhujizheng.IHome.everymomentmsg.controller; import com.zhujizheng.IHome.everymomentmsg.service.PYEveryMomentMsgService; import com.zhujizheng.IHome.everymomentmsg.vo.PYEveryMomentMsgVO; import com.zhujizheng.IHome.everymomentmsg.vo.PYEveryMomentUnreadMsgVO; import com.zhujizheng.IHome.util.response.ResponseResult; import com.zhujizheng.IHome.util.response.RestResultGenerator; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; /** * Created with IntelliJ IDEA *

* Author: yons * Date: 2019/04/29 * Time: 00:03 * Description: * Copyright © 2019年 com.zhujizheng. All rights reserved. */ @Api("系统消息相关") @RestController @RequestMapping("/everymomentmsg") public class PYEveryMomentMsgController { @Autowired private PYEveryMomentMsgService msgService; @ApiOperation("获取每刻消息") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "int"), @ApiImplicitParam(name = "msgType", value = "消息类型", paramType = "path", required = true, dataType = "int"), @ApiImplicitParam(name = "msgId", value = "新消息id", paramType = "path", required = true, dataType = "int") }) @GetMapping("/pull/{userId}/{msgType}/{msgId}") public ResponseResult getSystemMessages(@PathVariable int userId, @PathVariable int msgType, @PathVariable int msgId) { List voList = msgService.pullEveryMomentMsg(userId, msgType, msgId); if (voList == null) { return RestResultGenerator.genErrorResult("获取每刻消息失败"); } return RestResultGenerator.genResult(voList, "获取每刻消息成功"); } @ApiOperation("全部标记为已读") @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "int") @GetMapping("/markreaded/{userId}") public ResponseResult markReaded(@PathVariable int userId) { int result = msgService.updateEveryMomentMsgAllReadedWithUserId(userId); if (result == 0) { return RestResultGenerator.genErrorResult("全部标记为已读失败"); } else { return RestResultGenerator.genResult("全部标记为已读成功"); } } @ApiOperation("一次性获取所有未读消息") @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "int") @GetMapping("/pullunread/{userId}") public ResponseResult getAllUnreadedMsg(@PathVariable int userId) { PYEveryMomentUnreadMsgVO vo = msgService.selectAllUnreadedMsg(userId); if (vo == null) { return RestResultGenerator.genErrorResult("一次性获取所有未读消息失败"); } return RestResultGenerator.genResult(vo, "一次性获取所有未读消息成功"); } }