Skip to content

Commit 11efbe7

Browse files
author
pixel
committed
initdb默认string长度改为191
1 parent 329d094 commit 11efbe7

File tree

9 files changed

+207
-137
lines changed

9 files changed

+207
-137
lines changed

server/api/v1/sys_auto_code.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,12 @@ func PreviewTemp(c *gin.Context) {
3030
response.FailWithMessage(err.Error(), c)
3131
return
3232
}
33-
if a.AutoCreateApiToSql {
34-
if err := service.AutoCreateApi(&a); err != nil {
35-
global.GVA_LOG.Error("自动化创建失败!请自行清空垃圾数据!", zap.Any("err", err))
36-
c.Writer.Header().Add("success", "false")
37-
c.Writer.Header().Add("msg", url.QueryEscape("自动化创建失败!请自行清空垃圾数据!"))
38-
return
39-
}
40-
}
41-
m, err := service.PreviewTemp(a)
33+
autoCode, err := service.PreviewTemp(a)
4234
if err != nil {
43-
c.Writer.Header().Add("success", "false")
44-
c.Writer.Header().Add("msg", url.QueryEscape(err.Error()))
35+
global.GVA_LOG.Error("预览失败!", zap.Any("err", err))
36+
response.FailWithMessage("预览失败", c)
4537
} else {
46-
c.Writer.Header().Add("Content-Type", "application/json")
47-
c.Writer.Header().Add("success", "true")
48-
c.JSON(200, m)
38+
response.OkWithDetailed(gin.H{"autoCode": autoCode}, "预览成功", c)
4939
}
5040
}
5141

server/cmd/gva/mysql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (m *_mysql) Init() {
4444
m._config.DisableForeignKeyConstraintWhenMigrating = true
4545
m.db, m.err = gorm.Open(mysql.New(mysql.Config{
4646
DSN: global.GVA_CONFIG.Mysql.Dsn(), // DSN data source name
47-
DefaultStringSize: 256, // string 类型字段的默认长度
47+
DefaultStringSize: 191, // string 类型字段的默认长度
4848
DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
4949
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
5050
DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列

server/cmd/information/system/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ var apis = []model.SysApi{
9292
{global.GVA_MODEL{ID: 77, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getMyNeed", "获取我的待办", "workflowProcess", "GET"},
9393
{global.GVA_MODEL{ID: 78, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getWorkflowMoveByID", "根据id获取当前节点详情和历史", "workflowProcess", "GET"},
9494
{global.GVA_MODEL{ID: 79, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/completeWorkflowMove", "提交工作流", "workflowProcess", "POST"},
95+
{global.GVA_MODEL{ID: 80, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/preview", "预览自动化代码", "autoCode", "POST"},
9596
}
9697

9798
//@author: [SliverHorn](https://github.com/SliverHorn)

server/cmd/information/system/casbin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var carbines = []gormadapter.CasbinRule{
5555
{PType: "p", V0: "888", V1: "/customer/customer", V2: "GET"},
5656
{PType: "p", V0: "888", V1: "/customer/customerList", V2: "GET"},
5757
{PType: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
58+
{PType: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"},
5859
{PType: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
5960
{PType: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
6061
{PType: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},

server/service/sys_auto_code.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,20 @@ func PreviewTemp(autoCode model.AutoCodeStruct) (map[string]string, error) {
6767
return nil, err
6868
}
6969
builder := strings.Builder{}
70-
builder.WriteString("```\n")
70+
builder.WriteString("```")
71+
if ext != "" && strings.Contains(ext, ".") {
72+
builder.WriteString(strings.Replace(ext, ".", "", -1))
73+
}
74+
builder.WriteString("\n\n")
7175
data, err := ioutil.ReadAll(f)
7276
if err != nil {
7377
return nil, err
7478
}
7579
builder.Write(data)
76-
builder.WriteString("\n```")
77-
if ext != "" && strings.Contains(ext, ".") {
78-
builder.WriteString(strings.Replace(ext, ".", "", -1))
79-
}
80+
builder.WriteString("\n\n```")
8081

81-
ret[value.autoCodePath] = builder.String()
82+
pathArr := strings.Split(value.autoCodePath,"\\")
83+
ret[pathArr[1]+"-"+pathArr[3]] = builder.String()
8284
_ = f.Close()
8385

8486
}

web/package.json

Lines changed: 75 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,77 @@
11
{
2-
"name": "gin-vue-admin",
3-
"version": "0.1.0",
4-
"private": true,
5-
"scripts": {
6-
"serve": "node openDocument.js && vue-cli-service serve",
7-
"build": "vue-cli-service build",
8-
"lint": "vue-cli-service lint"
2+
"name": "gin-vue-admin",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "node openDocument.js && vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"@antv/dom-util": "2.0.2",
12+
"@antv/g-canvas": "^0.4.12",
13+
"@antv/g6": "3.5.2",
14+
"@antv/matrix-util": "2.0.7",
15+
"@antv/util": "~2.0.9",
16+
"@moefe/vue-aplayer": "^2.0.0-beta.5",
17+
"axios": "^0.19.2",
18+
"core-js": "^3.6.5",
19+
"echarts": "^4.7.0",
20+
"element-ui": "^2.12.0",
21+
"highlight.js": "^10.6.0",
22+
"marked": "^2.0.0",
23+
"node-sass": "^4.14.1",
24+
"path": "^0.12.7",
25+
"qs": "^6.8.0",
26+
"quill": "^1.3.7",
27+
"sass-loader": "^8.0.0",
28+
"screenfull": "^5.0.2",
29+
"script-ext-html-webpack-plugin": "^2.1.4",
30+
"spark-md5": "^3.0.1",
31+
"timeline-vuejs": "1.1.1",
32+
"vue": "^2.6.10",
33+
"vue-particle-line": "^0.1.4",
34+
"vue-router": "^3.1.3",
35+
"vue-simple-uploader": "^0.7.4",
36+
"vuescroll": "^4.14.4",
37+
"vuex": "^3.1.1",
38+
"vuex-persist": "^2.1.0"
39+
},
40+
"devDependencies": {
41+
"@vue/cli-plugin-babel": "^4.5.6",
42+
"@vue/cli-plugin-eslint": "^4.5.6",
43+
"@vue/cli-service": "^4.5.6",
44+
"babel-eslint": "^10.1.0",
45+
"eslint": "^6.7.2",
46+
"eslint-plugin-vue": "^6.2.2",
47+
"vue-template-compiler": "^2.6.10",
48+
"core-js": "^3.3.2",
49+
"node-sass": "^4.12.0",
50+
"numericjs": "^1.2.6",
51+
"raw-loader": "^3.1.0",
52+
"sass-loader": "^8.0.0"
53+
},
54+
"eslintConfig": {
55+
"root": true,
56+
"env": {
57+
"node": true
958
},
10-
"dependencies": {
11-
"@moefe/vue-aplayer": "^2.0.0-beta.5",
12-
"axios": "^0.19.2",
13-
"core-js": "^3.6.5",
14-
"echarts": "^4.7.0",
15-
"element-ui": "^2.12.0",
16-
"node-sass": "^4.14.1",
17-
"path": "^0.12.7",
18-
"qs": "^6.8.0",
19-
"quill": "^1.3.7",
20-
"sass-loader": "^8.0.0",
21-
"screenfull": "^5.0.2",
22-
"script-ext-html-webpack-plugin": "^2.1.4",
23-
"spark-md5": "^3.0.1",
24-
"timeline-vuejs": "1.1.1",
25-
"vue": "^2.6.10",
26-
"vue-particle-line": "^0.1.4",
27-
"vue-router": "^3.1.3",
28-
"vue-simple-uploader": "^0.7.4",
29-
"vuescroll": "^4.14.4",
30-
"vuex": "^3.1.1",
31-
"vuex-persist": "^2.1.0",
32-
"@antv/dom-util": "2.0.2",
33-
"@antv/matrix-util": "2.0.7",
34-
"@antv/g-canvas": "^0.4.12",
35-
"@antv/g6": "3.5.2",
36-
"@antv/util": "~2.0.9"
37-
},
38-
"devDependencies": {
39-
"@vue/cli-plugin-babel": "^4.5.6",
40-
"@vue/cli-plugin-eslint": "^4.5.6",
41-
"@vue/cli-service": "^4.5.6",
42-
"babel-eslint": "^10.1.0",
43-
"eslint": "^6.7.2",
44-
"eslint-plugin-vue": "^6.2.2",
45-
"vue-template-compiler": "^2.6.10",
46-
"core-js": "^3.3.2",
47-
"node-sass": "^4.12.0",
48-
"numericjs": "^1.2.6",
49-
"raw-loader": "^3.1.0",
50-
"sass-loader": "^8.0.0"
51-
},
52-
"eslintConfig": {
53-
"root": true,
54-
"env": {
55-
"node": true
56-
},
57-
"extends": [
58-
"plugin:vue/essential",
59-
"eslint:recommended"
60-
],
61-
"rules": {},
62-
"parserOptions": {
63-
"parser": "babel-eslint"
64-
}
65-
},
66-
"postcss": {
67-
"plugins": {
68-
"autoprefixer": {}
69-
}
70-
},
71-
"browserslist": [
72-
"> 1%",
73-
"last 2 versions"
74-
]
75-
}
59+
"extends": [
60+
"plugin:vue/essential",
61+
"eslint:recommended"
62+
],
63+
"rules": {},
64+
"parserOptions": {
65+
"parser": "babel-eslint"
66+
}
67+
},
68+
"postcss": {
69+
"plugins": {
70+
"autoprefixer": {}
71+
}
72+
},
73+
"browserslist": [
74+
"> 1%",
75+
"last 2 versions"
76+
]
77+
}

web/src/api/autoCode.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import service from '@/utils/request'
2-
// @Tags api
3-
// @Summary 分页获取角色列表
4-
// @Security ApiKeyAuth
5-
// @accept application/json
6-
// @Produce application/json
7-
// @Param data body modelInterface.PageInfo true "分页获取用户列表"
8-
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
9-
// @Router /api/getApiList [post]
10-
// {
11-
// page int
12-
// pageSize int
13-
// }
2+
3+
export const preview = (data) => {
4+
return service({
5+
url: "/autoCode/preview",
6+
method: 'post',
7+
data,
8+
})
9+
}
10+
1411
export const createTemp = (data) => {
1512
return service({
1613
url: "/autoCode/createTemp",
@@ -20,7 +17,6 @@ export const createTemp = (data) => {
2017
})
2118
}
2219

23-
2420
// @Tags SysApi
2521
// @Summary 获取当前所有数据库
2622
// @Security ApiKeyAuth
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<div class="previewCode">
3+
<el-tabs v-model="activeName">
4+
<el-tab-pane :label="key" :name="key" v-for="(item,key) in previewCode" :key="key">
5+
<div style="background:#fff;padding:0 20px" :id="key"></div>
6+
</el-tab-pane>
7+
</el-tabs>
8+
</div>
9+
</template>
10+
11+
<script>
12+
import marked from "marked"
13+
import hljs from "highlight.js";
14+
// import 'highlight.js/styles/atelier-cave-light.css';
15+
import 'highlight.js/styles/atelier-plateau-light.css';
16+
export default {
17+
props:{
18+
previewCode:{
19+
type:Object,
20+
default(){
21+
return {}
22+
}
23+
}
24+
},
25+
data(){
26+
return{
27+
activeName: "",
28+
}
29+
},
30+
mounted(){
31+
marked.setOptions({
32+
renderer: new marked.Renderer(),
33+
highlight: function(code) {
34+
return hljs.highlightAuto(code).value;
35+
},
36+
pedantic: false,
37+
gfm: true,
38+
tables: true,
39+
breaks: false,
40+
sanitize: false,
41+
smartLists: true,
42+
smartypants: false,
43+
xhtml: false
44+
}
45+
);
46+
for(const key in this.previewCode){
47+
if(this.activeName == ""){
48+
this.activeName = key
49+
}
50+
document.getElementById(key).innerHTML = marked(this.previewCode[key])
51+
}
52+
}
53+
}
54+
</script>
55+
56+
<style lang="scss">
57+
58+
</style>

0 commit comments

Comments
 (0)