package com.community.huiju.controller;


import com.community.huiju.common.base.BaseController;
import com.community.huiju.common.base.ResponseBean;
import com.community.huiju.service.ITaUserVerifyService;
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.*;

/**
 * <p>
 * app端用户审核表，存放用户的角色还有房产信息 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-05-16
 */
@RestController
@RequestMapping("/")
@Api(value = "用户审核 API", description = "用户审核 API")
public class TaUserVerifyController extends BaseController {

    @Autowired
    private ITaUserVerifyService iTaUserVerifyService;


    @RequestMapping(value = "/user/verify",method = RequestMethod.POST)
    @ApiOperation(value = "添加房产关联", notes = "添加房产关联")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "roleId", value = "角色Id：1 户主 2 租客 3 家属"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "communityId", value = "小区Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "phaseId", value = "期Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "buildingId", value = "栋Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "unitId", value = "单元Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "levelId", value = "楼层Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "roomNoId", value = "房间号Id"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),

    })
    public ResponseBean addUserVerify(@RequestParam(value = "userId") Integer userId,
                                      @RequestParam(value = "roleId") Integer roleId,
                                      @RequestParam(value = "communityId") Integer communityId,
                                      @RequestParam(value = "phaseId") Integer phaseId,
                                      @RequestParam(value = "buildingId") Integer buildingId,
                                      @RequestParam(value = "unitId") Integer unitId,
                                      @RequestParam(value = "levelId") Integer levelId,
                                      @RequestParam(value = "roomNoId") Integer roomNoId) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iTaUserVerifyService.addUserVerify(userId, roleId, communityId, phaseId, buildingId, unitId, levelId, roomNoId);
        return responseBean;
    }

    @RequestMapping(value = "/user/verify/{userVerifyId}", method = RequestMethod.DELETE)
    @ApiOperation(value = "用户删除房产关联关系", notes = "用户删除房产关联关系")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "form", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "path", name = "userVerifyId", value = "房产审核Id"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),
    })
    public ResponseBean deleteUserVerify(@RequestParam(value = "userId") Integer userId,
                                         @PathVariable(value = "userVerifyId") Integer userVerifyId) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iTaUserVerifyService.deleteUserVerify(userId, userVerifyId);
        return responseBean;
    }

    @RequestMapping(value = "/user/verify/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询用户的房产关联关系列表", notes = "查询用户的房产关联关系列表")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "query", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "query", name = "communityId", value = "小区Id"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean getUserVerify(@RequestParam(value = "userId") Integer userId,
                                      @RequestParam(value = "communityId") Integer communityId) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iTaUserVerifyService.getUserVerifyByUserIdAndCommunityId(userId, communityId);
        return responseBean;
    }


    @RequestMapping(value = "/user/verify/{userVerifyId}", method = RequestMethod.GET)
    @ApiOperation(value = "根据 用户id 和 房产审核id ", notes = "根据 用户id 和 房产审核id ")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "query", name = "userId", value = "用户Id"),
            @ApiImplicitParam(dataTypeClass = Integer.class, paramType = "path", name = "userVerifyId", value = "房产审核Id"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean getUserVerifyByByUserIdAndUserVerifyId(@RequestParam(value = "userId") Integer userId,
                                         @PathVariable(value = "userVerifyId") Integer userVerifyId) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iTaUserVerifyService.getUserVerifyByByUserIdAndUserVerifyId(userId, userVerifyId);
        return responseBean;
    }

}
