fix
This commit is contained in:
@@ -18,13 +18,13 @@ func NewAPIToken(service *service.SettingsService) *APIToken {
|
||||
|
||||
func (h *APIToken) Create(c *gin.Context) {
|
||||
var req dto.CreateAPITokenRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
httpx.Fail(c, "参数错误")
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
httpx.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
token, err := h.service.CreateAPIToken(c.Request.Context(), req.UserID, req.AuthorityID, req.Days, req.Remark)
|
||||
if err != nil {
|
||||
httpx.Fail(c, "签发失败:"+err.Error())
|
||||
httpx.Fail(c, "签发失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Write(c, httpx.CodeSuccess, gin.H{"token": token}, "签发成功")
|
||||
@@ -32,8 +32,8 @@ func (h *APIToken) Create(c *gin.Context) {
|
||||
|
||||
func (h *APIToken) List(c *gin.Context) {
|
||||
var req dto.APITokenListRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
httpx.Fail(c, "参数错误")
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
httpx.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
items, total, err := h.service.APITokens(c.Request.Context(), req.Page, req.PageSize, req.UserID, req.Status)
|
||||
@@ -46,13 +46,13 @@ func (h *APIToken) List(c *gin.Context) {
|
||||
|
||||
func (h *APIToken) Delete(c *gin.Context) {
|
||||
var req dto.IDRequest
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
httpx.Fail(c, "参数错误")
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
httpx.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
if err := h.service.DisableAPIToken(c.Request.Context(), req.ID); err != nil {
|
||||
httpx.Fail(c, "作废失败")
|
||||
return
|
||||
}
|
||||
httpx.OK(c)
|
||||
httpx.Write(c, httpx.CodeSuccess, gin.H{}, "作废成功")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user