package com.icloud.server.scala

import io.swagger.annotations.{Api, ApiImplicitParam, ApiImplicitParams, ApiOperation}
import org.springframework.data.redis.core.StringRedisTemplate
import org.springframework.web.bind.annotation.{GetMapping, PostMapping, RequestBody, RequestMapping, RestController}
import springfox.documentation.annotations.ApiIgnore

import javax.annotation.Resource
import scala.beans.BeanProperty
@Api( tags = Array( "demo" ), value = "API",hidden = true )
@ApiIgnore
@RestController
@RequestMapping(Array("/aaa/"))
class Demo {

  @Resource
  @BeanProperty
  var stringredistemplate: StringRedisTemplate = _
  @ApiOperation( value = "id", notes = "",hidden = true )
  @GetMapping(Array("id"))
  def getid() = "1"
  @ApiOperation( value = "test", notes = "",hidden = true )
  @ApiImplicitParams( Array(
    new ApiImplicitParam( name = "req", value = "支付实体类", required = true, dataType = "CreateWxReq" ),
    new ApiImplicitParam( name = "title", value = "标题", required = true, dataType = "String" ),
    new ApiImplicitParam( name = "content", value = "文本内容", required = true, dataType = "String" ),
    new ApiImplicitParam( name = "p_type", value = "归类", required = true, dataType = "String" ),
    new ApiImplicitParam( name = "mFile", value = "文档", required = true, dataType = "Array[MultipartFile]" ),
    new ApiImplicitParam( name = "imgs", value = "图片", required = true, dataType = "Array[MultipartFile]" )
  ) )
  @PostMapping(Array("tt") )
  def tt(@RequestBody a:A):String = {
    println("a:"+a)
    println("a.a:"+a.a)
    println("a.b.c:"+a.b.c)
    "ok"
  }
  @PostMapping(Array("set") )
  def set():String = {
    stringredistemplate.opsForValue().set("a","a")
    "ok"
  }
  @PostMapping(Array("get") )
  def get():String = {
    stringredistemplate.opsForValue().get("a")
  }
}
// @transient
//  @BeanProperty
//  @Column
//  var name:String=_

case class A( @BeanProperty a:String,  @BeanProperty b:B)
case class B( @BeanProperty c:String,  @BeanProperty d:String)