qixiaoning
2025-07-31 1fda1e433489e43387dbd082f8aba37d136755b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package models
 
import (
    "strings"
    "time"
)
 
type BaseEntity struct {
    Id         string `gorm:"primary_key;column:id" json:"id" example:""`
    CreateTime string `gorm:"column:createTime" json:"createTime,omitempty" example:""`
    UpdateTime string `gorm:"column:updateTime" json:"updateTime,omitempty" example:""`
    CreateBy   string `gorm:"column:createBy" json:"createBy,omitempty" example:""`
    IsDelete   int    `gorm:"column:isDelete" json:"isDelete" example:"0 未删除 1已删除"`
    Enable     int    `gorm:"column:enable" json:"enable" example:" 1生效 0未生效"`
}
 
func (dp *BaseEntity) PriInsert() {
    dp.CreateTime = time.Now().Format("2006-01-02 15:04:05")
    dp.CreateBy = "admin"
    dp.IsDelete = 0
    dp.Enable = 1
}
 
func (dp *BaseEntity) PriUpdate() {
    dp.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
}
 
func IsStack(id string) bool {
    if strings.HasPrefix(id, "stack_") {
        return true
    }
    return false
}