package com.icloud.server.scala.shiro

import com.icloud.server.web.err.ServicerunException
import com.icloud.server.web.json.JsonResult
import io.swagger.annotations.Api
import org.springframework.web.bind.annotation._
import springfox.documentation.annotations.ApiIgnore

import javax.annotation.Resource
import scala.beans.BeanProperty

/**
  * @Author : yang_y_1.0.2
  * @Date : 2020/11/24 3:24 下午 
  * @Version : 1.2.1
  */
@Api( tags = Array( "用户" ), value = "API",hidden = true )
//@ApiIgnore
@RestController
@RequestMapping( Array( "/user/" ) )
@CrossOrigin
class UserController {
  @BeanProperty
  @Resource var us: UserService = _



//  @PostMapping( Array( "setuser" ) )
//  @ResponseBody def setuser (id:Int,nick:String,pwd:String,checked:Boolean): JsonResult = {
//   var  d = if (checked) 1 else 0
//    if(checked &&(nick==null) && (nick.equals(""))){
//      throw new ServicerunException("昵称不能为空!")
//    }
//    new JsonResult( us.setuser(id,nick,pwd,d))
//  }

//  @PostMapping( Array( "getnick" ) )
//  @ResponseBody def getnick (id:Int): JsonResult = {
//    new JsonResult(  us.getnick(id) )
//  }

  @PostMapping( Array( "setpwd" ) )
  @ResponseBody def setpwd (id:Int,pwd:String): JsonResult = {
    new JsonResult(  us.setpwd(id,pwd) )
  }

  @PostMapping( Array( "initpwd" ) )
  @ResponseBody def initpwd (username:String): JsonResult = {
    new JsonResult(  us.initpwd(username) )
  }

  @PostMapping( Array( "register" ) )
  @ResponseBody def register (username:String,pwd:String): JsonResult = {
    new JsonResult(  us.register(username,pwd) )
  }

}
