duyong mac 7 månader sedan
förälder
incheckning
546edbf7b0
4 ändrade filer med 60 tillägg och 0 borttagningar
  1. 3 0
      go.mod
  2. 6 0
      go.sum
  3. 19 0
      internal/iam/models/user.go
  4. 32 0
      internal/pkg/models/by.go

+ 3 - 0
go.mod

@@ -8,6 +8,7 @@ require (
 	github.com/zsais/go-gin-prometheus v0.1.0
 	gogs.tyduyong.com/duyong/dy-pkg v0.1.1
 	google.golang.org/grpc v1.63.2
+	gorm.io/gorm v1.25.9
 )
 
 require (
@@ -30,6 +31,8 @@ require (
 	github.com/gosuri/uitable v0.0.4 // indirect
 	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/inconshreveable/mousetrap v1.1.0 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jinzhu/now v1.1.5 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/klauspost/cpuid/v2 v2.2.7 // indirect
 	github.com/leodido/go-urn v1.4.0 // indirect

+ 6 - 0
go.sum

@@ -75,6 +75,10 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
+github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
+github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
 github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
@@ -257,5 +261,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
+gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
 nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

+ 19 - 0
internal/iam/models/user.go

@@ -0,0 +1,19 @@
+package models
+
+import "gogs.tyduyong.com/duyong/dy-admin/internal/pkg/models"
+
+type SysUser struct {
+	UserID    int    `gorm:"primaryKey;autoIncrement;comment:编码"  json:"userId"`
+	Username  string `json:"username" gorm:"size:64;comment:用户名"`
+	Password  string `json:"-" gorm:"size:128;comment:密码"`
+	NickName  string `json:"nickName" gorm:"size:128;comment:昵称"`
+	Phone     string `json:"phone" gorm:"size:11;comment:手机号"`
+	Salt      string `json:"-" gorm:"size:255;comment:加盐"`
+	Avatar    string `json:"avatar" gorm:"size:255;comment:头像"`
+	Sex       string `json:"sex" gorm:"size:255;comment:性别"`
+	Remark    string `json:"remark" gorm:"size:255;comment:备注"`
+	Status    string `json:"status" gorm:"size:4;comment:状态"`
+	TenantIDs []int  `json:"tenantIds" gorm:"-"` //加入的租户
+	models.ControlBy
+	models.ModelTime
+}

+ 32 - 0
internal/pkg/models/by.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"time"
+
+	"gorm.io/gorm"
+)
+
+type ControlBy struct {
+	CreateBy string `json:"createBy" gorm:"index;comment:创建者"`
+	UpdateBy string `json:"updateBy" gorm:"index;comment:更新者"`
+}
+
+// SetCreateBy 设置创建人id
+func (e *ControlBy) SetCreateBy(createBy string) {
+	e.CreateBy = createBy
+}
+
+// SetUpdateBy 设置修改人id
+func (e *ControlBy) SetUpdateBy(updateBy string) {
+	e.UpdateBy = updateBy
+}
+
+type Model struct {
+	Id string `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
+}
+
+type ModelTime struct {
+	CreatedAt time.Time      `json:"createdAt" gorm:"comment:创建时间"`
+	UpdatedAt time.Time      `json:"updatedAt" gorm:"comment:最后更新时间"`
+	DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"`
+}