diff --git a/docs/simple-admin/en/docs/FAQ.md b/docs/simple-admin/en/docs/FAQ.md index b46d4323..534d7f12 100644 --- a/docs/simple-admin/en/docs/FAQ.md +++ b/docs/simple-admin/en/docs/FAQ.md @@ -1,9 +1,11 @@ # FAQ -## Q: What is the default account? +> Q: What is the default account? + A: account: admin password: simple-admin -## Q: Why the account I register cannot log in? +> Q: Why the account I register cannot log in? + A: The use register's default role is member. He does not have authorization to log in. \ You should modify the role's authority or change the user's role. diff --git a/docs/simple-admin/en/docs/api_example.md b/docs/simple-admin/en/docs/api_example.md index ec1599f5..a5c863f3 100644 --- a/docs/simple-admin/en/docs/api_example.md +++ b/docs/simple-admin/en/docs/api_example.md @@ -1,19 +1,18 @@ # Step by step develop API service -Make sure that you have been installed follow software: -- Consul +> Make sure that you have been installed follow software: - simple-admin-tool (goctls) -- -## Create api project +> Create api project \ Create example project ```shell goctls api new example ``` -You can see the struct +>You can see the struct + ![Example](../../assets/example-struct.png) -The go.mod is +> The go.mod is ```shell module example @@ -22,14 +21,13 @@ go 1.19 ``` -You should run command +> You should run command, to replace go-zero ```shell goctls migrate --zero-version v1.4.1 --tool-version v0.0.6 ``` -The version you can go to the github to find the latest release. \ - +> The version you can go to the github to find the latest release. \ After running the command, the mod file becomes: ```text @@ -133,28 +131,8 @@ replace github.com/zeromicro/go-zero v1.4.1 => github.com/suyuan32/simple-admin- ``` -And then edit etc/example.yaml - -```yaml -Consul: - Host: 127.0.0.1:8500 # consul endpoint - #Token: 'f0512db6-76d6-f25e-f344-a98cc3484d42' # consul ACL token (optional) - ListenOn: 0.0.0.0:8888 - Key: example.api - Meta: - Protocol: grpc - Tag: - - example - - api -``` - -Modify the host and you should use token to ensure security. +> And then edit etc/example.yaml -Visit consul and add kv - -### key -exampleApiConf -### value ```yaml Name: example.api Host: 127.0.0.1 @@ -162,13 +140,14 @@ Port: 9100 Timeout: 30000 ``` -And then you can run the code ! +> And then you can run the code ! ```shell go run example.go -f etc/example.yaml ``` -You can see +> You can see + ```shell Starting server at 127.0.0.1:9100... ``` diff --git a/docs/simple-admin/en/docs/authorization.md b/docs/simple-admin/en/docs/authorization.md index 7f677611..9b716006 100644 --- a/docs/simple-admin/en/docs/authorization.md +++ b/docs/simple-admin/en/docs/authorization.md @@ -1,7 +1,7 @@ # Authorization We use Casbin to do authorization validating. -## Initialize +> Initialize ```go cbn := utils.NewCasbin(db) @@ -9,7 +9,7 @@ cbn := utils.NewCasbin(db) [cbn](https://github.com/suyuan32/simple-admin-core/blob/master/api/internal/svc/servicecontext.go) -## Use in middleware +> Use in middleware ```go package middleware @@ -86,7 +86,7 @@ func (m *AuthorityMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc { [Middleware](https://github.com/suyuan32/simple-admin-core/blob/master/api/internal/middleware/authoritymiddleware.go) -### Use in api file +> Use in api file ```text @server( diff --git a/docs/simple-admin/en/docs/env_setting.md b/docs/simple-admin/en/docs/env_setting.md index 34e53ebb..e95ab05f 100644 --- a/docs/simple-admin/en/docs/env_setting.md +++ b/docs/simple-admin/en/docs/env_setting.md @@ -1,27 +1,28 @@ # Local Development Setting -## Environment Requirement +> Environment Requirement - golang 1.19 - nodejs 18.8.0 - mysql 5.7 + - redis 6.0 + -## Backend Setting +> Backend Setting -### simple admin core +## simple admin core simple admin core is the core service for simple admin. It offers user management, authorization, menu management and API management and so on. It must be running. -#### Default Account +> Default Account + username: admin \ password: simple-admin -### Clone the core code +> Clone the core code ```bash git clone https://github.com/suyuan32/simple-admin-core.git ``` -### Local development setting +> Local development setting #### API Service ##### Notice: You should add core_dev.yaml for development to avoid conflicting with core.yaml in production. > Add api/etc/core_dev.yaml @@ -108,13 +109,13 @@ RedisConf: # Pass: xxx # You can also set the password ``` -### Sync dependencies +> Sync dependencies ```shell go mod tidy ``` -### Run rpc service +> Run rpc service ```bash cd rpc @@ -122,8 +123,7 @@ cd rpc go run core.go -f etc/core_dev.yaml ``` - -### Run api service +> Run api service ```bash cd api @@ -131,32 +131,34 @@ cd api go run core.go -f etc/core_dev.yaml ``` -## Front end setting - -### Clone the code +> Front end setting +> +> Clone the code ```shell git clone https://github.com/suyuan32/simple-admin-backend-ui.git ``` -### Sync dependencies +> Sync dependencies ```shell yarn install ``` -### Run in development mode +> Run in development mode ```shell yarn serve ``` -### Build +> Build + ```shell yarn build ``` -### Preview +> Preview + ```shell # build and preview yarn preview @@ -165,7 +167,7 @@ yarn preview yarn preview:dist ``` -### Notice: Set the API address +> Notice: Set the API address > .env.development ```text diff --git a/docs/simple-admin/en/docs/file_manager.md b/docs/simple-admin/en/docs/file_manager.md index 81505300..d039fe75 100644 --- a/docs/simple-admin/en/docs/file_manager.md +++ b/docs/simple-admin/en/docs/file_manager.md @@ -1,18 +1,11 @@ ## File manager service -### Get code +> Get code ```shell git clone https://github.com/suyuan32/simple-admin-file.git ``` -### Modify configuration file - -Add kv in consul - -#### key -fileApiConf - -#### value +> Modify configuration file ```yaml Name: file_manager_0 @@ -55,10 +48,7 @@ UploadConf: PublicStorePath: /home/ryan/www/public # public path for every one access e.g. nginx path ``` -You should use nginx to set PublicStorePath as static path for front end. - -Make sure AccessSecret is the same as simple-admin-core' api set - -The configure is similar as core - -Run code the same as core \ No newline at end of file +> You should use nginx to set PublicStorePath as static path for front end. +> Make sure AccessSecret is the same as simple-admin-core' api set +> The configuration is similar as core +> Run code the same as core \ No newline at end of file diff --git a/docs/simple-admin/en/docs/global_vars.md b/docs/simple-admin/en/docs/global_vars.md index eef330c3..d5955095 100644 --- a/docs/simple-admin/en/docs/global_vars.md +++ b/docs/simple-admin/en/docs/global_vars.md @@ -1,6 +1,6 @@ # Global Variable -We define the global variables in internal/svc/servicecontext.go, and initialize them. \ +> We define the global variables in internal/svc/servicecontext.go, and initialize them. \ For example: ```go @@ -55,7 +55,7 @@ func NewServiceContext(c config.Config) *ServiceContext { ``` -How to use it? +> How to use it? ```go package api @@ -102,4 +102,4 @@ func (l *CreateOrUpdateApiLogic) CreateOrUpdateApi(req *types.CreateOrUpdateApiR ``` -We can get the global variables via l.svcCtx. \ No newline at end of file +> We can get the global variables via l.svcCtx. \ No newline at end of file diff --git a/docs/simple-admin/en/docs/gorm.md b/docs/simple-admin/en/docs/gorm.md index 28784a41..38c9af54 100644 --- a/docs/simple-admin/en/docs/gorm.md +++ b/docs/simple-admin/en/docs/gorm.md @@ -1,6 +1,6 @@ # GORM Usage -### Initialize GORM +> Initialize GORM ```go db, err := c.DB.NewGORM() @@ -12,7 +12,7 @@ [Init](https://github.com/suyuan32/simple-admin-core/blob/master/rpc/internal/svc/servicecontext.go) -### Define Model +> Define Model ```go package model @@ -31,7 +31,7 @@ type Api struct { [Model](https://github.com/suyuan32/simple-admin-core/tree/master/rpc/internal/model) -### Get Data +> Get Data ```go package logic @@ -107,7 +107,7 @@ func (l *GetApiListLogic) GetApiList(in *core.ApiPageReq) (*core.ApiListResp, er } ``` -Use l.svc.DB.Model().Where().Find() to do that. +> Use l.svc.DB.Model().Where().Find() to do that. [GetApiList](https://github.com/suyuan32/simple-admin-core/blob/master/rpc/internal/logic/getapilistlogic.go) diff --git a/docs/simple-admin/en/docs/quick_develop_example.md b/docs/simple-admin/en/docs/quick_develop_example.md index 3def80ed..7684cf97 100644 --- a/docs/simple-admin/en/docs/quick_develop_example.md +++ b/docs/simple-admin/en/docs/quick_develop_example.md @@ -1,11 +1,11 @@ ## Back end example demo [Example](https://github.com/suyuan32/simple-admin-core/tree/example) -## Install goctls +> Install goctls [Simple-admin-tool](simple-admin/zh-cn/docs/simple-admin-tools.md) -## RPC service - -### Firstly, modify rpc/core.proto +> RPC service +> +> Firstly, modify rpc/core.proto ```protobuf syntax = "proto3"; @@ -320,9 +320,9 @@ service core { } ``` -To add example rpc interface - -#### run in rpc directory +> To add example rpc interface +> +> run in rpc directory ```shell goctls rpc protoc core.proto --proto_path=/home/ryan/GolandProjects/simple-admin-core/rpc/ --go_out=./types --go-grpc_out=./types --zrpc_out=./ @@ -330,7 +330,7 @@ goctls rpc protoc core.proto --proto_path=/home/ryan/GolandProjects/simple-admin proto_path better use absolute path -#### modify internal/logic/hellologic.go +> modify internal/logic/hellologic.go ```go package logic @@ -365,7 +365,7 @@ func (l *HelloLogic) Hello(in *core.HelloReq) (*core.BaseResp, error) { ``` -And the add example.api into api/api_desc/ +> And the add example.api into api/api_desc/ ```api syntax = "v1" @@ -419,7 +419,7 @@ service core { ``` -Modify core.api +> Modify core.api ```api syntax = "v1" @@ -461,12 +461,13 @@ service core { } ``` -Run in api_desc directory +> Run in api_desc directory + ```shell goctls api go -api core.api -dir .. ``` -Modify api/internal/logic/example/hellologic.go +> Modify api/internal/logic/example/hellologic.go ```go package example @@ -505,7 +506,7 @@ func (l *HelloLogic) Hello(req *types.HelloReq) (resp *types.HelloResp, err erro ``` -### Run rpc and api service +> Run rpc and api service Run in api and rpc directory respectively @@ -513,6 +514,6 @@ Run in api and rpc directory respectively go run core.go -f etc/core.yaml ``` -## Front end development +> Front end development [Simple Admin UI](simple-admin/en/docs/web_develop_example.md) diff --git a/docs/simple-admin/en/docs/rpc_example.md b/docs/simple-admin/en/docs/rpc_example.md index 71560a46..ca771e02 100644 --- a/docs/simple-admin/en/docs/rpc_example.md +++ b/docs/simple-admin/en/docs/rpc_example.md @@ -1,19 +1,21 @@ # Step by step develop RPC service -Make sure that you have been installed follow software: -- Consul +> Make sure that you have been installed follow software: - simple-admin-tool (goctls) -## Create RPC project +> Create RPC project \ Create example project + ```shell goctls api new example ``` -You can see the struct \ + +> You can see the struct + ![Example](../../assets/example_rpc_struct.png) -The go.mod is +> The go.mod is ```shell module example @@ -22,14 +24,13 @@ go 1.19 ``` -You should run command +> You should run command ```shell goctls migrate --zero-version v1.4.1 --tool-version v0.0.6 ``` -The version you can go to the github to find the latest release. \ - +> The version you can go to the github to find the latest release. \ After running the command, the mod file becomes: ```text @@ -129,36 +130,14 @@ replace github.com/zeromicro/go-zero v1.4.1 => github.com/suyuan32/simple-admin- ``` -And then edit etc/example.yaml - -```yaml -Consul: - Host: 127.0.0.1:8500 # consul endpoint - #Token: 'f0512db6-76d6-f25e-f344-a98cc3484d42' # consul ACL token (optional) - ListenOn: 0.0.0.0:8888 - Key: example.rpc - Meta: - Protocol: grpc - Tag: - - example - - rpc -``` - -Modify the host and you should use token to ensure security. - -Visit consul and add kv +> And then edit etc/example.yaml -### key -exampleRpcConf -### value ```yaml Name: example.rpc -Host: 127.0.0.1 -Port: 9101 -Timeout: 30000 +ListenOn: 0.0.0.0:9103 ``` -And then you can run the code ! +> And then you can run the code ! ```shell go run example.go -f etc/example.yaml @@ -166,12 +145,12 @@ go run example.go -f etc/example.yaml You can see ```shell -Starting server at 127.0.0.1:9101... +Starting server at 127.0.0.1:9103... ``` That means it runs successfully. -# simple admin core's API service calls RPC interfaces. +> simple admin core's API service calls RPC interfaces. ### Add config ```go @@ -186,41 +165,34 @@ import ( ) type Config struct { - rest.RestConf `yaml:",inline"` - Auth Auth `json:"auth" yaml:"Auth"` - RedisConf redis.RedisConf `json:"redisConf" yaml:"RedisConf"` - CoreRpc zrpc.RpcClientConf `json:"coreRpc" yaml:"CoreRpc"` - ExampleRpc zrpc.RpcClientConf `json:"exampleRpc" yaml:"ExampleRpc"` - Captcha Captcha `json:"captcha" yaml:"Captcha"` - DB gormsql.GORMConf `json:"databaseConf" yaml:"DatabaseConf"` + rest.RestConf + Auth rest.AuthConf + RedisConf redis.RedisConf + CoreRpc zrpc.RpcClientConf + ExampleRpc zrpc.RpcClientConf + Captcha Captcha + DB gormsql.GORMConf } type Captcha struct { - KeyLong int `json:"keyLong" yaml:"KeyLong"` // captcha length - ImgWidth int `json:"imgWidth" yaml:"ImgWidth"` // captcha width - ImgHeight int `json:"imgHeight" yaml:"ImgHeight"` // captcha height -} - -type Auth struct { - AccessSecret string `json:"accessSecret" yaml:"AccessSecret"` - AccessExpire int64 `json:"accessExpire" yaml:"AccessExpire"` -} - -type ConsulConfig struct { - Consul consul.Conf + KeyLong int // captcha length + ImgWidth int // captcha width + ImgHeight int // captcha height } ``` +> 修改 api/etc/core_dev.yaml -#### consul ```yaml Name: core.api Host: 127.0.0.1 Port: 9100 Timeout: 30000 + Auth: AccessSecret: # longer than 8 AccessExpire: 259200 # Seconds + Log: ServiceName: coreApiLogger Mode: file @@ -229,16 +201,20 @@ Log: Compress: false KeepDays: 7 StackCooldownMillis: 100 + RedisConf: Host: 192.168.50.216:6379 Type: node + CoreRpc: - Target: consul://127.0.0.1:8500/core.rpc?wait=14s - #Token: 'f0512db6-76d6-f25e-f344-a98cc3484d42' # consul ACL token (optional) + Endpoints: + - 127.0.0.1:9101 + Captcha: KeyLong: 5 ImgWidth: 240 ImgHeight: 80 + DatabaseConf: Type: mysql Path: 127.0.0.1 @@ -251,12 +227,16 @@ DatabaseConf: MaxOpenConn: 100 LogMode: error LogZap: false + ExampleRpc: - Target: consul://127.0.0.1:8500/example.rpc?wait=14s + Endpoints: + - 127.0.0.1:9103 ``` + Add example rpc configuration. -### Modify service context +> Modify service context + ```go package svc @@ -311,4 +291,4 @@ func NewServiceContext(c config.Config) *ServiceContext { ``` -And then you can use in logic via l.svcCtx.Example. \ No newline at end of file +> And then you can use in logic via l.svcCtx.Example. \ No newline at end of file diff --git a/docs/simple-admin/en/docs/screenshot.md b/docs/simple-admin/en/docs/screenshot.md index 296b3ddd..daa2750b 100644 --- a/docs/simple-admin/en/docs/screenshot.md +++ b/docs/simple-admin/en/docs/screenshot.md @@ -1,18 +1,26 @@ -## Initialization +> Initialization + ![pic](../../assets/init_en.png) -## Login and Register +> Login and Register + ![pic](../../assets/register_en.png) ![pic](../../assets/login_en.png) -## Dashboard +> Dashboard + ![pic](../../assets/dashboard_en.png) -## User Management +> User Management + ![pic](../../assets/user_en.png) -## Menu Management +> Menu Management + ![pic](../../assets/menu_en.png) -## Role Management +> Role Management + ![pic](../../assets/role_en.png) -## Authorization Management +> Authorization Management + ![pic](../../assets/authority_en.png) -## File Management +> File Management + ![pic](../../assets/file_list_en.png) ![pic](../../assets/file_preview_en.png) \ No newline at end of file diff --git a/docs/simple-admin/en/docs/simple-admin-tools.md b/docs/simple-admin/en/docs/simple-admin-tools.md index 9bee212d..8bf5df94 100644 --- a/docs/simple-admin/en/docs/simple-admin-tools.md +++ b/docs/simple-admin/en/docs/simple-admin-tools.md @@ -8,15 +8,10 @@ It provides more addition features than origin project such as: - fully support validator and easy to use - so on -But it is a little complex to install the goctls and import the dependencies due to forking.\ -\ -We cannot just use go get and go install the goctl but download binary file or build goctl by ourselves. \ -\ -The binary file can be used in ubuntu 22.04.\ -\ +> But it is a little complex to install the goctls and import the dependencies due to forking.\ Let me show you how to build the code by yourself. -## Build goctls +> Build goctls ```shell git clone https://github.com/suyuan32/simple-admin-tools.git @@ -32,15 +27,16 @@ cp ./goctls $GOPATH/bin/goctls ``` It is easy right? -### How to use it? +> How to use it? + +> Auto fix all dependencies command -#### Auto fix all dependencies command ```shell goctls env check -i -f --verbose ``` Run this command can auto install protoc and so on. -#### API command +> API command The command is the same as goctl but you should use goctls instead. ```shell @@ -72,14 +68,14 @@ OPTIONS: --help, -h show help ``` -example: +> Example: ```shell goctls api go -api core.api -dir . ``` This means generating go files by core.api's declaration in current directory. -dir set the output path. -### Rpc command +> Rpc command ```shell $ goctl rpc protoc -h @@ -102,11 +98,13 @@ OPTIONS: --verbose, -v enable log output ``` -Example: +> Example: \ Generate proto template + ```shell goctl rpc template -o=user.proto ``` + ```shell syntax = "proto3"; @@ -125,13 +123,15 @@ service User { rpc Ping(Request) returns(Response); } ``` -Generate go files +> Generate go files + ```shell goctl rpc protoc user.proto --go_out=. --go-grpc_out=. --zrpc_out=. ``` [More](https://go-zero.dev/docs/goctl/zrpc) -## Project go.mod setting +> Project go.mod setting + We know that if we want to import fork project we should use replace command. ```mod @@ -159,12 +159,12 @@ require ( replace github.com/zeromicro/go-zero v1.4.1 => github.com/suyuan32/simple-admin-tools v0.0.6 ``` -In order to make it easier. You can use the command in goctls. +> In order to make it easier. You can use the command in goctls. ```shell goctls migrate --zero-version v1.4.1 --tool-version v0.0.6 ``` -It can help you to add replace code but it cannot run multiple times because it will add multiple replace lines -in the go.mod file. You can just edit go.mod file can modify the simple-admin-tools version manually and run - **go mod tidy**. +> It can help you to add replace code but it cannot run multiple times because it will add multiple replace lines +> in the go.mod file. You can just edit go.mod file can modify the simple-admin-tools version manually and run +> **go mod tidy**. diff --git a/docs/simple-admin/en/docs/swagger.md b/docs/simple-admin/en/docs/swagger.md index a2af5330..a1bd54a6 100644 --- a/docs/simple-admin/en/docs/swagger.md +++ b/docs/simple-admin/en/docs/swagger.md @@ -1,11 +1,10 @@ ## Use swagger -### Environment setting +> Environment setting [go-swagger](https://zhuanlan.zhihu.com/p/556171256?) -### In the root of project run -simple-admin-core/ +> In the root of project run simple-admin-core/ ```shell swagger generate spec --output=./core.yml --scan-models @@ -15,9 +14,11 @@ swagger serve --no-open -F=swagger --port 36666 core.yaml ![pic](../../assets/swagger.png) -### Get Token -#### Firstly, log in the system and press F12 to get authorization from any request +> Get Token +> Firstly, log in the system and press F12 to get authorization from any request + ![pic](../../assets/get_token.png) -#### Copy to swagger +> Copy to swagger + ![pic](../../assets/swagger_authority.png) \ No newline at end of file diff --git a/docs/simple-admin/en/docs/validator.md b/docs/simple-admin/en/docs/validator.md index 8a1c2939..5a2a6340 100644 --- a/docs/simple-admin/en/docs/validator.md +++ b/docs/simple-admin/en/docs/validator.md @@ -1,6 +1,6 @@ ## Validator 使用 -You can just edit api file and add validate tag for the struct. +> You can just edit api file and add validate tag for the struct. ```text // login request | 登录参数 @@ -29,7 +29,7 @@ You can just edit api file and add validate tag for the struct. } ``` -Default support Chinese and English, you can add other languages in servicecontext.go like below +> Default translation support Chinese and English, you can add other languages in servicecontext.go like below [Example](https://github.com/suyuan32/simple-admin-core/blob/master/api/internal/svc/servicecontext_test.go) diff --git a/docs/simple-admin/en/docs/web-setting.md b/docs/simple-admin/en/docs/web-setting.md index 0479e437..1301f5b2 100644 --- a/docs/simple-admin/en/docs/web-setting.md +++ b/docs/simple-admin/en/docs/web-setting.md @@ -1,8 +1,8 @@ ## Web UI setting -### Mainly modify env file +> Mainly modify env file -#### .env +> .env ```text # port @@ -18,7 +18,7 @@ VITE_GLOB_APP_SHORT_NAME = Simple_Admin You can set develop port and the name or system. -#### .env.development +> .env.development ```text # Whether to open mock @@ -51,5 +51,6 @@ VITE_GLOB_API_URL_PREFIX= ``` Mainly modify the VITE_PROXY to CROS request to different host. -### You must write your code in one line. -VITE_PROXY = [["/sys-api","http://localhost:9100"],["/file-manager","http://localhost:9102"]] \ No newline at end of file + +> You must write your code in one line. +> VITE_PROXY = [["/sys-api","http://localhost:9100"],["/file-manager","http://localhost:9102"]] \ No newline at end of file diff --git a/docs/simple-admin/zh-cn/docs/api_example.md b/docs/simple-admin/zh-cn/docs/api_example.md index 2657aa26..78c69120 100644 --- a/docs/simple-admin/zh-cn/docs/api_example.md +++ b/docs/simple-admin/zh-cn/docs/api_example.md @@ -1,7 +1,6 @@ # 手把手教你开发 API 服务 首先确认你安装了以下软件: -- Consul - simple-admin-tool (goctls) diff --git a/docs/simple-admin/zh-cn/docs/file_manager.md b/docs/simple-admin/zh-cn/docs/file_manager.md index 6b1e463e..58f4fa4b 100644 --- a/docs/simple-admin/zh-cn/docs/file_manager.md +++ b/docs/simple-admin/zh-cn/docs/file_manager.md @@ -5,12 +5,7 @@ git clone https://github.com/suyuan32/simple-admin-file.git ``` -> 修改配置文件 - -添加 kv 进 consul - -#### key -fileApiConf +> 修改配置文件 etc/file.yaml #### value ```yaml