广汽一期(old)
<p>[TOC]</p>
<p>版本:V1.3.20210915
更新知识库接口</p>
<p>内网在线接口文档地址: <a href="http://10.129.8.22/web/#/19">http://10.129.8.22/web/#/19</a>
外网在线接口文档地址: <a href="https://www.showdoc.com.cn/gaccms">https://www.showdoc.com.cn/gaccms</a></p>
<p>环境:测试环境
地址:
内网:
外网:<a href="http://cms.gp2dev.fii-fmc.com/">http://cms.gp2dev.fii-fmc.com/</a>
测试Client_ID: client
测试Client_Secret: secret
测试账号:star
测试密码:123456</p>
<p><strong>正式接入请进行“应用注册”后获取属于自己应用的Client_ID,Client_Secret</strong></p>
<h1>广汽应用系统对接说明</h1>
<ol>
<li>广汽项目由安东,设备,质量,物流,交互中心,AVI组成,需要各系统集成单点登录(采用OAuth2.0规范与流程);</li>
<li>权限统一管理,可通过用户,角色统一设置所有应用的权限,并能查看在各应用中的权限项(统一权限资源录入管理,统一权限设置,各应用获取到登录账号的权限后自行鉴权);</li>
<li>一个用户支持多个角色,但只在一个组织下</li>
</ol>
<h1>应用对接登录</h1>
<p>前端WEB需要注意:</p>
<blockquote>
<p>红色线条为重定向跳转
前端工程可通过是否存在 access_token 判断登录状态
前端工程跳转之前需记录用户访问的页面地址,方便登录完成后重定向回去</p>
</blockquote>
<p>获取access_token需要请求<strong>后端API</strong>工程去完成,不是前端WEB工程自己直接请求, 原因是需要传client_Secret参数,这个参数不能暴露
参考地址:<a href="https://developer.aliyun.com/article/750026">https://developer.aliyun.com/article/750026</a></p>
<ul>
<li>
<h2>1. 用户登录跳转</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li>
<p><code>http://{host:port}/oauth/authorize?response_type={code}&client_id={client}&redirect_uri={http://xxxx}</code></p>
</li>
<li><code>examples: http://10.178.28.166:8000/oauth/authorize?response_type=code&client_id=client&redirect_uri=http://www.baidu.com</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>
<p>GET </p>
<p><strong>返回说明</strong>
登录成功后返回回调地址并带上Code</p>
</li>
<li>
<h2>2. 获取Token</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/token</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST/form-data</li>
</ul>
<pre><code>"grant_type":"authorization_code", --固定值
"client_id":"{client}", --应用注册返回Client值
"client_secret":"{secret}", --应用注册返回Secret值
"redirect_uri":"http://xxxx",--填写第一步中同样的地址
"code":"{code}"--第一步返回的Code</code></pre>
<p><strong>返回说明</strong></p>
<pre><code>{
"access_token": "66097363-f49d-4d76-8307-c54a84ec7620",
"token_type": "bearer",
"refresh_token": "70df78a2-8635-4805-bca4-b552d599a350",
"expires_in": 1736,
"scope": "read write"
}</code></pre>
<ul>
<li>
<h2>3. 获取用户信息</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/current/user</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST /form-data</li>
</ul>
<p><strong>参数:</strong> </p>
<pre><code>access_token:"xxxx" --第二步中返回的Token值</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"index": null,
"id": "6fbbcf07-fb4d-4418-bbf5-228b1c771bf1",
"domain": "焊装车间", //厂域
"account": "F20210709", //工号
"username": "test账号5", //姓名
"sex": "男",
"mobile": "12345678901",
"email": "F20210709@yean.net",
"category": "直接", //类型
"position": "组长", //职位
"onboardingTime": "2021/07/05", //入厂日期
"status": 0,
"superiorId": "1",
"superior": "170202", //上级主管工号
"superiorName": "张鸣峰",//上级主管姓名
"agentId": "2",
"agent": "180034", // 代理人工号
"agentName": "曹楠",//代理人姓名
"organizeId": "dd850354-58b9-40bf-9855-38d0f65614b7",//组织ID
"organizeName": "线下返修B班",//组织名
"technicalList": [],//技能,待做功能
"roleList": [{ //角色
"id": "2",
"roleName": "系统管理员",
"enable": 0,
"count": null,
"delete": 0
}],
"authorityInfo": [{//权限
"appId": "5f934999-26a2-4de7-b563-fc8204257582",
"appName": "系统管理",//应用名
"clientId": "084ad33e-cbf6-4f3c-95f5-033a58c3f517", //应用ID,各应用可根据接入登录的应用ID获取自己的权限列表进行权限鉴权
"authorityInfo": [{
"id": "56d7555c-3f6a-4dc2-bf34-2283e825909e",
"modelName": "查看权限",
"modelParentId": "19d59891-af19-482a-87be-3101367c4ef1",
"resourceId": "SYS-USER-LOOKAUTH",//资源ID
"resourceName": "查看权限",//资源描述
"status": 0,
"other": "",
"appId": "5f934999-26a2-4de7-b563-fc8204257582",
"appName": "系统管理",
"clientId": "084ad33e-cbf6-4f3c-95f5-033a58c3f517"
}, {
"id": "42111f6d-1e0f-46e9-837f-0c3e9c35eb09",
"modelName": "编辑权限",
"modelParentId": "fdb3c4f2-0de0-46da-b98d-7185b2c3cd1c",
"resourceId": "SYS-ROLE-AUTH-EDIT",
"resourceName": "编辑权限",
"status": 0,
"other": "",
"appId": "5f934999-26a2-4de7-b563-fc8204257582",
"appName": "系统管理",
"clientId": "084ad33e-cbf6-4f3c-95f5-033a58c3f517"
}]
}, {
"appId": "e11c6aee-2af3-4e19-a56e-9a2635d01429",
"appName": "交互中心",
"clientId": "9260cb85-9216-4f6d-9014-baf576c6daca",
"authorityInfo": [{
"id": "167f69b3-415e-4712-933c-043cffcab227",
"modelName": "指标库",
"modelParentId": "28e70646-70f7-49eb-8efc-7756739f2627",
"resourceId": "302",
"resourceName": "指标库",
"status": 0,
"other": "指标库",
"appId": "e11c6aee-2af3-4e19-a56e-9a2635d01429",
"appName": "交互中心",
"clientId": "9260cb85-9216-4f6d-9014-baf576c6daca"
}, {
"id": "21882029-cd27-4310-b29e-40c25b165e5b",
"modelName": "看板管理",
"modelParentId": "28e70646-70f7-49eb-8efc-7756739f2627",
"resourceId": "303",
"resourceName": "看板管理",
"status": 0,
"other": "看板管理",
"appId": "e11c6aee-2af3-4e19-a56e-9a2635d01429",
"appName": "交互中心",
"clientId": "9260cb85-9216-4f6d-9014-baf576c6daca"
}]
}]
}
}</code></pre>
<ul>
<li>
<h2>手机APP接入登录</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/token</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>
<p>POST/form-data</p>
<pre><code>grant_type:password,
username:{用户名},
password:{密码},
client_id:{client},-- 应用注册时返回的Client
client_secret:{secret} --应用注册时返回的Secret</code></pre>
<p><strong>返回示例</strong></p>
</li>
</ul>
<pre><code>{
"access_token": "938300d5-f1f4-462f-b53d-e84ec1a6b636",
"token_type": "bearer",
"refresh_token": "70df78a2-8635-4805-bca4-b552d599a350",
"expires_in": 1799,
"scope": "read write"
}</code></pre>
<ul>
<li>
<h2>验证token是否有效</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://10.178.28.166:8000/oauth/check_token</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST</li>
</ul>
<p>Authorization:
Basic_Auth
username:{client}
password:{secret}</p>
<p>form-data
token:"xxxx"</p>
<p><strong>返回示例</strong></p>
<pre><code> {
"aud": [
"oauth2-resource"
],
"sub": "Subject",
"user_name": "star",
"scope": [
"read",
"write"
],
"iss": "GAC-CMS",
"active": true,
"exp": 1623383434,
"iat": 1623382132,
"authorities": [
"admin"
],
"client_id": "client"
}
--Token无效时
{
"error": "invalid_token",
"error_description": "Token was not recognised"
}</code></pre>
<p><strong>返回参数说明</strong>
返回error就代表Token无效</p>
<ul>
<li>
<h2>刷新token</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/token</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST /form-data</li>
</ul>
<p><strong>参数:</strong> </p>
<pre><code>"grant_type":"refresh_token", --固定值
"client_id":"{client}", --应用注册返回Client值
"client_secret":"{secret}", --应用注册返回Secret值
"refresh_token":"{refreshToken}" --刷新Token的值</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"access_token": "a17fe8bd-b317-45f0-8eb5-8fce4c33ac9b",
"token_type": "bearer",
"refresh_token": "70df78a2-8635-4805-bca4-b552d599a350",
"expires_in": 1799,
"scope": "read write"
}</code></pre>
<h2>修改密码</h2>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/edit/password</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST /form-data</li>
</ul>
<p>header:
Authorization: "Bearer {token}"</p>
<p><strong>参数:</strong> </p>
<pre><code>"oldPassword":"xxxx", --旧密码
"newPassword":"xxx", --新密码
"userId":"{userId}", --用户ID</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": null
}</code></pre>
<h2>修改个人信息</h2>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/update/personal</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST</li>
</ul>
<p>header:
Authorization: "Bearer {token}"</p>
<p><strong>参数:</strong> </p>
<pre><code>{
"userId": "xxxxx",
"username": "xxx",//姓名
"sex": "xxx",//性别
"phone": "xxxx",//电话
"email": "xxx",//邮件
"agent": "xxx"//代理人
}</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": null
}</code></pre>
<ul>
<li>
<h2>退出登录(app)</h2>
</li>
<li>按下面步骤退出
<ol>
<li>各應用不支持單獨退出,廣汽需求是統一在CMS中退出</li>
</ol></li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/logout</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" --Header传入token</p>
<ul>
<li>
<h2>批量获取用户信息</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/info/accounts</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>
<p>GET</p>
<pre><code>参数:accounts= 工号,工号</code></pre>
<p><strong>返回示例</strong></p>
</li>
</ul>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"account": "180100",
"username": "蔡龙德",
"mobile": "18033160837",
"email": "default@gacne.com.cn"
},
{
"account": "18901",
"username": "张三",
"mobile": "10086",
"email": "default@gac.com"
}
]
}</code></pre>
<ul>
<li>
<h2>传入用户工号获取下属信息</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/sbordinate/info</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>
<p>GET</p>
<pre><code>参数:account= 工号</code></pre>
<p><strong>返回示例</strong></p>
</li>
</ul>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"account": "180296",
"username": "沈宁远",
"mobile": "18257220813",
"email": "default@gacne.com.cn"
},
{
"account": "170345",
"username": "李赞云",
"mobile": "10086",
"email": "111113@gacne.com.cn"
}
]
}</code></pre>
<h1>统一菜单接入接口</h1>
<ul>
<li>
<h2>各应用返回当前登录用户<strong>有权限</strong>的菜单列表</h2>
</li>
</ul>
<p><strong>请求URL示例:</strong> </p>
<ul>
<li>GET <code>http://{host:port}/xxx/getUserMenus</code>
-- 1. 菜单地址可自定义,GET方式
-- 2. 菜单地址在应用注册时录入到配置中(如果应用注册时勾选了“统一菜单集成”)
-- 3. <strong>调用接口Header头Authorization传入"Bearer {Token}",可用于获取当前用户信息,以验证用户有权限的菜单是哪些</strong></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>
<p>GET </p>
<p><strong>返回示例</strong></p>
</li>
</ul>
<pre><code> {
"code": 0,
"message":"",
"payload": [{
"id":"1", --ID为字符型
"parentId":"0", --父ID, 根节点为0值
"name":"设备管理",-- 菜单名
"url":""--菜单相对地址,如果是目录,URL值给""
},
{
"id":"2",
"parentId":"1",
"name":"设备列表",
"url":"/equipment/list"
}]
}</code></pre>
<p><strong>返回参数说明</strong>
请<font color="red"><strong>参照上面的格式</strong></font>,如果菜单树有多级目录,平铺展开数据,树形菜单由公共模块前端组织</p>
<p><img src="http://10.129.8.22/server/../Public/Uploads/2021-06-18/60cbfb4ba1723.png" alt="" /></p>
<h2>Q&A:</h2>
<h3>1. 系统已经有自己的左侧菜单和顶部导航,要怎么集成?</h3>
<p>A: 返回的菜单可加上参数,如 /equipment/list?isHidenFlag=true, 页在打开时,隐藏左侧菜单和顶部导航,做到单独部署也可以有自己的菜单,"isHidenFlag" 参数可系统自行定义</p>
<h3>2. 没有做登录对接与权限管理,要怎么处理?</h3>
<p>A: 先确保本次6.30演示的功能列表,返回,后期对接用户,设置权限,再返回相应用户有权限的菜单</p>
<h3>3. 为什么公共模块不增加菜单配置进行统一菜单管理?</h3>
<p>A: 解偶,应用增加、删除页面自行维护,减少与其它系统的依赖与注册操作</p>
<h1>用户管理</h1>
<ul>
<li>
<h2>获取用户列表</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/open/oauth/user/list</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong> </p>
<p>body: json</p>
<pre><code>{
"account": "", --工号或姓名,支持模糊查询
"position": "", --职位,支持模糊查询
"technicalName": "",--技能等级
"superiorId": "", --上级主管 ,支持模糊查询
"organizeId": "",--所属组织
"startDate": "",--入职日期(开始时间)
"endDate": "",--入职日期(结束时间)
"pageNum": 0,
"pageSize": 0
}</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 80,
"pageCount": 4,
"pageNum": 1,
"pageSize": 20,
"data": [{
"index": 1,
"id": "817f7a2e-2681-47c8-958b-7e26ee4f2a43",
"account": "F1337218",
"username": "henryliu",
"sex": "男",
"mobile": "13712345678",
"email": "630913166@qq.com",
"category": "直接",
"position": "PJM",
"onboardingTime": "2021/07/01",
"status": 0,
"superiorId": null,
"superior": null,
"superiorName": null,
"agentId": null,
"agent": null,
"agentName": null,
"organizeId": "b6b85b68-4a75-4494-9395-abbeb800f0fc",
"organizeName": "冲压一线四部",
"technicalList": [],
"roleList": [{
"id": "d128c365-2abc-4dce-983d-d919d6cabb86",
"roleName": "测试01",
"enable": 0,
"count": null,
"delete": 0
}],
"authorityInfo": null,
"localRes": null
}]
}
}</code></pre>
<ul>
<li>
<h2>获取单个用户信息</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/user/list</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" --Header传入token</p>
<p>body: json</p>
<pre><code>{
"account": "180133", --工号或姓名
}</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"index": 1,
"account": "180133",
"username": "陈嘉俊",
"sex": "男",
"mobile": "12345678901",
"email": "eqewfd@dfads.com",
"category": "直接",
"position": "综合管理组组长",
"onboardingTime": "2020/02/11",
"status": 0,
"superior": null,
"superiorName": null,
"agent": null,
"agentName": null,
"organizeId": "1",
"organizeName": "未编制",
"technicalList": [],
"roleList": [
{
"id": 3,
"roleName": "普通管理员",
"enable": 0,
"count": null,
"isEdit": "1"
}
]
}
]
}</code></pre>
<h1>角色管理</h1>
<ul>
<li>
<h2>获取角色列表</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/role/role/list</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" --Header传入token</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"index": 1,
"id": "2",
"roleName": "系统管理员", -- 角色名
"status": 0, --状态,0正常,1禁用
"isEdit": 1, --是否可修改
"count": 1 --角色下人数
}
]
}</code></pre>
<ul>
<li>
<h2>获取角色下用户列表</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/user/list</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" --Header传入token</p>
<p>body:</p>
<pre><code>{
"account": "",
"endDate": "",
"organizeId": "",
"pageNum": 0,
"pageSize": 0,
"position": "",
"roleId": "5", --传入角色ID
"startDate": "",
"superiorId": "",
"technicalName": ""
}
</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"index": 1,
"id": "8",
"account": "F2021612",
"username": "test2",
"sex": "男",
"mobile": "12345678903",
"email": "F2021612@yean.net",
"category": "间接",
"position": "未知",
"onboardingTime": "2021/06/12",
"status": 0,
"superiorId": null,
"superior": null,
"superiorName": null,
"agentId": null,
"agent": null,
"agentName": null,
"organizeId": "1",
"organizeName": "未编制",
"technicalList": [],
"roleList": [
{
"id": "5",
"roleName": "test管理员",
"enable": 0,
"count": null,
"delete": 0
}
]
}
]
}</code></pre>
<h1>组织管理</h1>
<ul>
<li>
<h2>获取组织列表</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/organize/list/info</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" --Header传入token</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"id": "1469da92-67f7-4a91-b204-4c175b912927",
"organizeName": "冲压线",
"organizeParent": "0", -- 父组织ID, 0代表根节点
"userId": null, -- 组织负责人ID
"account": "", -- 组织负责人账号
"username": "", -- 组织负责人姓名
"phone": "",
"email": "",
"other": "",
"status": 0,
"count": 0
},
{
"id": "52781756-9240-4c5c-b79e-e88f0b927da6",
"organizeName": "冲压一线一部",
"organizeParent": "6901f97d-308d-400c-8243-e88d0c66a790",
"userId": "",
"account": "",
"username": "",
"phone": "",
"email": "",
"other": "",
"status": 0,
"count": 0
}
]
}</code></pre>
<ul>
<li>
<h2>通过组织ID获取单个组织数据</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/open/organize/info</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
organizeId = '{id}'</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"id": "1469da92-67f7-4a91-b204-4c175b912927",
"organizeName": "冲压科",
"organizeParent": null,
"userId": null,
"account": "fei",
"username": "fei",
"phone": "1",
"email": "fe@a.com",
"other": "",
"status": 0,
"count": 0
}
}</code></pre>
<ul>
<li>
<h2>获取组织下用户列表</h2>
</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/oauth/user/list</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" --Header传入token</p>
<p>body: json</p>
<pre><code>{
"account": "",
"position": "",
"technicalName": "",
"superiorId": "",
"organizeId": "6901f97d-308d-400c-8243-e88d0c66a790",--传入所属组织ID
"startDate": "",
"endDate": "",
"pageNum": 0,
"pageSize": 0
}</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"index": 1,
"account": "180133",
"username": "陈嘉俊",
"sex": "男",
"mobile": "12345678901",
"email": "eqewfd@dfads.com",
"category": "直接",
"position": "综合管理组组长",
"onboardingTime": "2020/02/11",
"status": 0,
"superior": null,
"superiorName": null,
"agent": null,
"agentName": null,
"organizeId": "1",
"organizeName": "未编制",
"technicalList": [],
"roleList": [
{
"id": 3,
"roleName": "普通管理员",
"enable": 0,
"count": null,
"isEdit": "1"
}
]
}
]
}</code></pre>
<h1>应用注册</h1>
<p>应用接入的Client_ID,Client_Secret信息,需要在应用注册页面进行填写信息后,得到相应的信息。
接入应用有三种情况:</p>
<ol>
<li>只接入用户登录鉴权
在应用注册页面中,只输入应用名,应用地址,选择应用类型,点击【确定】按钮进行保存。
添加的应用会在登录成功后,主页面左侧菜单中出现应用名,点击后跳转到相应的应用链接</li>
<li>接入用户登录鉴权+菜单链接
在应用注册页面中,输入应用名,应用地址,勾选接入模块 “统一菜单集成”,输入菜单地址
菜单地址返回数据格式请按以下格式:
<pre><code>{
"code": 0,
"message":"",
"payload": [{
"id":"1", --ID为字符型
"parentId":"0", --父ID, 根节点为0值
"name":"设备管理",-- 菜单名
"url":"/equipment/list",--菜单相对地址,如果是目录,URL值给""
},
{....}]
}</code></pre></li>
<li>接入用户登录鉴权+菜单链接+权限设置
在应用注册页面中,输入应用名,应用地址,勾选接入模块 “统一菜单集成”,输入菜单地址,勾选“统一权限管理”
后继权限资源录入,权限设置统一在公共模块进行,具体权限设置查看权限管理</li>
</ol>
<h1>权限管理</h1>
<p>应客户胡锡雄提的需求,广汽所有应用,权限统一管理,统一配置,用户,角色可以一下看到他在各应用下的权限。</p>
<p>当页面没有权限时,页面跳转到404,提示“您所访问的资源不存在”;
当按钮没有权限时,按钮进行隐藏;
当数据没有权限时,后台数据查询不查询出来,页面不显示相应字段或用“/”替代。</p>
<h1>消息中心</h1>
<pre><code>RabbitMQ 测试环境:
gost -L tcp://127.0.1.10:5672/rabbitmq-user-root.rabbitmq-1:5672 -F socks5+mws://gost-mws.10-124-130-142.sslip.io:80
test/123456</code></pre>
<p>消息中心采用MQ进行系统解偶,按以下json格式发送消息到 RabbitMQ 服务器中的 gac_message_queue 队列中</p>
<h2>消息格式</h2>
<pre><code>{
"from": "设备叫修", //发送方(必填)
"recipient": "188001,17923", //接收方(必填):工号,多个用英文逗号隔开
"messageType": "normal", //消息类型(必填):normal(普通消息)/todo(待办事项)
"subject": "【设备故障】xxxxxxxxxx", //消息标题(必填)
"message": "{ //json字符串(选填)
"workCode": "UR20210909114444483", //工单编号
"workType": "紧急维修", //工单类型
"status": "3", // 工单状态(不同工单类型工单状态定义不同)
}",
"content": "xxxxx,xxxxxx", //消息内容(必填)
"url":"",//链接地址(选填)
"time":"2021-09-09 13:05"//消息发生时间(必填)
"sending": "app,mail,wechat", //发送途径(必填):app,mail,wechat,多个用英文逗号隔开
"todoId": "xxxxxxxx" //待办事项ID(UUID)-当消息类型为todo时必填
}</code></pre>
<p>待办事项更新状态 发送消息到 gac_message_status_queue 队列</p>
<pre><code>[{
"todoId": "xxxxxxxx",
"status": 1 //处理中
}, {
"todoId": "xxxxxxxx",
"status": 2 //已完成
}, {
"todoId": "xxxxxxxx",
"status": 3 //删除
}]</code></pre>
<h2>APP推送消息(待验证方案)</h2>
<ul>
<li>流程: 消息中心接收到需要推送到APP的消息后,转换成APP需要的字段格式,并将多人接收的消息转成单个人</li>
<li>消息Topic 使用 :gac_app<em>msg</em>{工号}, 如 gac_app_msg_188001 , APP用户登录后会消费指定的自己的MQ</li>
</ul>
<pre><code>{
"from": "设备叫修", //发送方(必填)
"recipient": "188001",//接收人(必填,单个工号)
"messageType": "normal", //消息类型(必填):normal(普通消息)/todo(待办事项)
"subject": "【设备故障】xxxxxxxxxx", //消息标题(必填)
"message": "{ //json字符串(选填)
"workCode": "UR20210909114444483", //工单编号
"workType": "紧急维修", //工单类型
"status": "3", // 工单状态(不同工单类型工单状态定义不同)
}",
"content": "xxxxx,xxxxxx", //消息内容(必填)
"time":"2021-09-09 13:05",//消息发生时间(必填)
"todoId":"",// 任务单号
"url":"",//链接地址(选填)
}</code></pre>
<h3>Q: 为什么不是接口提供出来?</h3>
<h3>A: 1. 解耦,2. 发送消息给多人多种方式,可能时间会比较长,产生消息的时候,用户并不关注发送结果,不能让操作的人等待太长时间</h3>
<h3>Q:为什么不用MQTT?</h3>
<h3>A:让数采单独MQTT服务器不受影响,其它的消息使用另外的MQ服务器,从消息中心的量级上选择 RabbitMQ</h3>
<h2>消息中心接口</h2>
<h3>1. 消息列表</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/message/list?messageType=normal&pageNum=1&pageSize=10</code></li>
<li>messageType : normal 站内消息,todo 待办</li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 40,
"pageCount": 4,
"pageNum": 1,
"pageSize": 10,
"data": [{
"id": "fa50311d-4551-45ff-9dc4-06a020b6c18e",
"subject": "安全告知",
"content": "【安全告知】:工事任务G20210927150558009涉及安全作业,更多注意事项请查看工单详情",
"url": "http://106.52.232.176/gx/Urgency/ModelDetail/G20210927150558009",
"status": "0", --状态,0-未开始,1-处理中,2-完成
"isRead": 0, --是否已读 0 未读,1 已读
"receiveDate": "2021-09-27 23:05:58"
}]
}
}</code></pre>
<h3>2. 删除消息</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/message/remove</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST</li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p>Form Data:
ids: {消息id}</p>
<p><strong>返回示例</strong></p>
<pre><code>{"code":0,"errmsg":"Success","payload":null}</code></pre>
<h1>知识库</h1>
<h2>作业文档</h2>
<h3>1. 作业文档接口</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/doc/list</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}" </p>
<p>body: json</p>
<pre><code>{
"key_word": "xxxx", //搜索关键字
"page_num": 1,
"page_size": 20
}</code></pre>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 22,
"pageCount": 2,
"pageNum": 1,
"pageSize": 20,
"data": [
{
"docId": "37", //文档ID
"docCode": "Word12",//文档编号
"docName": "sdf",//文档名
"version": "1",//文档最新版本号
"docDesc": "",//文档描述
"assetType": "设备",//资产类型,是设备还是模具
"equipmentType": "", //资产类型
"equipmentCode": "", //资产代码
"typeName": "冲压车间文档",//文档类型
"typeId": "13",//文档类型ID
"binding": false, //是否绑定资产
"fileId": "80", //附件ID
"fileName": "0820任务Word12sdf1.doc", //附件名
"preview": true//是否支持在线预览
}
]
}
}</code></pre>
<h3>2. 作业文档 - 附件下载</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/doc/downloadurl?doc_id={docId}</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>get </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong>
使用Payload中返回URL下载文件</p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": "http://minio01.10-124-130-142.sslip.io/gac-cms-file/document/DOC1%E6%B8%85%E6%B4%97%E6%9C%BA%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C1.1_c0006197-fedc-4228-8892-0fbf56dbb3d3.xlsx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20210915%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210915T083740Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=f960531fcaffb9ded4697d4920267f6231b6c907e5f05fd2028873367528517e"
}</code></pre>
<h3>3. 作业文档 - 附件 - 历史版本列表接口</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/doc/history?doc_id={作业文档ID}&page_num=1&page_size=10</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 1,
"pageCount": 1,
"pageNum": 1,
"pageSize": 10,
"data": [
{
"doc_id": "9",
"version": "1.0",
"file_id": "10",//文件ID
"file_name": "DOC1清洗机操作手册1.0.doc",//附件名
"preview": false,
"update_time": "2021-08-19 10:19:37"
}
]
}
}</code></pre>
<h2>培训项目</h2>
<h3>1. 培训项目列表接口</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/project/list?keyword={xxxx}&page_num=1&page_size=20</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 4,
"pageCount": 1,
"pageNum": 1,
"pageSize": 20,
"data": [
{
"id": "15",//培训项目ID
"project_code": "C10201", //培训项目编号
"project_name": "设备基本操作",//培训项目名称
"project_desc": "",//培训项目说明
"count": 2 //课程数量
}
]
}
}</code></pre>
<h3>2. 培训项目 - 课程接口</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/project/course/list?project_id={培训项目ID}</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"id": "12",//课程ID
"course_code": "C010103",//课程编号
"course_name": "研配机作业标准书系列",//课程名称
"ability_detail": "能进行研配机的基本操作",//考核内容
"training_duration": "3h",//培训时长
"practice_duration": "1周",//练习时长
"examine_duration": "1h",//考核时长
"examine_details": "研配机的基本操作",//考核内容
"count": 2 //附件数
},
{
"id": "11",
"course_code": "C1010102",
"course_name": "压力机作业标准书系列",
"ability_detail": "能进行压力机及液压垫的基本操作",
"training_duration": "4h",
"practice_duration": "2周",
"examine_duration": "1h",
"examine_details": "压力机及液压垫操作",
"count": 0
}
]
}</code></pre>
<h3>3. 培训项目 - 课程附件列表 接口</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/project/course/annex/list?course_id={课程ID}</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong></p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [
{
"id": "68", //附件ID
"file_name": "研配机作业标准书系列数字化决策+报表查询+KPI+20210825 (2).xls1.xls", //附件名
"preview": true,
"version": "1", //最新版本号
"createTime": "2021-08-25 15:49:55"
},
{
"id": "64",
"file_name": "研配机作业标准书系列0820任务.doc1.doc",
"preview": true,
"version": "1",
"createTime": "2021-08-25 15:46:42"
}
]
}</code></pre>
<h3>4. 培训项目 - 课程 - 附件 - 下载接口</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/project/course/annex/download?file_id={附件ID}</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong>
使用Payload中URL下载文件本地查看</p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": "http://minio01.10-124-130-142.sslip.io/gac-cms-file/projectcourse/%E7%A0%94%E9%85%8D%E6%9C%BA%E4%BD%9C%E4%B8%9A%E6%A0%87%E5%87%86%E4%B9%A6%E7%B3%BB%E5%88%97%E6%95%B0%E5%AD%97%E5%8C%96%E5%86%B3%E7%AD%96%2B%E6%8A%A5%E8%A1%A8%E6%9F%A5%E8%AF%A2%2BKPI%2B20210825%20%282%29.xls1_bccdf1ac-635d-4231-97e2-c60d0125690c.xls?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20210915%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210915T085653Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=d60d2b1e6761bf8454863060e3c898b10ab74034c7ed854db8eb1c921984263d"
}</code></pre>
<h4>5. 培训项目 - 课程 - 附件 - 历史版本列表接口</h4>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/project/course/annex/history?file_id={附件ID}&page_num=1&page_size=10</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET </li>
</ul>
<p><strong>参数:</strong>
header:
Authorization: "Bearer {token}"</p>
<p><strong>返回示例</strong>
使用Payload中URL下载文件本地查看</p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 3,
"pageCount": 1,
"pageNum": 1,
"pageSize": 10,
"data": [
{
"id": "65", //附件ID
"file_name": "研配机作业标准书系列0824开发周会纪要.doc1.doc", //附件名
"preview": true,
"version": "1.1",//版本号
"createTime": "2021-08-25 15:48:23"
},
{
"id": "66",
"file_name": "研配机作业标准书系列信润录屏旁白信息收集-20210823(調整產品順序).xlsx1.xlsx",
"preview": true,
"version": "1.2",
"createTime": "2021-08-25 15:48:31"
},
{
"id": "67",
"file_name": "研配机作业标准书系列数字化决策+报表查询+KPI+20210825.xls1.xls",
"preview": true,
"version": "1.3",
"createTime": "2021-08-25 15:49:55"
}
]
}
}</code></pre>
<h1>学习相关接口</h1>
<h2>1. 学习任务推送</h2>
<h3>1). 准备课程数据</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/user/list</code> -- 获取用户列表</li>
<li><code>http://{host:port}/project/list</code> -- 获取课程列表</li>
<li><code>http://{host:port}/project/course/list?project_id={课程id}</code> -- 获取课程目录列表</li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<h3>2). 任务推送</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/create/task</code> </li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST</li>
</ul>
<p><strong>参数</strong></p>
<pre><code>{
"course_ids": ["16", "15"], -- 课程信息
"user_ids": ["4105a8b2-5cf3-47a8-805b-1ea0924579a9", "b4ee2217-e23e-4590-a846-4cac2f31f999"] --用户id
}</code></pre>
<p><strong>返回示例:</strong> </p>
<pre><code>{"code":0,"errmsg":"Success","payload":null}</code></pre>
<h2>2. 学习任务</h2>
<h3>1). 学习列表</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/task?pageNum=1&pageSize=10&status=false</code> </li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>返回示例:</strong> </p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 1,
"pageCount": 1,
"pageNum": 1,
"pageSize": 1,
"data": [{
"id": "11",
"task_num": "STM20210103071569", -- 任务编号
"create_time": "2021-10-30 08:20:39",
"complete_time": null,
"projects": [{
"project_id": "9",
"project_name": "测试002", -- 培训项目名
"courses": [{
"course_id": "16",-- 培训课程ID
"course_name": "abca", -- 培训课程名
"course_code": "111",
"ability_detail": "",
"status": "0" -- 学习状态,1 已学习,0 未学习
}]
}, {
"project_id": "8",
"project_name": "测试课程",
"courses": [{
"course_id": "15",
"course_name": "test",
"course_code": "ttest001",
"ability_detail": "x",
"status": "0"
}]
}]
}]
}
}</code></pre>
<h3>2). 学习附件</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/course/annex/list?course_id={培训课程ID}&task_id={学习任务id}</code> -- 如上数据 course_id=15&task_id=11</li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>返回示例:</strong> </p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [{
"id": "48",
"file_name": "0820任务test1.doc",
"preview": true,
"version": "1",
"createTime": "2021-10-30 08:01:23",
"status": "0"
}]
}</code></pre>
<h3>3). 学习完成</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/complete?task_id={学习任务id}&file_ids={文件id}</code> -- 如上数据 /study/complete?task_id=11&file_ids=48</li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>返回示例:</strong> </p>
<pre><code>{"code":0,"errmsg":"Success","payload":null}</code></pre>
<h2>3. 员工学习记录</h2>
<h3>1). 员工学习记录列表</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/task/user/list?keyword=&page_num=1&page_size=10</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>返回示例:</strong> </p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": {
"count": 2,
"pageCount": 1,
"pageNum": 1,
"pageSize": 10,
"data": [{
"id": "b4ee2217-e23e-4590-a846-4cac2f31f999",
"domain": "焊装车间",
"account": "zsshz2",
"username": "zss焊装2",
"password": null,
"sex": null,
"mobile": null,
"email": null,
"enabled": 0,
"category": null,
"position": "上车体A班保全员",
"onboardingTime": null,
"onboarding_time": null,
"superiorId": null,
"superior": null,
"superiorName": null,
"agentId": null,
"agent": null,
"agentName": null,
"organizeId": "59ea5f78-c3c7-48f9-b560-94a7081cfc2b",
"organizeName": "上车体A班",
"technicalList": [],
"roleList": null
}, {
"id": "4105a8b2-5cf3-47a8-805b-1ea0924579a9",
"domain": "焊装车间",
"account": "zsshz",
"username": "zss焊装",
"password": null,
"sex": null,
"mobile": null,
"email": null,
"enabled": 0,
"category": null,
"position": "上车体A班保全员",
"onboardingTime": null,
"onboarding_time": null,
"superiorId": null,
"superior": null,
"superiorName": null,
"agentId": null,
"agent": null,
"agentName": null,
"organizeId": "59ea5f78-c3c7-48f9-b560-94a7081cfc2b",
"organizeName": "上车体A班",
"technicalList": [],
"roleList": null
}]
}
}</code></pre>
<h3>2). 员工学习记录明细</h3>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>http://{host:port}/study/user/record?user_id={用户id}</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>GET</li>
</ul>
<p><strong>返回示例:</strong> </p>
<pre><code>{
"code": 0,
"errmsg": "Success",
"payload": [{
"task_num": "STM20210103071569",
"course_code": "ttest001",
"course_name": "test",
"create_time": "2021-10-30 08:20:39",
"complete_time": "2021-10-30 08:31:10",
"status": "1", -- 学习状态,1 已学习,0 未学习
"technicalList": []
}, {
"task_num": "STM20210103071569",
"course_code": "111",
"course_name": "abca",
"create_time": "2021-10-30 08:20:39",
"complete_time": null,
"status": "0",
"technicalList": []
}]
}</code></pre>