Browse Source

Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev

main
pixel 4 years ago
parent
commit
6dade013a6
  1. 4
      README.md
  2. 2
      server/middleware/cors.go
  3. 4
      server/middleware/jwt.go
  4. 4
      server/resource/template/fe/table.vue.tpl
  5. 4
      server/resource/template/te/model.go.tpl
  6. 27
      server/service/exa_simple_uploader.go
  7. 5
      web/src/style/main.scss
  8. 1
      web/src/view/systemTools/autoCode/component/fieldDialog.vue

4
README.md

@ -12,12 +12,14 @@
[English](./README-en.md) | 简体中文
[gitee地址](https://gitee.com/pixelmax/gin-vue-admin)
[gitee地址](https://gitee.com/pixelmax/gin-vue-admin)|
[github地址](https://github.com/flipped-aurora/gin-vue-admin)
# 项目文档
[在线文档](https://www.gin-vue-admin.com/) : https://www.gin-vue-admin.com/
[从环境到部署教学视频](https://www.bilibili.com/video/BV1fV411y7dT)
[开发教学](https://www.gin-vue-admin.com/docs/help) (贡献者: <a href="https://github.com/LLemonGreen">LLemonGreen</a> And <a href="https://github.com/fkk0509">Fann</a>)
- 前端UI框架:[element-ui](https://github.com/ElemeFE/element)
- 后台框架:[gin](https://github.com/gin-gonic/gin)

2
server/middleware/cors.go

@ -11,7 +11,7 @@ func Cors() gin.HandlerFunc {
method := c.Request.Method
origin := c.Request.Header.Get("Origin")
c.Header("Access-Control-Allow-Origin", origin)
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id\"")
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id")
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT")
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
c.Header("Access-Control-Allow-Credentials", "true")

4
server/middleware/jwt.go

@ -16,7 +16,7 @@ import (
func JWTAuth() gin.HandlerFunc {
return func(c *gin.Context) {
// 我们这里jwt鉴权取头部信息 x-token 登录时回返回token信息 这里前端需要把token存储到cookie或者本地localSstorage中 不过需要跟后端协商过期时间 可以约定刷新令牌或者重新登录
// 我们这里jwt鉴权取头部信息 x-token 登录时回返回token信息 这里前端需要把token存储到cookie或者本地localStorage中 不过需要跟后端协商过期时间 可以约定刷新令牌或者重新登录
token := c.Request.Header.Get("x-token")
if token == "" {
response.Result(response.ERROR, gin.H{
@ -66,7 +66,7 @@ func JWTAuth() gin.HandlerFunc {
if err!=nil {
global.GVA_LOG.Error("get redis jwt failed", zap.Any("err", err))
}else{
service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken})
_ = service.JsonInBlacklist(model.JwtBlacklist{Jwt: RedisJwtToken})
//当之前的取成功时才进行拉黑操作
}
// 无论如何都要记录当前的活跃状态

4
server/resource/template/fe/table.vue.tpl

@ -67,7 +67,7 @@
{{ end }}
<el-table-column label="按钮组">
<template slot-scope="scope">
<el-button @click="update{{.StructName}}(scope.row)" size="small" type="primary">变更</el-button>
<el-button class="table-button" @click="update{{.StructName}}(scope.row)" size="small" type="primary" icon="el-icon-edit">变更</el-button>
<el-popover placement="top" width="160" v-model="scope.row.visible">
<p>确定要删除吗?</p>
<div style="text-align: right; margin: 0">
@ -136,7 +136,7 @@ import {
find{{.StructName}},
get{{.StructName}}List
} from "@/api/{{.PackageName}}"; // 此处请自行替换地址
import { formatTimeToStr } from "@/utils/data";
import { formatTimeToStr } from "@/utils/date";
import infoList from "@/mixins/infoList";
export default {
name: "{{.StructName}}",

4
server/resource/template/te/model.go.tpl

@ -9,9 +9,9 @@ import (
type {{.StructName}} struct {
global.GVA_MODEL {{- range .Fields}}
{{- if eq .FieldType "bool" }}
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
{{- else }}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
{{- end }} {{- end }}
}

27
server/service/exa_simple_uploader.go

@ -51,27 +51,26 @@ func MergeFileMd5(md5 string, fileName string) (err error) {
if err != nil {
return err
}
//创建事务
tx := global.GVA_DB.Begin()
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
//删除切片信息
err = tx.Delete(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, false).Error
// 添加文件信息
if err != nil {
if err = tx.Delete(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, false).Error; err != nil {
fmt.Println(err)
tx.Rollback()
return err
}
err = tx.Create(&model.ExaSimpleUploader{
data := model.ExaSimpleUploader{
Identifier: md5,
IsDone: true,
FilePath: finishDir + fileName,
Filename: fileName,
}).Error
if err != nil {
}
// 添加文件信息
if err = tx.Create(&data).Error; err != nil {
fmt.Println(err)
tx.Rollback()
return err
}
tx.Commit()
//清除切片
err = os.RemoveAll(dir)
return
return nil
})
err = os.RemoveAll(dir) //清除切片
return err
}

5
web/src/style/main.scss

@ -1027,3 +1027,8 @@ li {
cursor: pointer;
font-size: 13px;
}
.table-button{
margin-right:8px !important;
}

1
web/src/view/systemTools/autoCode/component/fieldDialog.vue

@ -195,7 +195,6 @@ export default {
}
},
async created() {
this.getDbfdOptions();
const dictRes = await getSysDictionaryList({
page: 1,
pageSize: 999999

Loading…
Cancel
Save