新增repo表处理
This commit is contained in:
parent
330f16a3f6
commit
43c5f20ad7
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 组织表
|
||||||
|
type Organization struct {
|
||||||
|
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
|
||||||
|
Name string `gorm:"column:name;NOT NULL"` // 组织名
|
||||||
|
ParentID uint `gorm:"column:parent_id;default:0"` // 上级组织id
|
||||||
|
Sort uint `gorm:"column:sort;default:0"` // 层级序号
|
||||||
|
Status int `gorm:"column:status;default:1"` // 状态:0-无效,1-有效
|
||||||
|
Path string `gorm:"column:path"` // 全路径
|
||||||
|
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||||
|
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
|
||||||
|
ModifiedBy string `gorm:"column:modified_by"` // 修改人
|
||||||
|
ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Organization) TableName() string {
|
||||||
|
return "organization"
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrganizationRepo interface{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type orginizationRepo struct{
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrganization(i *do.Injector)(OrganizationRepo,error){
|
||||||
|
return &orginizationRepo{
|
||||||
|
db:do.MustInvoke[*gorm.DB](i),
|
||||||
|
},nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func init(){
|
||||||
|
do.Provide[UserOrganizationRepo](nil,NewUserOrganizationRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组织角色表
|
||||||
|
type OrganizationRole struct {
|
||||||
|
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
|
||||||
|
OrgID uint `gorm:"column:org_id;NOT NULL"` // 组织id
|
||||||
|
RoleID uint `gorm:"column:role_id;NOT NULL"` // 角色id
|
||||||
|
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||||
|
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
|
||||||
|
ModifiedBy string `gorm:"column:modified_by"` // 修改人
|
||||||
|
ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *OrganizationRole) TableName() string {
|
||||||
|
return "organization_role"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type OrganizationRoleRepo interface{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type organizationRoleRepo struct {
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrganizationRoleRepo(i *do.Injector)(OrganizationRoleRepo,error){
|
||||||
|
return &organizationRoleRepo{
|
||||||
|
db:do.MustInvoke[*gorm.DB](i),
|
||||||
|
},nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init(){
|
||||||
|
do.Provide[OrganizationRoleAuthorRepo](nil,NewOrganizationRoleAuthorRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组织角色授权表
|
||||||
|
type OrganizationRoleAuthor struct {
|
||||||
|
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
|
||||||
|
OrgID uint `gorm:"column:org_id;NOT NULL"` // 组织id
|
||||||
|
RoleID uint `gorm:"column:role_id;NOT NULL"` // 角色id
|
||||||
|
Option int `gorm:"column:option;default:0;NOT NULL"` // 选择:0-选择组织,1-选择组织含下级
|
||||||
|
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||||
|
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
|
||||||
|
ModifiedBy string `gorm:"column:modified_by"` // 修改人
|
||||||
|
ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *OrganizationRoleAuthor) TableName() string {
|
||||||
|
return "organization_role_author"
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrganizationRoleAuthorRepo interface{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type organizationRoleAuthorRepo struct{
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrganizationRoleAuthorRepo(i *do.Injector)(OrganizationRoleAuthorRepo,error){
|
||||||
|
return &organizationRoleAuthorRepo{
|
||||||
|
db:do.MustInvoke[*gorm.DB](i),
|
||||||
|
},nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init(){
|
||||||
|
do.Provide[RoleRepo](nil,NewRoleRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表
|
||||||
|
type Role struct {
|
||||||
|
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
|
||||||
|
Name string `gorm:"column:name;NOT NULL"` // 名称
|
||||||
|
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||||
|
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
|
||||||
|
ModifiedBy string `gorm:"column:modified_by"` // 修改人
|
||||||
|
ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Role) TableName() string {
|
||||||
|
return "role"
|
||||||
|
}
|
||||||
|
|
||||||
|
type RoleRepo interface{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type roleRepo struct{
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRoleRepo(i *do.Injector)(RoleRepo,error){
|
||||||
|
return &roleRepo{
|
||||||
|
db :do.MustInvoke[*gorm.DB](i),
|
||||||
|
},nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init(){
|
||||||
|
do.Provide[RoleMenuPermissionRepo](nil,NewRoleMenuPermissionRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 角色菜单权限表
|
||||||
|
type RoleMenuPermission struct {
|
||||||
|
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
|
||||||
|
MenuID uint `gorm:"column:menu_id;NOT NULL"` // 菜单id
|
||||||
|
RoleID uint `gorm:"column:role_id;NOT NULL"` // 角色id
|
||||||
|
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||||
|
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
|
||||||
|
ModifiedBy string `gorm:"column:modified_by"` // 修改人
|
||||||
|
ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *RoleMenuPermission) TableName() string {
|
||||||
|
return "role_menu_permission"
|
||||||
|
}
|
||||||
|
|
||||||
|
type RoleMenuPermissionRepo interface{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type roleMenuPermissionRepo struct{
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRoleMenuPermissionRepo(i *do.Injector)(RoleMenuPermissionRepo,error){
|
||||||
|
return &roleMenuPermissionRepo{
|
||||||
|
db:do.MustInvoke[*gorm.DB](i),
|
||||||
|
},nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Code generated by sql2gorm. DO NOT EDIT.
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init(){
|
||||||
|
do.Provide[UserOrganizationRepo](nil,NewUserOrganizationRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户组织表
|
||||||
|
type UserOrganization struct {
|
||||||
|
ID uint `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
|
||||||
|
UserID uint `gorm:"column:user_id;NOT NULL"` // 用户id
|
||||||
|
OrgID uint `gorm:"column:org_id;NOT NULL"` // 组织id
|
||||||
|
Leader int `gorm:"column:leader;default:0"` // 是否是组织领导:一个组织只能有一个领导人
|
||||||
|
CreatedBy string `gorm:"column:created_by"` // 创建人
|
||||||
|
CreatedOn time.Time `gorm:"column:created_on;default:CURRENT_TIMESTAMP;NOT NULL"` // 记录创建时间
|
||||||
|
ModifiedBy string `gorm:"column:modified_by"` // 修改人
|
||||||
|
ModifiedOn time.Time `gorm:"column:modified_on;default:CURRENT_TIMESTAMP"` // 记录修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *UserOrganization) TableName() string {
|
||||||
|
return "user_organization"
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserOrganizationRepo interface{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type userOrganizationRepo struct{
|
||||||
|
db *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserOrganizationRepo(i *do.Injector)(UserOrganizationRepo,error){
|
||||||
|
return &userOrganizationRepo{
|
||||||
|
db:do.MustInvoke[*gorm.DB](i),
|
||||||
|
},nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package organization
|
||||||
|
|
||||||
|
import (
|
||||||
|
"busniess-user-center/config"
|
||||||
|
"busniess-user-center/internal/repo"
|
||||||
|
"busniess-user-center/pkg/redis"
|
||||||
|
|
||||||
|
"github.com/samber/do"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
do.Provide(nil, NewOrganizationService)
|
||||||
|
}
|
||||||
|
|
||||||
|
type organizationService struct {
|
||||||
|
logger *zap.SugaredLogger
|
||||||
|
appRepo repo.OrganizationRepo
|
||||||
|
menuRepo repo.MenuRepo
|
||||||
|
redis *redis.Redis
|
||||||
|
conf *config.AppConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrganizationService(i *do.Injector) (OrganizationService, error) {
|
||||||
|
return &organizationService{
|
||||||
|
logger: do.MustInvoke[*zap.SugaredLogger](i),
|
||||||
|
appRepo: do.MustInvoke[repo.OrganizationRepo](i),
|
||||||
|
menuRepo: do.MustInvoke[repo.MenuRepo](i),
|
||||||
|
redis: do.MustInvoke[*redis.Redis](i),
|
||||||
|
conf: do.MustInvoke[*config.AppConfig](i),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue