This commit is contained in:
吕金泽
2021-10-24 20:09:53 +08:00
commit 4a7d1d08ac
509 changed files with 142640 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "02df51e4d7184780a98b632f43dc5848",
"name" : "后台",
"type" : "1",
"parentId" : "0",
"path" : "",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "1952f25c81084e24b55b11385767dc38",
"name" : "安全",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/security",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,144 @@
{
"properties" : { },
"id" : "6f604c0abbe446b381381ae929026a28",
"script" : null,
"groupId" : "1952f25c81084e24b55b11385767dc38",
"name" : "登录",
"createTime" : null,
"updateTime" : 1635043797677,
"lock" : "0",
"method" : "POST",
"path" : "/login",
"parameters" : [ ],
"option" : "[{\"name\":\"require_login\",\"value\":\"false\",\"description\":\"该接口需要登录才允许访问\"}]",
"requestBody" : "{\r\n \"username\": \"admin\",\r\n \"password\": \"1\"\r\n}",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 500,\n \"message\": \"系统内部出现错误\",\n \"data\": null,\n \"timestamp\": 1634225636093,\n \"executeTime\": 9174\n}",
"description" : null,
"requestBodyDefinition" : {
"name" : "root",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "username",
"value" : "admin",
"description" : "",
"required" : true,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "password",
"value" : "1",
"description" : "",
"required" : true,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "500",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "系统内部出现错误",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634225636093",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "9174",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : {
"require_login" : "false"
}
}
================================
import log
import 'cn.dev33.satoken.secure.SaSecureUtil';
import 'cn.dev33.satoken.stp.StpUtil';
var user = db.table("sys_user").where().eq("username",body.username).eq("password",SaSecureUtil.sha256(body.password)).selectOne()
if(!user){
exit 0,'用户名或密码错误'
}
StpUtil.login(user.id)
return StpUtil.getTokenValueByLoginId(user.id)
@@ -0,0 +1,127 @@
{
"properties" : { },
"id" : "c97e92eef5024994a32352cddbe73d6d",
"script" : null,
"groupId" : "1952f25c81084e24b55b11385767dc38",
"name" : "获取当前用户权限code",
"createTime" : 1634724871163,
"updateTime" : 1634724871163,
"lock" : "0",
"method" : "POST",
"path" : "/permissions",
"parameters" : [ ],
"option" : "[{\"name\":\"\",\"value\":\"\",\"description\":\"\"}]",
"requestBody" : "{\r\n\t\r\n}",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [\n \"role:view\",\n \"role:save\",\n \"role:delete\",\n \"menu:delete\",\n \"office:office:list\",\n \"office:office:save\",\n \"office:office:delete\",\n \"dict:items:delete\",\n \"sys:test:aaa\",\n \"dict:delete\",\n \"dict:items\",\n \"dict:save\",\n \"user:save\",\n \"dict:view\",\n \"user:delete\",\n \"menu:save\",\n \"dict:items:save\"\n ],\n \"timestamp\": 1634092982336,\n \"executeTime\": 25\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "200",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "success",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Array",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "",
"value" : "role:view",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
}, {
"name" : "timestamp",
"value" : "1634092982336",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "25",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : {
"" : ""
}
}
================================
import 'cn.dev33.satoken.stp.StpUtil';
var userId = StpUtil.getLoginId()
return db.select("""
SELECT DISTINCT
sm.permission
FROM
sys_menu sm
left JOIN sys_role_menu srm ON sm.id = srm.menu_id
left JOIN sys_user_role sur ON sur.role_id = srm.role_id
left JOIN sys_user su ON su.id = sur.user_id
?{userId != '1', AND su.id = #{userId}}
AND su.is_del = 0
WHERE
sm.is_del = 0
AND sm.permission != ''
AND sm.permission IS NOT NULL
""").map((it) => {return it.permission})
@@ -0,0 +1,100 @@
{
"properties" : { },
"id" : "72bd167de1b9456fb91ed939214ff7b4",
"script" : null,
"groupId" : "1952f25c81084e24b55b11385767dc38",
"name" : "退出登录",
"createTime" : 1634724871162,
"updateTime" : 1634724871162,
"lock" : "0",
"method" : "GET",
"path" : "/logout",
"parameters" : [ ],
"option" : "[{\"name\":\"require_login\",\"value\":\"false\",\"description\":\"该接口需要登录才允许访问\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 500,\n \"message\": \"系统内部出现错误\",\n \"data\": null,\n \"timestamp\": 1634046032107,\n \"executeTime\": 8\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "500",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "系统内部出现错误",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634046032107",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "8",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : {
"require_login" : "false"
}
}
================================
import 'cn.dev33.satoken.stp.StpUtil';
StpUtil.logout();
exit 200
@@ -0,0 +1,99 @@
{
"properties" : { },
"id" : "a716bb16c71e47dcad23f1cc77c807f4",
"script" : null,
"groupId" : "1952f25c81084e24b55b11385767dc38",
"name" : "验证token",
"createTime" : 1634724871160,
"updateTime" : 1634724871160,
"lock" : "0",
"method" : "GET",
"path" : "/validateToken",
"parameters" : [ ],
"option" : "[{\"name\":\"require_login\",\"value\":\"false\",\"description\":\"该接口需要登录才允许访问\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 500,\n \"message\": \"系统内部出现错误\",\n \"data\": null,\n \"timestamp\": 1634047764762,\n \"executeTime\": 8\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "500",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "系统内部出现错误",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634047764762",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "8",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : {
"require_login" : "false"
}
}
================================
import 'cn.dev33.satoken.stp.StpUtil';
return StpUtil.isLogin();
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "c7ce65f5b3cf4aaa913f6fec7d35d176",
"name" : "数据字典",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/dict",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,26 @@
{
"properties" : { },
"id" : "cbf24a795f6441d6af123d6dff065e37",
"script" : null,
"groupId" : "c7ce65f5b3cf4aaa913f6fec7d35d176",
"name" : "保存",
"createTime" : null,
"updateTime" : 1634734554311,
"lock" : "0",
"method" : "POST",
"path" : "/save",
"parameters" : [ ],
"option" : "[{\"name\":\"wrap_request_parameter\",\"value\":\"data\",\"description\":\"包装请求参数到一个变量中\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : {
"wrap_request_parameter" : "data"
}
}
================================
return db.table("sys_dict").primary("id").saveOrUpdate(data)
@@ -0,0 +1,102 @@
{
"properties" : { },
"id" : "1d9e4e7ad6a1484db6555700ea23144c",
"script" : null,
"groupId" : "c7ce65f5b3cf4aaa913f6fec7d35d176",
"name" : "列表",
"createTime" : null,
"updateTime" : 1634736176170,
"lock" : "0",
"method" : "GET",
"path" : "/list",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 402,\n \"message\": \"凭证已过期\",\n \"data\": null,\n \"timestamp\": 1634734488837,\n \"executeTime\": null\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "402",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "凭证已过期",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634734488837",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
return db.page("""
select id,dict_type,desc_ribe,type,remarks,sort from sys_dict
where is_del = 0
?{type, and type like concat('%',#{type},'%')}
?{dictType, and dict_type = #{dictType}}
order by create_date desc
""")
@@ -0,0 +1,25 @@
{
"properties" : { },
"id" : "46d45f15b5ab4de7b6718fd0c9b05e7b",
"script" : null,
"groupId" : "c7ce65f5b3cf4aaa913f6fec7d35d176",
"name" : "删除",
"createTime" : null,
"updateTime" : 1634734751223,
"lock" : "0",
"method" : "POST",
"path" : "/delete",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
db.table("sys_dict_items").logic().where().eq("dictId",id).delete()
return db.table("sys_dict").logic().where().eq("id",id).delete()
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "376f26eb43a44a3daeafd27020a96f48",
"name" : "字典项",
"type" : "1",
"parentId" : "c7ce65f5b3cf4aaa913f6fec7d35d176",
"path" : "/items",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,26 @@
{
"properties" : { },
"id" : "695ff3257c314ea4bfa63edeaa511af0",
"script" : null,
"groupId" : "376f26eb43a44a3daeafd27020a96f48",
"name" : "保存",
"createTime" : null,
"updateTime" : 1634735495162,
"lock" : "0",
"method" : "POST",
"path" : "/save",
"parameters" : [ ],
"option" : "[{\"name\":\"wrap_request_parameter\",\"value\":\"data\",\"description\":\"包装请求参数到一个变量中\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : {
"wrap_request_parameter" : "data"
}
}
================================
return db.table("sys_dict_items").primary("id").saveOrUpdate(data)
@@ -0,0 +1,211 @@
{
"properties" : { },
"id" : "1fd1864c9c2d44c691302e7115a0168a",
"script" : null,
"groupId" : "376f26eb43a44a3daeafd27020a96f48",
"name" : "列表",
"createTime" : null,
"updateTime" : 1634736189568,
"lock" : "0",
"method" : "GET",
"path" : "/list",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": {\n \"total\": 17,\n \"list\": [\n {\n \"id\": \"56aee220-cb12-4bb2-8453-84ee49672193\",\n \"value\": \"3\",\n \"label\": \"3\",\n \"dictId\": \"4b9b4a7e-25a1-4efa-ab9a-a004f203f1f4\",\n \"remarks\": \"\",\n \"sort\": 30\n },\n {\n \"id\": \"6a127863-8130-48be-88bf-e5179f5c33e6\",\n \"value\": \"2\",\n \"label\": \"2\",\n \"dictId\": \"4b9b4a7e-25a1-4efa-ab9a-a004f203f1f4\",\n \"remarks\": \"\",\n \"sort\": 20\n },\n {\n \"id\": \"f19152f4-dd72-4509-a350-af70d802dcdf\",\n \"value\": \"1\",\n \"label\": \"1\",\n \"dictId\": \"4b9b4a7e-25a1-4efa-ab9a-a004f203f1f4\",\n \"remarks\": \"\",\n \"sort\": 10\n },\n {\n \"id\": \"ac1ee828-62e1-42fd-9d18-cf37203855b2\",\n \"value\": \"12\",\n \"label\": \"12\",\n \"dictId\": \"3c393981-9ddd-40b2-8c19-85f0a9d9a98f\",\n \"remarks\": \"\",\n \"sort\": 30\n },\n {\n \"id\": \"457517be-5245-4d98-b9fa-8b6753a9cfc6\",\n \"value\": \"2\",\n \"label\": \"公司\",\n \"dictId\": \"3c393981-9ddd-40b2-8c19-85f0a9d9a98f\",\n \"remarks\": \"\",\n \"sort\": 20\n },\n {\n \"id\": \"b928f5b1-07bd-4f09-9142-897c767c5303\",\n \"value\": \"1\",\n \"label\": \"部门\",\n \"dictId\": \"3c393981-9ddd-40b2-8c19-85f0a9d9a98f\",\n \"remarks\": \"\",\n \"sort\": 10\n },\n {\n \"id\": \"0f91de6e8406d59762bebe5d2dfc9d36\",\n \"value\": \"0\",\n \"label\": \"不禁用\",\n \"dictId\": \"ae9a2cd400264ff6bdc2f00b62d6e941\",\n \"remarks\": null,\n \"sort\": 0\n },\n {\n \"id\": \"c5cf8715a74537156ea29c8bbc622b05\",\n \"value\": \"1\",\n \"label\": \"禁用\",\n \"dictId\": \"ae9a2cd400264ff6bdc2f00b62d6e941\",\n \"remarks\": null,\n \"sort\": 0\n },\n {\n \"id\": \"ze9a2cd400264ff6bdc2f00b62d6e911\",\n \"value\": \"0\",\n \"label\": \"系统类\",\n \"dictId\": \"ae9a2cd400264ff6bdc2f00b62d6e911\",\n \"remarks\": null,\n \"sort\": 0\n },\n {\n \"id\": \"ze9a2cd400264ff6bdc2f00b62d6e910\",\n \"value\": \"1\",\n \"label\": \"业务类\",\n \"dictId\": \"ae9a2cd400264ff6bdc2f00b62d6e911\",\n \"remarks\": null,\n \"sort\": 0\n }\n ]\n },\n \"timestamp\": 1634735383948,\n \"executeTime\": 13\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "200",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "success",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "total",
"value" : "17",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "list",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Array",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "id",
"value" : "56aee220-cb12-4bb2-8453-84ee49672193",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "value",
"value" : "3",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "label",
"value" : "3",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "dictId",
"value" : "4b9b4a7e-25a1-4efa-ab9a-a004f203f1f4",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "remarks",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "sort",
"value" : "30",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
} ]
} ]
}, {
"name" : "timestamp",
"value" : "1634735383948",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "13",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
return db.page("""
select id,value,label,dict_id,remarks,sort from sys_dict_items
where is_del = 0
?{label, and label like concat('%',#{label},'%')}
?{dictId, and dict_id = #{dictId}}
?{value, and value like concat('%',#{value},'%')}
order by create_date desc
""")
@@ -0,0 +1,24 @@
{
"properties" : { },
"id" : "ed33e9c6270446118cf5674299778959",
"script" : null,
"groupId" : "376f26eb43a44a3daeafd27020a96f48",
"name" : "删除",
"createTime" : 1634735543067,
"updateTime" : 1634735543067,
"lock" : "0",
"method" : "POST",
"path" : "/delete",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.table("sys_dict_items").logic().where().eq("id",id).delete();
@@ -0,0 +1,98 @@
{
"properties" : { },
"id" : "18b186e0712449efa4e34c9ee75b0704",
"script" : null,
"groupId" : "376f26eb43a44a3daeafd27020a96f48",
"name" : "获取所有字典项",
"createTime" : null,
"updateTime" : 1634735167647,
"lock" : "0",
"method" : "GET",
"path" : "/all",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "{\r\n\t\r\n}",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 402,\n \"message\": \"凭证已过期\",\n \"data\": null,\n \"timestamp\": 1634093797926,\n \"executeTime\": null\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "402",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "凭证已过期",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634093797926",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
return db.select("""
select label,value,d.type from sys_dict_items it left join sys_dict d on d.id = it.dict_id where it.is_del = '0' and d.is_del = '0' order by it.sort
""")
@@ -0,0 +1,24 @@
{
"properties" : { },
"id" : "5d5fc243a5594f79b95ed279e184732e",
"script" : null,
"groupId" : "376f26eb43a44a3daeafd27020a96f48",
"name" : "获取排序号",
"createTime" : 1634735599490,
"updateTime" : 1634735599490,
"lock" : "0",
"method" : "GET",
"path" : "/sort",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.selectInt("""select max(sort) + 10 from sys_dict_items where dict_id = #{dictId} and is_del = '0'""") || 10;
@@ -0,0 +1,24 @@
{
"properties" : { },
"id" : "247133030553488a8871aa47b9f5e76c",
"script" : null,
"groupId" : "c7ce65f5b3cf4aaa913f6fec7d35d176",
"name" : "获取排序号",
"createTime" : null,
"updateTime" : 1634735056733,
"lock" : "0",
"method" : "GET",
"path" : "/sort",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.selectInt("""select max(sort) + 10 from sys_dict where is_del = '0'""") || 10;
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "fd3d225a1cf141bf9998c4ec4bf4a6ab",
"name" : "文件管理",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/file",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,35 @@
{
"properties" : { },
"id" : "cc20896df1c546fba56929cc75cb0309",
"script" : null,
"groupId" : "fd3d225a1cf141bf9998c4ec4bf4a6ab",
"name" : "上传",
"createTime" : null,
"updateTime" : 1635075982440,
"lock" : "0",
"method" : "POST",
"path" : "/upload",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
import 'org.ssssssss.magicboot.utils.FileUtils'
import request;
var map = FileUtils.saveFile(request.getFile('file'));
db.table("sys_file").primary("id").saveOrUpdate({
url: map.url,
externalId: externalId,
externalType: externalType
})
return map;
@@ -0,0 +1,33 @@
{
"properties" : { },
"id" : "a18a418e9d2a437dbdb51191340086c9",
"script" : null,
"groupId" : "fd3d225a1cf141bf9998c4ec4bf4a6ab",
"name" : "删除",
"createTime" : null,
"updateTime" : 1635075573670,
"lock" : "0",
"method" : "GET",
"path" : "/delete",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
import 'java.net.URLDecoder'
import 'org.ssssssss.magicboot.model.Global'
import 'org.ssssssss.magicboot.utils.FileUtils'
url = URLDecoder.decode(url, "UTF-8");
db.table("sys_file").where().eq("url",url).delete()
String realPath = Global.getUserFilesBaseDir() + "/" + url;
FileUtil.del(realPath);
@@ -0,0 +1,30 @@
{
"properties" : { },
"id" : "1d736fb0b9b54566943a0ea6696492c6",
"script" : null,
"groupId" : "fd3d225a1cf141bf9998c4ec4bf4a6ab",
"name" : "排序",
"createTime" : 1635074732708,
"updateTime" : 1635074732708,
"lock" : "0",
"method" : "GET",
"path" : "/resort",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
import 'java.net.URLDecoder'
for(index,url in urls.split(',')){
url = URLDecoder.decode(url, "UTF-8")
var id = db.selectValue("select id from sys_file where url = #{url}")
db.table("sys_file").column("sort",index + 1).where().eq("id",id).update()
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,35 @@
{
"properties" : { },
"id" : "874aea2c17ca4c79bcdff3d4cc458c87",
"script" : null,
"groupId" : "fd3d225a1cf141bf9998c4ec4bf4a6ab",
"name" : "裁剪",
"createTime" : null,
"updateTime" : 1635075977442,
"lock" : "0",
"method" : "POST",
"path" : "/cropper",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
import 'org.ssssssss.magicboot.model.Global'
import 'org.ssssssss.magicboot.utils.FileUtils'
url = URLDecoder.decode(url, "UTF-8");
String realPath = Global.getUserFilesBaseDir() + "/" + url;
FileUtil.del(realPath);
var map = FileUtils.saveFile(request.getFile('file'));
db.table("sys_file").column("url", map.url).where().eq("url", url).update()
return map
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "用户管理",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/user",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,42 @@
{
"properties" : { },
"id" : "877918736c764253a85d0780cbd5f763",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "保存",
"createTime" : null,
"updateTime" : 1634730816739,
"lock" : "0",
"method" : "POST",
"path" : "/save",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
import 'cn.dev33.satoken.secure.SaSecureUtil';
var user = {
id,
name,
username,
password: SaSecureUtil.sha256(password),
phone,
isLogin
}
if(id){
db.update("""
delete from sys_user_role where user_id = #{id}
""")
}
id = db.table("sys_user").primary("id").saveOrUpdate(user)
for(roleId in roles.split(',')){
db.table("sys_user_role").column('userId', id).column("roleId", roleId).insert()
}
@@ -0,0 +1,24 @@
{
"properties" : { },
"id" : "64ba47c2a11346e1972c63245cbf962c",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "修改登录状态",
"createTime" : null,
"updateTime" : 1634729738648,
"lock" : "0",
"method" : "GET",
"path" : "/change/login/status",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.table("sys_user").column("isLogin", isLogin).where().eq("id",id).update()
@@ -0,0 +1,38 @@
{
"properties" : { },
"id" : "4399f2eb199b46448aa98682fe792667",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "列表",
"createTime" : null,
"updateTime" : 1634738477796,
"lock" : "0",
"method" : "GET",
"path" : "/list",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.page("""
select
su.id,
su.username,
su.name,
su.is_login,
su.phone,
su.create_date
from sys_user su
where su.is_del = 0
?{username, and su.username like concat('%',#{username},'%')}
?{name, and su.name like concat('%',#{name},'%')}
?{isLogin, and su.is_login = #{isLogin}}
order by ${orderBy || 'su.create_date desc'}
""")
@@ -0,0 +1,27 @@
{
"properties" : { },
"id" : "c86e4f8fd4bc4d63bfaec8a53ea333cf",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "删除",
"createTime" : null,
"updateTime" : 1634731401903,
"lock" : "0",
"method" : "POST",
"path" : "/delete",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
for(userId in id.split(',')){
db.table("sys_user").logic().where().eq("id",userId).delete();
}
return true
@@ -0,0 +1,110 @@
{
"properties" : { },
"id" : "fc8e8dbfa2dd40e0922a22f680cde084",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "根据用户id获取角色列表",
"createTime" : null,
"updateTime" : 1634730972184,
"lock" : "0",
"method" : "GET",
"path" : "/roles",
"parameters" : [ {
"name" : "userId",
"value" : "674a3aa6b1ea4d91a1f72e7879d415c3",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : null,
"error" : null,
"expression" : null,
"children" : null
} ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 402,\n \"message\": \"凭证已过期\",\n \"data\": null,\n \"timestamp\": 1634729977953,\n \"executeTime\": null\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "402",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "凭证已过期",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634729977953",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
return db.select("""
select role_id from sys_user_role where user_id = #{userId}
""").map(it => {return it.roleId})
@@ -0,0 +1,101 @@
{
"properties" : { },
"id" : "5f05c02a8f60480c8c81f0cac54800df",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "获取用户信息",
"createTime" : 1634724871155,
"updateTime" : 1634724871155,
"lock" : "0",
"method" : "GET",
"path" : "/info",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "{}",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 402,\n \"message\": \"凭证已过期\",\n \"data\": null,\n \"timestamp\": 1634093332235,\n \"executeTime\": null\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "402",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "凭证已过期",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634093332235",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
import 'cn.dev33.satoken.stp.StpUtil';
import "@post:/security/permissions" as authoritiesList;
var user = db.table("sys_user").where().eq("id",StpUtil.getLoginId()).selectOne()
user.authorities = authoritiesList()
return user
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "67b2ce258e24491194b74992958c74aa",
"name" : "菜单管理",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/menu",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,26 @@
{
"properties" : { },
"id" : "d6d05df1e8b14a6ebc270113b2cdd1ed",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "保存",
"createTime" : 1634724871170,
"updateTime" : 1634724871170,
"lock" : "0",
"method" : "POST",
"path" : "/save",
"parameters" : [ ],
"option" : "[{\"name\":\"wrap_request_parameter\",\"value\":\"data\",\"description\":\"包装请求参数到一个变量中\"}]",
"requestBody" : "{}",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : {
"wrap_request_parameter" : "data"
}
}
================================
return db.table("sys_menu").primary("id").saveOrUpdate(data);
@@ -0,0 +1,26 @@
{
"properties" : { },
"id" : "62020bd7a49949378e90ce2d14fef8f7",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "修改是否显示",
"createTime" : 1634724871168,
"updateTime" : 1634724871168,
"lock" : "0",
"method" : "GET",
"path" : "/change/show",
"parameters" : [ ],
"option" : "[{\"name\":\"wrap_request_parameter\",\"value\":\"data\",\"description\":\"包装请求参数到一个变量中\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : {
"wrap_request_parameter" : "data"
}
}
================================
return db.table("sys_menu").primary("id").update(data)
@@ -0,0 +1,24 @@
{
"properties" : { },
"id" : "3564ad867beb48898f85c44bd3f7aa3f",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "删除",
"createTime" : 1634724871164,
"updateTime" : 1634724871164,
"lock" : "0",
"method" : "POST",
"path" : "/delete",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.table("sys_menu").logic().where().eq("id",id).delete();
File diff suppressed because one or more lines are too long
@@ -0,0 +1,110 @@
{
"properties" : { },
"id" : "9f4ebd1f444341c593a3d2a79d1a3356",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "根据角色获取菜单",
"createTime" : 1634724871165,
"updateTime" : 1634724871165,
"lock" : "0",
"method" : "GET",
"path" : "/by/role",
"parameters" : [ {
"name" : "roleId",
"value" : "4d80f40315f747768d5b14095a0a7336",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : null,
"error" : null,
"expression" : null,
"children" : null
} ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": [],\n \"timestamp\": 1634310952202,\n \"executeTime\": 9\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "200",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "success",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Array",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634310952202",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "9",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
return db.select("""
select sm.id,sm.name from sys_menu sm join sys_role_menu srm on sm.id = srm.menu_id and srm.role_id = #{roleId} where sm.is_del = 0
""")
@@ -0,0 +1,36 @@
{
"properties" : { },
"id" : "4f966df34dbe41ff8b9941da4671eb2d",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "获取排序号",
"createTime" : 1634724871167,
"updateTime" : 1634724871167,
"lock" : "0",
"method" : "GET",
"path" : "/sort",
"parameters" : [ {
"name" : "pid",
"value" : "",
"description" : "",
"required" : true,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : null,
"error" : null,
"expression" : null,
"children" : null
} ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.selectInt("""select max(sort) + 10 from sys_menu where pid = #{pid} and is_del = '0'""") || 10;
@@ -0,0 +1,102 @@
{
"properties" : { },
"id" : "ffb6988226d14e6789cc30193e008183",
"script" : null,
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "获取菜单tree",
"createTime" : 1634724871168,
"updateTime" : 1634724871168,
"lock" : "0",
"method" : "GET",
"path" : "/tree",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "{\r\n\t\r\n}",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 402,\n \"message\": \"凭证已过期\",\n \"data\": null,\n \"timestamp\": 1634309660370,\n \"executeTime\": null\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "402",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "凭证已过期",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1634309660370",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
var toTree = (list,pid) => select t.*,toTree(list,t.id) children from list t where t.pid = pid
var list = toTree(db.select('select id,name,pid,is_show,url,sort,permission,desc_ribe from sys_menu where is_del = 0 order by sort'),'0')
return {
list: list,
total: list.getLength()
}
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "89130d496f6f467c88b22ae4a7f688eb",
"name" : "角色管理",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/role",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,38 @@
{
"properties" : { },
"id" : "f9a5956afdfd4492966b1a3c04dbadf6",
"script" : null,
"groupId" : "89130d496f6f467c88b22ae4a7f688eb",
"name" : "保存",
"createTime" : null,
"updateTime" : 1634730841303,
"lock" : "0",
"method" : "POST",
"path" : "/save",
"parameters" : [ ],
"option" : "[{\"name\":\"\",\"value\":\"\",\"description\":\"\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : {
"" : ""
}
}
================================
var role = {
type,
name,
sort,
id
}
if(id){
db.table("sys_role_menu").where().eq("role_id",id).delete()
}
id = db.table("sys_role").primary("id").saveOrUpdate(role);
for(menuId in menus.split(',')){
db.table("sys_role_menu").column("menu_id",menuId).column("role_id", id).insert();
}
@@ -0,0 +1,161 @@
{
"properties" : { },
"id" : "9a204a5c8a8243f7b07e842f87d4d65b",
"script" : null,
"groupId" : "89130d496f6f467c88b22ae4a7f688eb",
"name" : "列表",
"createTime" : 1634724871177,
"updateTime" : 1634724871177,
"lock" : "0",
"method" : "GET",
"path" : "/list",
"parameters" : [ ],
"option" : "[{\"name\":\"permission\",\"value\":\"role:view\",\"description\":\"允许拥有该权限的访问\"}]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": {\n \"total\": 1,\n \"list\": [\n {\n \"id\": \"1\",\n \"name\": \"管理员\"\n }\n ]\n },\n \"timestamp\": 1634309991187,\n \"executeTime\": 5\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "200",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "success",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "total",
"value" : "1",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "list",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Array",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "id",
"value" : "1",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "name",
"value" : "管理员",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
} ]
} ]
}, {
"name" : "timestamp",
"value" : "1634309991187",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "5",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : {
"permission" : "role:view"
}
}
================================
return db.page("""
select id, name from sys_role where is_del = 0
?{name, and name like concat('%',#{name},'%')}
""")
@@ -0,0 +1,24 @@
{
"properties" : { },
"id" : "633b78b93bba43fba785c71c1c18d7f7",
"script" : null,
"groupId" : "89130d496f6f467c88b22ae4a7f688eb",
"name" : "删除",
"createTime" : 1634724871175,
"updateTime" : 1634724871175,
"lock" : "0",
"method" : "POST",
"path" : "/delete",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : null,
"optionMap" : { }
}
================================
return db.table("sys_role").logic().where().eq("id",id).delete();
@@ -0,0 +1,10 @@
{
"properties" : { },
"id" : "5c36bdc1de454d6e9d1a464d87c96091",
"name" : "配置",
"type" : "1",
"parentId" : "02df51e4d7184780a98b632f43dc5848",
"path" : "/config",
"paths" : [ ],
"options" : [ ]
}
@@ -0,0 +1,111 @@
{
"properties" : { },
"id" : "cd127e22d1de486780316887a73996f0",
"script" : null,
"groupId" : "5c36bdc1de454d6e9d1a464d87c96091",
"name" : "获取所有配置",
"createTime" : null,
"updateTime" : 1635043799494,
"lock" : "0",
"method" : "GET",
"path" : "/list",
"parameters" : [ ],
"option" : "[]",
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 402,\n \"message\": \"凭证已过期\",\n \"data\": null,\n \"timestamp\": 1635043795053,\n \"executeTime\": null\n}",
"description" : null,
"requestBodyDefinition" : null,
"responseBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ {
"name" : "code",
"value" : "402",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "message",
"value" : "凭证已过期",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "data",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "timestamp",
"value" : "1635043795053",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "null",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
},
"optionMap" : { }
}
================================
return {
filePrefix: '1',
upload: {
// oss,disk(磁盘)
type: 'disk',
dir: 'D:/psyduck/',
oss: {
endpoint: '',
accessKeyId: '',
accessKeySecret: '',
bucketName: '',
// https,http
transportProtocol: ''
}
}
}
File diff suppressed because one or more lines are too long
+71
View File
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/>
</parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-boot</artifactId>
<version>0.0.1</version>
<name>magic-boot</name>
<description>magic-boot</description>
<properties>
<java.version>1.8</java.version>
<magic-api.version>1.5.3</magic-api.version>
<druid.version>1.2.1</druid.version>
<hutool-all.version>5.7.13</hutool-all.version>
<sa-token.version>1.26.0</sa-token.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-spring-boot-starter</artifactId>
<version>${magic-api.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool-all.version}</version>
</dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-boot-starter</artifactId>
<version>${sa-token.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>magic-boot</finalName>
<mainClass>org.ssssssss.magicboot.MagicBootApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,13 @@
package org.ssssssss.magicboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MagicBootApplication {
public static void main(String[] args) {
SpringApplication.run(MagicBootApplication.class, args);
}
}
@@ -0,0 +1,19 @@
package org.ssssssss.magicboot.configuration;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Configuration
public class MagicBootConfiguration {
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeSerializer);
}
}
@@ -0,0 +1,31 @@
package org.ssssssss.magicboot.extension;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.modules.table.NamedTable;
import org.ssssssss.magicboot.model.MagicBootConstants;
import org.ssssssss.script.annotation.Comment;
import org.ssssssss.script.functions.ExtensionMethod;
import java.util.Map;
@Component
public class NamedTableFunctionExtension implements ExtensionMethod {
@Override
public Class<?> support() {
return NamedTable.class;
}
@Comment("保存到表中,当主键有值时则修改,否则插入")
public static Object saveOrUpdate(NamedTable namedTable, @Comment("各项列和值") Map<String, Object> data){
namedTable.setAttribute(MagicBootConstants.COMMON_FIELD, true);
namedTable.save(data,true);
return namedTable.getAttribute(MagicBootConstants.ID);
}
@Comment("保存到表中,当主键有值时则修改,否则插入")
public static Object saveOrUpdate(NamedTable namedTable){
return saveOrUpdate(namedTable, null);
}
}
@@ -0,0 +1,34 @@
package org.ssssssss.magicboot.interceptor;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.IdUtil;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.interceptor.NamedTableInterceptor;
import org.ssssssss.magicapi.model.SqlMode;
import org.ssssssss.magicapi.modules.table.NamedTable;
import static org.ssssssss.magicboot.model.MagicBootConstants.*;
import java.util.Date;
@Component
public class NamedTableHandlerInterceptor implements NamedTableInterceptor {
@Override
public void preHandle(SqlMode sqlMode, NamedTable namedTable) {
if(Boolean.TRUE == namedTable.getAttribute(COMMON_FIELD)){
if(sqlMode == SqlMode.INSERT) {
String id = IdUtil.simpleUUID();
namedTable.setAttribute(namedTable.getPrimary(), id);
namedTable.column(namedTable.getPrimary(), id);
namedTable.column(CREATE_BY, StpUtil.getLoginId());
namedTable.column(CREATE_DATE, new Date());
}
if(sqlMode == SqlMode.UPDATE){
namedTable.setAttribute(namedTable.getPrimary(), namedTable.getColumns().get(namedTable.getPrimary()));
namedTable.column(UPDATE_BY, StpUtil.getLoginId());
namedTable.column(UPDATE_DATE, new Date());
}
}
}
}
@@ -0,0 +1,49 @@
package org.ssssssss.magicboot.interceptor;
import cn.dev33.satoken.stp.StpUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.interceptor.RequestInterceptor;
import org.ssssssss.magicapi.model.ApiInfo;
import org.ssssssss.magicapi.model.Options;
import org.ssssssss.magicapi.provider.MagicAPIService;
import org.ssssssss.magicboot.model.StatusCode;
import org.ssssssss.script.MagicScriptContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Objects;
@Component
@Order(1)
public class PermissionInterceptor implements RequestInterceptor {
@Autowired
MagicAPIService magicAPIService;
/*
* 当返回对象时,直接将此对象返回到页面,返回null时,继续执行后续操作
*/
@Override
public Object preHandle(ApiInfo info, MagicScriptContext context, HttpServletRequest request, HttpServletResponse response) {
String requireLogin = Objects.toString(info.getOptionValue(Options.REQUIRE_LOGIN), "");
if(requireLogin.equals("false")){
return null;
}
if(!StpUtil.isLogin()){
return StatusCode.CERTIFICATE_EXPIRED.json();
} else {
// TODO
List<String> permissions = (List<String>) magicAPIService.execute("post", "/security/permissions", null);
String permission = Objects.toString(info.getOptionValue(Options.PERMISSION), "");
if (StringUtils.isNotBlank(permission) && !permissions.contains(permission)) {
return StatusCode.FORBIDDEN.json();
}
}
return null;
}
}
@@ -0,0 +1,89 @@
package org.ssssssss.magicboot.model;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.ssssssss.magicboot.utils.WebUtils;
@Component
public class Global {
/**
* 文件上的根目录
*/
public static String dir;
public final static String USER_FILES_BASE_URL = "/userfiles/";
public static String getDir() {
return dir;
}
@Value("${upload.dir:D:/psyduck/}")
public void setDir(String dir) {
this.dir = dir;
}
/**
* 获取上传文件的根目录
*
* @return
*/
public static String getUserFilesBaseDir() {
String dir = getDir();
if (StrUtil.isBlank(dir)) {
try {
dir = WebUtils.getHttpServletRequest().getSession().getServletContext().getRealPath("/");
} catch (Exception e) {
return "";
}
}
if (!dir.endsWith("/")) {
dir += "/";
}
return dir;
}
public static String OSS_ENDPOINT;
public static String OSS_ACCESS_KEY_ID;
public static String OSS_ACCESS_KEY_SECRET;
public static String OSS_BUCKET_NAME;
public static String OSS_TRANSPORT_PROTOCOL;
@Value("${upload.oss.endpoint}")
public void setOssEndpoint(String ossEndpoint) {
OSS_ENDPOINT = ossEndpoint;
}
@Value("${upload.oss.access-key-id}")
public void setOssAccessKeyId(String ossAccessKeyId) {
OSS_ACCESS_KEY_ID = ossAccessKeyId;
}
@Value("${upload.oss.access-key-secret}")
public void setOssAccessKeySecret(String ossAccessKeySecret) {
OSS_ACCESS_KEY_SECRET = ossAccessKeySecret;
}
@Value("${upload.oss.bucket-name}")
public void setOssBucketName(String ossBucketName) {
OSS_BUCKET_NAME = ossBucketName;
}
@Value("${upload.oss.transport-protocol:https}")
public void setOssTransportProtocol(String ossTransportProtocol) {
OSS_TRANSPORT_PROTOCOL = ossTransportProtocol;
}
public static String UPLOAD_TYPE;
@Value("${upload.type}")
public void setUploadType(String uploadType) {
UPLOAD_TYPE = uploadType;
}
}
@@ -0,0 +1,37 @@
package org.ssssssss.magicboot.model;
/**
* Magic Boot 中使用的常量
*/
public class MagicBootConstants {
/**
* 设置通用字段
*/
public static final String COMMON_FIELD = "setCommonField";
/**
* id
*/
public static final String ID = "id";
/**
* 创建人
*/
public static final String CREATE_BY = "createBy";
/**
* 修改人
*/
public static final String UPDATE_BY = "updateBy";
/**
* 创建时间
*/
public static final String CREATE_DATE = "createDate";
/**
* 修改时间
*/
public static final String UPDATE_DATE = "updateDate";
}
@@ -0,0 +1,23 @@
package org.ssssssss.magicboot.model;
import org.ssssssss.magicapi.model.JsonBean;
public enum StatusCode {
CERTIFICATE_EXPIRED(402, "凭证已过期"),
FORBIDDEN(403, "禁止访问");
StatusCode(int code, String message) {
this.code = code;
this.message = message;
}
private int code;
private String message;
public JsonBean json(){
return new JsonBean<>(this.code, this.message);
}
}
@@ -0,0 +1,348 @@
package org.ssssssss.magicboot.model;
import org.ssssssss.magicboot.utils.WebUtils;
public class UeditorConfig {
private String imageActionName ="uploadImage";//执行上传图片的action名称
private String imageFieldName = "file";//提交的图片表单名称
private long imageMaxSize = 2048000;//上传大小限制,单位B
private String[] imageAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"};/* 上传图片格式显示 */
private boolean imageCompressEnable = true;//是否压缩图片,默认是true
private int imageCompressBorder = 1600;//图片压缩最长边限制
private String imageInsertAlign = "none";//插入的图片浮动方式
private String imageUrlPrefix = WebUtils.getUeditorPrefix();//图片访问路径前缀
/* 上传保存路径,可以自定义保存路径和文件名格式 */
/* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
/* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
/* {time} 会替换成时间戳 */
/* {yyyy} 会替换成四位年份 */
/* {yy} 会替换成两位年份 */
/* {mm} 会替换成两位月份 */
/* {dd} 会替换成两位日期 */
/* {hh} 会替换成两位小时 */
/* {ii} 会替换成两位分钟 */
/* {ss} 会替换成两位秒 */
/* 非法字符 \ : * ? " < > | */
/* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */
private String imagePathFormat = "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}";
/*抓取远程图片配置*/
private String catcherLocalDomain[] = new String[]{"127.0.0.1", "localhost", "img.baidu.com"};
private String catcherActionName = "catchimage";/* 执行抓取远程图片的action名称 */
private String catcherFieldName = "source";/* 提交的图片列表表单名称 */
private String catcherPathFormat ="/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
private long catcherMaxSize= 2048000; /* 上传大小限制,单位B */
private String catcherAllowFiles[] = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"}; /* 抓取图片格式显示 */
/* 上传文件配置 */
private String fileActionName = "uploadFile";
private String fileFieldName = "file"; /* 提交的文件表单名称 */
private String filePathFormat = "/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}"; /* 上传保存路径,可以自定义保存路径和文件名格式 */
private String fileUrlPrefix = WebUtils.getUeditorPrefix(); /* 文件访问路径前缀 */
private long fileMaxSize = 51200000; /* 上传大小限制,单位B,默认50MB */
/* 上传文件格式显示 */
private String[] fileAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp",".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg", ".ogv", ".mov", ".wmv", ".mp4",".mp3", ".wav", ".mid",".rar", ".zip", ".tar", ".gz", ".7z",".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt"};
/* 列出指定目录下的图片 */
private String imageManagerActionName = "listimage";/* 执行图片管理的action名称 */
private String imageManagerListPath = "/upload/image/"; /* 指定要列出图片的目录 */
private int imageManagerListSize = 20; /* 每次列出文件数量 */
private String imageManagerUrlPrefix = WebUtils.getUeditorPrefix(); /* 图片访问路径前缀 */
private String imageManagerInsertAlign = "none"; /* 插入的图片浮动方式 */
private String[] imageManagerAllowFiles = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"}; /* 列出的文件类型 */
/* 列出指定目录下的文件 */
private String fileManagerActionName = "listfile";/* 执行文件管理的action名称 */
private String fileManagerListPath = "/upload/file/"; /* 指定要列出文件的目录 */
private String fileManagerUrlPrefix = WebUtils.getUeditorPrefix(); /* 文件访问路径前缀 */
private int fileManagerListSize = 20; /* 每次列出文件数量 */
/* 列出的文件类型 */
private String fileManagerAllowFiles[] = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp",".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg", ".ogv", ".mov", ".wmv", ".mp4",".mp3", ".wav", ".mid",".rar", ".zip", ".tar", ".gz", ".7z",".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt"};
public String getImageActionName() {
return imageActionName;
}
public void setImageActionName(String imageActionName) {
this.imageActionName = imageActionName;
}
public String getImageFieldName() {
return imageFieldName;
}
public void setImageFieldName(String imageFieldName) {
this.imageFieldName = imageFieldName;
}
public long getImageMaxSize() {
return imageMaxSize;
}
public void setImageMaxSize(long imageMaxSize) {
this.imageMaxSize = imageMaxSize;
}
public String[] getImageAllowFiles() {
return imageAllowFiles;
}
public void setImageAllowFiles(String[] imageAllowFiles) {
this.imageAllowFiles = imageAllowFiles;
}
public boolean isImageCompressEnable() {
return imageCompressEnable;
}
public void setImageCompressEnable(boolean imageCompressEnable) {
this.imageCompressEnable = imageCompressEnable;
}
public int getImageCompressBorder() {
return imageCompressBorder;
}
public void setImageCompressBorder(int imageCompressBorder) {
this.imageCompressBorder = imageCompressBorder;
}
public String getImageInsertAlign() {
return imageInsertAlign;
}
public void setImageInsertAlign(String imageInsertAlign) {
this.imageInsertAlign = imageInsertAlign;
}
public String getImageUrlPrefix() {
return imageUrlPrefix;
}
public void setImageUrlPrefix(String imageUrlPrefix) {
this.imageUrlPrefix = imageUrlPrefix;
}
public String getImagePathFormat() {
return imagePathFormat;
}
public void setImagePathFormat(String imagePathFormat) {
this.imagePathFormat = imagePathFormat;
}
public String[] getCatcherLocalDomain() {
return catcherLocalDomain;
}
public void setCatcherLocalDomain(String[] catcherLocalDomain) {
this.catcherLocalDomain = catcherLocalDomain;
}
public String getCatcherActionName() {
return catcherActionName;
}
public void setCatcherActionName(String catcherActionName) {
this.catcherActionName = catcherActionName;
}
public String getCatcherFieldName() {
return catcherFieldName;
}
public void setCatcherFieldName(String catcherFieldName) {
this.catcherFieldName = catcherFieldName;
}
public String getCatcherPathFormat() {
return catcherPathFormat;
}
public void setCatcherPathFormat(String catcherPathFormat) {
this.catcherPathFormat = catcherPathFormat;
}
public long getCatcherMaxSize() {
return catcherMaxSize;
}
public void setCatcherMaxSize(long catcherMaxSize) {
this.catcherMaxSize = catcherMaxSize;
}
public String[] getCatcherAllowFiles() {
return catcherAllowFiles;
}
public void setCatcherAllowFiles(String[] catcherAllowFiles) {
this.catcherAllowFiles = catcherAllowFiles;
}
public String getFileActionName() {
return fileActionName;
}
public void setFileActionName(String fileActionName) {
this.fileActionName = fileActionName;
}
public String getFileFieldName() {
return fileFieldName;
}
public void setFileFieldName(String fileFieldName) {
this.fileFieldName = fileFieldName;
}
public String getFilePathFormat() {
return filePathFormat;
}
public void setFilePathFormat(String filePathFormat) {
this.filePathFormat = filePathFormat;
}
public String getFileUrlPrefix() {
return fileUrlPrefix;
}
public void setFileUrlPrefix(String fileUrlPrefix) {
this.fileUrlPrefix = fileUrlPrefix;
}
public long getFileMaxSize() {
return fileMaxSize;
}
public void setFileMaxSize(long fileMaxSize) {
this.fileMaxSize = fileMaxSize;
}
public String[] getFileAllowFiles() {
return fileAllowFiles;
}
public void setFileAllowFiles(String[] fileAllowFiles) {
this.fileAllowFiles = fileAllowFiles;
}
public String getImageManagerActionName() {
return imageManagerActionName;
}
public void setImageManagerActionName(String imageManagerActionName) {
this.imageManagerActionName = imageManagerActionName;
}
public String getImageManagerListPath() {
return imageManagerListPath;
}
public void setImageManagerListPath(String imageManagerListPath) {
this.imageManagerListPath = imageManagerListPath;
}
public int getImageManagerListSize() {
return imageManagerListSize;
}
public void setImageManagerListSize(int imageManagerListSize) {
this.imageManagerListSize = imageManagerListSize;
}
public String getImageManagerUrlPrefix() {
return imageManagerUrlPrefix;
}
public void setImageManagerUrlPrefix(String imageManagerUrlPrefix) {
this.imageManagerUrlPrefix = imageManagerUrlPrefix;
}
public String getImageManagerInsertAlign() {
return imageManagerInsertAlign;
}
public void setImageManagerInsertAlign(String imageManagerInsertAlign) {
this.imageManagerInsertAlign = imageManagerInsertAlign;
}
public String[] getImageManagerAllowFiles() {
return imageManagerAllowFiles;
}
public void setImageManagerAllowFiles(String[] imageManagerAllowFiles) {
this.imageManagerAllowFiles = imageManagerAllowFiles;
}
public String getFileManagerActionName() {
return fileManagerActionName;
}
public void setFileManagerActionName(String fileManagerActionName) {
this.fileManagerActionName = fileManagerActionName;
}
public String getFileManagerListPath() {
return fileManagerListPath;
}
public void setFileManagerListPath(String fileManagerListPath) {
this.fileManagerListPath = fileManagerListPath;
}
public String getFileManagerUrlPrefix() {
return fileManagerUrlPrefix;
}
public void setFileManagerUrlPrefix(String fileManagerUrlPrefix) {
this.fileManagerUrlPrefix = fileManagerUrlPrefix;
}
public int getFileManagerListSize() {
return fileManagerListSize;
}
public void setFileManagerListSize(int fileManagerListSize) {
this.fileManagerListSize = fileManagerListSize;
}
public String[] getFileManagerAllowFiles() {
return fileManagerAllowFiles;
}
public void setFileManagerAllowFiles(String[] fileManagerAllowFiles) {
this.fileManagerAllowFiles = fileManagerAllowFiles;
}
}
@@ -0,0 +1,55 @@
package org.ssssssss.magicboot.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import org.springframework.web.multipart.MultipartFile;
import org.ssssssss.magicboot.model.Global;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class FileUtils {
public static Map<String, String> createFileAttr(String originalFilename){
String ret = Global.USER_FILES_BASE_URL + DateUtil.today() + "/" + IdUtil.simpleUUID() + "/";
String suffix = FileUtil.getSuffix(originalFilename);
Map<String, String> map = new HashMap<>();
map.put("ret", ret);
map.put("filePath", ret.substring(1) + originalFilename);
map.put("fileNames", originalFilename);
map.put("suffix", suffix);
return map;
}
public static Map<String, String> saveFile(MultipartFile file) {
Map<String, String> fileAttr = createFileAttr(file.getOriginalFilename());
String fileNames = fileAttr.get("fileNames");
String ret = fileAttr.get("ret");
String suffix = fileAttr.get("suffix");
String realPath = Global.getUserFilesBaseDir() + ret;
FileUtil.mkdir(FileUtil.normalize(realPath));
File tempFile = new File(realPath + fileNames);
if (!tempFile.getParentFile().exists()) {
tempFile.getParentFile().mkdir();
}
try {
if (!tempFile.exists()) {
file.transferTo(tempFile);
}
} catch (IOException e) {
e.printStackTrace();
}
Map<String, String> params = new HashMap<>();
params.put("state", "SUCCESS");
params.put("original", file.getName());
params.put("name", file.getName());
params.put("size", file.getSize() + "");
params.put("type", suffix);
params.put("url", fileAttr.get("filePath"));
return params;
}
}
@@ -0,0 +1,28 @@
package org.ssssssss.magicboot.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.ssssssss.magicboot.model.Global;
import javax.servlet.http.HttpServletRequest;
public class WebUtils {
public static HttpServletRequest getHttpServletRequest(){
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
public static String getContextUrl() {
HttpServletRequest request = getHttpServletRequest();
StringBuffer url = request.getRequestURL();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(request.getServletContext().getContextPath()).append("/").toString();
}
public static String getUeditorPrefix(){
if(Global.UPLOAD_TYPE.equals("oss")){
return Global.OSS_TRANSPORT_PROTOCOL + "://" + Global.OSS_BUCKET_NAME + "." + Global.OSS_ENDPOINT + "/";
}
return getContextUrl();
}
}
@@ -0,0 +1,16 @@
package test;
import cn.dev33.satoken.secure.SaSecureUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.ssssssss.magicboot.MagicBootApplication;
@SpringBootTest(classes = MagicBootApplication.class)
public class MagicBootTest {
@Test
public void test(){
System.out.println(SaSecureUtil.sha256("1"));
}
}
@@ -0,0 +1,69 @@
server:
port: 8081
compression:
enabled: true
min-response-size: 128
spring:
servlet:
multipart:
max-file-size: 200MB
max-request-size: 200MB
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
datasource:
url: jdbc:mysql://localhost:3307/magic-boot?useSSL=false&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF8&autoReconnect=true&serverTimezone=Asia/Shanghai
username: root
password: root
upload:
# oss,disk(磁盘)
type: disk
dir: D:/psyduck/
oss:
endpoint:
access-key-id:
access-key-secret:
bucket-name:
# https,http
transport-protocol:
magic-api:
web: /magic/web
sql-column-case: camel
page-config:
page: current
size: size
cache-config:
enable: true #开启缓存,默认是不开启的
ttl: 3600000 #有效期1小时,默认-1 即永不过期
resource:
location: data/magic-api
response-code-config:
success: 200 #执行成功的code值
invalid: 400 #参数验证未通过的code值
exception: 500 #执行出现异常的code值
crud-config: # CRUD相关配置
logic-delete-column: is_del #逻辑删除列
logic-delete-value: 1 #逻辑删除值
# security-config:
# username: admin
# password: 123456
# Sa-Token配置
sa-token:
# token名称 (同时也是cookie名称)
token-name: token
# token有效期,单位s 默认30天, -1代表永不过期
timeout: 2592000
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: -1
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# token风格
token-style: uuid
# 是否输出操作日志
is-log: false