【草稿列表查询】

This commit is contained in:
weizhihong 2023-11-21 13:13:35 +08:00
parent 1c8379ada7
commit 24cf969c7f
2 changed files with 25 additions and 6 deletions

View File

@ -1,6 +1,10 @@
package dto
import "joylink.club/bj-rtsts-server/ts/protos/graphicData"
import (
"time"
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
)
type PageDraftingReqDto struct {
PageQueryDto
@ -22,3 +26,14 @@ type DraftingDto struct {
type DraftingMapDataDto struct {
Proto []byte `json:"proto" from:"proto"`
}
type DraftingResDto struct {
ID int32 `json:"id"` // id
Name string `json:"name"` // 草稿图名称
Category string `json:"category"` // 厂家编码
Type int32 `json:"type"` // 数据类型
CreatorID int32 `json:"creator_id"` // 创建人id
Creator string `json:"creator"` // 创建人
CreatedAt time.Time `json:"created_at"` // 创建时间
UpdateAt time.Time `json:"update_at"` // 修改时间
}

View File

@ -7,18 +7,22 @@ import (
"joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto"
"joylink.club/bj-rtsts-server/sys_error"
)
// 查询草稿列表
func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto {
d := dbquery.Drafting
dq := d.Where()
d, u := dbquery.Drafting, dbquery.User
dq := d.LeftJoin(u, u.ID.EqCol(d.CreatorID)).
Select(d.ID, d.Name, d.Category, d.Type, d.CreatorID, d.CreatedAt, d.UpdateAt, u.Name.As("creator")).
Where()
if query.Name != "" {
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name)))
}
records, total, err := dq.Debug().Omit(d.Proto).Order(d.UpdateAt.Desc()).FindByPage(query.Offset(), query.Size)
var records []*dto.DraftingResDto
total, err := dq.Debug().Order(d.UpdateAt.Desc()).ScanByPage(&records, query.Offset(), query.Size)
if err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
panic(sys_error.New("草稿查询错误", err))
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
}
@ -31,7 +35,7 @@ func ListDraftingQuery(query *dto.ListDraftingReqDto) []*model.Drafting {
}
records, err := dq.Debug().Omit(d.Proto).Order(d.UpdateAt.Desc()).Find()
if err != nil {
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
panic(sys_error.New("草稿查询错误", err))
}
return records
}