package io.renren.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.Result;
import io.renren.common.vo.agree.AgreeApplyReq;
import io.renren.common.vo.agree.AgreeApplyResp;
import io.renren.common.vo.agree.AgreePageQueryResp;
import io.renren.common.vo.agree.AgreeQueryResp;
import io.renren.service.AgreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/api/acctserial")
@Api(tags="协议管理")
public class AgreeController {
	
	@Autowired
	private AgreeService agreeService;

	@PostMapping("/agreeApply")
    @ApiOperation("协议申请")
    public Result<AgreeApplyResp> agreeApply(@Valid @RequestBody AgreeApplyReq agreeSignInfo) throws Exception{
    	return new Result<AgreeApplyResp>().ok(agreeService.agreeApply(agreeSignInfo));
    }

    @GetMapping("/agreeQuery")
    @ApiOperation("协议单条查询")
    public Result<AgreeQueryResp> agreeQuery(@RequestParam("userId") String userId,@RequestParam("agreeNo") String agreeNo) throws Exception{
    	return new Result<AgreeQueryResp>().ok(agreeService.agreeQuery(userId, agreeNo));
    }
    
    @GetMapping("/agreePageQuery")
    @ApiOperation("协议分页查询")
    public Result<AgreePageQueryResp> agreePageQuery(@RequestParam("userId") String userId) throws Exception{
    	return new Result<AgreePageQueryResp>().ok(agreeService.agreePageQuery(userId));
    }
    
    
}