init: taotie-api 项目初始化

This commit is contained in:
2026-05-16 00:14:19 +08:00
commit eb15ef4b87
33 changed files with 1746 additions and 0 deletions

43
model/po/tbase.go Normal file
View File

@@ -0,0 +1,43 @@
package po
import "go.mongodb.org/mongo-driver/bson/primitive"
type TBase struct {
OID primitive.ObjectID `bson:"_id,omitempty"` // 主键
CreatedAt int64 `bson:"createdAt"` // 创建时间
UpdatedAt int64 `bson:"updatedAt"` // 更新时间
DeletedAt int64 `bson:"deletedAt"` // 删除时间
CreatedBy_OID primitive.ObjectID `bson:"createdBy"` // 创建人OID
Tenant_OID primitive.ObjectID `bson:"tenantId"` // 租户ID
}
// Id 获取主键
func (t *TBase) Id() string {
return t.OID.Hex()
}
// CreatedBy 获取创建人 Id
func (t *TBase) CreatedBy() string {
return t.CreatedBy_OID.Hex()
}
// SetCreatedBy 设置创建人 Id
func (t *TBase) SetCreatedBy(createdBy string) {
t.CreatedBy_OID, _ = primitive.ObjectIDFromHex(createdBy)
}
// TenantId 获取租户 Id
func (t *TBase) TenantId() string {
return t.Tenant_OID.Hex()
}
// SetTenantId 设置租户 Id
func (t *TBase) SetTenantId(tenantId string) {
t.Tenant_OID, _ = primitive.ObjectIDFromHex(tenantId)
}
// SetNow 设置当前时间
func (t *TBase) SetNow(now int64) {
t.CreatedAt = now
t.UpdatedAt = now
}

8
model/po/ttenant.go Normal file
View File

@@ -0,0 +1,8 @@
package po
type TTenant struct {
TBase `bson:",inline"`
TenantNo string `bson:"tenantNo"`
TenantName string `bson:"tenantName"`
}

9
model/po/tuser.go Normal file
View File

@@ -0,0 +1,9 @@
package po
type TUser struct {
TBase `bson:",inline"`
NickName string `bson:"nickName"` // 昵称
UserName string `bson:"userName"` // 用户名
Password string `bson:"password"` // 密码
}