mirror of https://github.com/veypi/OneAuth.git
feat: update api interface
parent
3e744e4d9f
commit
dcce188e7a
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2024-10-11 00:18:06
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
import webapi from "./webapi"
|
||||
import * as models from "./models"
|
||||
export interface ListOpts {
|
||||
app_id: String
|
||||
user_id?: String
|
||||
role_id?: String
|
||||
name?: String
|
||||
}
|
||||
export interface ListQuery {
|
||||
created_at?: Date
|
||||
updated_at?: Date
|
||||
}
|
||||
export function List(json: ListOpts, query: ListQuery) {
|
||||
return webapi.Get<models.Access>(`/access`, { json, query })
|
||||
}
|
||||
|
||||
export interface PostOpts {
|
||||
app_id: String
|
||||
user_id?: String
|
||||
role_id?: String
|
||||
name: String
|
||||
t_id: String
|
||||
level: Number
|
||||
}
|
||||
export function Post(json: PostOpts) {
|
||||
return webapi.Post<models.Access>(`/access`, { json })
|
||||
}
|
||||
|
@ -1,12 +1,112 @@
|
||||
import webapi from "./gocliRequest"
|
||||
import * as components from "./mainComponents"
|
||||
export * from "./mainComponents"
|
||||
|
||||
/**
|
||||
* @description
|
||||
* @param params
|
||||
* @param req
|
||||
*/
|
||||
export function login(pa: string, req: components.AppReq, params: components.AppReqParams) {
|
||||
return webapi.get<components.AppResp>(`/api/app/login/${pa}`, {"params":params, "req":req})
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2024-10-11 00:18:06
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
import webapi from "./webapi"
|
||||
import * as models from "./models"
|
||||
export interface GetOpts {
|
||||
name: String
|
||||
}
|
||||
export function Get(app_id: String, json: GetOpts) {
|
||||
return webapi.Get<models.App>(`/app/${app_id}`, { json })
|
||||
}
|
||||
|
||||
export function AppUserDelete(app_user_id: String, app_id: String) {
|
||||
return webapi.Delete<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { })
|
||||
}
|
||||
|
||||
export function ResourcePatch(app_id: String) {
|
||||
return webapi.Patch<models.Resource>(`/app/${app_id}/resource`, { })
|
||||
}
|
||||
|
||||
export interface PatchOpts {
|
||||
name?: String
|
||||
icon?: String
|
||||
des?: String
|
||||
participate?: String
|
||||
init_role_id?: String
|
||||
}
|
||||
export function Patch(app_id: String, json: PatchOpts) {
|
||||
return webapi.Patch<models.App>(`/app/${app_id}`, { json })
|
||||
}
|
||||
|
||||
export interface PostOpts {
|
||||
name: String
|
||||
icon: String
|
||||
des: String
|
||||
participate: String
|
||||
}
|
||||
export function Post(json: PostOpts) {
|
||||
return webapi.Post<models.App>(`/app`, { json })
|
||||
}
|
||||
|
||||
export interface AppUserListOpts {
|
||||
user_id?: String
|
||||
status?: String
|
||||
}
|
||||
export function AppUserList(app_id: String, json: AppUserListOpts) {
|
||||
return webapi.Get<models.AppUser>(`/app/${app_id}/app_user`, { json })
|
||||
}
|
||||
|
||||
export interface ResourceListQuery {
|
||||
created_at?: Date
|
||||
updated_at?: Date
|
||||
}
|
||||
export function ResourceList(app_id: String, query: ResourceListQuery) {
|
||||
return webapi.Get<models.Resource>(`/app/${app_id}/resource`, { query })
|
||||
}
|
||||
|
||||
export interface ResourcePostOpts {
|
||||
name: String
|
||||
des: String
|
||||
}
|
||||
export function ResourcePost(app_id: String, json: ResourcePostOpts) {
|
||||
return webapi.Post<models.Resource>(`/app/${app_id}/resource`, { json })
|
||||
}
|
||||
|
||||
export function Delete(app_id: String) {
|
||||
return webapi.Delete<models.App>(`/app/${app_id}`, { })
|
||||
}
|
||||
|
||||
export interface ListOpts {
|
||||
name?: String
|
||||
}
|
||||
export function List(json: ListOpts) {
|
||||
return webapi.Get<models.App>(`/app`, { json })
|
||||
}
|
||||
|
||||
export interface AppUserGetOpts {
|
||||
user_id: String
|
||||
}
|
||||
export function AppUserGet(app_user_id: String, app_id: String, json: AppUserGetOpts) {
|
||||
return webapi.Get<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json })
|
||||
}
|
||||
|
||||
export function ResourceGet(app_id: String) {
|
||||
return webapi.Get<models.Resource>(`/app/${app_id}/resource`, { })
|
||||
}
|
||||
|
||||
export interface AppUserPatchOpts {
|
||||
status?: String
|
||||
}
|
||||
export function AppUserPatch(app_user_id: String, app_id: String, json: AppUserPatchOpts) {
|
||||
return webapi.Patch<models.AppUser>(`/app/${app_id}/app_user/${app_user_id}`, { json })
|
||||
}
|
||||
|
||||
export interface AppUserPostOpts {
|
||||
status: String
|
||||
user_id: String
|
||||
}
|
||||
export function AppUserPost(app_id: String, json: AppUserPostOpts) {
|
||||
return webapi.Post<models.AppUser>(`/app/${app_id}/app_user`, { json })
|
||||
}
|
||||
|
||||
export interface ResourceDeleteOpts {
|
||||
name: String
|
||||
}
|
||||
export function ResourceDelete(app_id: String, json: ResourceDeleteOpts) {
|
||||
return webapi.Delete<models.Resource>(`/app/${app_id}/resource`, { json })
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
/*
|
||||
* index.ts
|
||||
* Copyright (C) 2024 veypi <i@veypi.com>
|
||||
* 2024-08-02 17:40
|
||||
* Distributed under terms of the MIT license.
|
||||
*/
|
||||
|
||||
import * as user from './user'
|
||||
import * as app from './app'
|
||||
import * as user from "./user"
|
||||
import * as token from "./token"
|
||||
import * as role from "./role"
|
||||
import * as app from "./app"
|
||||
import * as access from "./access"
|
||||
|
||||
export default {
|
||||
user,
|
||||
app
|
||||
token,
|
||||
role,
|
||||
app,
|
||||
access
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
export interface Access {
|
||||
app_id: String
|
||||
app?: App
|
||||
user_id?: String
|
||||
user?: User
|
||||
role_id?: String
|
||||
role?: Role
|
||||
name: String
|
||||
t_id: String
|
||||
level: Number
|
||||
}
|
||||
export interface App {
|
||||
name: String
|
||||
icon: String
|
||||
des: String
|
||||
participate: String
|
||||
init_role_id?: String
|
||||
init_role?: Role
|
||||
init_url: String
|
||||
user_count: Number
|
||||
key: String
|
||||
}
|
||||
export interface AppUser {
|
||||
app_id: String
|
||||
app?: App
|
||||
user_id: String
|
||||
user?: User
|
||||
status: String
|
||||
}
|
||||
export interface Resource {
|
||||
app_id: String
|
||||
app?: App
|
||||
name: String
|
||||
des: String
|
||||
}
|
||||
export interface Role {
|
||||
name: String
|
||||
des: String
|
||||
app_id: String
|
||||
app?: App
|
||||
user_count: Number
|
||||
access: any
|
||||
}
|
||||
export interface Testb {
|
||||
test_id: String
|
||||
test?: Test
|
||||
name: String
|
||||
}
|
||||
export interface Test {
|
||||
name: String
|
||||
}
|
||||
export interface Token {
|
||||
user_id: String
|
||||
user?: User
|
||||
app_id: String
|
||||
app?: App
|
||||
expired_at: Date
|
||||
over_perm: String
|
||||
device: String
|
||||
}
|
||||
export interface User {
|
||||
username: String
|
||||
nickname: String
|
||||
icon: String
|
||||
email: String
|
||||
phone: String
|
||||
status: Number
|
||||
salt: String
|
||||
code: String
|
||||
}
|
||||
export interface UserRole {
|
||||
user_id: String
|
||||
user?: User
|
||||
role_id: String
|
||||
role?: Role
|
||||
app_id: String
|
||||
app?: App
|
||||
status: String
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2024-10-11 00:18:06
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
import webapi from "./webapi"
|
||||
import * as models from "./models"
|
||||
export interface ListOpts {
|
||||
name?: String
|
||||
}
|
||||
export function List(json: ListOpts) {
|
||||
return webapi.Get<models.Role>(`/role`, { json })
|
||||
}
|
||||
|
||||
export function Get(role_id: String) {
|
||||
return webapi.Get<models.Role>(`/role/${role_id}`, { })
|
||||
}
|
||||
|
||||
export interface PatchOpts {
|
||||
name?: String
|
||||
des?: String
|
||||
app_id?: String
|
||||
}
|
||||
export function Patch(role_id: String, json: PatchOpts) {
|
||||
return webapi.Patch<models.Role>(`/role/${role_id}`, { json })
|
||||
}
|
||||
|
||||
export function Delete(role_id: String) {
|
||||
return webapi.Delete<models.Role>(`/role/${role_id}`, { })
|
||||
}
|
||||
|
||||
export interface PostOpts {
|
||||
name: String
|
||||
des: String
|
||||
app_id: String
|
||||
}
|
||||
export function Post(json: PostOpts) {
|
||||
return webapi.Post<models.Role>(`/role`, { json })
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2024-10-11 00:18:06
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
import webapi from "./webapi"
|
||||
import * as models from "./models"
|
||||
export function Delete(token_id: String) {
|
||||
return webapi.Delete<models.Token>(`/token/${token_id}`, {})
|
||||
}
|
||||
|
||||
export interface ListOpts {
|
||||
user_id: String
|
||||
app_id: String
|
||||
}
|
||||
export function List(json: ListOpts) {
|
||||
return webapi.Get<models.Token>(`/token`, { json })
|
||||
}
|
||||
|
||||
export interface TokenSaltOpts {
|
||||
username: String
|
||||
typ?: String
|
||||
}
|
||||
|
||||
// keep
|
||||
export function TokenSalt(json: TokenSaltOpts) {
|
||||
return webapi.Post<String>(`/token/salt`, { json })
|
||||
}
|
||||
|
||||
export interface PostOpts {
|
||||
user_id: String
|
||||
token?: String
|
||||
salt?: String
|
||||
code?: String
|
||||
app_id?: String
|
||||
expired_at?: Date
|
||||
over_perm?: String
|
||||
device?: String
|
||||
}
|
||||
export function Post(json: PostOpts) {
|
||||
return webapi.Post<models.Token>(`/token`, { json })
|
||||
}
|
||||
|
||||
export function Get(token_id: String) {
|
||||
return webapi.Get<models.Token>(`/token/${token_id}`, {})
|
||||
}
|
||||
|
||||
export interface PatchOpts {
|
||||
expired_at?: Date
|
||||
over_perm?: String
|
||||
}
|
||||
export function Patch(token_id: String, json: PatchOpts) {
|
||||
return webapi.Patch<models.Token>(`/token/${token_id}`, { json })
|
||||
}
|
||||
|
@ -1,33 +1,92 @@
|
||||
import webapi from "./gocliRequest"
|
||||
import * as components from "./mainComponents"
|
||||
export * from "./mainComponents"
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2024-10-11 00:18:06
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
/**
|
||||
* @description
|
||||
* @param req
|
||||
*/
|
||||
export function reg(req: components.RegReq) {
|
||||
return webapi.post<null>(`/api/user`, {"req":req})
|
||||
import webapi from "./webapi"
|
||||
import * as models from "./models"
|
||||
export interface PostOpts {
|
||||
username: String
|
||||
nickname?: String
|
||||
icon?: String
|
||||
email?: String
|
||||
phone?: String
|
||||
salt: String
|
||||
code: String
|
||||
}
|
||||
export function Post(json: PostOpts) {
|
||||
return webapi.Post<models.User>(`/user`, { json })
|
||||
}
|
||||
|
||||
export function UserRoleGet(user_role_id: String, user_id: String) {
|
||||
return webapi.Get<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, {})
|
||||
}
|
||||
|
||||
export interface UserRolePatchOpts {
|
||||
status?: String
|
||||
}
|
||||
export function UserRolePatch(user_role_id: String, user_id: String, json: UserRolePatchOpts) {
|
||||
return webapi.Patch<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json })
|
||||
}
|
||||
|
||||
export interface UserRoleDeleteOpts {
|
||||
role_id: String
|
||||
app_id: String
|
||||
}
|
||||
export function UserRoleDelete(user_role_id: String, user_id: String, json: UserRoleDeleteOpts) {
|
||||
return webapi.Delete<models.UserRole>(`/user/${user_id}/user_role/${user_role_id}`, { json })
|
||||
}
|
||||
|
||||
export interface UserRolePostOpts {
|
||||
status: String
|
||||
role_id: String
|
||||
app_id: String
|
||||
}
|
||||
export function UserRolePost(user_id: String, json: UserRolePostOpts) {
|
||||
return webapi.Post<models.UserRole>(`/user/${user_id}/user_role`, { json })
|
||||
}
|
||||
|
||||
export interface UserLoginOpts {
|
||||
pwd: String
|
||||
typ: String
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
* @param params
|
||||
*/
|
||||
export function login(id: string, params: components.LoginReqParams) {
|
||||
return webapi.head<null>(`/api/user/${id}`, {"params":params})
|
||||
export function Get(user_id: String) {
|
||||
return webapi.Get<models.User>(`/user/${user_id}`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
*/
|
||||
export function list() {
|
||||
return webapi.get<Array<components.UserResp>>(`/api/user`, {})
|
||||
export function Delete(user_id: String) {
|
||||
return webapi.Delete<models.User>(`/user/${user_id}`, {})
|
||||
}
|
||||
|
||||
export interface UserRoleListOpts {
|
||||
status?: String
|
||||
}
|
||||
export function UserRoleList(user_id: String, json: UserRoleListOpts) {
|
||||
return webapi.Get<models.UserRole>(`/user/${user_id}/user_role`, { json })
|
||||
}
|
||||
|
||||
/**
|
||||
* @description
|
||||
*/
|
||||
export function get(id: number) {
|
||||
return webapi.get<components.UserResp>(`/api/user/${id}`, {})
|
||||
export interface PatchOpts {
|
||||
username?: String
|
||||
nickname?: String
|
||||
icon?: String
|
||||
email?: String
|
||||
phone?: String
|
||||
status?: Number
|
||||
}
|
||||
export function Patch(user_id: String, json: PatchOpts) {
|
||||
return webapi.Patch<models.User>(`/user/${user_id}`, { json })
|
||||
}
|
||||
|
||||
export interface ListOpts {
|
||||
username?: String
|
||||
nickname?: String
|
||||
email?: String
|
||||
phone?: String
|
||||
status?: Number
|
||||
}
|
||||
export function List(json: ListOpts) {
|
||||
return webapi.Get<models.User>(`/user`, { json })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue