Browse Source

修改了自动化代码自动化创建api会被禁止的bug

main
QM303176530 4 years ago
parent
commit
78559ed97d
  1. 2
      server/config.yaml
  2. 2
      server/core/server.go
  3. 10
      server/service/sys_auto_code.go

2
server/config.yaml

@ -56,7 +56,7 @@ mysql:
config: 'charset=utf8mb4&parseTime=True&loc=Local'
db-name: 'qmPlus'
username: 'root'
password: 'root123'
password: 'Aa@6447985'
max-idle-conns: 10
max-open-conns: 100
log-mode: false

2
server/core/server.go

@ -29,7 +29,7 @@ func RunWindowsServer() {
fmt.Printf(`
欢迎使用 Gin-Vue-Admin
当前版本:V2.3.6
当前版本:V2.3.7
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:8080
如果项目让您获得了收益希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/docs/coffee

10
server/service/sys_auto_code.go

@ -209,7 +209,6 @@ func addAutoMoveFile(data *tplData) {
}
}
//@author: [piexlmax](https://github.com/piexlmax)
//@author: [SliverHorn](https://github.com/SliverHorn)
//@function: CreateApi
@ -259,11 +258,10 @@ func AutoCreateApi(a *model.AutoCodeStruct) (err error) {
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
for _, v := range apiList {
var api model.SysApi
if err := tx.Where("path = ? AND method = ?", v.Path, v.Method).First(&api).Error; err != nil {
return err
}
if err := tx.Create(&v).Error; err != nil { // 遇到错误时回滚事务
return err
if errors.Is(tx.Where("path = ? AND method = ?", v.Path, v.Method).First(&api).Error, gorm.ErrRecordNotFound) {
if err := tx.Create(&v).Error; err != nil { // 遇到错误时回滚事务
return err
}
}
}
return nil

Loading…
Cancel
Save