-
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.
Merge pull request #5 from li1553770945/dev
feat(project):实现项目管理功能
- Loading branch information
Showing
14 changed files
with
136 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package constant | ||
|
||
const MaxProjectsNum = 50 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package error_type | ||
|
||
import "fmt" | ||
|
||
type ErrorType struct { | ||
Code int | ||
Message string | ||
} | ||
|
||
func (e *ErrorType) Error() string { | ||
return fmt.Sprintf("Code: %d, Message: %s", e.Code, e.Message) | ||
} | ||
|
||
var ( | ||
ErrBadRequest = &ErrorType{Code: 4001, Message: "参数错误"} | ||
ErrNotFound = &ErrorType{Code: 4004, Message: "未找到相关数据"} | ||
ErrNotLogin = &ErrorType{Code: 4003, Message: "您还未登录"} | ||
ErrNotPermitted = &ErrorType{Code: 4103, Message: "您无权执行此操作"} | ||
ErrInternal = &ErrorType{Code: 5001, Message: "系统错误,请联系管理员"} | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package global_service | ||
|
||
import ( | ||
"github.com/cloudwego/hertz/pkg/app" | ||
"github.com/hertz-contrib/sessions" | ||
"personal-page-be/biz/internal/domain" | ||
"personal-page-be/biz/internal/service/error_type" | ||
) | ||
|
||
func (s *GlobalService) CheckLogin(c *app.RequestContext, needAdmin bool) (*error_type.ErrorType, *domain.UserEntity) { | ||
session := sessions.Default(c) | ||
v := session.Get("username") | ||
if v == nil { | ||
return error_type.ErrNotLogin, nil | ||
} | ||
user, err := s.Repo.FindUser(v.(string)) | ||
if err != nil { | ||
return error_type.ErrNotLogin, nil | ||
} | ||
|
||
if needAdmin && user.Role != "admin" { | ||
return error_type.ErrNotPermitted, nil | ||
} | ||
return nil, user | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.