2021-10-24 20:09:53 +08:00
|
|
|
{
|
|
|
|
"properties" : { },
|
|
|
|
"id" : "877918736c764253a85d0780cbd5f763",
|
|
|
|
"script" : null,
|
|
|
|
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
|
|
|
|
"name" : "保存",
|
|
|
|
"createTime" : null,
|
2022-02-05 17:20:12 +08:00
|
|
|
"updateTime" : 1644046192172,
|
2021-10-24 20:09:53 +08:00
|
|
|
"lock" : "0",
|
|
|
|
"method" : "POST",
|
|
|
|
"path" : "/save",
|
|
|
|
"parameters" : [ ],
|
|
|
|
"option" : "[]",
|
|
|
|
"requestBody" : "",
|
|
|
|
"headers" : [ ],
|
|
|
|
"paths" : [ ],
|
|
|
|
"responseBody" : null,
|
|
|
|
"description" : null,
|
|
|
|
"requestBodyDefinition" : null,
|
|
|
|
"responseBodyDefinition" : null,
|
|
|
|
"optionMap" : { }
|
|
|
|
}
|
|
|
|
================================
|
2022-02-01 18:26:42 +08:00
|
|
|
import cn.dev33.satoken.secure.SaSecureUtil;
|
2022-01-04 14:56:52 +08:00
|
|
|
import org.ssssssss.magicapi.cache.SqlCache
|
2021-10-24 20:09:53 +08:00
|
|
|
|
2022-02-05 17:20:12 +08:00
|
|
|
var usernameCount = db.selectInt("select count(1) from sys_user where is_del = 0 and username = #{username} ?{id, and id != #{id}}")
|
|
|
|
if(usernameCount > 0){
|
|
|
|
exit 0,'登录名称已存在'
|
|
|
|
}
|
|
|
|
|
2022-01-04 14:56:52 +08:00
|
|
|
password = password ? SaSecureUtil.sha256(password) : ''
|
2021-10-24 20:09:53 +08:00
|
|
|
var user = {
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
username,
|
2022-01-04 14:56:52 +08:00
|
|
|
password: password,
|
2021-10-24 20:09:53 +08:00
|
|
|
phone,
|
2022-01-13 23:29:56 +08:00
|
|
|
isLogin,
|
|
|
|
officeId
|
2021-10-24 20:09:53 +08:00
|
|
|
}
|
|
|
|
if(id){
|
2022-01-04 14:56:52 +08:00
|
|
|
SqlCache.delete(`permissions:${id}`)
|
2021-10-24 20:09:53 +08:00
|
|
|
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(',')){
|
2022-01-04 14:56:52 +08:00
|
|
|
db.table("sys_user_role").column('user_id', id).column("role_id", roleId).insert()
|
2021-10-24 20:09:53 +08:00
|
|
|
}
|