sys_user_role.go 1007 字节
package models

import (
	"fmt"
	"gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/internal/pkg/domain"
	"gorm.io/gorm"
)

type SysUserRole struct {
	Id int64 // 唯一标识
}

func (m *SysUserRole) TableName() string {
	return "sys_user_role"
}

func (m *SysUserRole) BeforeCreate(tx *gorm.DB) (err error) {
	// m.CreatedAt = time.Now().Unix()
	// m.UpdatedAt = time.Now().Unix()
	return
}

func (m *SysUserRole) BeforeUpdate(tx *gorm.DB) (err error) {
	// m.UpdatedAt = time.Now().Unix()
	return
}

func (m *SysUserRole) CacheKeyFunc() string {
	if m.Id == 0 {
		return ""
	}
	return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
}

func (m *SysUserRole) CacheKeyFuncByObject(obj interface{}) string {
	if v, ok := obj.(*SysUserRole); ok {
		return v.CacheKeyFunc()
	}
	return ""
}

func (m *SysUserRole) CachePrimaryKeyFunc() string {
	if len("") == 0 {
		return ""
	}
	return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
}