package com.huiju.estateagents.property.controller;


import com.huiju.estateagents.base.BaseController;
import com.huiju.estateagents.base.ResponseBean;
import com.huiju.estateagents.center.taUser.entity.TaUser;
import com.huiju.estateagents.property.common.UserElement;
import com.huiju.estateagents.property.service.IMessageService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * <p>
 * 物业端消息表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-03-05
 */
@RestController
@RequestMapping("/")
@Api(value = "消息通知API", description = "消息通知API")
public class MessageController extends BaseController {

    @Autowired
    private IMessageService messageService;
    @ApiOperation(value = "消息待办", notes = "消息待办")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "messageType:待办消息类型(-1:论坛，-2:工单，-3:缴费),status:(0:无效，1:有效)，createDate：时间，messageContent:内容 ")
    })
    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
    @RequestMapping(value = "/messageLiset", method = RequestMethod.POST)
    public ResponseBean messageLiset(@RequestBody String parameter, HttpServletRequest request){
        TaUser userElement = getTaUser(request);
        ResponseBean  responseBean = messageService.messageLiset(parameter,userElement.getOrgId(),userElement.getUserId());
        return responseBean;
    }

    @ApiOperation(value = "我的消息", notes = "我的消息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "messageType:消息类型(-1:论坛，-2:工单，-3:缴费),readStatus:(0:未读，1:已读)，createDate：时间，messageContent:内容 ")
    })
    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
    @RequestMapping(value = "/myMessageList", method = RequestMethod.POST)
    public ResponseBean myMessageList(@RequestBody String parameter, HttpServletRequest request){
        TaUser userElement = getTaUser(request);
        ResponseBean  responseBean = messageService.myMessageList(parameter,userElement.getOrgId(),userElement.getUserId());
        return responseBean;
    }

    @ApiOperation(value = "消息已读", notes = "消息已读")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body",dataType = "String",name = "parameter",value = "id:(多个) ")
    })
    @ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "token")
    @RequestMapping(value = "/delectRead", method = RequestMethod.POST)
    public ResponseBean delectRead(@RequestBody String parameter, HttpServletRequest request){
        TaUser userElement = getTaUser(request);
        ResponseBean  responseBean = messageService.delectRead(parameter,userElement.getUserId());
        return responseBean;
    }
}


