From 646f87c178545a5d94f14f31e490fd5f3fd55c2c Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 28 Oct 2024 15:08:37 +0800 Subject: [PATCH 1/4] 1 --- src/super/dao/user_list_dao.go | 4 +++- src/super/dao/user_open_permission_dao.go | 12 +++++++++++ src/super/implement/user_list_implement.go | 14 +++++++++++++ .../user_open_permission_implement.go | 21 +++++++++++++++++++ src/super/model/user_list.go | 11 +++++----- src/super/model/user_open_permission.go | 9 ++++++++ 6 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 src/super/dao/user_open_permission_dao.go create mode 100644 src/super/implement/user_open_permission_implement.go create mode 100644 src/super/model/user_open_permission.go diff --git a/src/super/dao/user_list_dao.go b/src/super/dao/user_list_dao.go index ba8058c..5fce688 100644 --- a/src/super/dao/user_list_dao.go +++ b/src/super/dao/user_list_dao.go @@ -1,5 +1,7 @@ package dao +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + type UserListDao interface { - //TODO:: You can add specific method definitions here + GetUserListByOpenAppSecret(appSecret string) (m *model.UserList, err error) } diff --git a/src/super/dao/user_open_permission_dao.go b/src/super/dao/user_open_permission_dao.go new file mode 100644 index 0000000..fdbd256 --- /dev/null +++ b/src/super/dao/user_open_permission_dao.go @@ -0,0 +1,12 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type UserOpenPermissionDao interface { + GetUserOpenPermission(masterId int) (list []*GetUserOpenPermissionResp, total int64, err error) +} + +type GetUserOpenPermissionResp struct { + model.UserOpenPermission `xorm:"extends"` + model.Permission `xorm:"extends"` +} diff --git a/src/super/implement/user_list_implement.go b/src/super/implement/user_list_implement.go index 0c106d3..9106447 100644 --- a/src/super/implement/user_list_implement.go +++ b/src/super/implement/user_list_implement.go @@ -2,6 +2,8 @@ package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" "xorm.io/xorm" ) @@ -12,3 +14,15 @@ func NewUserListDb(engine *xorm.Engine) dao.UserListDao { type UserListDb struct { Db *xorm.Engine } + +func (u UserListDb) GetUserListByOpenAppSecret(appSecret string) (m *model.UserList, err error) { + m = new(model.UserList) + has, err := u.Db.Where("open_app_secret =?", appSecret).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} diff --git a/src/super/implement/user_open_permission_implement.go b/src/super/implement/user_open_permission_implement.go new file mode 100644 index 0000000..b045dbe --- /dev/null +++ b/src/super/implement/user_open_permission_implement.go @@ -0,0 +1,21 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "xorm.io/xorm" +) + +func NewUserOpenPermissionDb(engine *xorm.Engine) dao.UserOpenPermissionDao { + return &UserOpenPermissionDb{Db: engine} +} + +type UserOpenPermissionDb struct { + Db *xorm.Engine +} + +func (u UserOpenPermissionDb) GetUserOpenPermission(masterId int) (list []*dao.GetUserOpenPermissionResp, total int64, err error) { + total, err = u.Db.Where("user_open_permission.master_id =?", masterId). + Join("LEFT", "permission", "user_open_permission.permission_id = permission.id"). + FindAndCount(&list) + return +} diff --git a/src/super/model/user_list.go b/src/super/model/user_list.go index 2761aa6..f9de1e2 100644 --- a/src/super/model/user_list.go +++ b/src/super/model/user_list.go @@ -5,9 +5,10 @@ import ( ) type UserList struct { - Uuid int `json:"uuid" xorm:"not null default 0 comment('msater_id') INT(10)"` - Name string `json:"name" xorm:"not null default '' comment('昵称') VARCHAR(32)"` - Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` - State int `json:"state" xorm:"not null default 1 comment('状态0未激活,1正常.2禁用') TINYINT(1)"` - DeleteAt time.Time `json:"delete_at" xorm:"comment('删除时间') TIMESTAMP"` + Uuid int `json:"uuid" xorm:"not null default 0 comment('msater_id') INT(10)"` + Name string `json:"name" xorm:"not null default '' comment('昵称') VARCHAR(32)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` + OpenAppSecret string `json:"open_app_secret" xorm:"not null default '' comment('开放平台秘钥') VARCHAR(255)"` + State int `json:"state" xorm:"not null default 1 comment('状态0未激活,1正常.2禁用') TINYINT(1)"` + DeleteAt time.Time `json:"delete_at" xorm:"comment('删除时间') TIMESTAMP"` } diff --git a/src/super/model/user_open_permission.go b/src/super/model/user_open_permission.go new file mode 100644 index 0000000..0d632f2 --- /dev/null +++ b/src/super/model/user_open_permission.go @@ -0,0 +1,9 @@ +package model + +type UserOpenPermission struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + MasterId int `json:"master_id" xorm:"not null default 0 comment('站长id') INT(11)"` + PermissionId int `json:"permission_id" xorm:"not null default 0 comment('权限id') INT(11)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` +} From f6f1288fc52e97158b3b8e2c52d61838936531c3 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 28 Oct 2024 15:14:33 +0800 Subject: [PATCH 2/4] 2 --- src/super/dao/user_open_permission_dao.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/super/dao/user_open_permission_dao.go b/src/super/dao/user_open_permission_dao.go index fdbd256..ec9c5ef 100644 --- a/src/super/dao/user_open_permission_dao.go +++ b/src/super/dao/user_open_permission_dao.go @@ -10,3 +10,7 @@ type GetUserOpenPermissionResp struct { model.UserOpenPermission `xorm:"extends"` model.Permission `xorm:"extends"` } + +func (GetUserOpenPermissionResp) TableName() string { + return "user_open_permission" +} From 356f24ca1cfab783241f76c8533683b1b291e262 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 28 Oct 2024 15:31:36 +0800 Subject: [PATCH 3/4] updaste --- src/super/dao/user_open_permission_dao.go | 2 +- src/super/model/open_permission.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/super/model/open_permission.go diff --git a/src/super/dao/user_open_permission_dao.go b/src/super/dao/user_open_permission_dao.go index ec9c5ef..f22b0d6 100644 --- a/src/super/dao/user_open_permission_dao.go +++ b/src/super/dao/user_open_permission_dao.go @@ -8,7 +8,7 @@ type UserOpenPermissionDao interface { type GetUserOpenPermissionResp struct { model.UserOpenPermission `xorm:"extends"` - model.Permission `xorm:"extends"` + model.OpenPermission `xorm:"extends"` } func (GetUserOpenPermissionResp) TableName() string { diff --git a/src/super/model/open_permission.go b/src/super/model/open_permission.go new file mode 100644 index 0000000..bfd236a --- /dev/null +++ b/src/super/model/open_permission.go @@ -0,0 +1,10 @@ +package model + +type OpenPermission struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` + Action string `json:"action" xorm:"not null default '' comment('路由') unique VARCHAR(255)"` + State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:废弃)') TINYINT(1)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` +} From ef7ecbd0db8da066e1da246b3223ac6b8837df60 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 28 Oct 2024 15:39:07 +0800 Subject: [PATCH 4/4] 1 --- src/super/implement/user_open_permission_implement.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/super/implement/user_open_permission_implement.go b/src/super/implement/user_open_permission_implement.go index b045dbe..d0bf4ee 100644 --- a/src/super/implement/user_open_permission_implement.go +++ b/src/super/implement/user_open_permission_implement.go @@ -15,7 +15,7 @@ type UserOpenPermissionDb struct { func (u UserOpenPermissionDb) GetUserOpenPermission(masterId int) (list []*dao.GetUserOpenPermissionResp, total int64, err error) { total, err = u.Db.Where("user_open_permission.master_id =?", masterId). - Join("LEFT", "permission", "user_open_permission.permission_id = permission.id"). + Join("LEFT", "open_permission", "user_open_permission.permission_id = open_permission.id"). FindAndCount(&list) return }