adm_key_management.go 960 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package model
  2. import (
  3. "git.getensh.com/common/gopkgsv2/database"
  4. "gorm.io/gorm"
  5. )
  6. type AdmKeyManagementModel interface{
  7. Get(db *gorm.DB) (*AdmKeyManagement, error)
  8. }
  9. type AdmKeyManagement struct {
  10. ID int64 `gorm:"column:id" json:"id"`
  11. Key string `gorm:"column:key" json:"key"`
  12. Desc string `gorm:"column:desc" json:"desc"`
  13. CreatedAt int64 `gorm:"column:created_at" json:"created_at"`
  14. UpdatedAt int64 `gorm:"column:updated_at" json:"updated_at"`
  15. }
  16. type defaultAdmKeyManagementModel struct {
  17. tableName string
  18. fields string
  19. }
  20. func NewAdmKeyManagementModel() AdmKeyManagementModel {
  21. return &defaultAdmKeyManagementModel{
  22. tableName: "t_adm_key_management",
  23. fields: "id, `key`, `desc`, created_at, updated_at",
  24. }
  25. }
  26. func (d *defaultAdmKeyManagementModel) Get(db *gorm.DB) (*AdmKeyManagement, error){
  27. var res AdmKeyManagement
  28. err := database.Get(db, &res, database.Option{
  29. TableName: d.tableName,
  30. Fields: d.fields,
  31. })
  32. return &res, err
  33. }