package com.diagbot.web;


import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.QueryAuthProgressDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.dto.UserAuthenticationDTO;
import com.diagbot.dto.WaitAuthenDTO;
import com.diagbot.facade.UserAuthenticationFacade;
import com.diagbot.vo.UserAuthenticationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
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.RestController;

import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 * 用户认证信息表 前端控制器
 * </p>
 *
 * @author zhaops
 * @since 2018-09-13
 */
@RestController
@Api(value="用户认证API", tags={"用户认证API"})
@RequestMapping("/userAuthentication")
@SuppressWarnings("unchecked")
public class UserAuthenticationController {
    @Autowired
    private UserAuthenticationFacade userAuthenticationFacade;


    @ApiOperation(value = "用户认证[by:zhaops]",
            notes = "userName：用户名，必填<br>" +
                    "organization：组织机构，必填<br>")
    @PostMapping("/userAuthentication")
    @SysLogger("userAuthentication")
    @Transactional
    public RespDTO<UserAuthenticationDTO> userAuthentication(@RequestBody @Valid UserAuthenticationVO userAuthenticationVO) {
        UserAuthenticationDTO userAuthenticationDTO = userAuthenticationFacade.userAuthentication(userAuthenticationVO);
        return RespDTO.onSuc(userAuthenticationDTO);
    }

    @ApiOperation(value = "获取当前用户信息[by:zhaops]")
    @PostMapping("/getuserAuthenticationInfo")
    @SysLogger("getuserAuthenticationInfo")
    public RespDTO<UserAuthenticationDTO> getuserAuthenticationInfo() {
        UserAuthenticationDTO userAuthenticationDTO = userAuthenticationFacade.getuserAuthenticationInfo();
        return RespDTO.onSuc(userAuthenticationDTO);
    }

    @ApiOperation(value = "获取当前用户认证状态[by:zhaops]")
    @PostMapping("/getUserAuthenticationStatus")
    @SysLogger("getUserAuthenticationStatus")
    public RespDTO<Map<Integer, Object>> getUserAuthenticationStatus() {
        Map<Integer, Object> map = userAuthenticationFacade.getUserAuthenticationStatus();
        return RespDTO.onSuc(map);
    }
    
    @ApiOperation(value = "控制台-账号认证进度(示例)[by:rengb]",notes="控制台-账号认证进度")
	@PostMapping("/queryAuthProgress")
	@SysLogger("queryAuthProgress")
	public RespDTO<QueryAuthProgressDTO> queryAuthProgress() {
		return RespDTO.onSuc(userAuthenticationFacade.queryAuthProgress());
	}
	
	@ApiOperation(value = "控制台-待认证账号数量(示例)[by:rengb]",notes="控制台-待认证账号数量")
	@PostMapping("/waitAuthen")
	@SysLogger("waitAuthen")
	public RespDTO<WaitAuthenDTO> waitAuthen() {
		return RespDTO.onSuc(userAuthenticationFacade.waitAuthen());
	}
    
}
