feat: 实现企业卡授权和授权记录管理功能
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m9s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m9s
主要功能: - 添加企业卡授权/回收接口 (POST /enterprises/:id/allocate-cards, recall-cards) - 添加授权记录管理接口 (GET/PUT /authorizations) - 实现代理用户数据权限过滤(只能查看自己店铺下企业的授权记录) - 添加 GORM callback 支持授权记录表的数据权限过滤 技术改进: - 原生 SQL 查询手动添加数据权限过滤(ListWithJoin, GetByIDWithJoin) - 移除卡授权预检接口(allocate-cards/preview),保留内部方法 - 完善单元测试和集成测试覆盖
This commit is contained in:
@@ -61,40 +61,6 @@ components:
|
||||
description: 用户名
|
||||
type: string
|
||||
type: object
|
||||
DtoAllocateCardsPreviewReq:
|
||||
properties:
|
||||
iccids:
|
||||
description: 需要授权的 ICCID 列表(最多1000个)
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
type: array
|
||||
required:
|
||||
- iccids
|
||||
type: object
|
||||
DtoAllocateCardsPreviewResp:
|
||||
properties:
|
||||
device_bundles:
|
||||
description: 需要整体授权的设备包
|
||||
items:
|
||||
$ref: '#/components/schemas/DtoDeviceBundle'
|
||||
nullable: true
|
||||
type: array
|
||||
failed_items:
|
||||
description: 失败的卡
|
||||
items:
|
||||
$ref: '#/components/schemas/DtoFailedItem'
|
||||
nullable: true
|
||||
type: array
|
||||
standalone_cards:
|
||||
description: 可直接授权的卡(未绑定设备)
|
||||
items:
|
||||
$ref: '#/components/schemas/DtoStandaloneCard'
|
||||
nullable: true
|
||||
type: array
|
||||
summary:
|
||||
$ref: '#/components/schemas/DtoAllocatePreviewSummary'
|
||||
type: object
|
||||
DtoAllocateCardsReq:
|
||||
properties:
|
||||
confirm_device_bundles:
|
||||
@@ -130,24 +96,6 @@ components:
|
||||
description: 成功数量
|
||||
type: integer
|
||||
type: object
|
||||
DtoAllocatePreviewSummary:
|
||||
properties:
|
||||
device_card_count:
|
||||
description: 设备卡数量
|
||||
type: integer
|
||||
device_count:
|
||||
description: 设备数量
|
||||
type: integer
|
||||
failed_count:
|
||||
description: 失败数量
|
||||
type: integer
|
||||
standalone_card_count:
|
||||
description: 独立卡数量
|
||||
type: integer
|
||||
total_card_count:
|
||||
description: 总卡数量
|
||||
type: integer
|
||||
type: object
|
||||
DtoAllocateStandaloneCardsRequest:
|
||||
properties:
|
||||
batch_no:
|
||||
@@ -451,6 +399,81 @@ components:
|
||||
nullable: true
|
||||
type: array
|
||||
type: object
|
||||
DtoAuthorizationItem:
|
||||
properties:
|
||||
authorized_at:
|
||||
description: 授权时间
|
||||
format: date-time
|
||||
type: string
|
||||
authorized_by:
|
||||
description: 授权人ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
authorizer_name:
|
||||
description: 授权人名称
|
||||
type: string
|
||||
authorizer_type:
|
||||
description: 授权人类型:2=平台,3=代理
|
||||
type: integer
|
||||
card_id:
|
||||
description: 卡ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
enterprise_id:
|
||||
description: 企业ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
enterprise_name:
|
||||
description: 企业名称
|
||||
type: string
|
||||
iccid:
|
||||
description: ICCID
|
||||
type: string
|
||||
id:
|
||||
description: 授权记录ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
msisdn:
|
||||
description: 手机号
|
||||
type: string
|
||||
remark:
|
||||
description: 备注
|
||||
type: string
|
||||
revoked_at:
|
||||
description: 回收时间
|
||||
format: date-time
|
||||
nullable: true
|
||||
type: string
|
||||
revoked_by:
|
||||
description: 回收人ID
|
||||
minimum: 0
|
||||
nullable: true
|
||||
type: integer
|
||||
revoker_name:
|
||||
description: 回收人名称
|
||||
type: string
|
||||
status:
|
||||
description: 状态:1=有效,0=已回收
|
||||
type: integer
|
||||
type: object
|
||||
DtoAuthorizationListResp:
|
||||
properties:
|
||||
items:
|
||||
description: 授权记录列表
|
||||
items:
|
||||
$ref: '#/components/schemas/DtoAuthorizationItem'
|
||||
nullable: true
|
||||
type: array
|
||||
page:
|
||||
description: 当前页码
|
||||
type: integer
|
||||
size:
|
||||
description: 每页数量
|
||||
type: integer
|
||||
total:
|
||||
description: 总记录数
|
||||
type: integer
|
||||
type: object
|
||||
DtoChangePasswordRequest:
|
||||
properties:
|
||||
new_password:
|
||||
@@ -881,37 +904,6 @@ components:
|
||||
description: 总记录数
|
||||
type: integer
|
||||
type: object
|
||||
DtoDeviceBundle:
|
||||
properties:
|
||||
bundle_cards:
|
||||
description: 连带卡(同设备的其他卡)
|
||||
items:
|
||||
$ref: '#/components/schemas/DtoDeviceBundleCard'
|
||||
nullable: true
|
||||
type: array
|
||||
device_id:
|
||||
description: 设备ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
device_no:
|
||||
description: 设备号
|
||||
type: string
|
||||
trigger_card:
|
||||
$ref: '#/components/schemas/DtoDeviceBundleCard'
|
||||
type: object
|
||||
DtoDeviceBundleCard:
|
||||
properties:
|
||||
iccid:
|
||||
description: ICCID
|
||||
type: string
|
||||
iot_card_id:
|
||||
description: 卡ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
msisdn:
|
||||
description: 手机号
|
||||
type: string
|
||||
type: object
|
||||
DtoEnterpriseCardItem:
|
||||
properties:
|
||||
carrier_id:
|
||||
@@ -2054,26 +2046,6 @@ components:
|
||||
description: 总记录数
|
||||
type: integer
|
||||
type: object
|
||||
DtoStandaloneCard:
|
||||
properties:
|
||||
carrier_id:
|
||||
description: 运营商ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
iccid:
|
||||
description: ICCID
|
||||
type: string
|
||||
iot_card_id:
|
||||
description: 卡ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
msisdn:
|
||||
description: 手机号
|
||||
type: string
|
||||
status_name:
|
||||
description: 状态名称
|
||||
type: string
|
||||
type: object
|
||||
DtoStandaloneIotCardResponse:
|
||||
properties:
|
||||
activated_at:
|
||||
@@ -2178,6 +2150,12 @@ components:
|
||||
nullable: true
|
||||
type: string
|
||||
type: object
|
||||
DtoUpdateAuthorizationRemarkReq:
|
||||
properties:
|
||||
remark:
|
||||
description: 备注(最多500字)
|
||||
type: string
|
||||
type: object
|
||||
DtoUpdateCustomerAccountPasswordReq:
|
||||
properties:
|
||||
password:
|
||||
@@ -3307,6 +3285,199 @@ paths:
|
||||
summary: 分配记录详情
|
||||
tags:
|
||||
- 资产分配记录
|
||||
/api/admin/authorizations:
|
||||
get:
|
||||
parameters:
|
||||
- description: 页码
|
||||
in: query
|
||||
name: page
|
||||
schema:
|
||||
description: 页码
|
||||
minimum: 1
|
||||
type: integer
|
||||
- description: 每页数量
|
||||
in: query
|
||||
name: page_size
|
||||
schema:
|
||||
description: 每页数量
|
||||
maximum: 100
|
||||
minimum: 1
|
||||
type: integer
|
||||
- description: 按企业ID筛选
|
||||
in: query
|
||||
name: enterprise_id
|
||||
schema:
|
||||
description: 按企业ID筛选
|
||||
minimum: 0
|
||||
nullable: true
|
||||
type: integer
|
||||
- description: 按ICCID模糊查询
|
||||
in: query
|
||||
name: iccid
|
||||
schema:
|
||||
description: 按ICCID模糊查询
|
||||
type: string
|
||||
- description: 授权人类型:2=平台,3=代理
|
||||
in: query
|
||||
name: authorizer_type
|
||||
schema:
|
||||
description: 授权人类型:2=平台,3=代理
|
||||
nullable: true
|
||||
type: integer
|
||||
- description: 状态:0=已回收,1=有效
|
||||
in: query
|
||||
name: status
|
||||
schema:
|
||||
description: 状态:0=已回收,1=有效
|
||||
nullable: true
|
||||
type: integer
|
||||
- description: 授权时间起(格式:2006-01-02)
|
||||
in: query
|
||||
name: start_time
|
||||
schema:
|
||||
description: 授权时间起(格式:2006-01-02)
|
||||
type: string
|
||||
- description: 授权时间止(格式:2006-01-02)
|
||||
in: query
|
||||
name: end_time
|
||||
schema:
|
||||
description: 授权时间止(格式:2006-01-02)
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DtoAuthorizationListResp'
|
||||
description: OK
|
||||
"400":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 请求参数错误
|
||||
"401":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 未认证或认证已过期
|
||||
"403":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 无权访问
|
||||
"500":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 服务器内部错误
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: 授权记录列表
|
||||
tags:
|
||||
- 授权记录管理
|
||||
/api/admin/authorizations/{id}:
|
||||
get:
|
||||
parameters:
|
||||
- description: 授权记录ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
description: 授权记录ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DtoAuthorizationItem'
|
||||
description: OK
|
||||
"400":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 请求参数错误
|
||||
"401":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 未认证或认证已过期
|
||||
"403":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 无权访问
|
||||
"500":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 服务器内部错误
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: 授权记录详情
|
||||
tags:
|
||||
- 授权记录管理
|
||||
/api/admin/authorizations/{id}/remark:
|
||||
put:
|
||||
parameters:
|
||||
- description: 授权记录ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
description: 授权记录ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DtoUpdateAuthorizationRemarkReq'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DtoAuthorizationItem'
|
||||
description: OK
|
||||
"400":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 请求参数错误
|
||||
"401":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 未认证或认证已过期
|
||||
"403":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 无权访问
|
||||
"500":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 服务器内部错误
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: 修改授权备注
|
||||
tags:
|
||||
- 授权记录管理
|
||||
/api/admin/commission/withdrawal-requests:
|
||||
get:
|
||||
parameters:
|
||||
@@ -4149,58 +4320,6 @@ paths:
|
||||
summary: 授权卡给企业
|
||||
tags:
|
||||
- 企业卡授权
|
||||
/api/admin/enterprises/{id}/allocate-cards/preview:
|
||||
post:
|
||||
parameters:
|
||||
- description: 企业ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
description: 企业ID
|
||||
minimum: 0
|
||||
type: integer
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DtoAllocateCardsPreviewReq'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DtoAllocateCardsPreviewResp'
|
||||
description: OK
|
||||
"400":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 请求参数错误
|
||||
"401":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 未认证或认证已过期
|
||||
"403":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 无权访问
|
||||
"500":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: 服务器内部错误
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: 卡授权预检
|
||||
tags:
|
||||
- 企业卡授权
|
||||
/api/admin/enterprises/{id}/cards:
|
||||
get:
|
||||
parameters:
|
||||
|
||||
Reference in New Issue
Block a user