# label_sys **Repository Path**: bravomikekilo/label_sys ## Basic Information - **Project Name**: label_sys - **Description**: 标注系统的后端部分,基于go语言和hertz框架 - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2022-12-05 - **Last Updated**: 2024-09-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # label_sys后端系统 ## 运行 ```` go build ./demo.exe ```` 默认运行在8080端口,可在`main.go`文件中修改 ## 测试 ``` go test -v ./... ``` 或者 ``` make test ``` ## API ### POST:/api/v1/login * 功能:登录 * 请求body示例: ``` { "username":"root", "password":"test-password" } ``` ### GET:/api/v1/auth/refresh_token ### GET:/api/v1/user/ * 功能:查询所有用户信息 ### GET:/api/v1/user/:id * 功能:查询某一个id用户的信息 ### POST:/api/v1/user/ * 功能:注册用户 * 权限:仅管理员 * 请求body示例: ``` { "username":"test", "password":"test-password", "isadmin":true } ``` ### POST:/api/v1/user/:id/enabled * 功能:允许用户 * 权限:仅管理员 ### DELETE:/api/v1/user/:id/enabled * 功能:禁用用户 * 权限:仅管理员 ### PATCH:/api/v1/user/:id * 功能:更改某一个id用户的信息 * 权限:仅管理员 * 请求body示例: ``` { "id":1, "username":"xxxx", "isadmin":true, "disable":false } ``` ### PATCH:/api/v1/user/:id/password * 功能:更改某一个id用户的密码 * 权限:仅管理员 * 请求body示例: ``` { "password":"xxxxx" } ``` ### PATCH:/api/v1/user/sample/ ### GET:/api/v1/user/sample/ * 功能:获取所有样本信息 ### GET:/api/v1/user/sample/:id * 功能:获取某一个id样本的信息 ### GET:/api/v1/user/sample/:id/selections * 功能:获取某一个id的sample下的所有selections的信息 * 查询参数: | 参数 | 类型 | 描述| | ---- | ---- | ---- | | status | string | 状态 | | author | uint64 |用户 | ### GET:/api/v1/selection/ * 功能:按id查询selection信息 * 查询参数: | 参数 | 类型 | 描述| | ---- | ---- | ---- | | status | string | 状态 | | author | uint64 |用户 | ### POST:/api/v1/selection/ * 功能:创建新的selection * 请求body示例: ``` { "author_id":1, // uint 做出筛选的用户 "sample_id":"asdasdasd", //string 进行筛选的样本 "label": , //string 样本的标注 "admin_id":, //*uint 最终确认样本的管理员的用户ID "status": "working", //string 筛选样本的状态 "medias": , //[]Media 筛选出的视频 "comment": "test comment" //string 注释 } ``` ### GET:/api/v1/selection/:id * 功能:获取某一个id的selection的信息 ### POST:/api/v1/selection/:id/status * 功能:修改某一个id的selection的状态 * 权限:用户只能修改自己所属的;管理员可以修改所有的 * 请求body示例: ``` { "status": "working" } ``` ### POST:/api/v1/selection/:id/comment * 功能:修改某一个id的selection的备注 * 权限:用户只能修改自己所属的;管理员可以修改所有的 * 请求body示例: ``` { "comment": "test" } ``` ### PATCH:/api/v1/selection/:id * 功能:修改某一个id的selection的内容 * 权限:用户只能修改自己所属的;管理员可以修改所有的 * 请求body示例: ``` { "id":1, //uint "author_id":1, // uint "sample_id":"asdasdasd", //string "label": , //string "admin_id":, //*uint "status": "working", //string "medias": , //[]Media "comment": "test comment" //string } ``` ### DELETE:/api/v1/selection/:id * 功能:按id删除的selection * 权限:用户只能删除自己所属的;管理员可以删除所有的 ### GET:/api/v1/media/ * 功能:获取所有的media信息 ### GET:/api/v1/media/:id * 功能:按id查询media信息 ### GET:/api/v1/media/:id/label * 功能:按id查询该media下的所有label * 查询参数: | 参数 | 类型 | 描述 | ---- | ---- | ---- | | status | string | 仅查询某个状态的label| | author | uint64 |仅查询某个用户的label| ### GET:/api/v1/label/ * 功能:获取所有的label信息 * 查询参数: | 参数 | 类型 | 描述 | ---- | ---- | ---- | | status | string | 仅查询某个状态的label| | author | uint64 |仅查询某个用户的label| ### POST:/api/v1/label/ * 功能:创建新的label信息 * 请求body示例: ``` { "data": , //string 标注结果的具体数据 "comment":, //string 标注结果相关的注释 "status:, //string 标注结果的审核状态 "author_id":, //string 标注结果的用户名 "media_id: //uint 标注对应的media } ``` ### POST:/api/v1/label/:id/status * 功能:修改指定id label的状态 * 权限:用户只能修改自己所属的;管理员可以修改所有的 * 请求body示例: ``` { "status": "working" } ``` ### POST:/api/v1/label/:id/comment * 功能:修改指定id label的comment * 权限:用户只能修改自己所属的;管理员可以修改所有的 * 请求body示例: ``` { "comment": "test" } ``` ### GET:/api/v1/label/:id * 功能:按id查询指定label ### PATCH:/api/v1/label/:id * 功能:修改label的内容 * 权限:用户只能修改自己所属的;管理员可以修改所有的 * 请求body示例: ``` { "id":, //uint "data": , //string 标注结果的具体数据 "comment":, //string 标注结果相关的注释 "status:, //string 标注结果的审核状态 "author_id":, //string 标注结果的用户名 "media_id: //uint 标注对应的media } ``` ### DELETE:/api/v1/label/:id * 功能:按id删除label ### GET:/api/v1/meta/view ### POST:/api/v1/job/ * 功能:创建新的job * 请求body示例: ``` //创建新的selection任务 { "author_id": 1, "selection_id":1 } ``` ``` //创建新的sample任务 { "author_id": 1, "sample_id":"testid" } ``` ### GET:/api/v1/job/:id/sample * 功能:查询某个用户id被分配所有的样本 * 返回示例: ``` [ { "id": "testid", "created_at": "1970-01-01T00:13:24Z", "updated_at": "1970-01-01T00:16:29Z", "path": "/home/Administrator/Pictures/img_730384.png", "selections": null, "dicomdir_hash": "tinkr55tHK" }, { "id": "testid2", "created_at": "1970-01-01T00:16:08Z", "updated_at": "1970-01-01T00:01:34Z", "path": "/home/Administrator/Pictures/img_684752.jpg", "selections": null, "dicomdir_hash": "nDHStHTeyN" } ] ``` ### GET:/api/v1/job/:id/selection * 功能:查询某个用户id被分配所有的筛选 * 返回示例: ``` [ { "id": 1, "created_at": "1970-01-01T00:05:18Z", "updated_at": "1970-01-01T00:01:32Z", "author_id": 336, "sample_id": "testid", "label": "R8DwUYD8sY", "admin_id": 23, "status": "NJ1Zzf0le4", "medias": null, "comment": "ZRdsVQy92z" }, { "id": 2, "created_at": "1970-01-01T00:11:50Z", "updated_at": "1970-01-01T00:14:23Z", "author_id": 106, "sample_id": "testid2", "label": "U2QxYiFahd", "admin_id": 624, "status": "endsgsZtm6", "medias": null, "comment": "PGsLWWBAFs" } ] ``` ### POST:/api/v1/mission/ * 功能:创建新的mission * 请求body示例: ``` { "name":"strings", "author_id":1, "comment":"string", "label":[ { "view":"string", "annotation":[ "string" ] } ] } ``` * 返回示例: ``` { "id": 2 } ``` ### DELETE:/api/v1/mission/:id * 功能:按id删除mission ### GET:/api/v1/mission/ * 功能:获取所有的mission信息 * 返回示例: ``` [ { "id": 2, "created_at": "2023-03-12T06:20:25.0555803Z", "updated_at": "2023-03-12T06:20:25.0555803Z", "name": "strings", "label": [ { "annotation": [ "string" ], "view": "string" } ], "author_id": 0, "comment": "" }, { "id": 3, "created_at": "2023-03-12T06:38:01.3497259Z", "updated_at": "2023-03-12T06:38:01.3497259Z", "name": "string", "label": [ { "annotation": [ "string" ], "view": "string" } ], "author_id": 0, "comment": "" }, { "id": 4, "created_at": "2023-03-12T06:44:32.4505282Z", "updated_at": "2023-03-12T06:44:32.4505282Z", "name": "xxxxx", "label": [ { "annotation": [ "string" ], "view": "string" } ], "author_id": 0, "comment": "" }, { "id": 5, "created_at": "2023-03-14T12:12:28.7023525Z", "updated_at": "2023-03-14T12:12:28.7023525Z", "name": "xxxxx1", "label": [ { "annotation": [ "string" ], "view": "string" } ], "author_id": 1, "comment": "string" }, { "id": 6, "created_at": "2023-03-14T12:13:04.7553248Z", "updated_at": "2023-03-14T12:13:04.7553248Z", "name": "xxxxx2", "label": [], "author_id": 1, "comment": "string" } ] ``` ### GET:/api/v1/mission/:id * 功能:获取某个id的mission信息 * 返回示例: ``` { "id": 2, "created_at": "2023-03-12T06:20:25.0555803Z", "updated_at": "2023-03-12T06:20:25.0555803Z", "name": "strings", "label": [ { "annotation": [ "string" ], "view": "string" } ], "author_id": 0, "comment": "" } ``` ### GET:/api/v1/mission/:id/status * 功能:查询某个id的mission的状态 * 返回示例: ``` { "finished": 2, "pending": 1, "total": 6 } ``` ### GET:/api/v1/mission/:id/video * 功能:查询某个id的mission的下的video * 返回示例: ``` { "video": [ { "instance_uid": "1", "series_number": 111, "instance_number": 111, "sha1": "111", "path": "path", "view": "view", "comment": "", "status": "submit" }, { "instance_uid": "1", "series_number": 111, "instance_number": 111, "sha1": "111", "path": "path", "view": "view", "comment": "", "status": "working" } ] } ``` ### POST: /api/v1/collection * 功能: 创建一个新的结构化信息收集表 * 请求Body示例 ``` { name: "收集表", schema: [ { "name": "sex", "kind": "radio", "label": "性别", "required": true, "define": [ "男", "女" ] }, { "name": "age", "label": "年龄", "kind": "number", "required": true, "define": null }, { "name": "diagnose", "label": "诊断", "kind": "string", "define": null }, ] } ``` * 返回实例 ``` { "id": 2 } ``` ### GET: /api/v1/collection/:id * 功能: 返回信息收集表内容 ### DELETE: /api/v1/collection/:id * 功能: 删除信息收集表 ### GET: /api/v1/collection/:id/report * 功能: 列出信息收集表 下所有的结构化报告 ### GET: /api/v1/report/:id * 功能: 返回某个结构化报告 ### UPDATE: /api/v1/report/:id * 功能: 更新某个结构化报告