This commit is contained in:
@@ -341,3 +341,43 @@ func (h *AssetHandler) UpdateRealnamePolicy(c *fiber.Ctx) error {
|
||||
RealnamePolicy: req.RealnamePolicy,
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateRealnameStatus 手动更新资产实名状态
|
||||
// PATCH /api/admin/assets/:identifier/realname-status
|
||||
func (h *AssetHandler) UpdateRealnameStatus(c *fiber.Ctx) error {
|
||||
identifier := c.Params("identifier")
|
||||
if identifier == "" {
|
||||
return errors.New(errors.CodeInvalidParam)
|
||||
}
|
||||
|
||||
var req dto.UpdateAssetRealnameStatusRequest
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return errors.New(errors.CodeInvalidParam)
|
||||
}
|
||||
|
||||
if req.RealNameStatus != constants.RealNameStatusNotVerified &&
|
||||
req.RealNameStatus != constants.RealNameStatusVerified {
|
||||
return errors.New(errors.CodeInvalidParam, "无效的实名状态")
|
||||
}
|
||||
|
||||
asset, err := h.assetService.Resolve(c.UserContext(), identifier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if asset.AssetType != "card" {
|
||||
return errors.New(errors.CodeInvalidParam, "仅支持IoT卡资产手动修改实名状态")
|
||||
}
|
||||
|
||||
card, err := h.iotCardService.ManualUpdateRealnameStatus(c.UserContext(), asset.AssetID, req.RealNameStatus)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return response.Success(c, &dto.UpdateAssetRealnameStatusResponse{
|
||||
AssetType: asset.AssetType,
|
||||
AssetID: asset.AssetID,
|
||||
RealNameStatus: card.RealNameStatus,
|
||||
RealNameStatusName: constants.GetRealNameStatusName(card.RealNameStatus),
|
||||
FirstRealnameAt: card.FirstRealnameAt,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user