@@ -1,5 +1,7 @@ | |||||
package dao | package dao | ||||
import "code.fnuoos.com/zhimeng/model.git/src/super/model" | |||||
type UserListDao interface { | type UserListDao interface { | ||||
//TODO:: You can add specific method definitions here | |||||
GetUserListByOpenAppSecret(appSecret string) (m *model.UserList, err error) | |||||
} | } |
@@ -0,0 +1,16 @@ | |||||
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.OpenPermission `xorm:"extends"` | |||||
} | |||||
func (GetUserOpenPermissionResp) TableName() string { | |||||
return "user_open_permission" | |||||
} |
@@ -2,6 +2,8 @@ package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/zhimeng/model.git/src/super/dao" | "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" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -12,3 +14,15 @@ func NewUserListDb(engine *xorm.Engine) dao.UserListDao { | |||||
type UserListDb struct { | type UserListDb struct { | ||||
Db *xorm.Engine | 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 | |||||
} |
@@ -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", "open_permission", "user_open_permission.permission_id = open_permission.id"). | |||||
FindAndCount(&list) | |||||
return | |||||
} |
@@ -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"` | |||||
} |
@@ -5,9 +5,10 @@ import ( | |||||
) | ) | ||||
type UserList struct { | 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"` | |||||
} | } |
@@ -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"` | |||||
} |