-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin, hitokoto): admin hitokoto management
- Loading branch information
1 parent
525b366
commit 59265e1
Showing
41 changed files
with
715 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package adminV1 | ||
|
||
import "github.com/gogf/gf/v2/frame/g" | ||
|
||
type DeleteListReq struct { | ||
g.Meta `path:"/hitokoto" method:"DELETE" summary:"批量删除句子" tags:"句子"` | ||
UUIDs []string `json:"uuids" dc:"句子 UUID" v:"required|length:1,100" in:"query"` | ||
} | ||
|
||
type DeleteListRes struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package adminV1 | ||
|
||
import ( | ||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/hitokoto-osc/reviewer/internal/model" | ||
) | ||
|
||
// GetListReq 获取句子列表 | ||
type GetListReq struct { | ||
g.Meta `path:"/hitokoto" method:"GET" summary:"获取句子列表" tags:"句子"` | ||
model.GetHitokotoV1SchemaListInput | ||
} | ||
|
||
type GetListRes model.GetHitokotoV1SchemaListOutput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package adminV1 | ||
|
||
import ( | ||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/hitokoto-osc/reviewer/internal/consts" | ||
) | ||
|
||
type MoveSentenceReq struct { | ||
g.Meta `path:"/hitokoto/:uuid" method:"POST" summary:"移动句子" tags:"句子"` | ||
UUID string `json:"uuid" dc:"句子 UUID" v:"required|regex:^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$#请输入 UUID|UUID 非法" in:"path"` //nolint:lll | ||
Target consts.HitokotoStatus `json:"target" dc:"目标状态" v:"required|in:pending,approved,rejected" in:"query"` | ||
} | ||
|
||
type MoveSentenceRes struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package adminV1 | ||
|
||
import ( | ||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/hitokoto-osc/reviewer/internal/model" | ||
) | ||
|
||
type UpdateOneReq struct { | ||
g.Meta `path:"/hitokoto/:uuid" method:"PUT" summary:"更新句子" tags:"句子"` | ||
UUID string `json:"uuid" dc:"句子 UUID" v:"required|regex:^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$#请输入 UUID|UUID 非法" in:"path"` //nolint:lll | ||
// 句子相关 | ||
model.DoHitokotoV1Update | ||
} | ||
|
||
type UpdateOneRes struct{} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
internal/controller/admin/admin_v1_grant_user_authority.go
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
internal/controller/hitokoto/hitokoto_adminV1_delete_list.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package hitokoto | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hitokoto-osc/reviewer/internal/service" | ||
|
||
"github.com/gogf/gf/v2/errors/gcode" | ||
"github.com/gogf/gf/v2/errors/gerror" | ||
|
||
"github.com/hitokoto-osc/reviewer/api/hitokoto/adminV1" | ||
) | ||
|
||
func (c *ControllerAdminV1) DeleteList(ctx context.Context, req *adminV1.DeleteListReq) (res *adminV1.DeleteListRes, err error) { | ||
err = service.Hitokoto().Delete(ctx, req.UUIDs) | ||
if err != nil { | ||
return nil, gerror.WrapCode(gcode.CodeInternalError, err) | ||
} | ||
return nil, nil | ||
} |
27 changes: 27 additions & 0 deletions
27
internal/controller/hitokoto/hitokoto_adminV1_move_sentence.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hitokoto | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hitokoto-osc/reviewer/internal/service" | ||
|
||
"github.com/gogf/gf/v2/errors/gcode" | ||
"github.com/gogf/gf/v2/errors/gerror" | ||
|
||
"github.com/hitokoto-osc/reviewer/api/hitokoto/adminV1" | ||
) | ||
|
||
func (c *ControllerAdminV1) MoveSentence(ctx context.Context, req *adminV1.MoveSentenceReq) (res *adminV1.MoveSentenceRes, err error) { | ||
sentence, err := service.Hitokoto().GetHitokotoV1SchemaByUUID(ctx, req.UUID) | ||
if err != nil { | ||
return nil, gerror.WrapCode(gcode.CodeInternalError, err) | ||
} | ||
if sentence == nil { | ||
return nil, gerror.NewCode(gcode.CodeNotFound, "未找到指定的句子") | ||
} | ||
err = service.Hitokoto().Move(ctx, sentence, req.Target) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return nil, nil | ||
} |
27 changes: 27 additions & 0 deletions
27
internal/controller/hitokoto/hitokoto_adminV1_update_one.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hitokoto | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hitokoto-osc/reviewer/internal/service" | ||
|
||
"github.com/gogf/gf/v2/errors/gcode" | ||
"github.com/gogf/gf/v2/errors/gerror" | ||
|
||
"github.com/hitokoto-osc/reviewer/api/hitokoto/adminV1" | ||
) | ||
|
||
func (c *ControllerAdminV1) UpdateOne(ctx context.Context, req *adminV1.UpdateOneReq) (res *adminV1.UpdateOneRes, err error) { | ||
sentence, err := service.Hitokoto().GetHitokotoV1SchemaByUUID(ctx, req.UUID) | ||
if err != nil { | ||
return nil, gerror.WrapCode(gcode.CodeInternalError, err) | ||
} | ||
if sentence == nil { | ||
return nil, gerror.NewCode(gcode.CodeNotFound, "未找到指定的句子") | ||
} | ||
err = service.Hitokoto().UpdateByUUID(ctx, sentence, &req.DoHitokotoV1Update) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return nil, nil | ||
} |
Oops, something went wrong.