package req import ( "context" "errors" "gitea.ddegame.cn/open/servicebase/pkg/log" ) type CommonAuthReq struct { Type string `json:"type"` // app_user_wechat app_driver_wechat admin_company Code string `json:"code" form:"code" uri:"code"` // 微信登录:type=app_user_wechat|app_driver_wechat Login string `json:"login"` // 账号密码登录:type=admin_company Password string `json:"password"` // 账号密码登录:type=admin_company } func (d *CommonAuthReq) Check() error { return nil } type AdminUserRoleAllReq struct { UserID string `json:"user_id" form:"user_id" uri:"user_id"` // ID } type TenantRolePrivilegeAllReq struct { RoleID string `json:"role_id" form:"role_id" uri:"role_id"` // ID } type AdminUserPassResetReq struct { UserID string `json:"user_id"` // USERNAME EMAIL AUTO PrePass string `json:"pre_password"` NewPass string `json:"new_password"` } func (d *AdminUserPassResetReq) Check() error { if len(d.UserID) == 0 { return errors.New("请指定用户ID") } if len(d.PrePass) == 0 { return errors.New("请指定旧密码") } if len(d.NewPass) == 0 { return errors.New("请指定新密码") } if len(d.NewPass) < 6 { return errors.New("密码不能少于6位") } return nil } type UserCheckReq struct { UserID string `json:"user_id"` Point string `json:"point"` } func (d UserCheckReq) Check(c context.Context) error { if len(d.UserID) == 0 || len(d.Point) == 0 { log.ErrorF("privilege check 参数错误: uid=%s point=%s", d.UserID, d.Point) return errors.New("参数错误") } return nil } type ServiceUserResourceReq struct { UserID string `json:"user_id" form:"user_id" uri:"user_id"` } func (d ServiceUserResourceReq) Check() error { if len(d.UserID) == 0 { return errors.New("参数错误") } return nil } type TenantAddReq struct { Name string `gorm:"column:name;type:varchar(255);not null;index:idx_name,priority:1;comment:租户名" json:"name"` Contact string `gorm:"column:contact;type:varchar(255);not null;comment:联系方式" json:"contact"` Desc string `gorm:"column:desc;type:varchar(255);not null;comment:备注" json:"desc"` } func (d *TenantAddReq) Check() error { if len(d.Name) == 0 { return errors.New("名称不能为空") } return nil } type TenantUpdateReq struct { IDBody TenantAddReq } func (d *TenantUpdateReq) Check() error { if len(d.ID) == 0 { return errors.New("ID不能为空") } return nil } type AdminPrivilegeAddReq struct { TenantID string `gorm:"column:tenant_id;type:char(32);not null;default:system;comment:企业ID" json:"tenant_id"` ScopeID string `gorm:"column:scope_id;type:char(32);not null;comment:范围" json:"scope_id"` ParentID string `gorm:"column:parent_id;type:char(32);not null;comment:父ID" json:"parent_id"` Code string `gorm:"column:code;type:varchar(64);not null;comment:代码" json:"code"` Name string `gorm:"column:name;type:varchar(64);not null;index:idx_name,priority:1;comment:权限名称" json:"name"` Level int32 `gorm:"column:level;type:int;not null;comment:权限级别" json:"level"` SourceType string `gorm:"column:source_type;type:varchar(64);not null;comment:类型:resource、interface等" json:"source_type"` TargetType string `gorm:"column:target_type;type:varchar(255);not null" json:"target_type"` Target string `gorm:"column:target;type:varchar(255);not null;comment:权限值 resource:菜单路径; api=url-pre" json:"target"` Desc string `gorm:"column:desc;type:varchar(64);not null;comment:描述" json:"desc"` } func (d *AdminPrivilegeAddReq) Check() error { return nil } type AdminPrivilegeUpdateReq struct { IDBody AdminPrivilegeAddReq } func (d *AdminPrivilegeUpdateReq) Check() error { return nil } type AdminRoleAddReq struct { Name string `json:"name"` // 名称 Code string `json:"code"` // 名称 Desc string `json:"desc"` // 描述 } type AdminRoleUpdateReq struct { IDBody AdminRoleAddReq } type AdminUserAddReq struct { Username string `json:"username" form:"username" uri:"username"` // ID Nickname string `json:"nickname" form:"nickname" uri:"nickname"` // Desc string `json:"desc" form:"desc" uri:"desc"` // Password string `json:"password" form:"password" uri:"password"` // } type AdminUserUpdateReq struct { IDBody Username string `json:"username" form:"username" uri:"username"` // ID Nickname string `json:"nickname" form:"nickname" uri:"nickname"` // Desc string `json:"desc" form:"desc" uri:"desc"` // State int32 `json:"state" form:"state" uri:"state"` // } type AdminUserUpdatePasswordReq struct { IDBody Password string `json:"password" form:"password" uri:"password"` // ID } type AdminUserRoleAddReq struct { ScopeID string `json:"scope_id"` // UserID string `json:"user_id"` // RoleID string `json:"role_id"` // } type AdminRolePrivilegeAddReq struct { ScopeID string `json:"scope_id"` // RoleID string `json:"role_id"` // PrivilegeID string `json:"privilege_id"` // }