Browse Source

增加自动化代码回滚功能

增加自动化代码回滚功能
main
奇淼(piexlmax 3 years ago
committed by GitHub
parent
commit
ea693efc66
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      server/model/sys_autocode_history.go
  2. 1
      server/source/api.go
  3. 1
      server/source/casbin.go
  4. 2
      server/source/menu.go
  5. 8
      web/src/api/autoCode.js
  6. 19
      web/src/view/systemTools/autoCodeAdmin/index.vue

2
server/model/sys_autocode_history.go

@ -13,6 +13,6 @@ type SysAutoCodeHistory struct {
StructName string `json:"structName"`
StructCNName string `json:"structCNName"`
ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容
Flag int // 表示对应状态 0 代表创建, 1 代表回滚 ...
Flag int `json:"flag"` // 表示对应状态 0 代表创建, 1 代表回滚 ...
}

1
server/source/api.go

@ -89,6 +89,7 @@ var apis = []model.SysApi{
{global.GVA_MODEL{ID: 86, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getSysHistory", "查询回滚记录", "autoCode", "POST"},
{global.GVA_MODEL{ID: 87, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/rollback", "回滚自动生成代码", "autoCode", "POST"},
{global.GVA_MODEL{ID: 88, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getMeta", "获取meta信息", "autoCode", "POST"},
{global.GVA_MODEL{ID: 89, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/delSysHistory", "删除回滚记录", "autoCode", "POST"},
}
//@author: [SliverHorn](https://github.com/SliverHorn)

1
server/source/casbin.go

@ -89,6 +89,7 @@ var carbines = []gormadapter.CasbinRule{
{PType: "p", V0: "888", V1: "/autoCode/getSysHistory", V2: "POST"},
{PType: "p", V0: "888", V1: "/autoCode/rollback", V2: "POST"},
{PType: "p", V0: "888", V1: "/autoCode/getMeta", V2: "POST"},
{PType: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"},
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
{PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
{PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},

2
server/source/menu.go

@ -38,7 +38,7 @@ var menus = []model.SysBaseMenu{
{GVA_MODEL: global.GVA_MODEL{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Hidden: false, Component: "/", Sort: 0, Meta: model.Meta{Title: "官方网站", Icon: "s-home"}},
{GVA_MODEL: global.GVA_MODEL{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: model.Meta{Title: "服务器状态", Icon: "cloudy"}},
{GVA_MODEL: global.GVA_MODEL{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "14", Path: "autoCodeAdmin", Name: "autoCodeAdmin", Hidden: false, Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: model.Meta{Title: "自动化代码管理", Icon: "s-finance"}},
{GVA_MODEL: global.GVA_MODEL{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "14", Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Hidden: true, Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 0, Meta: model.Meta{Title: "自动化代码(复用)", Icon: "s-finance"}},
{GVA_MODEL: global.GVA_MODEL{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "14", Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Hidden: true, Component: "view/systemTools/autoCode/index.vue", Sort: 0, Meta: model.Meta{Title: "自动化代码(复用)", Icon: "s-finance"}},
}
//@author: [SliverHorn](https://github.com/SliverHorn)

8
web/src/api/autoCode.js

@ -84,3 +84,11 @@ export const getMeta = (data) => {
data
})
}
export const delSysHistory = (data) => {
return service({
url: '/autoCode/delSysHistory',
method: 'post',
data
})
}

19
web/src/view/systemTools/autoCodeAdmin/index.vue

@ -48,9 +48,9 @@
<el-table-column label="操作" min-width="180">
<template slot-scope="scope">
<div>
<el-button size="mini" type="primary" @click="rollback(scope.row)">回滚</el-button>
<el-button size="mini" type="primary" :disabled="scope.row.flag === 1" @click="rollback(scope.row)">回滚</el-button>
<el-button size="mini" type="success" @click="goAutoCode(scope.row)">复用</el-button>
<el-button size="mini" type="warning" @click="deleteRow(scope.row)">删除</el-button>
<el-button size="mini" type="danger" @click="deleteRow(scope.row)">删除</el-button>
</div>
</template>
</el-table-column>
@ -71,7 +71,7 @@
<script>
// mixins getTableData this.searchInfo
import { getSysHistory, rollback } from '@/api/autoCode.js'
import { getSysHistory, rollback, delSysHistory } from '@/api/autoCode.js'
import { formatTimeToStr } from '@/utils/date'
import infoList from '@/mixins/infoList'
@ -104,6 +104,19 @@ export default {
this.getTableData()
},
methods: {
async deleteRow(row) {
this.$confirm('此操作将删除本历史, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async() => {
const res = await delSysHistory({ id: Number(row.ID) })
if (res.code === 0) {
this.$message.success('删除成功')
this.getTableData()
}
})
},
async rollback(row) {
this.$confirm('此操作将删除自动创建的文件和api, 是否继续?', '提示', {
confirmButtonText: '确定',

Loading…
Cancel
Save