mirror of
https://github.com/Teamlinker/Teamlinker.git
synced 2025-06-03 03:00:17 +00:00
fix
This commit is contained in:
parent
490cd96425
commit
cd17ff8676
@ -1,5 +1,5 @@
|
||||
export interface ICommon_Model_Admin {
|
||||
id:bigint,
|
||||
id:string,
|
||||
name:string,
|
||||
password:string,
|
||||
description:string,
|
||||
|
@ -1,8 +1,8 @@
|
||||
export interface ICommon_Model_Comment {
|
||||
id:bigint,
|
||||
id:string,
|
||||
type:number,
|
||||
type_id:bigint,
|
||||
user_id:bigint,
|
||||
type_id:string,
|
||||
user_id:string,
|
||||
content:string,
|
||||
created_time:Date,
|
||||
modified_time:Date
|
||||
|
@ -1,12 +1,12 @@
|
||||
export interface ICommon_Model_Field {
|
||||
id:bigint,
|
||||
type_id:bigint,
|
||||
id:string,
|
||||
type_id:string,
|
||||
system:number,
|
||||
description:string,
|
||||
created_time:Date,
|
||||
modified_time:Date,
|
||||
created_by:bigint,
|
||||
modified_by:bigint,
|
||||
created_by:string,
|
||||
modified_by:string,
|
||||
name:string
|
||||
}
|
||||
export const Table_Field="field"
|
@ -1,10 +1,10 @@
|
||||
export interface ICommon_Model_Field_Component {
|
||||
id:bigint,
|
||||
id:string,
|
||||
description:string,
|
||||
created_time:Date,
|
||||
modified_time:Date,
|
||||
created_by:bigint,
|
||||
modified_by:bigint,
|
||||
created_by:string,
|
||||
modified_by:string,
|
||||
name:string
|
||||
}
|
||||
export const Table_Field_Component="field_component"
|
@ -1,12 +1,12 @@
|
||||
export interface ICommon_Model_Field_Component_Field {
|
||||
id:bigint,
|
||||
type_id:bigint,
|
||||
id:string,
|
||||
type_id:string,
|
||||
system:number,
|
||||
description:string,
|
||||
created_time:Date,
|
||||
modified_time:Date,
|
||||
created_by:bigint,
|
||||
modified_by:bigint,
|
||||
created_by:string,
|
||||
modified_by:string,
|
||||
name:string
|
||||
}
|
||||
export const Table_Field_Component_Field="field_component_field"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Field_Config_Value {
|
||||
id: bigint,
|
||||
field_id :bigint,
|
||||
id: string,
|
||||
field_id :string,
|
||||
value :string,
|
||||
sort :number,
|
||||
label :string,
|
||||
|
@ -1,9 +1,9 @@
|
||||
export interface ICommon_Model_Field_Solution {
|
||||
id :bigint,
|
||||
id :string,
|
||||
created_time :Date,
|
||||
modified_time :Date ,
|
||||
created_by :bigint,
|
||||
modified_by: bigint,
|
||||
created_by :string,
|
||||
modified_by: string,
|
||||
name :string,
|
||||
description :string,
|
||||
system :number,
|
||||
|
@ -1,7 +1,7 @@
|
||||
export interface ICommon_Model_Field_Solution_Config_Or_Field {
|
||||
id :bigint,
|
||||
id :string,
|
||||
type :number,
|
||||
field_solution_id :bigint,
|
||||
component_or_field_id :bigint,
|
||||
field_solution_id :string,
|
||||
component_or_field_id :string,
|
||||
}
|
||||
export const Table_Field_Solution_Config_Or_Field="field_solution_config_or_field"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Field_Solution_Workflow {
|
||||
id: bigint,
|
||||
field_solution_id :bigint,
|
||||
workflow_id :bigint,
|
||||
id: string,
|
||||
field_solution_id :string,
|
||||
workflow_id :string,
|
||||
}
|
||||
export const Table_Field_Solution_Workflow="field_solution_workflow"
|
@ -1,8 +1,8 @@
|
||||
export interface ICommon_Model_Field_Solution_Workflow_Action {
|
||||
id :bigint,
|
||||
field_solution :bigint ,
|
||||
workflow_action_id :bigint ,
|
||||
field :bigint,
|
||||
id :string,
|
||||
field_solution :string ,
|
||||
workflow_action_id :string ,
|
||||
field :string,
|
||||
optional :number,
|
||||
default_value :string,
|
||||
multi :number,
|
||||
|
@ -1,7 +1,7 @@
|
||||
export interface ICommon_Model_Field_Type {
|
||||
id :bigint,
|
||||
id :string,
|
||||
name :string,
|
||||
icon :bigint,
|
||||
icon :string,
|
||||
description :string,
|
||||
multi :number,
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
export interface ICommon_Model_File {
|
||||
id :bigint,
|
||||
user_id :bigint,
|
||||
project_id :bigint ,
|
||||
size: bigint ,
|
||||
id :string,
|
||||
user_id :string,
|
||||
project_id :string ,
|
||||
size: string ,
|
||||
filename :string,
|
||||
type :string,
|
||||
created_time :Date,
|
||||
|
@ -1,8 +1,8 @@
|
||||
export interface ICommon_Model_Group {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
name :string,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
created_by :bigint ,
|
||||
created_by :string ,
|
||||
}
|
||||
export const Table_Group="group"
|
@ -1,7 +1,7 @@
|
||||
export interface ICommon_Model_Issue_Type {
|
||||
id:bigint,
|
||||
id:string,
|
||||
name:string,
|
||||
icon:bigint,
|
||||
icon:string,
|
||||
description:string,
|
||||
multi:number
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
export interface ICommon_Model_Issue_Type_Solution {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
name :string,
|
||||
description :string,
|
||||
system :number,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
created_by :bigint ,
|
||||
modified_by :bigint ,
|
||||
created_by :string ,
|
||||
modified_by :string ,
|
||||
}
|
||||
export const Table_Issue_Type_Solution="issue_type_solution"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Issue_Type {
|
||||
id :bigint ,
|
||||
issue_type_id :bigint,
|
||||
issue_type_solution_id :bigint,
|
||||
id :string ,
|
||||
issue_type_id :string,
|
||||
issue_type_solution_id :string,
|
||||
}
|
||||
export const Table_Issue_Type="issue_type"
|
@ -1,9 +1,9 @@
|
||||
export interface ICommon_Model_Permission {
|
||||
id: bigint,
|
||||
id: string,
|
||||
name :string,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
type :number,
|
||||
type :string,
|
||||
value :number,
|
||||
}
|
||||
export const Table_Permission="permission"
|
@ -1,9 +1,9 @@
|
||||
export interface ICommon_Model_Permission_Target {
|
||||
id :bigint,
|
||||
permission_id: bigint,
|
||||
target_id :bigint,
|
||||
id :string,
|
||||
permission_id: string,
|
||||
target_id :string,
|
||||
target_type :number,
|
||||
item_id :bigint,
|
||||
item_id :string,
|
||||
item_type :number,
|
||||
}
|
||||
export const Table_Permission_Target="permission_target"
|
@ -1,11 +1,11 @@
|
||||
export interface ICommon_Model_Project {
|
||||
id :bigint,
|
||||
id :string,
|
||||
key :string,
|
||||
name :string,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
image :bigint,
|
||||
created_by :bigint ,
|
||||
image :string,
|
||||
created_by :string ,
|
||||
description :string,
|
||||
}
|
||||
export const Table_Project="project"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Field_Solution {
|
||||
id: bigint,
|
||||
project_id :bigint ,
|
||||
field_solution_id :bigint ,
|
||||
id: string,
|
||||
project_id :string ,
|
||||
field_solution_id :string ,
|
||||
}
|
||||
export const Table_Project_Field_Solution="project_field_solution"
|
@ -1,15 +1,15 @@
|
||||
export interface ICommon_Model_Project_Issue {
|
||||
unique_id :number,
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
created_by :bigint ,
|
||||
modified_by :bigint ,
|
||||
project_id :bigint ,
|
||||
issue_type_id :bigint ,
|
||||
created_by :string ,
|
||||
modified_by :string ,
|
||||
project_id :string ,
|
||||
issue_type_id :string ,
|
||||
name :string,
|
||||
priority :number,
|
||||
assigner_id :bigint ,
|
||||
reporter_id :bigint ,
|
||||
assigner_id :string ,
|
||||
reporter_id :string ,
|
||||
}
|
||||
export const Table_Project_Issue="project_issue"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Issue_Description {
|
||||
id :bigint,
|
||||
project_issue_id :bigint,
|
||||
id :string,
|
||||
project_issue_id :string,
|
||||
content:string
|
||||
}
|
||||
export const Table_Project_Issue_Description="project_issue_description"
|
@ -1,7 +1,7 @@
|
||||
export interface ICommon_Model_Project_Issue_Field_Value {
|
||||
id :bigint,
|
||||
project_issue_id :bigint,
|
||||
field_id :bigint,
|
||||
id :string,
|
||||
project_issue_id :string,
|
||||
field_id :string,
|
||||
value :string,
|
||||
sort :number,
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Issue_Parent {
|
||||
id :bigint,
|
||||
parent_id :bigint,
|
||||
child_id:bigint
|
||||
id :string,
|
||||
parent_id :string,
|
||||
child_id:string
|
||||
}
|
||||
export const Table_Project_Issue_Parent="project_issue_parent"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Issue_Related {
|
||||
id :bigint,
|
||||
project_issue_1_id :bigint,
|
||||
project_issue_2_id:bigint
|
||||
id :string,
|
||||
project_issue_1_id :string,
|
||||
project_issue_2_id:string
|
||||
}
|
||||
export const Table_Project_Issue_Related="project_issue_related"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Issue_Solution {
|
||||
id :bigint,
|
||||
project_id :bigint,
|
||||
issue_solution_id:bigint
|
||||
id :string,
|
||||
project_id :string,
|
||||
issue_solution_id:string
|
||||
}
|
||||
export const Table_Project_Issue_Solution="project_issue_solution"
|
@ -1,5 +1,5 @@
|
||||
export interface ICommon_Model_Project_Lable {
|
||||
id :bigint,
|
||||
id :string,
|
||||
name:string
|
||||
}
|
||||
export const Table_Project_Label="project_label"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Lable_Issue {
|
||||
id :bigint,
|
||||
project_label_id:bigint,
|
||||
project_issue_id:bigint
|
||||
id :string,
|
||||
project_label_id:string,
|
||||
project_issue_id:string
|
||||
}
|
||||
export const Table_Project_Label_Issue="project_label_issue"
|
@ -1,5 +1,5 @@
|
||||
export interface ICommon_Model_Project_Module {
|
||||
id :bigint,
|
||||
id :string,
|
||||
name:string
|
||||
}
|
||||
export const Table_Project_Module="project_module"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Module_Issue {
|
||||
id :bigint,
|
||||
project_module_id:bigint,
|
||||
project_issue_id:bigint
|
||||
id :string,
|
||||
project_module_id:string,
|
||||
project_issue_id:string
|
||||
}
|
||||
export const Table_Project_Module_Issue="project_module_issue"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Module_Parent {
|
||||
id :bigint,
|
||||
parent_id:bigint,
|
||||
child_id:bigint
|
||||
id :string,
|
||||
parent_id:string,
|
||||
child_id:string
|
||||
}
|
||||
export const Table_Project_Module_Parent="project_module_parent"
|
@ -1,14 +1,14 @@
|
||||
export interface ICommon_Model_Project_Release {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
name :string,
|
||||
start_time :number,
|
||||
release_time :number,
|
||||
description :string,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
created_by :bigint ,
|
||||
modified_by :bigint,
|
||||
created_by :string ,
|
||||
modified_by :string,
|
||||
status :number,
|
||||
project_id :bigint,
|
||||
project_id :string,
|
||||
}
|
||||
export const Table_Project_Release="project_release"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Release_Issue {
|
||||
id :bigint ,
|
||||
project_release_id :bigint,
|
||||
project_issue_id:bigint
|
||||
id :string ,
|
||||
project_release_id :string,
|
||||
project_issue_id:string
|
||||
}
|
||||
export const Table_Project_Release_Issue="project_release_issue"
|
9
code/common/model/project_role.ts
Normal file
9
code/common/model/project_role.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export interface ICommon_Model_Project_Role {
|
||||
id :string,
|
||||
name :string,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
description:string,
|
||||
project_id:string
|
||||
}
|
||||
export const Table_Project_Role="project_role"
|
@ -1,9 +1,9 @@
|
||||
export interface ICommon_Model_Project_User {
|
||||
id :bigint,
|
||||
permission :bigint ,
|
||||
id :string,
|
||||
role :string ,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
project_id :bigint ,
|
||||
user_id :bigint ,
|
||||
project_id :string ,
|
||||
user_id :string ,
|
||||
}
|
||||
export const Table_Project_User="project_user"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Project_Workflow_Solution {
|
||||
id :bigint,
|
||||
project_id :bigint ,
|
||||
workflow_solution_id :bigint ,
|
||||
id :string,
|
||||
project_id :string ,
|
||||
workflow_solution_id :string ,
|
||||
}
|
||||
export const Table_Project_Workflow_Solution="project_workflow_solution"
|
@ -1,7 +0,0 @@
|
||||
export interface ICommon_Model_Role {
|
||||
id :bigint,
|
||||
name :string,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
}
|
||||
export const Table_Role="role"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_Role_Permission {
|
||||
role_id :bigint,
|
||||
permission_id :bigint,
|
||||
id :bigint ,
|
||||
role_id :string,
|
||||
permission_id :string,
|
||||
id :string ,
|
||||
}
|
||||
export const Table_Role_Permission="role_permission"
|
@ -1,5 +1,5 @@
|
||||
export interface ICommon_Model_User {
|
||||
id :bigint,
|
||||
id :string,
|
||||
username :string,
|
||||
email :string,
|
||||
phone :string,
|
||||
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_User_Has_Group {
|
||||
user_id :bigint,
|
||||
group_id :bigint,
|
||||
id :bigint ,
|
||||
user_id :string,
|
||||
group_id :string,
|
||||
id :string ,
|
||||
}
|
||||
export const Table_User_Has_Group="user_has_group"
|
@ -1,6 +1,6 @@
|
||||
export interface ICommon_Model_User_Role {
|
||||
user_id :bigint,
|
||||
role_id :bigint,
|
||||
id :bigint ,
|
||||
user_id :string,
|
||||
role_id :string,
|
||||
id :string ,
|
||||
}
|
||||
export const Table_User_Role="user_role"
|
@ -1,10 +1,10 @@
|
||||
export interface ICommon_Model_User_Setting {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
key :string,
|
||||
value :string,
|
||||
type :number,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
user_id :bigint,
|
||||
user_id :string,
|
||||
}
|
||||
export const Table_User_Setting="user_setting"
|
4
code/common/model/version.ts
Normal file
4
code/common/model/version.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface ICommon_Model_Version {
|
||||
version:string
|
||||
}
|
||||
export const Table_Version="version"
|
@ -1,11 +1,11 @@
|
||||
export interface ICommon_Model_Workflow {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
name :string,
|
||||
description :string,
|
||||
system :number,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
created_by :bigint ,
|
||||
modified_by :bigint ,
|
||||
created_by :string ,
|
||||
modified_by :string ,
|
||||
}
|
||||
export const Table_Workflow="workflow"
|
@ -1,10 +1,10 @@
|
||||
export interface ICommon_Model_Workflow_Action {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
name :string,
|
||||
system :number,
|
||||
description :string,
|
||||
source_node_id :bigint ,
|
||||
dest_node_id :bigint ,
|
||||
workflow_id :bigint,
|
||||
source_node_id :string ,
|
||||
dest_node_id :string ,
|
||||
workflow_id :string,
|
||||
}
|
||||
export const Table_Workflow_Action="workflow_action"
|
@ -1,9 +1,9 @@
|
||||
export interface ICommon_Model_Workflow_Node {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
name :string,
|
||||
description :string,
|
||||
system :number,
|
||||
status :number,
|
||||
workflow_id :bigint ,
|
||||
workflow_id :string ,
|
||||
}
|
||||
export const Table_Workflow_Node="workflow_node"
|
@ -1,9 +1,9 @@
|
||||
export interface ICommon_Model_Workflow_Solution {
|
||||
id :bigint ,
|
||||
id :string ,
|
||||
created_time :Date,
|
||||
modified_time :Date,
|
||||
created_by :bigint ,
|
||||
modified_by :bigint,
|
||||
created_by :string ,
|
||||
modified_by :string,
|
||||
system :number,
|
||||
name :string,
|
||||
description :string,
|
||||
|
@ -1,7 +1,7 @@
|
||||
export interface ICommon_Model_Workflow_Solution_Issue_Type {
|
||||
id :bigint,
|
||||
workflow_solution_id :bigint,
|
||||
workflow_id :bigint ,
|
||||
issue_type_id :bigint ,
|
||||
id :string,
|
||||
workflow_solution_id :string,
|
||||
workflow_id :string ,
|
||||
issue_type_id :string ,
|
||||
}
|
||||
export const Table_Workflow_Solution_Issue_Type="workflow_solution_issue_type"
|
@ -1,3 +0,0 @@
|
||||
export enum ECommon_Permission_Issue {
|
||||
|
||||
}
|
15
code/common/permission/permission.ts
Normal file
15
code/common/permission/permission.ts
Normal file
@ -0,0 +1,15 @@
|
||||
let v=0;
|
||||
export abstract class Permission_Base {
|
||||
constructor(private readonly name:string,public readonly value=v++){}
|
||||
toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
export namespace Permission_Types {
|
||||
export class Project extends Permission_Base {
|
||||
static readonly READ =new Project("read project")
|
||||
static readonly EDIT =new Project("edit project")
|
||||
static readonly DELETE =new Project("delete project")
|
||||
static readonly CREATE =new Project("create project")
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export enum ECommon_Permission_Project {
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export enum ECommon_Permission_User {
|
||||
|
||||
}
|
@ -59,7 +59,7 @@ const api={
|
||||
username:string,
|
||||
password:string
|
||||
}>{},
|
||||
res:<Omit<ICommon_Model_User,"password">>{},
|
||||
res:<Omit<ICommon_Model_User,"password">>{}
|
||||
},
|
||||
remove:{
|
||||
method:ECommon_HttpApi_Method.DELETE,
|
||||
|
@ -1,57 +1,44 @@
|
||||
export namespace Err {
|
||||
export abstract class BaseError {
|
||||
abstract code:number
|
||||
msg:string
|
||||
}
|
||||
export namespace Common {
|
||||
export class ParamError extends BaseError {
|
||||
code=0
|
||||
override msg="param error"
|
||||
}
|
||||
export class MysqlError extends BaseError {
|
||||
code=1
|
||||
override msg:string
|
||||
constructor(msg?:string) {
|
||||
super()
|
||||
this.msg=msg?msg:"mysql error"
|
||||
}
|
||||
export let Common = {
|
||||
paramError:{
|
||||
code:0,
|
||||
msg:"param error"
|
||||
},
|
||||
mysqlError:{
|
||||
code:1,
|
||||
msg:"mysql error"
|
||||
}
|
||||
}
|
||||
export namespace User {
|
||||
export class UserNotFound extends BaseError {
|
||||
code=1000
|
||||
override msg="user not found"
|
||||
}
|
||||
|
||||
export class UserExists extends BaseError {
|
||||
code=1001
|
||||
override msg="user exists"
|
||||
}
|
||||
|
||||
export class UserIdNotExists extends BaseError {
|
||||
code=1002
|
||||
override msg="user id not exists"
|
||||
}
|
||||
|
||||
export class UserNameNotExists extends BaseError {
|
||||
code=1003
|
||||
override msg="user name not exists"
|
||||
}
|
||||
|
||||
export class UserPasswordWrong extends BaseError {
|
||||
code=1004
|
||||
override msg="user password wrong"
|
||||
}
|
||||
|
||||
export class NotAuth extends BaseError {
|
||||
code=1005
|
||||
override msg="user not auth"
|
||||
export let User = {
|
||||
userNotFound:{
|
||||
code:1000,
|
||||
msg:"user not found"
|
||||
},
|
||||
userExists:{
|
||||
code:1001,
|
||||
msg:"user exists"
|
||||
},
|
||||
userIdNotExists:{
|
||||
code:1002,
|
||||
msg:"user id not exists"
|
||||
},
|
||||
userNameNotExists:{
|
||||
code:1003,
|
||||
msg:"user not found"
|
||||
},
|
||||
userPasswordWrong:{
|
||||
code:1004,
|
||||
msg:"user password wrong"
|
||||
},
|
||||
notAuth:{
|
||||
code:1005,
|
||||
msg:"user not auth"
|
||||
}
|
||||
}
|
||||
export namespace Http {
|
||||
export class OverFileSize extends BaseError {
|
||||
code=2000
|
||||
override msg="over file size"
|
||||
export let Http = {
|
||||
overFileSize:{
|
||||
code:2000,
|
||||
msg:"over file size"
|
||||
}
|
||||
}
|
||||
|
||||
|
2
code/server/common/cache/keys/user.ts
vendored
2
code/server/common/cache/keys/user.ts
vendored
@ -5,7 +5,7 @@ import {cacheRedisType} from "../../types/cache"
|
||||
import StringUtil from "../../util/string"
|
||||
export namespace REDIS_USER {
|
||||
let USER_TOKEN_KEY=`${ECommon_Services.User}:user:{0}:token`
|
||||
export function token(userId:bigint)
|
||||
export function token(userId:string)
|
||||
{
|
||||
let obj=new RedisStringKey(StringUtil.format(USER_TOKEN_KEY,userId),cacheRedisType<string>().String)
|
||||
return obj
|
||||
|
@ -21,7 +21,9 @@ export default class Mysql {
|
||||
database:info.database,
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
queueLimit: 0,
|
||||
supportBigNumbers:true,
|
||||
bigNumberStrings:true
|
||||
})
|
||||
this.sql=con.promise();
|
||||
g_mysqlConnection=this;
|
||||
@ -41,7 +43,7 @@ export default class Mysql {
|
||||
|
||||
} catch(err){
|
||||
console.error("mysql error:",err,sqlText)
|
||||
throw new Err.Common.MysqlError
|
||||
throw Err.Common.mysqlError
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
export abstract class Entity<T> {
|
||||
protected item:T;
|
||||
getId():bigint{
|
||||
getId():string{
|
||||
if(this.item) {
|
||||
return (<any>this.item).id
|
||||
} else {
|
||||
|
@ -70,6 +70,22 @@ export function DHttpReqParam(name:string,defalutValue?:any){
|
||||
}
|
||||
}
|
||||
|
||||
export function DHttpUser(target: Object, propertyKey: string, parameterIndex: number){
|
||||
let types=Reflect.getMetadata("design:paramtypes",target,propertyKey);
|
||||
let type=types[parameterIndex].name
|
||||
let key=target.constructor.name+"::"+propertyKey
|
||||
let obj:IServer_Common_Http_Structure_HandleParam={
|
||||
name:null,
|
||||
index:parameterIndex,
|
||||
type:type,
|
||||
category:EServer_Common_Http_Structure_HandleParam_Category.User
|
||||
}
|
||||
if(!g_objParam[key]){
|
||||
g_objParam[key]=[]
|
||||
}
|
||||
g_objParam[key].unshift(obj)
|
||||
}
|
||||
|
||||
export function DHttpReqParamRequired(name:string){
|
||||
return function(target: Object, propertyKey: string, parameterIndex: number){
|
||||
let types=Reflect.getMetadata("design:paramtypes",target,propertyKey);
|
||||
@ -163,7 +179,11 @@ export async function handleHttpCall(obj:IServer_Common_Http_Structure,ctx:IServ
|
||||
}
|
||||
else if(obj.type=="Object")
|
||||
{
|
||||
value=JSON.parse(value)
|
||||
try {
|
||||
value=JSON.parse(value)
|
||||
} catch {
|
||||
value={}
|
||||
}
|
||||
}
|
||||
arr.push(value)
|
||||
}
|
||||
@ -171,6 +191,10 @@ export async function handleHttpCall(obj:IServer_Common_Http_Structure,ctx:IServ
|
||||
{
|
||||
arr.push(objContext)
|
||||
}
|
||||
else if(obj.category==EServer_Common_Http_Structure_HandleParam_Category.User)
|
||||
{
|
||||
arr.push(ctx.user)
|
||||
}
|
||||
else if(obj.category==EServer_Common_Http_Structure_HandleParam_Category.File)
|
||||
{
|
||||
let objFile:IServer_Common_Http_Req_File=ctx.data[name]
|
||||
|
6
code/server/common/permission/base.ts
Normal file
6
code/server/common/permission/base.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface IServer_Common_Permission_Base<T=any> {
|
||||
key?:string;
|
||||
create?(...argv:any):Promise<T>
|
||||
check(obj:T):boolean
|
||||
clear?():void
|
||||
}
|
0
code/server/common/permission/function/clear.ts
Normal file
0
code/server/common/permission/function/clear.ts
Normal file
0
code/server/common/permission/function/create.ts
Normal file
0
code/server/common/permission/function/create.ts
Normal file
14
code/server/common/permission/project/relation.ts
Normal file
14
code/server/common/permission/project/relation.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Permission_Types } from '../../../../common/permission/permission';
|
||||
import { IServer_Common_Permission_Base } from '../base';
|
||||
|
||||
export type IPermission_Project_CacheValue =Exclude<keyof typeof Permission_Types.Project,"type"|"prototype">[]
|
||||
class PermissionProjectRead implements IServer_Common_Permission_Base<IPermission_Project_CacheValue> {
|
||||
key="permission:user:{0}:project:{1}"
|
||||
async create(...argv:any):Promise<IPermission_Project_CacheValue> {
|
||||
return null;
|
||||
}
|
||||
check(obj:IPermission_Project_CacheValue):boolean {
|
||||
return;
|
||||
}
|
||||
clear():void{}
|
||||
}
|
@ -6,4 +6,6 @@ export interface IServer_Common_RPC_User_CheckSession {
|
||||
}
|
||||
export default interface IServer_Common_RPC_User {
|
||||
checkSession?(token:string):Promise<IServer_Common_RPC_User_CheckSession>
|
||||
}
|
||||
}
|
||||
|
||||
export type IUserSession=IServer_Common_RPC_User_CheckSession
|
@ -1,10 +1,13 @@
|
||||
import { IServer_Common_RPC_User_CheckSession } from "../rpc/api/user";
|
||||
|
||||
export enum EServer_Common_Http_Structure_HandleParam_Category {
|
||||
Content,
|
||||
File,
|
||||
Param,
|
||||
Header,
|
||||
Cookie,
|
||||
Context
|
||||
Context,
|
||||
User
|
||||
}
|
||||
export interface IServer_Common_Http_Structure_HandleParam {
|
||||
name:string,
|
||||
@ -38,7 +41,8 @@ export interface IServer_Common_Http_Proxy {
|
||||
[param:string]:string
|
||||
},
|
||||
data:any,
|
||||
bodyType:EServer_Common_Http_Body_Type
|
||||
bodyType:EServer_Common_Http_Body_Type,
|
||||
user?:IServer_Common_RPC_User_CheckSession
|
||||
}
|
||||
|
||||
export interface IServer_Common_Http_Req_File {
|
||||
|
@ -1,19 +1,19 @@
|
||||
import{ UniqueID } from 'nodejs-snowflake';
|
||||
|
||||
const uid = new UniqueID({
|
||||
returnNumber: true
|
||||
returnNumber: false
|
||||
});
|
||||
|
||||
type EXPR={
|
||||
[key:string]:string|number|boolean|bigint|{
|
||||
value?:string|number|boolean|string[]|[number,number]|bigint,
|
||||
[key:string]:string|number|boolean|string|{
|
||||
value?:string|number|boolean|string[]|[number,number]|string,
|
||||
exp?:"="|">="|"<="|">"|"<"|"<>"|"is null"|"in"|"is not null"|"between"|"%like"|"like%"|"%like%"
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateSnowId() {
|
||||
let id =await uid.asyncGetUniqueID()
|
||||
return id as bigint
|
||||
return id as string
|
||||
}
|
||||
|
||||
function generateExp(objExpr?:EXPR,exprMode?:"and"|"or"):string{
|
||||
|
@ -14,6 +14,7 @@ import { PassThrough } from "stream";
|
||||
import { proxyRequest } from "../../common/rpc/rpc";
|
||||
import { Err } from "../../../common/status/error";
|
||||
import { ECommon_Services } from "../../../common/types";
|
||||
import { initSystem } from "../util/util";
|
||||
var apis:ICommon_HttpApi[]=[userApi];
|
||||
var app = new Koa();
|
||||
var pipe=function (from,to) :Promise<string>{
|
||||
@ -38,6 +39,7 @@ export default class GateWay extends Application {
|
||||
override async config() {
|
||||
let cacheService=new CacheService()
|
||||
cacheService.start()
|
||||
await initSystem()
|
||||
await this.initKoa();
|
||||
}
|
||||
async initKoa() {
|
||||
@ -67,7 +69,7 @@ export default class GateWay extends Application {
|
||||
if (ctx.headers['content-type'] && ctx.headers['content-type'].split(';')[0] === 'multipart/form-data') {
|
||||
const maxLength = 1024 * 1024 * 5;
|
||||
if (ctx.headers && ctx.headers['content-length'] && Number(ctx.headers['content-length']) > maxLength) {
|
||||
ctx.body = generateHttpErrorResponse(new Err.Http.OverFileSize)
|
||||
ctx.body = generateHttpErrorResponse(Err.Http.overFileSize)
|
||||
return;
|
||||
}
|
||||
let stream=new PassThrough()
|
||||
@ -113,12 +115,13 @@ export default class GateWay extends Application {
|
||||
if(!ignoreValidate) {
|
||||
let authorization = ctx.get("Authorization")
|
||||
if(!authorization) {
|
||||
throw new Err.User.NotAuth
|
||||
throw Err.User.notAuth
|
||||
}
|
||||
let ret= await userRpcApi.checkSession(authorization.substr(7))
|
||||
if(!ret) {
|
||||
throw new Err.User.NotAuth
|
||||
throw Err.User.notAuth
|
||||
}
|
||||
ctx.state.user=ret;
|
||||
}
|
||||
let obj = <IServer_Common_Http_Proxy>{}
|
||||
if (ctx.req.method == "POST" || ctx.req.method == "PUT" || ctx.req.method == "PATCH") {
|
||||
@ -133,6 +136,7 @@ export default class GateWay extends Application {
|
||||
obj.headers = <any>ctx.req.headers
|
||||
obj.data = ctx.state.formData ?? ctx.state.p
|
||||
obj.path = apiPath
|
||||
obj.user = ctx.state.user
|
||||
if (ctx.state.formData) {
|
||||
obj.bodyType = EServer_Common_Http_Body_Type.FORMDATA
|
||||
}
|
||||
|
34
code/server/gateway/util/obtp.ts
Normal file
34
code/server/gateway/util/obtp.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Permission_Base, Permission_Types } from "../../../common/permission/permission";
|
||||
function getAllPermissions(obj):Permission_Base[] {
|
||||
let arr:Permission_Base[] =[]
|
||||
let keys = Object.keys(obj)
|
||||
for (let key of keys) {
|
||||
let val = obj[key]
|
||||
if (val instanceof Permission_Base) {
|
||||
arr.push(val)
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
export namespace OBTPConfig {
|
||||
export namespace Role {
|
||||
export const Project_Role=<{
|
||||
[param:string]:{
|
||||
name:string,
|
||||
description:"",
|
||||
permission:Permission_Types.Project[]
|
||||
}
|
||||
}>{
|
||||
admin:{
|
||||
name:"admin",
|
||||
description:"",
|
||||
permission:getAllPermissions(Permission_Types.Project)
|
||||
},
|
||||
user:{
|
||||
name:"user",
|
||||
description:"",
|
||||
permission:[Permission_Types.Project.READ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,13 @@
|
||||
import { Table_Role_Permission } from './../../../common/model/role_permission';
|
||||
import { Table_Project_Role } from './../../../common/model/project_role';
|
||||
import { Table_Permission } from './../../../common/model/permission';
|
||||
import { Table_Admin } from './../../../common/model/admin';
|
||||
import { Table_Version } from './../../../common/model/version';
|
||||
import { getMysqlInstance } from "../../common/db/mysql";
|
||||
import { Permission_Base, Permission_Types } from '../../../common/permission/permission';
|
||||
import { generateSnowId } from '../../common/util/sql';
|
||||
import {version} from "../../package.json"
|
||||
import { OBTPConfig } from './obtp';
|
||||
export interface IServer_GateWay_FormData {
|
||||
isFile:boolean,
|
||||
name:string,
|
||||
@ -34,4 +44,53 @@ export function parseFormData(str:string) :IServer_GateWay_FormData[]{
|
||||
ret.push(objForm)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
async function resetSystem(){
|
||||
let mysql=getMysqlInstance()
|
||||
await mysql.execute(`delete from ${Table_Version}`)
|
||||
await mysql.execute(`delete from ${Table_Admin}`)
|
||||
await mysql.execute(`delete from ${Table_Permission}`)
|
||||
}
|
||||
|
||||
export async function initSystem() {
|
||||
await resetSystem()
|
||||
let mysql=getMysqlInstance()
|
||||
let ret=await mysql.execute<any[]>(`select * from ${Table_Version}`)
|
||||
if(ret===null || ret.length==0){
|
||||
let objPermission=<{
|
||||
[param:number]:string
|
||||
}>{}
|
||||
let adminId=await generateSnowId()
|
||||
await mysql.execute(`insert into ${Table_Admin} (id,name,password) values ('${adminId}','teamlinker','teamlinker')`)
|
||||
for(let key in Permission_Types) {
|
||||
let value=Permission_Types[key]
|
||||
let type=key
|
||||
let keys=Object.keys(value)
|
||||
for(let key of keys) {
|
||||
let val=value[key]
|
||||
if(val instanceof Permission_Base) {
|
||||
let name=val.toString()
|
||||
let value=val.value
|
||||
let id=await generateSnowId()
|
||||
await mysql.execute(`insert into ${Table_Permission} (id,name,type,value) values ('${id}','${name}','${type}','${value}')`)
|
||||
objPermission[value]=id
|
||||
}
|
||||
}
|
||||
}
|
||||
let objProjectRole=OBTPConfig.Role.Project_Role
|
||||
for(let key in objProjectRole) {
|
||||
let obj=objProjectRole[key]
|
||||
let projectRoleId=await generateSnowId()
|
||||
let name=obj.name
|
||||
let description=obj.description
|
||||
await mysql.execute(`insert into ${Table_Project_Role} (id,name,description) values ('${projectRoleId}','${name}','${description}')`)
|
||||
for(let o of obj.permission) {
|
||||
let id=await generateSnowId()
|
||||
await mysql.execute(`insert into ${Table_Role_Permission} (id,role_id,permission_id) values ('${id}','${projectRoleId}','${objPermission[o.value]}')`)
|
||||
}
|
||||
}
|
||||
await mysql.execute(`insert into ${Table_Version} (version) values ('${version}')`)
|
||||
}
|
||||
console.log("init finish")
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
import { DHttpApi, DHttpContext, DHttpReqParam, DHttpReqParamFile,DHttpContent, DHttpReqParamRequired } from "../../common/http/http"
|
||||
import { IUserSession } from './../../common/rpc/api/user';
|
||||
import { DHttpApi, DHttpContext, DHttpReqParam, DHttpReqParamFile,DHttpContent, DHttpReqParamRequired, DHttpUser } from "../../common/http/http"
|
||||
import * as userApi from "../../../common/routes/user"
|
||||
import HttpContext from "../../common/http/context"
|
||||
import UserService from "../service/user"
|
||||
import { Err } from "../../../common/status/error"
|
||||
class UserController {
|
||||
@DHttpApi(userApi.routes.create)
|
||||
async create(@DHttpContent content:typeof userApi.routes.create.req):Promise<typeof userApi.routes.create.res>{
|
||||
async create(@DHttpContent content:typeof userApi.routes.create.req,@DHttpUser userInfo:IUserSession):Promise<typeof userApi.routes.create.res>{
|
||||
console.log(userInfo)
|
||||
let user=new UserService()
|
||||
user.assignItem(content);
|
||||
let obj=await user.create()
|
||||
@ -17,7 +19,7 @@ class UserController {
|
||||
async login(@DHttpReqParamRequired("username") username:string,@DHttpReqParamRequired("password") password:string,@DHttpContext ctx:HttpContext):Promise<typeof userApi.routes.login.res> {
|
||||
let user=await UserService.getItemByName(username)
|
||||
if(!user) {
|
||||
throw new Err.User.UserNotFound
|
||||
throw Err.User.userNotFound
|
||||
}
|
||||
if(user.getItem().password===password) {
|
||||
let token=await user.startSession()
|
||||
@ -26,7 +28,7 @@ class UserController {
|
||||
ctx.setHeader("token",token)
|
||||
return ret
|
||||
} else {
|
||||
throw new Err.User.UserPasswordWrong
|
||||
throw Err.User.userPasswordWrong
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,20 @@ export namespace userMapper {
|
||||
}>(generateQuerySql(Table_User,["username"],{
|
||||
username:username
|
||||
}),true)
|
||||
if(ret instanceof Err.Common.MysqlError) {
|
||||
throw new Err.Common.MysqlError;
|
||||
}
|
||||
return !!ret
|
||||
}
|
||||
|
||||
export async function createUser(info:ICommon_Model_User):Promise<void> {
|
||||
if(!info || !info.username || !info.password ||!info.id){
|
||||
throw new Err.Common.ParamError
|
||||
throw Err.Common.paramError
|
||||
}
|
||||
var mysql=getMysqlInstance()
|
||||
await mysql.execute<Extract<typeof createUser,ICommon_Model_User>>(generateCreateSql(Table_User,info))
|
||||
}
|
||||
|
||||
export async function getUserById(id:bigint):Promise<ICommon_Model_User> {
|
||||
export async function getUserById(id:string):Promise<ICommon_Model_User> {
|
||||
if(!id) {
|
||||
throw new Err.User.UserIdNotExists
|
||||
throw Err.User.userIdNotExists
|
||||
}
|
||||
var mysql=getMysqlInstance();
|
||||
let ret=await mysql.execute<ICommon_Model_User>(generateQuerySql(Table_User,[],{id}),true)
|
||||
@ -38,7 +35,7 @@ export namespace userMapper {
|
||||
|
||||
export async function getUserByName(name:string):Promise<ICommon_Model_User> {
|
||||
if(!name) {
|
||||
throw new Err.User.UserNameNotExists
|
||||
throw Err.User.userNameNotExists
|
||||
}
|
||||
var mysql=getMysqlInstance();
|
||||
let ret=await mysql.execute<ICommon_Model_User>(generateQuerySql(Table_User,[],{username:name}),true)
|
||||
@ -47,7 +44,7 @@ export namespace userMapper {
|
||||
|
||||
export async function updateUser(info:ICommon_Model_User):Promise<void> {
|
||||
if(!info.id) {
|
||||
throw new Err.User.UserIdNotExists
|
||||
throw Err.User.userIdNotExists
|
||||
}
|
||||
var mysql=getMysqlInstance();
|
||||
let id=info.id;
|
||||
@ -57,7 +54,7 @@ export namespace userMapper {
|
||||
|
||||
export async function deleteUser(id):Promise<void> {
|
||||
if(!id) {
|
||||
throw new Err.User.UserIdNotExists
|
||||
throw Err.User.userIdNotExists
|
||||
}
|
||||
var mysql=getMysqlInstance();
|
||||
await mysql.execute(generateDeleteSql(Table_User,{id}))
|
||||
|
@ -13,9 +13,9 @@ export default class User extends Entity<ICommon_Model_User> {
|
||||
|
||||
async create():Promise<ICommon_Model_User>{
|
||||
if(!this.item) {
|
||||
throw new Err.User.UserNotFound;
|
||||
throw Err.User.userNotFound;
|
||||
} else if(this.item.id) {
|
||||
throw new Err.User.UserExists;
|
||||
throw Err.User.userExists;
|
||||
}
|
||||
this.item.id=await generateSnowId()
|
||||
await userMapper.createUser(this.item)
|
||||
@ -24,7 +24,7 @@ export default class User extends Entity<ICommon_Model_User> {
|
||||
}
|
||||
async update():Promise<ICommon_Model_User>{
|
||||
if(!this.item || !this.item.id) {
|
||||
throw new Err.User.UserNotFound;
|
||||
throw Err.User.userNotFound;
|
||||
}
|
||||
await userMapper.updateUser(this.item)
|
||||
return this.item;
|
||||
@ -35,13 +35,13 @@ export default class User extends Entity<ICommon_Model_User> {
|
||||
}
|
||||
async loadItem():Promise<ICommon_Model_User> {
|
||||
if(!this.item || !this.item.id) {
|
||||
throw new Err.User.UserNotFound;
|
||||
throw Err.User.userNotFound;
|
||||
}
|
||||
let obj = await userMapper.getUserById(this.item.id);
|
||||
this.item=obj;
|
||||
return this.item;
|
||||
}
|
||||
static async getItemById(id:bigint):Promise<InstanceType<typeof User>>{
|
||||
static async getItemById(id:string):Promise<InstanceType<typeof User>>{
|
||||
let obj = await userMapper.getUserById(id);
|
||||
if(obj) {
|
||||
let user = new User;
|
||||
@ -66,7 +66,7 @@ export default class User extends Entity<ICommon_Model_User> {
|
||||
async startSession():Promise<string>{
|
||||
let secret=getNacosInstance().globalConfig.jwt;
|
||||
if(!this.item || !this.item.id) {
|
||||
throw new Err.User.UserNotFound
|
||||
throw Err.User.userNotFound
|
||||
}
|
||||
return new Promise(async (resolve,reject)=>{
|
||||
jwt.sign({
|
||||
|
Loading…
Reference in New Issue
Block a user