magic-boot/data/magic-api/api/系统管理/角色管理/保存.ms

82 lines
2.0 KiB
Plaintext
Raw Normal View History

2021-10-24 20:09:53 +08:00
{
"properties" : { },
"id" : "f9a5956afdfd4492966b1a3c04dbadf6",
"script" : null,
"groupId" : "89130d496f6f467c88b22ae4a7f688eb",
"name" : "保存",
2022-03-30 23:54:24 +08:00
"createTime" : null,
"updateTime" : 1665500810912,
2021-10-24 20:09:53 +08:00
"lock" : "0",
"createBy" : null,
"updateBy" : "guyi",
2021-10-24 20:09:53 +08:00
"path" : "/save",
"method" : "POST",
2021-10-24 20:09:53 +08:00
"parameters" : [ ],
"options" : [ {
"name" : "permission",
"value" : "role:save",
"description" : "允许拥有该权限的访问",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : null,
"error" : null,
"expression" : null,
"children" : null
} ],
2022-02-06 12:34:56 +08:00
"requestBody" : "{\n\n}",
2021-10-24 20:09:53 +08:00
"headers" : [ ],
"paths" : [ ],
"responseBody" : null,
"description" : null,
2022-03-30 23:54:24 +08:00
"requestBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
},
"responseBodyDefinition" : null
2021-10-24 20:09:53 +08:00
}
================================
2022-03-30 23:54:24 +08:00
import '@get:/system/role/cache/delete' as cacheDelete
2022-01-04 14:56:52 +08:00
2022-02-05 17:20:12 +08:00
var codeCount = db.selectInt("select count(1) from sys_role where is_del = 0 and code = #{code} ?{id, and id != #{id}}")
if(codeCount > 0){
exit 0,'角色编码已存在'
}
2021-10-24 20:09:53 +08:00
var role = {
code,
permission,
descRibe,
2021-10-24 20:09:53 +08:00
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();
}
2022-01-16 18:10:18 +08:00
db.table("sys_role_office").where().eq("role_id",id).delete()
if(offices && permission == 1){
for(officeId in offices.split(',')){
db.table("sys_role_office").column("office_id",officeId).column("role_id", id).insert();
}
}
if(id){
// 先删除数据库 后删除缓存 不然拦截器会请求查询数据库 查到的还是老数据
var roleId = id
cacheDelete()
}