Files
iotlcm/server/api/system/v1/auth.go
T
MiFaZhan 59eb34976a chore: 初始开源发布
iotlcm-admin-svr:管理后台服务。

- Go module:iotlcm → git.5iot.com/iotlcm-public/iotlcm-admin-svr(729 文件)
- 凭据与地址脱敏:JWT signingKey(含代码里的 MustGet 默认值)、
  MySQL DSN、Redis 口令、告警邮件发件人邮箱全部改为占位;
  私网 IP → 文档地址段;库名 xiujie_admin → iotlcm
- 真实手机号/邮箱 → 合法 11 位编造号 / example.com
- 移除内部资产:CI 触发器、过时 DDL(sql/db_iotlcm.sql)、
  私有依赖 go get 行、明文 registry 登录口令
- 启动 banner 统一 IOTLCM 方块字 + 社区惯例署名
- Dockerfile 改用公共基础镜像
- 拼错的 RADEME.md → README.md,README 重写
- 需要真实数据库的用例改为可用 IOTLCM_TEST_WITH_DB=1 显式启用
- 补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes

数据库 schema 不随本仓发布(生产 DDL 已过时),README 已说明。
2026-10-23 14:48:30 +08:00

94 lines
3.4 KiB
Go

// Package v1
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package v1
import (
"github.com/gogf/gf/v2/frame/g"
)
type LoginReq struct {
g.Meta `path:"/auth/login" method:"post" tags:"系统-授权" summary:"登录"`
TenantId string `json:"tenantId" v:"required#租户ID不能为空" dc:"租户ID"`
Username string `json:"username" v:"required#用户名不能为空" dc:"用户名"`
Password string `json:"password" v:"required#密码不能为空" dc:"密码"`
CaptchaID string `json:"captchaID" dc:"验证码ID"`
CaptchaValue string `json:"captchaValue" v:"required#验证码不能为空" dc:"验证码"`
}
type LoginRes struct {
ID int64 `json:"id" dc:"用户ID"`
Username string `json:"username" dc:"用户名"`
NickName string `json:"nickName" dc:"昵称"`
Avatar string `json:"avatar" dc:"头像"`
AccessToken string `json:"accessToken" dc:"访问令牌"`
}
type SendSmsLoginCodeReq struct {
g.Meta `path:"/auth/sms-code" method:"post" tags:"系统-授权" summary:"发送手机验证码登录短信"`
Phone string `json:"phone" v:"required|phone#手机号不能为空|手机号格式不正确" dc:"手机号"`
}
type SendSmsLoginCodeRes struct{}
type SmsLoginReq struct {
g.Meta `path:"/auth/sms-login" method:"post" tags:"系统-授权" summary:"手机验证码登录"`
Phone string `json:"phone" v:"required|phone#手机号不能为空|手机号格式不正确" dc:"手机号"`
Code string `json:"code" v:"required|length:6,6#验证码不能为空|验证码应为6位" dc:"短信验证码"`
}
type SmsLoginRes struct {
ID int64 `json:"id" dc:"用户ID"`
Username string `json:"username" dc:"用户名"`
NickName string `json:"nickName" dc:"昵称"`
Avatar string `json:"avatar" dc:"头像"`
AccessToken string `json:"accessToken" dc:"访问令牌"`
}
type RefreshTokenReq struct {
g.Meta `path:"/auth/refresh" method:"post" tags:"系统-授权" summary:"刷新访问令牌"`
WithCredentials bool `json:"withCredentials" dc:"是否携带凭证"`
}
type RefreshTokenRes struct {
Data string `json:"data" dc:"新的访问令牌"`
Status int `json:"status" dc:"状态码"`
}
type LogoutReq struct {
g.Meta `path:"/auth/logout" method:"post" tags:"系统-授权" summary:"退出登录"`
WithCredentials bool `json:"withCredentials" dc:"是否携带凭证"`
}
type LogoutRes struct {
Data string `json:"data" dc:"退出登录"`
Status int `json:"status" dc:"状态码"`
}
type GetAccessCodesReq struct {
g.Meta `path:"/auth/codes" method:"get" tags:"系统-授权" summary:"获取用户权限码"`
IsCache bool `json:"isCache" dc:"是否从缓存中获取"`
}
type GetAccessCodesRes struct {
Data []string `json:"data" dc:"用户权限码"`
Status int `json:"status" dc:"状态码"`
}
type TenantListReq struct {
g.Meta `path:"/auth/getTenantList" method:"get" tags:"系统-授权" summary:"获取租户列表"`
}
type TenantListData struct {
CompanyName string `json:"companyName" dc:"企业名称"`
Domain string `json:"domain" dc:"域名"`
TenantId string `json:"tenantId" dc:"租户ID"`
}
type TenantListRes struct {
TenantEnabled bool `json:"tenantEnabled" dc:"是否启用租户"`
VoList []TenantListData `json:"voList" dc:"租户列表"`
}