package com.lutao.cloud.admin.controller;

import com.lutao.cloud.admin.api.dto.PhoneDTO;
import com.lutao.cloud.admin.service.MobileService;
import com.lutao.cloud.common.core.util.MessageInfo;
import com.lutao.cloud.common.log.annotation.SysLog;
import com.lutao.cloud.common.security.annotation.Inner;
import com.lutao.cloud.common.security.service.CloudUser;
import com.lutao.cloud.common.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**

 * @date 2018/11/14
 * <p>
 * 手机验证码
 */
@Api(value = "/mobile", tags ={"手机验证码"})
@RestController
@AllArgsConstructor
@RequestMapping("/mobile")
public class MobileController{

	private final MobileService mobileService;

//	@ApiOperation(value = "", notes = "", httpMethod = "GET")
//	@Inner(value = false)
//	@GetMapping("/{mobile}")
//	@ApiIgnore
//	public MessageInfo<Boolean> sendSmsCode(@PathVariable String mobile){
//		return mobileService.sendSmsCode(mobile);
//	}

	/**
	 * 获取验证码
	 * @return R
	 */
	@ApiOperation(value = "获取验证码", notes = "获取验证码")
	@SysLog("获取验证码" )
	@PostMapping("/verificode" )
	@Inner(value = false)
//    @PreAuthorize("@pms.hasPermission('admin_systhirdauth_del')" )
	public MessageInfo verificode(@RequestBody PhoneDTO phoneDTO){
//		CloudUser cloudUser = SecurityUtils.getUser();
		return mobileService.verificode(phoneDTO,null);
	}


//	/**
//	 * 注册手机发送验证码
//	 * @return R
//	 */
//	@ApiOperation(value = "注册手机发送验证码", notes = "注册手机发送验证码")
//	@SysLog("获取验证码" )
//	@GetMapping("/user" )
////    @PreAuthorize("@pms.hasPermission('admin_systhirdauth_del')" )
//	public MessageInfo userVerificode(){
//		CloudUser cloudUser = SecurityUtils.getUser();
//		return mobileService.userVerificode(cloudUser);
//	}

}
