golang open source background management system

golang open source background management system

go-admin

go-admin is a back-end management system developed in go language. The system is based on role-based authority management design (RBAC), completed the development of system management module functions (other sample modules will be added later), and adopts a front-end and back-end separation implementation method , The server is based on the go open source gin framework and the front-end open source framework vue-element-admin . Use Swagger 2.0 to automatically generate API documentation.

Design Principles

  1. Using the more popular open source frameworks gin and vue-element-admin (the multi-language version i18n downloaded here , not the master branch), these projects are better maintained and updated.
  2. Try to modify the code of the vue-element-admin framework as little as possible to facilitate future upgrades.
  3. The front and back ends are separated, and the front and back ends can be developed independently without affecting each other.
  4. The server controls the front-end menu display and corresponding permissions.

System environment

golang language: go1.13.3+,

Database: mysql5.7

Cache: redis3.0

project address

github:

https://github.com/guyan0319/...

Code Cloud (domestic):

https://gitee.com/jason0319/g...

Introduction

online preview

The relevant source code analysis articles of this project are as follows:

11.1.1 vue-element-admin background dynamic loading menu

Quick start

1. Clone project source code

git clone https://github.com/guyan0319/go-admin.git

Note: The source code of the project is managed here through the dependency management tool go mod .

2. Because the node_modules file in the vue-element-admin project is too large, package it into node_modules.zip (some students encountered many problems in updating the dependency package, so add the compressed package to the project), before running the project, Remember to unzip node_modules.zip to the node_modules directory.

Or execute the following command to change the dependent package.

Executables that need to be relied upon,

# Enter the project directory
cd vue-element-admin
npm install --registry=https://registry.npm.taobao.org

Note : The win system needs to execute commands in the vue-element-admin directory under doc.

3. Import the database file systemdb.sql in the data directory to your database

Modify the database configuration file conf/mysql.go

var Db = map[string]DbConfig{
    "db1": {
        DriverName: "mysql",
        Dsn: "root:123456@tcp(127.0.0.1:3306)/systemdb?charset=utf8mb4&parseTime=true&loc=Local",
        ShowSql: true,
        ShowExecTime: false,
        MaxIdle: 10,
        MaxOpen: 200,
    },
}

4. Modify the conf/redis.go file and set your own redis service configuration information.

var Redis = map[string]string{
    "name": "redis",
    "type": "tcp",
    "address": "127.0.0.1:6379",
    "auth": "",
}

5. Start the server

go run main.go

Note: go-admin uses front-end and back-end separation, and cross-domain issues need to be resolved before running. Here we can modify the main.go file.

func GetCorsConfig() cors.Config {
    config := cors.DefaultConfig()
    config.AllowOrigins = []string{"http://localhost:9529","http://localhost:9528","http://localhost:9527","http://localhost"}//here Add your front-end domain name
    config.AllowMethods = []string{"POST", "GET", "OPTIONS", "PUT", "DELETE"}
    config.AllowCredentials = true
    config.AllowHeaders = []string{"x-requested-with", "Content-Type", "AccessToken", "X-CSRF-Token","X-Token", "Authorization","token"}
    return config
}

6. Run the client

npm run dev

Here we assume that you are a development environment and node.js has been installed. If it is applied to an online environment, you need to package the front-end files and web service related deployment work (not repeat them here, please contact me or issues if you need it).

7. Running results

http://localhost:9527/#/login...

Login test account information

Account: admin

Password: 111111

8. Server interface document

http://localhost :8090/swagger/index.html

summary:

At present, only the development of the system management module has been completed, and other functions will be added later. If you encounter any problems or any suggestions during use, please reply to the message. Your support is my motivation to move forward.

Reference: https://cloud.tencent.com/developer/article/1706235 golang open source background management system-cloud + community-Tencent Cloud