mirror of https://github.com/veypi/OneAuth.git
v2.0
parent
2563324bb5
commit
f841f2599f
@ -0,0 +1,3 @@
|
||||
<!DOCTYPE html><html><head><title>OA</title><meta charset=utf-8><meta name=description content=oneauth><meta name=format-detection content="telephone=no"><meta name=msapplication-tap-highlight content=no><meta name=viewport content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width"><link rel=icon type=image/ico href="/favicon.ico"> <script type="module" crossorigin src="/assets/index.c16e83bc.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.30f45a7e.css">
|
||||
</head><body><div id=v-msg></div><div id=q-app></div></body></html>
|
@ -1,69 +0,0 @@
|
||||
//
|
||||
// userapp.rs
|
||||
// Copyright (C) 2023 veypi <i@veypi.com>
|
||||
// 2023-10-09 03:12
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
use actix_web::{get, post, web, Responder};
|
||||
use proc::access_read;
|
||||
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter, TransactionTrait};
|
||||
|
||||
use crate::{
|
||||
libs,
|
||||
models::{app, app_user},
|
||||
AppState, Error, Result,
|
||||
};
|
||||
|
||||
// 获取 app
|
||||
#[get("/user/{uid}/user/{aid}")]
|
||||
#[access_read("app")]
|
||||
pub async fn get(
|
||||
params: web::Path<(String, String)>,
|
||||
stat: web::Data<AppState>,
|
||||
) -> Result<impl Responder> {
|
||||
let (mut aid, mut uid) = params.into_inner();
|
||||
let mut q = app_user::Entity::find();
|
||||
if uid == "-" {
|
||||
uid = "".to_string();
|
||||
} else {
|
||||
q = q.filter(app_user::Column::UserId.eq(uid.clone()));
|
||||
}
|
||||
if aid == "-" {
|
||||
aid = "".to_string();
|
||||
} else {
|
||||
q = q.filter(app_user::Column::AppId.eq(aid.clone()));
|
||||
}
|
||||
if uid.is_empty() && aid.is_empty() {
|
||||
Err(Error::Missing("uid or aid".to_string()))
|
||||
} else {
|
||||
let s: Vec<(app_user::Model, Option<app::Model>)> =
|
||||
q.find_also_related(app::Entity).all(stat.db()).await?;
|
||||
let res: Vec<app::Model> = s
|
||||
.into_iter()
|
||||
.filter_map(|(l, a)| match a {
|
||||
Some(a) => Some(app::Model {
|
||||
status: l.status,
|
||||
..a
|
||||
}),
|
||||
None => None,
|
||||
})
|
||||
.collect();
|
||||
// let s: Vec<app_user::Model> = q.all(stat.db()).await?;
|
||||
Ok(web::Json(res))
|
||||
}
|
||||
}
|
||||
|
||||
// 关联app
|
||||
#[post("/user/{uid}/app/{aid}")]
|
||||
#[access_read("app")]
|
||||
pub async fn add(
|
||||
params: web::Path<(String, String)>,
|
||||
stat: web::Data<AppState>,
|
||||
) -> Result<impl Responder> {
|
||||
let (aid, uid) = params.into_inner();
|
||||
let db = stat.db().begin().await?;
|
||||
let res = libs::user::connect_to_app(uid, aid, &db, None).await?;
|
||||
db.commit().await?;
|
||||
Ok(web::Json(res))
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* access.ts
|
||||
* Copyright (C) 2023 veypi <i@veypi.com>
|
||||
* 2023-10-12 19:32
|
||||
* Distributed under terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
import ajax from './axios'
|
||||
|
||||
export default (app_id: string) => {
|
||||
return {
|
||||
local: `./app/${app_id}/access/`,
|
||||
create(name: string, props?: { name?: string, level?: number, role_id?: string, user_id?: string, rid?: string }) {
|
||||
return ajax.post(this.local, Object.assign({ name, level: 0 }, props))
|
||||
},
|
||||
get(id: string) {
|
||||
return ajax.get(this.local + id)
|
||||
},
|
||||
list(props?: { name?: string, role_id?: string, user_id?: string }) {
|
||||
return ajax.get(this.local, props)
|
||||
},
|
||||
update(uuid: string, props: any) {
|
||||
return ajax.patch(this.local + uuid, props)
|
||||
},
|
||||
del(id: string) {
|
||||
return ajax.delete(this.local + id)
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* resource.ts
|
||||
* Copyright (C) 2023 veypi <i@veypi.com>
|
||||
* 2023-10-12 18:03
|
||||
* Distributed under terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
import ajax from './axios'
|
||||
|
||||
export default (app_id: string) => {
|
||||
return {
|
||||
local: `./app/${app_id}/resource/`,
|
||||
create(name: string, props?: { des?: string }) {
|
||||
return ajax.post(this.local, Object.assign({ name }, props))
|
||||
},
|
||||
get(id: string) {
|
||||
return ajax.get(this.local + id)
|
||||
},
|
||||
list() {
|
||||
return ajax.get(this.local)
|
||||
},
|
||||
update(uuid: string, props: any) {
|
||||
return ajax.patch(this.local + uuid, props)
|
||||
},
|
||||
del(id: string) {
|
||||
return ajax.delete(this.local + id)
|
||||
},
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* role.ts
|
||||
* Copyright (C) 2023 veypi <i@veypi.com>
|
||||
* 2023-10-12 15:40
|
||||
* Distributed under terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
import ajax from './axios'
|
||||
|
||||
export default (app_id: string) => {
|
||||
return {
|
||||
local: `./app/${app_id}/role/`,
|
||||
create(name: string, props?: { des?: string }) {
|
||||
return ajax.post(this.local, Object.assign({ name }, props))
|
||||
},
|
||||
get(id: string) {
|
||||
return ajax.get(this.local + id)
|
||||
},
|
||||
list() {
|
||||
return ajax.get(this.local)
|
||||
},
|
||||
update(uuid: string, props: any) {
|
||||
return ajax.patch(this.local + uuid, props)
|
||||
},
|
||||
del(id: string) {
|
||||
return ajax.delete(this.local + id)
|
||||
},
|
||||
add(id: string, uid: string) {
|
||||
return ajax.get(this.local + `${id}/user/${uid}`)
|
||||
},
|
||||
drop(id: string, uid: string) {
|
||||
return ajax.delete(this.local + `${id}/user/${uid}`)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue