package com.icloud.server.scala

//import lombok.Data
//import org.h2.store.Data
import lombok.Data
import org.springframework.data.jpa.repository.{JpaRepository, JpaSpecificationExecutor}
import org.springframework.data.repository.{CrudRepository, PagingAndSortingRepository}
import org.springframework.stereotype.Repository
import org.springframework.web.bind.annotation.{GetMapping, RequestMapping, RestController}

import java.util
import javax.annotation.Resource
import javax.persistence.{Column, Entity, Id, Table}
import scala.beans.BeanProperty
import scala.jdk.CollectionConverters._

@RestController
@RequestMapping( Array( "/init/" ) )
class IinitController {
  @Resource
  @BeanProperty
  var mr:MenuinitRepository=_
  def aa(): Unit ={

  }
  @GetMapping( Array( "/list-menus" ) ) def getpromoter_list1 (): Object = {
    //一级菜单
    val menuinits = mr.findByTypesAndStatus( 1, 0 )


    menuinits
  }
}


@Repository trait MenuinitRepository extends CrudRepository[Menuinit, Long] with JpaSpecificationExecutor[Menuinit] with JpaRepository[Menuinit, Long] with PagingAndSortingRepository[Menuinit, Long] {
  //  def findByUidOrderByFidDesc( uid:Int,p:Pageable):util.List[Menuinit]
  //  def countByUid( uid:Int):Long
  def findByStatus(status:Int):util.List[Menuinit]
  def findByTypesAndStatus(types:Int,status:Int):util.List[Menuinit]
  def findByParentidAndStatus(parentid:Int,status:Int):util.List[Menuinit]

}
@Data
@Entity
@Table( name = "menu_init" )
class Menuinit{
  @Id
  @BeanProperty
  @Column var id: Int = _
  @BeanProperty
  @Column var name: String = _
  @BeanProperty
  @Column(name = "type")
  var types: Int = _
  @BeanProperty
  @Column var sort: Int = _
  @BeanProperty
  @Column(name="parent_id")
  var parentid: Int = _
  @BeanProperty
  @Column var path: String = _
  @BeanProperty
  @Column var icon: String = _
  @BeanProperty
  @Column var component: String = _
  @BeanProperty
  @Column var status: Int = _
  @BeanProperty
  @Column var deleted: Int = _

}
