Skip to content

Commit ea693ef

Browse files
author
奇淼(piexlmax
authored
增加自动化代码回滚功能
增加自动化代码回滚功能
2 parents 2d8e2ae + df33036 commit ea693ef

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

server/model/sys_autocode_history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ type SysAutoCodeHistory struct {
1313
StructName string `json:"structName"`
1414
StructCNName string `json:"structCNName"`
1515
ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容
16-
Flag int // 表示对应状态 0 代表创建, 1 代表回滚 ...
16+
Flag int `json:"flag"` // 表示对应状态 0 代表创建, 1 代表回滚 ...
1717

1818
}

server/source/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ var apis = []model.SysApi{
8989
{global.GVA_MODEL{ID: 86, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getSysHistory", "查询回滚记录", "autoCode", "POST"},
9090
{global.GVA_MODEL{ID: 87, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/rollback", "回滚自动生成代码", "autoCode", "POST"},
9191
{global.GVA_MODEL{ID: 88, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getMeta", "获取meta信息", "autoCode", "POST"},
92+
{global.GVA_MODEL{ID: 89, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/delSysHistory", "删除回滚记录", "autoCode", "POST"},
9293
}
9394

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

server/source/casbin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ var carbines = []gormadapter.CasbinRule{
8989
{PType: "p", V0: "888", V1: "/autoCode/getSysHistory", V2: "POST"},
9090
{PType: "p", V0: "888", V1: "/autoCode/rollback", V2: "POST"},
9191
{PType: "p", V0: "888", V1: "/autoCode/getMeta", V2: "POST"},
92+
{PType: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"},
9293
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
9394
{PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
9495
{PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},

server/source/menu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var menus = []model.SysBaseMenu{
3838
{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"}},
3939
{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"}},
4040
{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"}},
41-
{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"}},
41+
{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"}},
4242
}
4343

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

web/src/api/autoCode.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,11 @@ export const getMeta = (data) => {
8484
data
8585
})
8686
}
87+
88+
export const delSysHistory = (data) => {
89+
return service({
90+
url: '/autoCode/delSysHistory',
91+
method: 'post',
92+
data
93+
})
94+
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
<el-table-column label="操作" min-width="180">
4949
<template slot-scope="scope">
5050
<div>
51-
<el-button size="mini" type="primary" @click="rollback(scope.row)">回滚</el-button>
51+
<el-button size="mini" type="primary" :disabled="scope.row.flag === 1" @click="rollback(scope.row)">回滚</el-button>
5252
<el-button size="mini" type="success" @click="goAutoCode(scope.row)">复用</el-button>
53-
<el-button size="mini" type="warning" @click="deleteRow(scope.row)">删除</el-button>
53+
<el-button size="mini" type="danger" @click="deleteRow(scope.row)">删除</el-button>
5454
</div>
5555
</template>
5656
</el-table-column>
@@ -71,7 +71,7 @@
7171

7272
<script>
7373
// 获取列表内容封装在mixins内部 getTableData方法 初始化已封装完成 条件搜索时候 请把条件安好后台定制的结构体字段 放到 this.searchInfo 中即可实现条件搜索
74-
import { getSysHistory, rollback } from '@/api/autoCode.js'
74+
import { getSysHistory, rollback, delSysHistory } from '@/api/autoCode.js'
7575
import { formatTimeToStr } from '@/utils/date'
7676
import infoList from '@/mixins/infoList'
7777
@@ -104,6 +104,19 @@ export default {
104104
this.getTableData()
105105
},
106106
methods: {
107+
async deleteRow(row) {
108+
this.$confirm('此操作将删除本历史, 是否继续?', '提示', {
109+
confirmButtonText: '确定',
110+
cancelButtonText: '取消',
111+
type: 'warning'
112+
}).then(async() => {
113+
const res = await delSysHistory({ id: Number(row.ID) })
114+
if (res.code === 0) {
115+
this.$message.success('删除成功')
116+
this.getTableData()
117+
}
118+
})
119+
},
107120
async rollback(row) {
108121
this.$confirm('此操作将删除自动创建的文件和api, 是否继续?', '提示', {
109122
confirmButtonText: '确定',

0 commit comments

Comments
 (0)