【草稿列表查询】
This commit is contained in:
parent
1c8379ada7
commit
24cf969c7f
|
@ -1,6 +1,10 @@
|
||||||
package dto
|
package dto
|
||||||
|
|
||||||
import "joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
||||||
|
)
|
||||||
|
|
||||||
type PageDraftingReqDto struct {
|
type PageDraftingReqDto struct {
|
||||||
PageQueryDto
|
PageQueryDto
|
||||||
|
@ -22,3 +26,14 @@ type DraftingDto struct {
|
||||||
type DraftingMapDataDto struct {
|
type DraftingMapDataDto struct {
|
||||||
Proto []byte `json:"proto" from:"proto"`
|
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"` // 修改时间
|
||||||
|
}
|
||||||
|
|
|
@ -7,18 +7,22 @@ import (
|
||||||
"joylink.club/bj-rtsts-server/db/dbquery"
|
"joylink.club/bj-rtsts-server/db/dbquery"
|
||||||
"joylink.club/bj-rtsts-server/db/model"
|
"joylink.club/bj-rtsts-server/db/model"
|
||||||
"joylink.club/bj-rtsts-server/dto"
|
"joylink.club/bj-rtsts-server/dto"
|
||||||
|
"joylink.club/bj-rtsts-server/sys_error"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 查询草稿列表
|
// 查询草稿列表
|
||||||
func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto {
|
func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto {
|
||||||
d := dbquery.Drafting
|
d, u := dbquery.Drafting, dbquery.User
|
||||||
dq := d.Where()
|
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 != "" {
|
if query.Name != "" {
|
||||||
dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", 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 {
|
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}
|
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()
|
records, err := dq.Debug().Omit(d.Proto).Order(d.UpdateAt.Desc()).Find()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
panic(sys_error.New("草稿查询错误", err))
|
||||||
}
|
}
|
||||||
return records
|
return records
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue