magic-boot/data/magic-api/api/系统管理/用户管理/导入数据预览.ms

257 lines
33 KiB
Plaintext
Raw Normal View History

2022-04-02 11:16:06 +08:00
{
"properties" : { },
"id" : "49683f16141d4a808ce925b49affff29",
"script" : null,
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "导入数据预览",
"createTime" : null,
2022-05-09 21:49:00 +08:00
"updateTime" : 1651932636716,
2022-04-02 11:16:06 +08:00
"lock" : null,
"createBy" : null,
"updateBy" : null,
"path" : "/import/preview",
"method" : "POST",
"parameters" : [ {
"name" : "file",
"value" : { },
"description" : null,
"required" : false,
"dataType" : "MultipartFile",
"type" : null,
"defaultValue" : null,
"validateType" : null,
"error" : null,
"expression" : null,
"children" : null
} ],
2022-05-09 21:49:00 +08:00
"options" : [ {
"name" : "permission",
"value" : "user:import:preview",
"description" : "允许拥有该权限的访问",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : null,
"error" : null,
"expression" : null,
"children" : null
} ],
2022-04-02 11:16:06 +08:00
"requestBody" : "",
"headers" : [ ],
"paths" : [ ],
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": {\n \"sourceDatas\": \"[{\\\"登录名称\\\":\\\"test1\\\",\\\"密码\\\":1,\\\"姓名/昵称\\\":\\\"test1\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393296},{\\\"登录名称\\\":\\\"test2\\\",\\\"密码\\\":2,\\\"姓名/昵称\\\":\\\"test2\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393297},{\\\"登录名称\\\":\\\"test3\\\",\\\"密码\\\":3,\\\"姓名/昵称\\\":\\\"test3\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393298},{\\\"登录名称\\\":\\\"test4\\\",\\\"密码\\\":4,\\\"姓名/昵称\\\":\\\"test4\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393299},{\\\"登录名称\\\":\\\"test5\\\",\\\"密码\\\":5,\\\"姓名/昵称\\\":\\\"test5\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393300},{\\\"登录名称\\\":\\\"test6\\\",\\\"密码\\\":6,\\\"姓名/昵称\\\":\\\"test6\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393301},{\\\"登录名称\\\":\\\"test7\\\",\\\"密码\\\":7,\\\"姓名/昵称\\\":\\\"test7\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393302},{\\\"登录名称\\\":\\\"test8\\\",\\\"密码\\\":8,\\\"姓名/昵称\\\":\\\"test8\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393303},{\\\"登录名称\\\":\\\"test9\\\",\\\"密码\\\":9,\\\"姓名/昵称\\\":\\\"test9\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393304},{\\\"登录名称\\\":\\\"test10\\\",\\\"密码\\\":10,\\\"姓名/昵称\\\":\\\"test10\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393305},{\\\"登录名称\\\":\\\"test11\\\",\\\"密码\\\":11,\\\"姓名/昵称\\\":\\\"test11\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393306},{\\\"登录名称\\\":\\\"test12\\\",\\\"密码\\\":12,\\\"姓名/昵称\\\":\\\"test12\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393307},{\\\"登录名称\\\":\\\"test13\\\",\\\"密码\\\":13,\\\"姓名/昵称\\\":\\\"test13\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393308},{\\\"登录名称\\\":\\\"test14\\\",\\\"密码\\\":14,\\\"姓名/昵称\\\":\\\"test14\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393309},{\\\"登录名称\\\":\\\"test15\\\",\\\"密码\\\":15,\\\"姓名/昵称\\\":\\\"test15\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393310},{\\\"登录名称\\\":\\\"test16\\\",\\\"密码\\\":16,\\\"姓名/昵称\\\":\\\"test16\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393311},{\\\"登录名称\\\":\\\"test17\\\",\\\"密码\\\":17,\\\"姓名/昵称\\\":\\\"test17\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393312},{\\\"登录名称\\\":\\\"test18\\\",\\\"密码\\\":18,\\\"姓名/昵称\\\":\\\"test18\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393313},{\\\"登录名称\\\":\\\"test19\\\",\\\"密码\\\":19,\\\"姓名/昵称\\\":\\\"test19\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393314},{\\\"登录名称\\\":\\\"test20
"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" : "sourceDatas",
"value" : "[{\\\"登录名称\\\":\\\"test1\\\",\\\"密码\\\":1,\\\"姓名/昵称\\\":\\\"test1\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393296},{\\\"登录名称\\\":\\\"test2\\\",\\\"密码\\\":2,\\\"姓名/昵称\\\":\\\"test2\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393297},{\\\"登录名称\\\":\\\"test3\\\",\\\"密码\\\":3,\\\"姓名/昵称\\\":\\\"test3\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393298},{\\\"登录名称\\\":\\\"test4\\\",\\\"密码\\\":4,\\\"姓名/昵称\\\":\\\"test4\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393299},{\\\"登录名称\\\":\\\"test5\\\",\\\"密码\\\":5,\\\"姓名/昵称\\\":\\\"test5\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393300},{\\\"登录名称\\\":\\\"test6\\\",\\\"密码\\\":6,\\\"姓名/昵称\\\":\\\"test6\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393301},{\\\"登录名称\\\":\\\"test7\\\",\\\"密码\\\":7,\\\"姓名/昵称\\\":\\\"test7\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393302},{\\\"登录名称\\\":\\\"test8\\\",\\\"密码\\\":8,\\\"姓名/昵称\\\":\\\"test8\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393303},{\\\"登录名称\\\":\\\"test9\\\",\\\"密码\\\":9,\\\"姓名/昵称\\\":\\\"test9\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393304},{\\\"登录名称\\\":\\\"test10\\\",\\\"密码\\\":10,\\\"姓名/昵称\\\":\\\"test10\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393305},{\\\"登录名称\\\":\\\"test11\\\",\\\"密码\\\":11,\\\"姓名/昵称\\\":\\\"test11\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393306},{\\\"登录名称\\\":\\\"test12\\\",\\\"密码\\\":12,\\\"姓名/昵称\\\":\\\"test12\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393307},{\\\"登录名称\\\":\\\"test13\\\",\\\"密码\\\":13,\\\"姓名/昵称\\\":\\\"test13\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393308},{\\\"登录名称\\\":\\\"test14\\\",\\\"密码\\\":14,\\\"姓名/昵称\\\":\\\"test14\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393309},{\\\"登录名称\\\":\\\"test15\\\",\\\"密码\\\":15,\\\"姓名/昵称\\\":\\\"test15\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393310},{\\\"登录名称\\\":\\\"test16\\\",\\\"密码\\\":16,\\\"姓名/昵称\\\":\\\"test16\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393311},{\\\"登录名称\\\":\\\"test17\\\",\\\"密码\\\":17,\\\"姓名/昵称\\\":\\\"test17\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393312},{\\\"登录名称\\\":\\\"test18\\\",\\\"密码\\\":18,\\\"姓名/昵称\\\":\\\"test18\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393313},{\\\"登录名称\\\":\\\"test19\\\",\\\"密码\\\":19,\\\"姓名/昵称\\\":\\\"test19\\\",\\\"所属机构(编码)\\\":\\\"mxd\\\",\\\"角色(编码)\\\":\\\"admin\\\",\\\"手机号\\\":15300393314},{\\\"登录名称\\\":\\\"test20\\\",\\\"密码\\\":20,\\\"姓名/昵称\\\":\\\"test20\\\",\\\"所属机构(编码)\\\":\\\"mx
"description" : "",
"required" : false,
"dataType" : "Array",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "datas",
"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" : "登录名称",
"value" : "test1",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "密码",
"value" : "1",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "姓名/昵称",
"value" : "test1",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "所属机构(编码)",
"value" : "马小东总公司",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "角色(编码)",
"value" : "管理员",
"description" : "",
"required" : false,
"dataType" : "String",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "手机号",
"value" : "15300393296",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
} ]
} ]
}, {
"name" : "timestamp",
"value" : "1648866351442",
"description" : "",
"required" : false,
"dataType" : "Long",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
}, {
"name" : "executeTime",
"value" : "60",
"description" : "",
"required" : false,
"dataType" : "Integer",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
} ]
}
}
================================
import cn.hutool.json.JSONUtil
import java.io.ByteArrayInputStream
import java.io.InputStream
import cn.hutool.poi.excel.ExcelReader
import cn.hutool.poi.excel.ExcelUtil
import request
import log
var datas = ExcelUtil.getReader(new ByteArrayInputStream(request.getFile('file').getBytes())).readAll()
var sourceDatas = datas::stringify::json
datas.each((data, i) => {
var j = 0
data.each((key, value) => {
if(j == 3){
data[key] = db.selectValue("""
select name from sys_office where is_del = 0 and code = #{value}
""")
}
if(j == 4){
data[key] = db.selectValue("""
select name from sys_role where is_del = 0 and code = #{value}
""")
}
j++
})
})
return {
sourceDatas,
datas
}