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"` +}