diff --git a/admin/src/api/system/corn.ts b/admin/src/api/system/corn.ts index a99e2c4..4c55f67 100644 --- a/admin/src/api/system/corn.ts +++ b/admin/src/api/system/corn.ts @@ -23,12 +23,14 @@ export type type_system_corn_query = { TaskName?: string TaskCode?: string CornExpr?: string - Status?: number + Status?: any CreatedBy?: string CreateTimeStart?: string CreateTimeEnd?: string UpdateTimeStart?: string UpdateTimeEnd?: string + CreatedByNickname?: string + CreatedByUsername?: string } // 添加编辑 export type type_system_corn_edit = { diff --git a/admin/src/components/material/index.vue b/admin/src/components/material/index.vue index 4e110c6..aeb7ece 100644 --- a/admin/src/components/material/index.vue +++ b/admin/src/components/material/index.vue @@ -112,7 +112,7 @@ - 本地上传 - + diff --git a/admin/src/components/upload/index.vue b/admin/src/components/upload/Upload.vue similarity index 100% rename from admin/src/components/upload/index.vue rename to admin/src/components/upload/Upload.vue diff --git a/admin/src/views/monitor/project/index.vue b/admin/src/views/monitor/project/index.vue index 891b9a8..5b51d8d 100644 --- a/admin/src/views/monitor/project/index.vue +++ b/admin/src/views/monitor/project/index.vue @@ -75,7 +75,7 @@ 新增 - 导入 - + - 导入 - + 新增 - 导入 - + - + @@ -173,6 +173,7 @@ const queryParams = reactive({ CornExpr: null, Status: null, CreatedBy: null, + CreatedByNickname: null, CreateTimeStart: null, CreateTimeEnd: null, UpdateTimeStart: null, diff --git a/admin/src/views/user/protocol/index.vue b/admin/src/views/user/protocol/index.vue index 0f91f6c..7ef6f31 100644 --- a/admin/src/views/user/protocol/index.vue +++ b/admin/src/views/user/protocol/index.vue @@ -46,7 +46,7 @@ 新增 - 导入 - + - + diff --git a/server/app/schema/system_corn_schema.go b/server/app/schema/system_corn_schema.go index d25bf5a..9e2af69 100644 --- a/server/app/schema/system_corn_schema.go +++ b/server/app/schema/system_corn_schema.go @@ -47,13 +47,13 @@ type SystemCornDelBatchReq struct { // SystemCornResp 定时任务返回信息 type SystemCornResp struct { - Id string `swaggertype:"string"` // - TaskName core.NullString `swaggertype:"string"` // 任务名称 - TaskCode core.NullString `swaggertype:"string"` // 任务编码 - CornExpr core.NullString `swaggertype:"string"` // corn表达式 - Status core.NullInt `swaggertype:"number"` // 状态 - CreatedBy core.NullString `swaggertype:"string"` // 创建人 - CreatedUser systemSchema.SystemAuthAdminSimpleInfo `swaggertype:"string"` // 创建人 - CreateTime core.NullTime `swaggertype:"string"` // 创建时间 - UpdateTime core.NullTime `swaggertype:"string"` // 更新时间 + Id string `swaggertype:"string"` // + TaskName core.NullString `swaggertype:"string"` // 任务名称 + TaskCode core.NullString `swaggertype:"string"` // 任务编码 + CornExpr core.NullString `swaggertype:"string"` // corn表达式 + Status core.NullInt `swaggertype:"number"` // 状态 + CreatedBy core.NullString `swaggertype:"string"` // 创建人 + CreatedByUser systemSchema.SystemAuthAdminSimpleInfo `swaggertype:"string"` // 创建人 + CreateTime core.NullTime `swaggertype:"string"` // 创建时间 + UpdateTime core.NullTime `swaggertype:"string"` // 更新时间 } diff --git a/server/app/schema/user_protocol_schema.go b/server/app/schema/user_protocol_schema.go index e9a1209..d387716 100644 --- a/server/app/schema/user_protocol_schema.go +++ b/server/app/schema/user_protocol_schema.go @@ -57,12 +57,12 @@ type UserProtocolDelBatchReq struct { // UserProtocolResp 用户协议返回信息 type UserProtocolResp struct { UserProtocolPrimarykey - Tag core.NullString `swaggertype:"string"` // 标识 - Version core.NullInt `swaggertype:"number"` // 版本 - Title core.NullString `swaggertype:"string"` // 标题 - Content core.NullString `swaggertype:"string"` // 协议内容 - CreateTime core.NullTime `swaggertype:"string"` // 创建时间 - UpdateTime core.NullTime `swaggertype:"string"` // 更新时间 - CreatedBy string `swaggertype:"string"` // 创建人id - CreatedUser systemSchema.SystemAuthAdminSimpleInfo `swaggertype:"string"` // 创建人 + Tag core.NullString `swaggertype:"string"` // 标识 + Version core.NullInt `swaggertype:"number"` // 版本 + Title core.NullString `swaggertype:"string"` // 标题 + Content core.NullString `swaggertype:"string"` // 协议内容 + CreateTime core.NullTime `swaggertype:"string"` // 创建时间 + UpdateTime core.NullTime `swaggertype:"string"` // 更新时间 + CreatedBy string `swaggertype:"string"` // 创建人id + CreatedByUser systemSchema.SystemAuthAdminSimpleInfo `swaggertype:"string"` // 创建人 } diff --git a/server/app/service/generatorService/tpl_utils/constants.go b/server/app/service/generatorService/tpl_utils/constants.go index c5d377d..af4d5a5 100644 --- a/server/app/service/generatorService/tpl_utils/constants.go +++ b/server/app/service/generatorService/tpl_utils/constants.go @@ -69,6 +69,9 @@ var SqlConstants = sqlConstants{ ColumnNameNotList: []string{"id", "is_delete", "delete_time"}, //页面不需要查询字段 ColumnNameNotQuery: []string{"is_delete", "delete_time"}, //"create_time", "update_time", + + // 常用user id字段 + ColumnNameUserFiled: []string{"created_by", "updated_by", "deleted_by"}, } // HtmlConstants HTML相关常量 @@ -109,11 +112,12 @@ type sqlConstants struct { ColumnTypeInt []string ColumnTypeFloat []string - ColumnTimeName []string - ColumnNameNotAdd []string - ColumnNameNotEdit []string - ColumnNameNotList []string - ColumnNameNotQuery []string + ColumnTimeName []string + ColumnNameNotAdd []string + ColumnNameNotEdit []string + ColumnNameNotList []string + ColumnNameNotQuery []string + ColumnNameUserFiled []string } type htmlConstants struct { diff --git a/server/app/service/generatorService/tpl_utils/templates/gocode/model.go.tpl b/server/app/service/generatorService/tpl_utils/templates/gocode/model.go.tpl index 01a3723..d501c99 100644 --- a/server/app/service/generatorService/tpl_utils/templates/gocode/model.go.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/gocode/model.go.tpl @@ -10,9 +10,9 @@ import ( type {{{ toUpperCamelCase .EntityName }}} struct { {{{- range .Columns }}} {{{- if ne .ID "" }}} - {{{- if eq .ColumnName "created_by" }}} - CreatedBy {{{.GoNullType }}} `gorm:"column:created_by;type:{{{toSqlType .ColumnType .ColumnLength}}};comment:'{{{ .ColumnComment }}}'"` - CreatedUser system_model.SystemAuthAdminSimple `gorm:"foreignKey:CreatedBy"` + {{{- if .IsUid }}} + {{{.GoField}}} {{{.GoNullType }}} `gorm:"column:{{{.ColumnName}}};type:{{{toSqlType .ColumnType .ColumnLength}}};comment:'{{{ .ColumnComment }}}'"` + {{{.GoField}}}User system_model.SystemAuthAdminSimple `gorm:"foreignKey:{{{.GoField}}}"` {{{- else if eq .ColumnName "is_delete" }}} IsDelete soft_delete.DeletedAt `gorm:"column:{{{.ColumnName}}};type:{{{toSqlType .ColumnType .ColumnLength}}};not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"` {{{- else if eq .GoType "time.Time" }}} @@ -28,11 +28,13 @@ type {{{ toUpperCamelCase .EntityName }}} struct { {{{- if eq .PrimaryKeyGoType "string" }}} // 自动在创建时设置 UUIDv7 func (u *{{{ toUpperCamelCase .EntityName }}}) BeforeCreate(tx *gorm.DB) error { - id, err := uuid.NewV7() - if err != nil { - return err - } - u.Id = id.String() + if u.{{{toUpperCamelCase .PrimaryKey }}} == "" { + id, err := uuid.NewV7() + if err != nil { + return err + } + u.{{{toUpperCamelCase .PrimaryKey }}} = id.String() + } return nil } {{{- end }}} \ No newline at end of file diff --git a/server/app/service/generatorService/tpl_utils/templates/gocode/service.go.tpl b/server/app/service/generatorService/tpl_utils/templates/gocode/service.go.tpl index c5ef999..5940467 100644 --- a/server/app/service/generatorService/tpl_utils/templates/gocode/service.go.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/gocode/service.go.tpl @@ -37,7 +37,7 @@ type {{{ .EntityName }}}Service struct { // List {{{ .FunctionName }}}列表 func (service {{{ .EntityName }}}Service) GetModel(listReq schema.{{{ toUpperCamelCase .EntityName }}}ListReq) *gorm.DB { // 查询 - dbModel := service.db.Model(&model.{{{ toUpperCamelCase .EntityName }}}{}).Joins("CreatedUser") + dbModel := service.db.Model(&model.{{{ toUpperCamelCase .EntityName }}}{}).Joins("CreatedByUser") tableName := core.DBTableName(&model.{{{ toUpperCamelCase .EntityName }}}{}) {{{- range .Columns }}} {{{- if .IsQuery }}} @@ -47,10 +47,10 @@ func (service {{{ .EntityName }}}Service) GetModel(listReq schema.{{{ toUpperCam dbModel = dbModel.Where(tableName+".created_by = ?", *listReq.CreatedBy.GetValue()) } if listReq.Nickname.GetValue() != nil { - dbModel = dbModel.Where("CreatedUser.nickname like ?", "%"+*listReq.Nickname.GetValue()+"%") + dbModel = dbModel.Where("CreatedByUser.nickname like ?", "%"+*listReq.Nickname.GetValue()+"%") } if listReq.Username.GetValue() != nil { - dbModel = dbModel.Where("CreatedUser.nickname like ?", "%"+*listReq.Username.GetValue()+"%") + dbModel = dbModel.Where("CreatedByUser.nickname like ?", "%"+*listReq.Username.GetValue()+"%") } {{{- else if eq .HtmlType "datetime" }}} if listReq.{{{ toUpperCamelCase .ColumnName }}}Start.GetValue() != nil { @@ -141,7 +141,7 @@ func (service {{{ .EntityName }}}Service) Detail({{{ toUpperCamelCase .PrimaryKe var obj = model.{{{ toUpperCamelCase .EntityName }}}{} err := service.CacheUtil.GetCache({{{ toUpperCamelCase .PrimaryKey }}}, &obj) if err != nil { - err := service.db.Where("{{{ $.PrimaryKey }}} = ?{{{ if contains .AllFields "is_delete" }}} AND is_delete = ?{{{ end }}}", {{{ toUpperCamelCase .PrimaryKey }}}{{{ if contains .AllFields "is_delete" }}}, 0{{{ end }}}).Preload("CreatedUser").Limit(1).First(&obj).Error + err := service.db.Where("{{{ $.PrimaryKey }}} = ?{{{ if contains .AllFields "is_delete" }}} AND is_delete = ?{{{ end }}}", {{{ toUpperCamelCase .PrimaryKey }}}{{{ if contains .AllFields "is_delete" }}}, 0{{{ end }}}).Preload("CreatedByUser").Limit(1).First(&obj).Error if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil { return } @@ -201,8 +201,8 @@ func (service {{{ .EntityName }}}Service) Edit(editReq schema.{{{ toUpperCamelCa if e = response.CheckErr(err, "编辑失败"); e != nil { return } - service.CacheUtil.RemoveCache(obj.Id) - // service.Detail(obj.Id) + service.CacheUtil.RemoveCache(obj.{{{toUpperCamelCase .PrimaryKey }}}) + return } diff --git a/server/app/service/generatorService/tpl_utils/templates/uniapp/edit.vue.tpl b/server/app/service/generatorService/tpl_utils/templates/uniapp/edit.vue.tpl index c281dca..2b83831 100644 --- a/server/app/service/generatorService/tpl_utils/templates/uniapp/edit.vue.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/uniapp/edit.vue.tpl @@ -16,7 +16,7 @@ {{{- if ne .DictType "" }}} {{{- else if ne .ListAllApi "" }}} - + {{{- else }}} 请选择字典生成代码 {{{- end }}} diff --git a/server/app/service/generatorService/tpl_utils/templates/uniapp/search.vue.tpl b/server/app/service/generatorService/tpl_utils/templates/uniapp/search.vue.tpl index 0349e9a..993dd55 100644 --- a/server/app/service/generatorService/tpl_utils/templates/uniapp/search.vue.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/uniapp/search.vue.tpl @@ -11,7 +11,7 @@ {{{- if ne .DictType "" }}} {{{- else if ne .ListAllApi "" }}} - + {{{- end }}} {{{- else if eq .HtmlType "input" }}} diff --git a/server/app/service/generatorService/tpl_utils/templates/vue/api.ts.tpl b/server/app/service/generatorService/tpl_utils/templates/vue/api.ts.tpl index 8d93213..1056a5d 100644 --- a/server/app/service/generatorService/tpl_utils/templates/vue/api.ts.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/vue/api.ts.tpl @@ -8,7 +8,7 @@ import { clearEmpty } from '@/utils/util' export type type_{{{.ModuleName}}} = { {{{- range .Columns }}} -{{{- if .IsList }}} +{{{- if or .IsList .IsPk }}} {{{.TsField }}}?: {{{.TsType}}} {{{- end }}} {{{- end }}} diff --git a/server/app/service/generatorService/tpl_utils/templates/vue/details.vue.tpl b/server/app/service/generatorService/tpl_utils/templates/vue/details.vue.tpl index 6bc3a11..d5b59f9 100644 --- a/server/app/service/generatorService/tpl_utils/templates/vue/details.vue.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/vue/details.vue.tpl @@ -28,7 +28,7 @@ {{{- end }}} {{{- range .Columns }}} {{{- if .IsEdit }}} - {{{- if ne .TsField "Id" }}} + {{{- if not .IsPk }}} {{{- if eq .HtmlType "input" }}} @@ -43,109 +43,34 @@ {{{- else if eq .HtmlType "checkbox" }}} - - {{{- if ne .DictType "" }}} - {{!-- --}} + {{{- else if ne .ListAllApi "" }}} - {{!-- --}} - - {{!-- 请选择字典生成 --}} {{{- end }}} {{{- else if eq .HtmlType "select" }}} - - {{!-- --}} + {{{- if ne .DictType "" }}} - {{!-- --}} + {{{- else if ne .ListAllApi "" }}} - {{!-- --}} - - {{!-- --}} - {{{- end }}} - {{!-- --}} + {{{- end }}} {{{- else if eq .HtmlType "radio" }}} {{{- if ne .DictType "" }}} - {{!-- --}} {{{- else if ne .ListAllApi "" }}} - {{!-- - {{ item.Id }} - --}} - - {{!-- 请选择字典生成 --}} {{{- end }}} {{{- else if eq .HtmlType "datetime" }}} - {{!-- --}} {{{- else if eq .HtmlType "editor" }}} diff --git a/server/app/service/generatorService/tpl_utils/templates/vue/edit.vue.tpl b/server/app/service/generatorService/tpl_utils/templates/vue/edit.vue.tpl index 601dba0..efb553c 100644 --- a/server/app/service/generatorService/tpl_utils/templates/vue/edit.vue.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/vue/edit.vue.tpl @@ -60,8 +60,8 @@ {{{- else }}} 请选择字典生成 @@ -88,11 +88,11 @@ @@ -122,12 +122,12 @@ :key="index" :label="item.name" {{{- if eq .GoType "int" }}} - :value="parseInt(item.Id)" + :value="parseInt(item.ID)" {{{- else }}} - :value="item.Id" + :value="item.ID" {{{- end }}} > - {{ item.Id }} + {{ item.ID }} {{{- else }}} 请选择字典生成 diff --git a/server/app/service/generatorService/tpl_utils/templates/vue/index.vue.tpl b/server/app/service/generatorService/tpl_utils/templates/vue/index.vue.tpl index 2c59e6f..e3a6a9b 100644 --- a/server/app/service/generatorService/tpl_utils/templates/vue/index.vue.tpl +++ b/server/app/service/generatorService/tpl_utils/templates/vue/index.vue.tpl @@ -33,8 +33,8 @@ {{{- else }}} @@ -62,7 +62,7 @@ 新增 - 导入 - +