diff --git a/server/api/v1/sys_auto_code.go b/server/api/v1/sys_auto_code.go index a19aeed7..86fc9132 100644 --- a/server/api/v1/sys_auto_code.go +++ b/server/api/v1/sys_auto_code.go @@ -35,7 +35,7 @@ func CreateTemp(c *gin.Context) { return } if a.AutoCreateApiToSql { - apiList := [5]model.SysApi{ + apiList := [6]model.SysApi{ { Path: "/" + a.Abbreviation + "/" + "create" + a.StructName, Description: "新增" + a.Description, @@ -48,6 +48,12 @@ func CreateTemp(c *gin.Context) { ApiGroup: a.Abbreviation, Method: "DELETE", }, + { + Path: "/" + a.Abbreviation + "/" + "delete" + a.StructName+"ByIds", + Description: "批量删除" + a.Description, + ApiGroup: a.Abbreviation, + Method: "DELETE", + }, { Path: "/" + a.Abbreviation + "/" + "update" + a.StructName, Description: "更新" + a.Description, diff --git a/server/api/v1/sys_operation_record.go b/server/api/v1/sys_operation_record.go index ebf191bb..35b95788 100644 --- a/server/api/v1/sys_operation_record.go +++ b/server/api/v1/sys_operation_record.go @@ -48,6 +48,25 @@ func DeleteSysOperationRecord(c *gin.Context) { } } +// @Tags SysOperationRecord +// @Summary 批量删除SysOperationRecord +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "批量删除SysOperationRecord" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" +// @Router /sysOperationRecord/deleteSysOperationRecordByIds [delete] +func DeleteSysOperationRecordByIds(c *gin.Context) { + var IDS request.IdsReq + _ = c.ShouldBindJSON(&IDS) + err := service.DeleteSysOperationRecordByIds(IDS) + if err != nil { + response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) + } else { + response.OkWithMessage("删除成功", c) + } +} + // @Tags SysOperationRecord // @Summary 更新SysOperationRecord // @Security ApiKeyAuth diff --git a/server/config.yaml b/server/config.yaml index 0ed706d0..42be755c 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -11,8 +11,8 @@ jwt: # mysql connect configuration mysql: username: root - password: 'wztxz19971029' - path: '47.103.196.252:3306' + password: 'Aa@6447985' + path: '127.0.0.1:3306' db-name: 'qmPlus' config: 'charset=utf8&parseTime=True&loc=Local' max-idle-conns: 10 diff --git a/server/initialize/db_table.go b/server/initialize/db_table.go index bfe32f22..022fe884 100644 --- a/server/initialize/db_table.go +++ b/server/initialize/db_table.go @@ -22,6 +22,7 @@ func DBTables() { model.ExaFileChunk{}, model.ExaCustomer{}, model.SysOperationRecord{}, + model.TestMore{}, ) global.GVA_LOG.Debug("register table success") } diff --git a/server/initialize/router.go b/server/initialize/router.go index f0428d2e..20662df5 100644 --- a/server/initialize/router.go +++ b/server/initialize/router.go @@ -38,6 +38,7 @@ func Routers() *gin.Engine { router.InitSysDictionaryDetailRouter(ApiGroup) // 字典详情管理 router.InitSysDictionaryRouter(ApiGroup) // 字典管理 router.InitSysOperationRecordRouter(ApiGroup) + router.InitTestMoreRouter(ApiGroup) global.GVA_LOG.Info("router register success") return Router } diff --git a/server/model/request/common.go b/server/model/request/common.go index bfa6249a..f45a950a 100644 --- a/server/model/request/common.go +++ b/server/model/request/common.go @@ -10,3 +10,7 @@ type PageInfo struct { type GetById struct { Id float64 `json:"id" form:"id"` } + +type IdsReq struct { + Ids []int `json:"ids" form:"ids"` +} \ No newline at end of file diff --git a/server/resource/template/fe/api.js.tpl b/server/resource/template/fe/api.js.tpl index ffb02c4b..1c3c6d21 100644 --- a/server/resource/template/fe/api.js.tpl +++ b/server/resource/template/fe/api.js.tpl @@ -33,6 +33,22 @@ export const create{{.StructName}} = (data) => { }) } +// @Tags {{.StructName}} +// @Summary 删除{{.StructName}} +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "批量删除{{.StructName}}" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" +// @Router /{{.Abbreviation}}/delete{{.StructName}} [delete] + export const delete{{.StructName}}ByIds = (data) => { + return service({ + url: "/{{.Abbreviation}}/delete{{.StructName}}ByIds", + method: 'delete', + data + }) + } + // @Tags {{.StructName}} // @Summary 更新{{.StructName}} // @Security ApiKeyAuth diff --git a/server/resource/template/fe/table.vue.tpl b/server/resource/template/fe/table.vue.tpl index bce6ec9f..9c026c62 100644 --- a/server/resource/template/fe/table.vue.tpl +++ b/server/resource/template/fe/table.vue.tpl @@ -27,10 +27,21 @@ 新增{{.Description}} + + +

确定要删除吗?

+
+ 取消 + 确定 +
+ 批量删除 +
+
{ + ids.push(item.ID) + }) + const res = await delete{{.StructName}}ByIds({ ids }) + if (res.code == 0) { + this.$message({ + type: 'success', + message: '删除成功' + }) + this.deleteVisible = false + this.getTableData() + } + }, async update{{.StructName}}(row) { const res = await find{{.StructName}}({ ID: row.ID }); this.type = "update"; diff --git a/server/resource/template/te/api.go.tpl b/server/resource/template/te/api.go.tpl index 1ff29899..4346a480 100644 --- a/server/resource/template/te/api.go.tpl +++ b/server/resource/template/te/api.go.tpl @@ -48,6 +48,25 @@ func Delete{{.StructName}}(c *gin.Context) { } } +// @Tags {{.StructName}} +// @Summary 批量删除{{.StructName}} +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "批量删除{{.StructName}}" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" +// @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete] +func Delete{{.StructName}}ByIds(c *gin.Context) { + var IDS request.IdsReq + _ = c.ShouldBindJSON(&IDS) + err := service.Delete{{.StructName}}ByIds(IDS) + if err != nil { + response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) + } else { + response.OkWithMessage("删除成功", c) + } +} + // @Tags {{.StructName}} // @Summary 更新{{.StructName}} // @Security ApiKeyAuth diff --git a/server/resource/template/te/model.go.tpl b/server/resource/template/te/model.go.tpl index 3125c14b..91ef6e4e 100644 --- a/server/resource/template/te/model.go.tpl +++ b/server/resource/template/te/model.go.tpl @@ -9,9 +9,9 @@ import ( type {{.StructName}} struct { gorm.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 -}}'{{- end -}}"` + {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}}"` {{- else }} - {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:'{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}'{{- end -}}"` + {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}}"` {{- end }} {{- end }} } diff --git a/server/resource/template/te/router.go.tpl b/server/resource/template/te/router.go.tpl index 3d385be6..4177e624 100644 --- a/server/resource/template/te/router.go.tpl +++ b/server/resource/template/te/router.go.tpl @@ -7,10 +7,11 @@ import ( ) func Init{{.StructName}}Router(Router *gin.RouterGroup) { - {{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) + {{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()).Use(middleware.OperationRecord()) { {{.StructName}}Router.POST("create{{.StructName}}", v1.Create{{.StructName}}) // 新建{{.StructName}} {{.StructName}}Router.DELETE("delete{{.StructName}}", v1.Delete{{.StructName}}) // 删除{{.StructName}} + {{.StructName}}Router.DELETE("delete{{.StructName}}ByIds", v1.Delete{{.StructName}}ByIds) // 批量删除{{.StructName}} {{.StructName}}Router.PUT("update{{.StructName}}", v1.Update{{.StructName}}) // 更新{{.StructName}} {{.StructName}}Router.GET("find{{.StructName}}", v1.Find{{.StructName}}) // 根据ID获取{{.StructName}} {{.StructName}}Router.GET("get{{.StructName}}List", v1.Get{{.StructName}}List) // 获取{{.StructName}}列表 diff --git a/server/resource/template/te/service.go.tpl b/server/resource/template/te/service.go.tpl index 79635ee7..b84d4d16 100644 --- a/server/resource/template/te/service.go.tpl +++ b/server/resource/template/te/service.go.tpl @@ -28,6 +28,17 @@ func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) return err } +// @title Delete{{.StructName}}ByIds +// @description delete {{.StructName}}s +// @auth (2020/04/05 20:22) +// @param {{.Abbreviation}} model.{{.StructName}} +// @return error + +func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) { + err = global.GVA_DB.Delete(&[]model.{{.StructName}}{},"id in (?)",ids.Ids).Error + return err +} + // @title Update{{.StructName}} // @description update a {{.StructName}} // @param {{.Abbreviation}} *model.{{.StructName}} diff --git a/server/router/sys_operation_record.go b/server/router/sys_operation_record.go index 53bf0619..a9751f7c 100644 --- a/server/router/sys_operation_record.go +++ b/server/router/sys_operation_record.go @@ -13,8 +13,10 @@ func InitSysOperationRecordRouter(Router *gin.RouterGroup) { { SysOperationRecordRouter.POST("createSysOperationRecord", v1.CreateSysOperationRecord) // 新建SysOperationRecord SysOperationRecordRouter.DELETE("deleteSysOperationRecord", v1.DeleteSysOperationRecord) // 删除SysOperationRecord + SysOperationRecordRouter.DELETE("deleteSysOperationRecordByIds", v1.DeleteSysOperationRecordByIds) // 批量删除SysOperationRecord SysOperationRecordRouter.PUT("updateSysOperationRecord", v1.UpdateSysOperationRecord) // 更新SysOperationRecord SysOperationRecordRouter.GET("findSysOperationRecord", v1.FindSysOperationRecord) // 根据ID获取SysOperationRecord SysOperationRecordRouter.GET("getSysOperationRecordList", v1.GetSysOperationRecordList) // 获取SysOperationRecord列表 + } } diff --git a/server/service/sys_operation_record.go b/server/service/sys_operation_record.go index 6887703b..5d835cf6 100644 --- a/server/service/sys_operation_record.go +++ b/server/service/sys_operation_record.go @@ -17,6 +17,17 @@ func CreateSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err return err } +// @title DeleteSysOperationRecord +// @description delete SysOperationRecords +// @auth (2020/04/05 20:22) +// @param sysOperationRecord request.IdsReq +// @return error + +func DeleteSysOperationRecordByIds(ids request.IdsReq) (err error) { + err = global.GVA_DB.Delete(&[]model.SysOperationRecord{},"id in (?)",ids.Ids).Error + return err +} + // @title DeleteSysOperationRecord // @description delete a SysOperationRecord // @auth (2020/04/05 20:22) diff --git a/web/src/api/sysOperationRecord.js b/web/src/api/sysOperationRecord.js index 99d0107a..18a67e84 100644 --- a/web/src/api/sysOperationRecord.js +++ b/web/src/api/sysOperationRecord.js @@ -8,13 +8,29 @@ import service from '@/utils/request' // @Param data body model.SysOperationRecord true "删除SysOperationRecord" // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" // @Router /sysOperationRecord/deleteSysOperationRecord [delete] - export const deleteSysOperationRecord = (data) => { - return service({ - url: "/sysOperationRecord/deleteSysOperationRecord", - method: 'delete', - data - }) - } +export const deleteSysOperationRecord = (data) => { + return service({ + url: "/sysOperationRecord/deleteSysOperationRecord", + method: 'delete', + data + }) +} + +// @Tags SysOperationRecord +// @Summary 批量删除SysOperationRecord +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "删除SysOperationRecord" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" +// @Router /sysOperationRecord/deleteSysOperationRecord [delete] +export const deleteSysOperationRecordByIds = (data) => { + return service({ + url: "/sysOperationRecord/deleteSysOperationRecordByIds", + method: 'delete', + data + }) +} // @Tags SysOperationRecord // @Summary 分页获取SysOperationRecord列表 @@ -24,10 +40,10 @@ import service from '@/utils/request' // @Param data body request.PageInfo true "分页获取SysOperationRecord列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /sysOperationRecord/getSysOperationRecordList [get] - export const getSysOperationRecordList = (params) => { - return service({ - url: "/sysOperationRecord/getSysOperationRecordList", - method: 'get', - params - }) - } \ No newline at end of file +export const getSysOperationRecordList = (params) => { + return service({ + url: "/sysOperationRecord/getSysOperationRecordList", + method: 'get', + params + }) +} \ No newline at end of file diff --git a/web/src/view/superAdmin/operation/sysOperationRecord.vue b/web/src/view/superAdmin/operation/sysOperationRecord.vue index c6a1392a..64ad5863 100644 --- a/web/src/view/superAdmin/operation/sysOperationRecord.vue +++ b/web/src/view/superAdmin/operation/sysOperationRecord.vue @@ -14,10 +14,21 @@ 查询 + + +

确定要删除吗?

+
+ 取消 + 确定 +
+ 批量删除 +
+
@@ -95,7 +104,8 @@