Browse Source

Merge branches 'gin-vue-admin-adjust-log' and 'master' of https://github.com/piexlmax/QMPlus into gin-vue-admin-adjust-log

 Conflicts:
	QMPlusServer/init/qmsql/initMysql.go
	QMPlusServer/main.go
	QMPlusVuePage/src/view/superAdmin/autoCode/index.vue
pixel 5 years ago
parent
commit
83e5844ee8

+ 16 - 0
QMPlusServer/Dockerfile

@@ -0,0 +1,16 @@
+FROM golang:1.12 AS build
+
+WORKDIR /go/src/gin-vue-admin
+COPY . .
+
+ENV GO111MODULE=on
+ENV GOPROXY=https://goproxy.cn
+RUN go get ./... \
+    && go build -o gin-vue-admin
+
+FROM golang:1.12 AS serve
+
+COPY --from=build /go/src/gin-vue-admin /go/src/gin-vue-admin
+
+EXPOSE 8080
+ENTRYPOINT [ "./gin-vue-admin" ]

+ 8 - 5
QMPlusServer/config/config.go

@@ -32,11 +32,14 @@ type CasbinConfig struct { //casbin配置
 }
 
 type MysqlAdmin struct { // mysql admin 数据库配置
-	Username string `json:"username"`
-	Password string `json:"password"`
-	Path     string `json:"path"`
-	Dbname   string `json:"dbname"`
-	Config   string `json:"config"`
+	Username     string `json:"username"`
+	Password     string `json:"password"`
+	Path         string `json:"path"`
+	Dbname       string `json:"dbname"`
+	Config       string `json:"config"`
+	MaxIdleConns int    `json:"maxIdleConns"`
+	MaxOpenConns int    `json:"maxOpenConns"`
+	LogMode      bool   `json:"maxOpenConns"`
 }
 
 type RedisAdmin struct { // Redis admin 数据库配置

+ 3 - 2
QMPlusServer/init/qmsql/initMysql.go

@@ -15,8 +15,9 @@ func InitMysql(admin config.MysqlAdmin) *gorm.DB {
 		log.L.Error("DEFAULTDB数据库启动异常",err)
 	} else {
 		DEFAULTDB = db
-		DEFAULTDB.DB().SetMaxIdleConns(10)
-		DEFAULTDB.DB().SetMaxOpenConns(100)
+		DEFAULTDB.DB().SetMaxIdleConns(admin.MaxIdleConns)
+		DEFAULTDB.DB().SetMaxOpenConns(admin.MaxOpenConns)
+		DEFAULTDB.LogMode(admin.LogMode)
 	}
 	return DEFAULTDB
 }

+ 14 - 1
QMPlusServer/main.go

@@ -1,6 +1,8 @@
 package main
 
 import (
+	"os"
+
 	"fmt"
 	"gin-vue-admin/cmd"
 	"gin-vue-admin/config"
@@ -20,12 +22,23 @@ import (
 // @name x-token
 // @BasePath /
 
+var (
+	mysqlHost = os.Getenv("MYSQLHOST")
+	mysqlPort = os.Getenv("MYSQLPORT")
+)
+
 func main() {
 	if err:= qmlog.NewLogger(); err != nil {
 		fmt.Println(err)
 	}
+	// 可以通过环境变量来覆盖配置值
+	// 未设定有效的环境变量时,使用配置值
+	mysqlConfig := config.GinVueAdminconfig.MysqlAdmin
+	if mysqlHost != "" && mysqlPort != "" {
+		mysqlConfig.Path = mysqlHost + ":" + mysqlPort
+	}
 	// 链接初始化数据库
-	db := qmsql.InitMysql(config.GinVueAdminconfig.MysqlAdmin)
+	db := qmsql.InitMysql(mysqlConfig) // 链接初始化数据库
 	if config.GinVueAdminconfig.System.UseMultipoint {
 		// 初始化redis服务
 		_ = initRedis.InitRedis()

+ 23 - 0
QMPlusServer/model/autoCodeModel/autoCode.go

@@ -0,0 +1,23 @@
+package autoCodeModel
+
+//开发中功能,若您发现这块代码可以研究,可以无视
+type AutoCodeStruct struct {
+	StructName string      `json:"structName"`
+	StructType []string    `json:"structType"`
+	Components []Component `json:"components"`
+}
+
+type Component struct {
+	ComponentName       string       `json:"componentName"`
+	ComponentType       string       `json:"componentType"`
+	Ismultiple          bool         `json:"isMultiple"`
+	ComponentShowType   string       `json:"componentShowType"`
+	NideDictionary      bool         `json:"nideDictionary"`
+	DictionaryName      string       `json:"dictionaryName"`
+	ComponentDictionary []Dictionary `json:"dictionary"`
+}
+
+type Dictionary struct {
+	Label string `json:"label"`
+	Value string `json:"value"`
+}

+ 4 - 1
QMPlusServer/static/config/config.json

@@ -10,7 +10,10 @@
         "password": "YINGL19980716.",
         "path": "127.0.0.1:3306",
         "dbname": "qmPlus",
-        "config": "charset=utf8\u0026parseTime=True\u0026loc=Local"
+        "config": "charset=utf8\u0026parseTime=True\u0026loc=Local",
+        "maxIdleConns": 10,
+        "maxOpenConns": 100,
+        "logMode": true
     },
     "qiniu": {
         "accessKey": "25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ",

+ 1 - 1
QMPlusVuePage/src/view/login/login.vue

@@ -20,7 +20,7 @@
           <el-input
             v-model="loginForm.captcha"
             name="logVerify"
-            placeholder="请输入验证码(测试环境有问题可不输入 本地搭建环境可用)"
+            placeholder="请输入验证码"
             maxlength="10"
           />
           <img :src="path + picPath" alt="请输入验证码" @click="loginVefify()" class="vPic">

+ 179 - 0
QMPlusVuePage/src/view/superAdmin/autoCode/component/componentDialog.vue

@@ -0,0 +1,179 @@
+<template>
+    <div>
+        <el-form :model="dialogMiddle"  :inline="true" >
+            <el-form-item label="组件名称" label-width="80" :span="8">
+                <el-input v-model="dialogMiddle.componentName" autocomplete="off"></el-input>
+            </el-form-item>
+            <el-form-item label="数据类型" label-width="80" :span="8">
+            <el-select v-model="dialogMiddle.componentType" placeholder="请选择活动区域">
+                <el-option
+                    v-for="item in typeOptions"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value">
+                </el-option>
+            </el-select>
+            </el-form-item>
+            <el-form-item label="展示类型" label-width="80" :span="8">
+            <el-select v-model="dialogMiddle.componentShowType" placeholder="请选择活动区域">
+                <el-option
+                    v-for="item in showTypeOptions"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value">
+                    </el-option>
+            </el-select>
+            </el-form-item>
+            <el-form-item label="字典Key" label-width="80" :span="8">
+                <el-input v-model="dialogMiddle.dictionaryName" autocomplete="off"></el-input>
+            </el-form-item>
+            <div>
+            <el-form-item label="是否多选" label-width="80">
+                <el-switch
+                    v-model="dialogMiddle.isMultiple"
+                    active-text="多选"
+                    inactive-text="单选">
+                </el-switch>
+            </el-form-item>
+            </div>
+            <div>
+            <el-form-item label="是否使用字典" label-width="80">
+                <el-switch
+                    v-model="dialogMiddle.nideDictionary"
+                    active-text="使用"
+                    inactive-text="不使用">
+                </el-switch>
+            </el-form-item>
+            </div>
+        </el-form>
+        <div class="button-box clearflex">
+            <el-button @click="addDictionary" type="primary">新增组件</el-button>
+        </div>
+         <el-table
+            :data="dialogMiddle.componentDictionary"
+            stripe
+            style="width: 100%">
+            <el-table-column
+            label="展示值"
+            >
+            <template slot-scope="scope">
+                <el-input v-model="scope.row.label"></el-input>
+            </template>
+            </el-table-column>
+            <el-table-column
+            label="交互值"
+            >
+            <template slot-scope="scope">
+                <el-input v-model="scope.row.value"></el-input>
+            </template>
+            </el-table-column>
+             <el-table-column
+            label="操作"
+            >
+            <template slot-scope="scope">
+                <el-popover
+                    placement="top"
+                    width="160"
+                    v-model="scope.row.visible">
+                    <p>这是一段内容这是一段内容确定删除吗?</p>
+                    <div style="text-align: right; margin: 0">
+                        <el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
+                        <el-button type="primary" size="mini" @click="deleteRow(scope)">确定</el-button>
+                    </div>
+                    <el-button type="text" slot="reference">删除</el-button>
+                    </el-popover>
+            </template>
+            </el-table-column>
+        </el-table>
+    </div>
+</template>
+<script>
+const dictionaryTemplate = {
+    label:"",
+    value:"",
+    visible:false
+}
+export default {
+    name:"ComponentDialog",
+    props:{
+        dialogMiddle:{
+            type:Object,
+            default:function(){
+                return {}
+            }
+        }
+    },
+    data(){
+        return{
+            visible:false,
+            typeOptions:[
+                {
+                    label:"字符串",
+                    value:"string"
+                },
+                {
+                    label:"整型",
+                    value:"int"
+                },
+                {
+                    label:"布尔值",
+                    value:"bool"
+                },
+                {
+                    label:"浮点型",
+                    value:"float64"
+                },
+                {
+                    label:"时间",
+                    value:"time.Time"
+                },
+            ],
+            showTypeOptions:[
+                {
+                    label:"单选框",
+                    value:"radio"
+                },
+                {
+                    label:"多选框",
+                    value:"checkBox"
+                },
+                {
+                    label:"输入框",
+                    value:"input"
+                },
+                {
+                    label:"计数器",
+                    value:"inputNumber"
+                },
+                {
+                    label:"选择器",
+                    value:"select"
+                },
+                {
+                    label:"级联选择器",
+                    value:"cascader"
+                },
+                {
+                    label:"开关",
+                    value:"switch"
+                },
+                {
+                    label:"时间日期选择器",
+                    value:"datePicker"
+                }
+            ]
+        }
+    },
+    methods:{
+        addDictionary(){
+            this.dialogMiddle.componentDictionary.push({...dictionaryTemplate})
+        },
+        deleteRow(row){
+            this.dialogMiddle.componentDictionary.splice(row.$index,1)
+        }
+    }
+}
+</script>
+<style lang="scss">
+    
+</style>

+ 2 - 0
QMPlusVuePage/src/view/superAdmin/autoCode/index.vue

@@ -1,5 +1,6 @@
 <template>
     <div>
+        <!-- 开发中功能,若您发现这块代码可以研究,可以无视 -->
         <!-- 此版本为简单版 -->
         <!-- 结构体基础配置 -->
         <el-form ref="form" :model="form" label-width="100px" :inline="true">
@@ -143,6 +144,7 @@ export default {
             this.form.components.splice(index,1)
         },
         enterForm(){
+            console.log(this.form)
         }
     }
 }

+ 11 - 0
docker-compose.yml

@@ -16,3 +16,14 @@ services:
       MYSQL_ROOT_PASSWORD: Aa@6447985
       MYSQL_DATABASE: qmPlus
     user: root
+  server:
+    build: ./QMPlusServer
+    ports:
+      - 8080:8080
+      - 8888:8888
+    environment:
+      MYSQLHOST: database
+    working_dir: /go/src/gin-vue-admin
+    restart: always
+    depends_on:
+      - database