Skip to content

Commit

Permalink
docs: update english doc
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed Oct 12, 2022
1 parent a333f78 commit 57ac4da
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 199 deletions.
6 changes: 4 additions & 2 deletions docs/simple-admin/en/docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -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.

43 changes: 11 additions & 32 deletions docs/simple-admin/en/docs/api_example.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -133,42 +131,23 @@ 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
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...
```
Expand Down
6 changes: 3 additions & 3 deletions docs/simple-admin/en/docs/authorization.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Authorization
We use Casbin to do authorization validating.

## Initialize
> Initialize
```go
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
Expand Down Expand Up @@ -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(
Expand Down
38 changes: 20 additions & 18 deletions docs/simple-admin/en/docs/env_setting.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -108,55 +109,56 @@ 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

go run core.go -f etc/core_dev.yaml
```


### Run api service
> Run api service
```bash
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
Expand All @@ -165,7 +167,7 @@ yarn preview
yarn preview:dist
```

### Notice: Set the API address
> Notice: Set the API address
> .env.development
```text
Expand Down
22 changes: 6 additions & 16 deletions docs/simple-admin/en/docs/file_manager.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
> 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
6 changes: 3 additions & 3 deletions docs/simple-admin/en/docs/global_vars.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -55,7 +55,7 @@ func NewServiceContext(c config.Config) *ServiceContext {

```

How to use it?
> How to use it?
```go
package api
Expand Down Expand Up @@ -102,4 +102,4 @@ func (l *CreateOrUpdateApiLogic) CreateOrUpdateApi(req *types.CreateOrUpdateApiR

```

We can get the global variables via l.svcCtx.
> We can get the global variables via l.svcCtx.
8 changes: 4 additions & 4 deletions docs/simple-admin/en/docs/gorm.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GORM Usage

### Initialize GORM
> Initialize GORM
```go
db, err := c.DB.NewGORM()
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 57ac4da

Please sign in to comment.