convert.go 934 B

12345678910111213141516171819202122232425262728293031323334
  1. package application
  2. import (
  3. "time"
  4. "udeServer/internal/model"
  5. "udeServer/internal/types"
  6. )
  7. // toApplicationCredentials 将模型行转换为响应结构;ApiSecret 做掩码,原文只经下发接口输出。
  8. func toApplicationCredentials(row *model.TApplicationCredentials) types.ApplicationCredentials {
  9. return types.ApplicationCredentials{
  10. Id: row.Id,
  11. CredIden: row.CredIden,
  12. Name: row.Name,
  13. ApiKey: row.ApiKey,
  14. ApiSecret: maskSensitive(row.ApiSecret),
  15. Status: int(row.Status),
  16. Description: row.Description.String,
  17. CreatedBy: row.CreatedBy,
  18. CreatedAt: formatCredentialTime(row.CreatedAt),
  19. UpdatedBy: row.UpdatedBy,
  20. UpdatedAt: formatCredentialTime(row.UpdatedAt),
  21. }
  22. }
  23. // formatCredentialTime 时间展示格式与 sdf-serve 保持一致。
  24. func formatCredentialTime(t time.Time) string {
  25. if t.IsZero() {
  26. return ""
  27. }
  28. return t.Format("2006-01-02 15:04:05")
  29. }