更新
This commit is contained in:
1 parent
5718a00e31
commit
1850ac640e
226 files changed
+37772
-12071
No files matched your search
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"server/models"
|
||||
"server/pkg/identity"
|
||||
"server/pkg/jwtutil"
|
||||
"server/services"
|
||||
|
||||
@@ -22,22 +23,7 @@ type PlatformOperationLogController struct {
|
||||
}
|
||||
|
||||
func (c *PlatformOperationLogController) platformClaims() (*jwtutil.Claims, error) {
|
||||
auth := c.Ctx.Request.Header.Get("Authorization")
|
||||
if auth == "" {
|
||||
return nil, fmt.Errorf("未登录")
|
||||
}
|
||||
parts := strings.SplitN(auth, " ", 2)
|
||||
if len(parts) != 2 || parts[0] != "Bearer" {
|
||||
return nil, fmt.Errorf("认证信息格式错误")
|
||||
}
|
||||
claims, err := jwtutil.ParseToken(parts[1])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("无效的token")
|
||||
}
|
||||
if claims.UserType != "platform" {
|
||||
return nil, fmt.Errorf("无权访问")
|
||||
}
|
||||
return claims, nil
|
||||
return identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndPlatform)
|
||||
}
|
||||
|
||||
func (c *PlatformOperationLogController) jsonErr(httpStatus, bizCode int, msg string) {
|
||||
@@ -49,7 +35,8 @@ func (c *PlatformOperationLogController) jsonErr(httpStatus, bizCode int, msg st
|
||||
// List GET /platform/operationLogs?page=1&pageSize=20&keyword=&module=&action=&status=&startTime=&endTime=
|
||||
func (c *PlatformOperationLogController) List() {
|
||||
if _, err := c.platformClaims(); err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -175,7 +162,8 @@ func (c *PlatformOperationLogController) List() {
|
||||
// Detail GET /platform/operationLogs/:id
|
||||
func (c *PlatformOperationLogController) Detail() {
|
||||
if _, err := c.platformClaims(); err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
@@ -220,7 +208,8 @@ func (c *PlatformOperationLogController) Detail() {
|
||||
// Delete DELETE /platform/operationLogs/:id
|
||||
func (c *PlatformOperationLogController) Delete() {
|
||||
if _, err := c.platformClaims(); err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
@@ -253,7 +242,8 @@ type batchDeletePayload struct {
|
||||
// BatchDelete POST /platform/operationLogs/batchDelete
|
||||
func (c *PlatformOperationLogController) BatchDelete() {
|
||||
if _, err := c.platformClaims(); err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
raw, err := io.ReadAll(c.Ctx.Request.Body)
|
||||
@@ -287,7 +277,8 @@ func (c *PlatformOperationLogController) BatchDelete() {
|
||||
// 供前端筛选项:modules/actions
|
||||
func (c *PlatformOperationLogController) Statistics() {
|
||||
if _, err := c.platformClaims(); err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user