package com.nmgs.controller;

import com.nmgs.config.ResultData;
import com.nmgs.service.IntegralLevelMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value="rebackMsg")
@Api(tags = "信息反馈")
public class IntegralLevelMessageController {
    public IntegralLevelMessageService integralLevelMessageService;
    @Autowired
    public void setIntegralLevelMessageService(IntegralLevelMessageService integralLevelMessageService) {
        this.integralLevelMessageService = integralLevelMessageService;
    }

    @RequestMapping(value = "getList",
            method = {RequestMethod.POST}
    )
    @ApiOperation(httpMethod="POST",value="查询用户反馈信息")
    public ResultData<List> getList(@RequestParam(value = "userId",required = false) String userId,
                                                 @RequestParam(value = "ID",required = false) String id){
        List integrationList = this.integralLevelMessageService.getList(id, userId);
        if(integrationList != null){
            return ResultData.success("查询成功",integrationList,integrationList.size());
        }else{
            return ResultData.fail("查询失败");
        }
    }

    @RequestMapping(value = "commit",
            method = {RequestMethod.POST}
    )
    @ApiOperation(httpMethod="POST",value="提交反馈信息")
    public ResultData<List> commit(@RequestParam(value = "userId",required = true) String userId,
                                   @RequestParam(value = "position",required = true) String position,
                                    @RequestParam(value = "message",required = true) String message){
        int ret = this.integralLevelMessageService.commit(userId, position,message);
        if(ret>0){
            return ResultData.success(1,"提交成功");
        }else{
            return ResultData.fail("提交失败");
        }
    }
}
