package com.ruoyi.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.common.page.PageResult;
import com.ruoyi.controller.req.AppealMessagePageReq;
import com.ruoyi.controller.req.SendMessageReq;
import com.ruoyi.controller.resp.AppealDetailResp;
import com.ruoyi.controller.resp.AppealMessagePageResp;
import com.ruoyi.controller.resp.AppealPageResp;
import com.ruoyi.frequency.appeal.service.AppealService;
import com.ruoyi.frequency.appealdetail.service.AppealDetailService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.BodyIdReq;
import com.ruoyi.vo.PageBasic;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 申诉
 */
@CrossOrigin
@RestController
@RequestMapping("/api/appeal")
@Api(tags = "申诉")
public class ApiAppealController extends RyController {

    @Autowired
    private AppealService appealService;

    @Autowired
    private AppealDetailService appealDetailService;


    @PostMapping("/appealPage")
    @ApiOperation(value = "申诉列表", notes = "申诉列表")
    @UserLoginToken
    public ResponseData<PageResult<Page<AppealPageResp>>> appealPage(@RequestBody @Valid PageBasic req) {
        return appealService.appealPage(req,getUserVo());
    }

    @PostMapping("/appealDetail")
    @ApiOperation(value = "申诉详情", notes = "申诉详情")
    @UserLoginToken
    public ResponseData<AppealDetailResp> appealDetail(@RequestBody @Valid BodyIdReq req) {
        return appealService.appealDetail(req.getId(),getUserVo());
    }

    @PostMapping("/appealMessagePage")
    @ApiOperation(value = "申诉详情消息对话", notes = "申诉详情消息对话")
    @UserLoginToken
    public ResponseData<PageResult<Page<AppealMessagePageResp>>> appealMessagePage(@RequestBody @Valid AppealMessagePageReq req) {
        return appealDetailService.appealMessagePage(req,getUserVo());
    }

    @PostMapping("/sendMessage")
    @ApiOperation(value = "发送消息", notes = "发送消息")
    @UserLoginToken
    public ResponseData sendMessage(@RequestBody @Valid SendMessageReq  req) {
        return appealDetailService.sendMessage(req,getUserVo());
    }
}
