feat: update model

v3
veypi 3 weeks ago
parent 11521b4b1c
commit 1ad9cb686f

@ -251,7 +251,7 @@ func tokenList(x *rest.X) (any, error) {
query := cfg.DB() query := cfg.DB()
query = query.Where("user_id = ?", opts.UserID) query = query.Where("user_id = ?", opts.UserID)
query = query.Where("app_id = ?", opts.AppID) query = query.Where("app_id = ?", opts.AppID)
err = query.Find(&data).Error err = query.Limit(opts.Limit).Find(&data).Error
return data, err return data, err
} }

@ -41,8 +41,10 @@ func runWeb() error {
builtin.Enable(app) builtin.Enable(app)
app.Router().Any("/media/*", http.StripPrefix("/media", http.FileServer(http.Dir("/home/v/cache/"))).ServeHTTP) app.Router().Any("/media/*", http.StripPrefix("/media", http.FileServer(http.Dir("/home/v/cache/"))).ServeHTTP)
apiRouter := app.Router().SubRouter("api") apiRouter := app.Router().SubRouter("api")
api.Use(apiRouter) api.Use(apiRouter)
apiRouter.Use(errs.JsonResponse) apiRouter.Use(errs.JsonResponse)
apiRouter.SetErrFunc(errs.JsonErrorResponse) apiRouter.SetErrFunc(errs.JsonErrorResponse)
app.Router().EmbedDir("/", staticFs, "static/", "static/index.html") app.Router().EmbedDir("/", staticFs, "static/", "static/index.html")
app.Router().Print() app.Router().Print()

@ -5,11 +5,11 @@ import "time"
type AccessList struct { type AccessList struct {
CreatedAt *time.Time `json:"created_at" parse:"query"` CreatedAt *time.Time `json:"created_at" parse:"query"`
UpdatedAt *time.Time `json:"updated_at" parse:"query"` UpdatedAt *time.Time `json:"updated_at" parse:"query"`
AppID string `json:"app_id" gorm:"index;type:varchar(32)" parse:"json"` AppID string `json:"app_id" gorm:"index;type:varchar(32)" parse:"query"`
UserID *string `json:"user_id" gorm:"index;type:varchar(32);default: null" parse:"json"` UserID *string `json:"user_id" gorm:"index;type:varchar(32);default: null" parse:"query"`
RoleID *string `json:"role_id" gorm:"index;type:varchar(32);default: null" parse:"json"` RoleID *string `json:"role_id" gorm:"index;type:varchar(32);default: null" parse:"query"`
Name *string `json:"name" parse:"json"` ResourceID *string `json:"resource_id" gorm:"index;type:varchar(32);default: null" parse:"query"`
ResourceID *string `json:"resource_id" gorm:"index;type:varchar(32);default: null" parse:"json"` Name *string `json:"name" parse:"query"`
} }
type AccessPost struct { type AccessPost struct {

@ -27,13 +27,13 @@ type AppPost struct {
} }
type AppList struct { type AppList struct {
Name *string `json:"name" parse:"json"` Name *string `json:"name" parse:"query"`
} }
type AppUserGet struct { type AppUserGet struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(32)" parse:"path@app_user_id"` ID string `json:"id" gorm:"primaryKey;type:varchar(32)" parse:"path@app_user_id"`
UserID string `json:"user_id" parse:"json"`
AppID string `json:"app_id" parse:"path"` AppID string `json:"app_id" parse:"path"`
UserID string `json:"user_id" parse:"query"`
} }
type AppUserPatch struct { type AppUserPatch struct {
@ -49,8 +49,8 @@ type AppUserDelete struct {
type AppUserList struct { type AppUserList struct {
AppID *string `json:"app_id" parse:"path"` AppID *string `json:"app_id" parse:"path"`
UserID *string `json:"user_id" parse:"json"` UserID *string `json:"user_id" parse:"query"`
Status *string `json:"status" parse:"json"` Status *string `json:"status" parse:"query"`
} }
type AppUserPost struct { type AppUserPost struct {

@ -22,5 +22,5 @@ type RolePost struct {
} }
type RoleList struct { type RoleList struct {
Name *string `json:"name" parse:"json"` Name *string `json:"name" parse:"query"`
} }

@ -38,6 +38,7 @@ type TokenDelete struct {
} }
type TokenList struct { type TokenList struct {
UserID string `json:"user_id" gorm:"index;type:varchar(32)" parse:"json"` Limit int `json:"limit"`
AppID string `json:"app_id" gorm:"index;type:varchar(32)" parse:"json"` UserID string `json:"user_id" gorm:"index;type:varchar(32)" parse:"query"`
AppID string `json:"app_id" gorm:"index;type:varchar(32)" parse:"query"`
} }

@ -31,11 +31,11 @@ type UserPost struct {
} }
type UserList struct { type UserList struct {
Username *string `json:"username" gorm:"varchar(100);unique;default:not null" parse:"json"` Username *string `json:"username" gorm:"type:varchar(100);unique;default:not null" parse:"query"`
Nickname *string `json:"nickname" parse:"json"` Nickname *string `json:"nickname" gorm:"type:varchar(100)" parse:"query"`
Email *string `json:"email" gorm:"varchar(20);unique;default:null" parse:"json"` Email *string `json:"email" gorm:"unique;type:varchar(50);default:null" parse:"query"`
Phone *string `json:"phone" gorm:"varchar(50);unique;default:null" parse:"json"` Phone *string `json:"phone" gorm:"type:varchar(30);unique;default:null" parse:"query"`
Status *uint `json:"status" parse:"json"` Status *uint `json:"status" parse:"query"`
} }
type UserRoleGet struct { type UserRoleGet struct {
@ -64,6 +64,6 @@ type UserRolePost struct {
} }
type UserRoleList struct { type UserRoleList struct {
Status *string `json:"status" parse:"json"`
UserID string `json:"user_id" parse:"path"` UserID string `json:"user_id" parse:"path"`
Status *string `json:"status" parse:"query"`
} }

@ -6,18 +6,17 @@
import webapi from "./webapi" import webapi from "./webapi"
import * as models from "./models" import * as models from "./models"
export interface ListOpts { export interface ListQuery {
created_at?: Date
updated_at?: Date
app_id: string app_id: string
user_id?: string user_id?: string
role_id?: string role_id?: string
resource_id?: string
name?: string name?: string
} }
export interface ListQuery { export function List(query: ListQuery) {
created_at?: Date return webapi.Get<models.Access[]>(`/access`, { query })
updated_at?: Date
}
export function List(json: ListOpts, query: ListQuery) {
return webapi.Get<models.Access[]>(`/access`, { json, query })
} }
export interface PostOpts { export interface PostOpts {
@ -27,8 +26,21 @@ export interface PostOpts {
name: string name: string
t_id: string t_id: string
level: number level: number
resource_id?: string
} }
export function Post(json: PostOpts) { export function Post(json: PostOpts) {
return webapi.Post<models.Access>(`/access`, { json }) return webapi.Post<models.Access>(`/access`, { json })
} }
export function Get(access_id: string) {
return webapi.Get<models.Access>(`/access/${access_id}`, {})
}
export function Patch(access_id: string) {
return webapi.Patch<models.Access>(`/access/${access_id}`, {})
}
export function Delete(access_id: string) {
return webapi.Delete<models.Access>(`/access/${access_id}`, {})
}

@ -14,8 +14,9 @@ export interface PatchOpts {
name?: string name?: string
icon?: string icon?: string
des?: string des?: string
participate?: string
init_role_id?: string init_role_id?: string
typ?: string
status?: string
} }
export function Patch(app_id: string, json: PatchOpts) { export function Patch(app_id: string, json: PatchOpts) {
return webapi.Patch<models.App>(`/app/${app_id}`, { json }) return webapi.Patch<models.App>(`/app/${app_id}`, { json })
@ -28,8 +29,9 @@ export function Delete(app_id: string) {
export interface PostOpts { export interface PostOpts {
name: string name: string
icon: string icon: string
des: string des?: string
participate: string typ: string
status: string
} }
export function Post(json: PostOpts) { export function Post(json: PostOpts) {
return webapi.Post<models.App>(`/app`, { json }) return webapi.Post<models.App>(`/app`, { json })
@ -38,25 +40,25 @@ export function Post(json: PostOpts) {
export interface ListOpts { export interface ListOpts {
name?: string name?: string
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.App[]>(`/app`, { json }) return webapi.Get<models.App[]>(`/app`, { query })
} }
export interface AppUserGetOpts { export interface AppUserGetOpts {
user_id: string user_id: string
} }
export function AppUserGet(app_user_id: string, app_id: string, json: AppUserGetOpts) { export function AppUserGet(app_id: string, app_user_id: string, query: AppUserGetQuery) {
return webapi.Get<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json }) return webapi.Get<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { query })
} }
export interface AppUserPatchOpts { export interface AppUserPatchOpts {
status?: string status?: string
} }
export function AppUserPatch(app_user_id: string, app_id: string, json: AppUserPatchOpts) { export function AppUserPatch(app_id: string, app_user_id: string, json: AppUserPatchOpts) {
return webapi.Patch<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json }) return webapi.Patch<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json })
} }
export function AppUserDelete(app_user_id: string, app_id: string) { export function AppUserDelete(app_id: string, app_user_id: string) {
return webapi.Delete<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, {}) return webapi.Delete<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, {})
} }
@ -64,8 +66,8 @@ export interface AppUserListOpts {
user_id?: string user_id?: string
status?: string status?: string
} }
export function AppUserList(app_id: string, json: AppUserListOpts) { export function AppUserList(app_id: string, query: AppUserListQuery) {
return webapi.Get<models.AppUser[]>(`/app/${app_id}/app_user`, { json }) return webapi.Get<models.AppUser[]>(`/app/${app_id}/app_user`, { query })
} }
export interface AppUserPostOpts { export interface AppUserPostOpts {
@ -76,12 +78,8 @@ export function AppUserPost(app_id: string, json: AppUserPostOpts) {
return webapi.Post<models.AppUser>(`/app/${app_id}/app_user`, { json }) return webapi.Post<models.AppUser>(`/app/${app_id}/app_user`, { json })
} }
export interface ResourceListQuery { export function ResourceList(app_id: string) {
created_at?: Date return webapi.Get<models.Resource[]>(`/app/${app_id}/resource`, {})
updated_at?: Date
}
export function ResourceList(app_id: string, query: ResourceListQuery) {
return webapi.Get<models.Resource[]>(`/app/${app_id}/resource`, { query })
} }
export interface ResourcePostOpts { export interface ResourcePostOpts {
@ -95,15 +93,28 @@ export function ResourcePost(app_id: string, json: ResourcePostOpts) {
export interface ResourceDeleteOpts { export interface ResourceDeleteOpts {
name: string name: string
} }
export function ResourceDelete(app_id: string, json: ResourceDeleteOpts) { export function ResourceGet(app_id: string, resource_id: string) {
return webapi.Delete<models.Resource>(`/app/${app_id}/resource`, { json }) return webapi.Get<models.Resource>(`/app/${app_id}/resource/${resource_id}`, {})
} }
export function ResourceGet(app_id: string) { export interface ResourcePatchOpts {
return webapi.Get<models.Resource>(`/app/${app_id}/resource`, {}) des?: string
}
export function ResourcePatch(app_id: string, resource_id: string, json: ResourcePatchOpts) {
return webapi.Patch<models.Resource>(`/app/${app_id}/resource/${resource_id}`, { json })
} }
export function ResourcePatch(app_id: string) { export function ResourceDelete(app_id: string, resource_id: string) {
return webapi.Patch<models.Resource>(`/app/${app_id}/resource`, {}) return webapi.Delete<models.Resource>(`/app/${app_id}/resource/${resource_id}`, {})
} }
export interface ListQuery {
name?: string
}
export interface AppUserGetQuery {
user_id: string
}
export interface AppUserListQuery {
user_id?: string
status?: string
}

@ -1,12 +1,14 @@
export interface Access { export interface Access {
created_at: Date created_at: Date
updated_at: Date updated_at: Date
app_id: string id: string
user_id?: string user_id?: string
role_id?: string role_id?: string
name: string name: string
tid: string tid: string
level: number level: number
resource_id?: string
app_id: string
} }
export interface App { export interface App {
id: string id: string
@ -23,6 +25,9 @@ export interface App {
status: string status: string
user_status: string user_status: string
} }
export const AppTyp = ['public', 'apply', 'private']
export interface AppUser { export interface AppUser {
id: string id: string
created_at: Date created_at: Date
@ -36,9 +41,10 @@ export interface AppUser {
export interface Resource { export interface Resource {
created_at: Date created_at: Date
updated_at: Date updated_at: Date
app_id: string id: string
name: string name: string
des: string des: string
app_id: string
} }
export interface Role { export interface Role {
id: string id: string

@ -6,6 +6,7 @@
import webapi from "./webapi" import webapi from "./webapi"
import * as models from "./models" import * as models from "./models"
export function Get(role_id: string) { export function Get(role_id: string) {
return webapi.Get<models.Role>(`/role/${role_id}`, {}) return webapi.Get<models.Role>(`/role/${role_id}`, {})
} }
@ -32,10 +33,10 @@ export function Post(json: PostOpts) {
return webapi.Post<models.Role>(`/role`, { json }) return webapi.Post<models.Role>(`/role`, { json })
} }
export interface ListOpts { export interface ListQuery {
name?: string name?: string
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.Role[]>(`/role`, { json }) return webapi.Get<models.Role[]>(`/role`, { query })
} }

@ -12,7 +12,7 @@ export interface TokenSaltOpts {
} }
// keep // keep
export function TokenSalt(json: TokenSaltOpts) { export function TokenSalt(json: TokenSaltOpts) {
return webapi.Post<{ id: string, salt: string }>(`/token/salt`, { json }) return webapi.Get<{ id: string, salt: string }>(`/token/TokenSalt`, { json })
} }
export interface PostOpts { export interface PostOpts {
refresh?: string refresh?: string
@ -46,11 +46,11 @@ export function Delete(token_id: string) {
return webapi.Delete<models.Token>(`/token/${token_id}`, {}) return webapi.Delete<models.Token>(`/token/${token_id}`, {})
} }
export interface ListOpts { export interface ListQuery {
user_id: string user_id: string
app_id: string app_id: string
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.Token[]>(`/token`, { json }) return webapi.Get<models.Token[]>(`/token`, { query })
} }

@ -39,25 +39,25 @@ export function Post(json: PostOpts) {
return webapi.Post<models.User>(`/user`, { json }) return webapi.Post<models.User>(`/user`, { json })
} }
export interface ListOpts { export interface ListQuery {
username?: string username?: string
nickname?: string nickname?: string
email?: string email?: string
phone?: string phone?: string
status?: number status?: number
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.User[]>(`/user`, { json }) return webapi.Get<models.User[]>(`/user`, { query })
} }
export function UserRoleGet(user_role_id: string, user_id: string) { export function UserRoleGet(user_id: string, user_role_id: string) {
return webapi.Get<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, {}) return webapi.Get<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, {})
} }
export interface UserRolePatchOpts { export interface UserRolePatchOpts {
status?: string status?: string
} }
export function UserRolePatch(user_role_id: string, user_id: string, json: UserRolePatchOpts) { export function UserRolePatch(user_id: string, user_role_id: string, json: UserRolePatchOpts) {
return webapi.Patch<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json }) return webapi.Patch<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json })
} }
@ -65,7 +65,7 @@ export interface UserRoleDeleteOpts {
role_id: string role_id: string
app_id: string app_id: string
} }
export function UserRoleDelete(user_role_id: string, user_id: string, json: UserRoleDeleteOpts) { export function UserRoleDelete(user_id: string, user_role_id: string, json: UserRoleDeleteOpts) {
return webapi.Delete<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json }) return webapi.Delete<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json })
} }
@ -78,10 +78,10 @@ export function UserRolePost(user_id: string, json: UserRolePostOpts) {
return webapi.Post<models.UserRole>(`/user/${user_id}/user_role`, { json }) return webapi.Post<models.UserRole>(`/user/${user_id}/user_role`, { json })
} }
export interface UserRoleListOpts { export interface UserRoleListQuery {
status?: string status?: string
} }
export function UserRoleList(user_id: string, json: UserRoleListOpts) { export function UserRoleList(user_id: string, query: UserRoleListQuery) {
return webapi.Get<models.UserRole[]>(`/user/${user_id}/user_role`, { json }) return webapi.Get<models.UserRole[]>(`/user/${user_id}/user_role`, { query })
} }

@ -10,7 +10,7 @@ import * as typs from './typs'
import { proxy } from './v2dom' import { proxy } from './v2dom'
class Token { class Token {
iat?: string iat?: number
// oa_id // oa_id
iss?: string iss?: string
// token id // token id
@ -63,7 +63,8 @@ class Token {
if (!logic.token.refresh.isVaild() || this._typ === 'refresh') { if (!logic.token.refresh.isVaild() || this._typ === 'refresh') {
reject() reject()
} }
if (this.isVaild()) { let now = Math.floor(Date.now() / 1000)
if (this.isVaild() && this.iat && now - this.iat < 10) {
return resolve(this) return resolve(this)
} }
let aid = logic.oa_id let aid = logic.oa_id

@ -86,9 +86,6 @@ export default new class {
app: { app: {
Get: api.app.Get, Get: api.app.Get,
List: api.app.List, List: api.app.List,
},
token: {
Post: api.token.Post
} }
} }
} }

@ -6,18 +6,17 @@
import webapi from "./webapi" import webapi from "./webapi"
import * as models from "./models" import * as models from "./models"
export interface ListOpts { export interface ListQuery {
created_at?: Date
updated_at?: Date
app_id: string app_id: string
user_id?: string user_id?: string
role_id?: string role_id?: string
resource_id?: string
name?: string name?: string
} }
export interface ListQuery { export function List(query: ListQuery) {
created_at?: Date return webapi.Get<models.Access[]>(`/access`, { query })
updated_at?: Date
}
export function List(json: ListOpts, query: ListQuery) {
return webapi.Get<models.Access[]>(`/access`, { json, query })
} }
export interface PostOpts { export interface PostOpts {
@ -27,8 +26,21 @@ export interface PostOpts {
name: string name: string
t_id: string t_id: string
level: number level: number
resource_id?: string
} }
export function Post(json: PostOpts) { export function Post(json: PostOpts) {
return webapi.Post<models.Access>(`/access`, { json }) return webapi.Post<models.Access>(`/access`, { json })
} }
export function Get(access_id: string) {
return webapi.Get<models.Access>(`/access/${access_id}`, {})
}
export function Patch(access_id: string) {
return webapi.Patch<models.Access>(`/access/${access_id}`, {})
}
export function Delete(access_id: string) {
return webapi.Delete<models.Access>(`/access/${access_id}`, {})
}

@ -40,25 +40,25 @@ export function Post(json: PostOpts) {
export interface ListOpts { export interface ListOpts {
name?: string name?: string
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.App[]>(`/app`, { json }) return webapi.Get<models.App[]>(`/app`, { query })
} }
export interface AppUserGetOpts { export interface AppUserGetOpts {
user_id: string user_id: string
} }
export function AppUserGet(app_user_id: string, app_id: string, json: AppUserGetOpts) { export function AppUserGet(app_id: string, app_user_id: string, query: AppUserGetQuery) {
return webapi.Get<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json }) return webapi.Get<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { query })
} }
export interface AppUserPatchOpts { export interface AppUserPatchOpts {
status?: string status?: string
} }
export function AppUserPatch(app_user_id: string, app_id: string, json: AppUserPatchOpts) { export function AppUserPatch(app_id: string, app_user_id: string, json: AppUserPatchOpts) {
return webapi.Patch<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json }) return webapi.Patch<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json })
} }
export function AppUserDelete(app_user_id: string, app_id: string) { export function AppUserDelete(app_id: string, app_user_id: string) {
return webapi.Delete<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, {}) return webapi.Delete<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, {})
} }
@ -66,8 +66,8 @@ export interface AppUserListOpts {
user_id?: string user_id?: string
status?: string status?: string
} }
export function AppUserList(app_id: string, json: AppUserListOpts) { export function AppUserList(app_id: string, query: AppUserListQuery) {
return webapi.Get<models.AppUser[]>(`/app/${app_id}/app_user`, { json }) return webapi.Get<models.AppUser[]>(`/app/${app_id}/app_user`, { query })
} }
export interface AppUserPostOpts { export interface AppUserPostOpts {
@ -78,12 +78,8 @@ export function AppUserPost(app_id: string, json: AppUserPostOpts) {
return webapi.Post<models.AppUser>(`/app/${app_id}/app_user`, { json }) return webapi.Post<models.AppUser>(`/app/${app_id}/app_user`, { json })
} }
export interface ResourceListQuery { export function ResourceList(app_id: string) {
created_at?: Date return webapi.Get<models.Resource[]>(`/app/${app_id}/resource`, {})
updated_at?: Date
}
export function ResourceList(app_id: string, query: ResourceListQuery) {
return webapi.Get<models.Resource[]>(`/app/${app_id}/resource`, { query })
} }
export interface ResourcePostOpts { export interface ResourcePostOpts {
@ -97,15 +93,28 @@ export function ResourcePost(app_id: string, json: ResourcePostOpts) {
export interface ResourceDeleteOpts { export interface ResourceDeleteOpts {
name: string name: string
} }
export function ResourceDelete(app_id: string, json: ResourceDeleteOpts) { export function ResourceGet(app_id: string, resource_id: string) {
return webapi.Delete<models.Resource>(`/app/${app_id}/resource`, { json }) return webapi.Get<models.Resource>(`/app/${app_id}/resource/${resource_id}`, {})
} }
export function ResourceGet(app_id: string) { export interface ResourcePatchOpts {
return webapi.Get<models.Resource>(`/app/${app_id}/resource`, {}) des?: string
}
export function ResourcePatch(app_id: string, resource_id: string, json: ResourcePatchOpts) {
return webapi.Patch<models.Resource>(`/app/${app_id}/resource/${resource_id}`, { json })
} }
export function ResourcePatch(app_id: string) { export function ResourceDelete(app_id: string, resource_id: string) {
return webapi.Patch<models.Resource>(`/app/${app_id}/resource`, {}) return webapi.Delete<models.Resource>(`/app/${app_id}/resource/${resource_id}`, {})
} }
export interface ListQuery {
name?: string
}
export interface AppUserGetQuery {
user_id: string
}
export interface AppUserListQuery {
user_id?: string
status?: string
}

@ -1,12 +1,14 @@
export interface Access { export interface Access {
created_at: Date created_at: Date
updated_at: Date updated_at: Date
app_id: string id: string
user_id?: string user_id?: string
role_id?: string role_id?: string
name: string name: string
tid: string tid: string
level: number level: number
resource_id?: string
app_id: string
} }
export interface App { export interface App {
id: string id: string
@ -39,9 +41,10 @@ export interface AppUser {
export interface Resource { export interface Resource {
created_at: Date created_at: Date
updated_at: Date updated_at: Date
app_id: string id: string
name: string name: string
des: string des: string
app_id: string
} }
export interface Role { export interface Role {
id: string id: string

@ -6,6 +6,7 @@
import webapi from "./webapi" import webapi from "./webapi"
import * as models from "./models" import * as models from "./models"
export function Get(role_id: string) { export function Get(role_id: string) {
return webapi.Get<models.Role>(`/role/${role_id}`, {}) return webapi.Get<models.Role>(`/role/${role_id}`, {})
} }
@ -32,10 +33,10 @@ export function Post(json: PostOpts) {
return webapi.Post<models.Role>(`/role`, { json }) return webapi.Post<models.Role>(`/role`, { json })
} }
export interface ListOpts { export interface ListQuery {
name?: string name?: string
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.Role[]>(`/role`, { json }) return webapi.Get<models.Role[]>(`/role`, { query })
} }

@ -12,11 +12,11 @@ export interface TokenSaltOpts {
} }
// keep // keep
export function TokenSalt(json: TokenSaltOpts) { export function TokenSalt(json: TokenSaltOpts) {
return webapi.Post<{ id: string, salt: string }>(`/token/salt`, { json }) return webapi.Get<{ id: string, salt: string }>(`/token/TokenSalt`, { json })
} }
export interface PostOpts { export interface PostOpts {
refresh?: string refresh?: string
typ?: 'app' | 'ufs' typ?: string
user_id?: string user_id?: string
salt?: string salt?: string
code?: string code?: string
@ -46,12 +46,11 @@ export function Delete(token_id: string) {
return webapi.Delete<models.Token>(`/token/${token_id}`, {}) return webapi.Delete<models.Token>(`/token/${token_id}`, {})
} }
export interface ListOpts { export interface ListQuery {
user_id: string user_id: string
app_id: string app_id: string
limit: number
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.Token[]>(`/token`, { json }) return webapi.Get<models.Token[]>(`/token`, { query })
} }

@ -39,25 +39,25 @@ export function Post(json: PostOpts) {
return webapi.Post<models.User>(`/user`, { json }) return webapi.Post<models.User>(`/user`, { json })
} }
export interface ListOpts { export interface ListQuery {
username?: string username?: string
nickname?: string nickname?: string
email?: string email?: string
phone?: string phone?: string
status?: number status?: number
} }
export function List(json: ListOpts) { export function List(query: ListQuery) {
return webapi.Get<models.User[]>(`/user`, { json }) return webapi.Get<models.User[]>(`/user`, { query })
} }
export function UserRoleGet(user_role_id: string, user_id: string) { export function UserRoleGet(user_id: string, user_role_id: string) {
return webapi.Get<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, {}) return webapi.Get<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, {})
} }
export interface UserRolePatchOpts { export interface UserRolePatchOpts {
status?: string status?: string
} }
export function UserRolePatch(user_role_id: string, user_id: string, json: UserRolePatchOpts) { export function UserRolePatch(user_id: string, user_role_id: string, json: UserRolePatchOpts) {
return webapi.Patch<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json }) return webapi.Patch<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json })
} }
@ -65,7 +65,7 @@ export interface UserRoleDeleteOpts {
role_id: string role_id: string
app_id: string app_id: string
} }
export function UserRoleDelete(user_role_id: string, user_id: string, json: UserRoleDeleteOpts) { export function UserRoleDelete(user_id: string, user_role_id: string, json: UserRoleDeleteOpts) {
return webapi.Delete<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json }) return webapi.Delete<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json })
} }
@ -78,10 +78,10 @@ export function UserRolePost(user_id: string, json: UserRolePostOpts) {
return webapi.Post<models.UserRole>(`/user/${user_id}/user_role`, { json }) return webapi.Post<models.UserRole>(`/user/${user_id}/user_role`, { json })
} }
export interface UserRoleListOpts { export interface UserRoleListQuery {
status?: string status?: string
} }
export function UserRoleList(user_id: string, json: UserRoleListOpts) { export function UserRoleList(user_id: string, query: UserRoleListQuery) {
return webapi.Get<models.UserRole[]>(`/user/${user_id}/user_role`, { json }) return webapi.Get<models.UserRole[]>(`/user/${user_id}/user_role`, { query })
} }

Loading…
Cancel
Save