|
@@ -50,35 +50,35 @@ var {{.table.ClassName}} = new({{$structName}})
|
|
|
// GetList 获取任务列表
|
|
// GetList 获取任务列表
|
|
|
func (s *{{$structName}}) GetList(req *dao.{{.table.ClassName}}SearchReq) (total, page int, list []*model.{{.table.ClassName}}, err error) {
|
|
func (s *{{$structName}}) GetList(req *dao.{{.table.ClassName}}SearchReq) (total, page int, list []*model.{{.table.ClassName}}, err error) {
|
|
|
m := dao.{{.table.ClassName}}.Ctx(req.Ctx)
|
|
m := dao.{{.table.ClassName}}.Ctx(req.Ctx)
|
|
|
- if req != nil {
|
|
|
|
|
{{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
|
|
{{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
|
|
|
- {{if eq $column.QueryType "LIKE"}}
|
|
|
|
|
- if req.{{$column.GoField}} != "" {
|
|
|
|
|
- m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" like ?", "%"+req.{{$column.GoField}}+"%")
|
|
|
|
|
- } {{end}}
|
|
|
|
|
- {{if eq $column.QueryType "EQ"}} {{if eq $column.GoType "string"}}
|
|
|
|
|
- if req.{{$column.GoField}} != "" {
|
|
|
|
|
- m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" = ?", req.{{$column.GoField}})
|
|
|
|
|
- }
|
|
|
|
|
- {{else if and (eq $column.GoType "Time") (eq $column.ColumnName "created_at")}}
|
|
|
|
|
- if req.BeginTime != "" {
|
|
|
|
|
- m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" >=", req.BeginTime)
|
|
|
|
|
- }
|
|
|
|
|
- if req.EndTime != "" {
|
|
|
|
|
- m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" <", req.EndTime)
|
|
|
|
|
- }
|
|
|
|
|
- {{else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
|
|
|
|
- if req.{{$column.GoField}} != "" {
|
|
|
|
|
- m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" = ?", req.{{$column.GoField}})
|
|
|
|
|
- }
|
|
|
|
|
- {{end}} {{end}}
|
|
|
|
|
- {{if and (eq $column.QueryType "BETWEEN") (eq $column.ColumnType "datetime") }}
|
|
|
|
|
- if req.{{$column.GoField}} != nil {
|
|
|
|
|
- m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" >= ? AND "+dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" < ?", req.{{$column.GoField}}, req.{{$column.GoField}}.Add(gtime.D))
|
|
|
|
|
- }
|
|
|
|
|
- {{end}}
|
|
|
|
|
- {{end}}{{end}}
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ {{if eq $column.QueryType "LIKE"}}
|
|
|
|
|
+ if req.{{$column.GoField}} != "" {
|
|
|
|
|
+ m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" like ?", "%"+req.{{$column.GoField}}+"%")
|
|
|
|
|
+ } {{end}}
|
|
|
|
|
+ {{if eq $column.QueryType "EQ"}} {{if eq $column.GoType "string"}}
|
|
|
|
|
+ if req.{{$column.GoField}} != "" {
|
|
|
|
|
+ m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" = ?", req.{{$column.GoField}})
|
|
|
|
|
+ }
|
|
|
|
|
+ {{else if and (eq $column.GoType "Time") (eq $column.ColumnName "created_at")}}
|
|
|
|
|
+ if req.BeginTime != "" {
|
|
|
|
|
+ m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" >=", req.BeginTime)
|
|
|
|
|
+ }
|
|
|
|
|
+ if req.EndTime != "" {
|
|
|
|
|
+ m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" <", req.EndTime)
|
|
|
|
|
+ }
|
|
|
|
|
+ {{else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
|
|
|
|
+ if req.{{$column.GoField}} != "" {
|
|
|
|
|
+ m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" = ?", req.{{$column.GoField}})
|
|
|
|
|
+ }
|
|
|
|
|
+ {{end}} {{end}}
|
|
|
|
|
+ {{if and (eq $column.QueryType "BETWEEN") (eq $column.ColumnType "datetime") }}
|
|
|
|
|
+ if req.{{$column.GoField}} != nil {
|
|
|
|
|
+ m = m.Where(dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" >= ? AND "+dao.{{$.table.ClassName}}.Columns.{{$column.GoField}}+" < ?", req.{{$column.GoField}}, req.{{$column.GoField}}.Add(gtime.D))
|
|
|
|
|
+ }
|
|
|
|
|
+ {{end}}
|
|
|
|
|
+ {{end}}
|
|
|
|
|
+ {{end}}
|
|
|
|
|
+
|
|
|
total, err = m.Count()
|
|
total, err = m.Count()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
g.Log().Error(err)
|
|
g.Log().Error(err)
|
|
@@ -99,11 +99,11 @@ func (s *{{$structName}}) GetList(req *dao.{{.table.ClassName}}SearchReq) (total
|
|
|
}
|
|
}
|
|
|
err = m.Page(page, req.PageSize).Order(order).Scan(&list)
|
|
err = m.Page(page, req.PageSize).Order(order).Scan(&list)
|
|
|
{{else}}
|
|
{{else}}
|
|
|
- order:= "{{$pk}} asc"
|
|
|
|
|
- if req.OrderBy!=""{
|
|
|
|
|
- order = req.OrderBy
|
|
|
|
|
- }
|
|
|
|
|
- err = m.Order(order).Scan(&list)
|
|
|
|
|
|
|
+ order:= "{{$pk}} asc"
|
|
|
|
|
+ if req.OrderBy!=""{
|
|
|
|
|
+ order = req.OrderBy
|
|
|
|
|
+ }
|
|
|
|
|
+ err = m.Order(order).Scan(&list)
|
|
|
{{end}}
|
|
{{end}}
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
g.Log().Error(err)
|
|
g.Log().Error(err)
|