分页查询返回值json序列化逻辑修改
This commit is contained in:
parent
a040d2f502
commit
5c3363a5b0
37
config/bj_local_pxf.yml
Normal file
37
config/bj_local_pxf.yml
Normal file
@ -0,0 +1,37 @@
|
||||
# 服务配置
|
||||
server:
|
||||
# 服务端口
|
||||
port: 9091
|
||||
|
||||
# 数据源
|
||||
datasource:
|
||||
# 数据库访问url
|
||||
dsn: root:Joylink@0503@tcp(172.29.5.167:3306)/bj-rtsts?charset=utf8mb4&parseTime=true&loc=UTC
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
# 日志级别
|
||||
level: info
|
||||
# 格式化
|
||||
# format: json
|
||||
# 日志文件路径
|
||||
path: /logs/bjrtsts
|
||||
# 日志文件名
|
||||
fileName: bjrtsts.log
|
||||
# 单个日志文件大小,单位mb,超过会自动滚动
|
||||
fileMaxSize: 50
|
||||
# 日志文件最大备份数量
|
||||
fileMaxBackups: 100
|
||||
# 日志文件最大保留时间,单位 天
|
||||
maxAge: 30
|
||||
# 是否压缩日志
|
||||
compress: false
|
||||
# 控制台是否输出
|
||||
stdout: false
|
||||
|
||||
# 消息配置
|
||||
messaging:
|
||||
mqtt:
|
||||
address: tcp://172.29.5.168:1883
|
||||
username: rtsts_service
|
||||
password: joylink@0503
|
@ -6,7 +6,7 @@ server:
|
||||
# 数据源
|
||||
datasource:
|
||||
# 数据库访问url
|
||||
dsn: root:joylink0503@tcp(192.168.3.233:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
||||
dsn: root:joylink0503@tcp(192.168.33.233:3306)/bj-rtss?charset=utf8mb4&parseTime=true&loc=UTC
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
@ -32,6 +32,6 @@ logging:
|
||||
# 消息配置
|
||||
messaging:
|
||||
mqtt:
|
||||
address: tcp://192.168.3.233:1883
|
||||
address: tcp://192.168.33.233:1883
|
||||
username: rtsts_service
|
||||
password: joylink@0503
|
@ -32,10 +32,17 @@ type PageQueryDto struct {
|
||||
Orders []OrderItem `form:"orders" json:"orders"`
|
||||
}
|
||||
|
||||
type PageDto struct {
|
||||
type PageDto[T any] struct {
|
||||
Total int `form:"total" json:"total"`
|
||||
PageQueryDto
|
||||
Records any `form:"records" json:"records"`
|
||||
Records []T `form:"records" json:"records"`
|
||||
}
|
||||
|
||||
func (p *PageDto[T]) MarshalJSON() ([]byte, error) {
|
||||
if p.Records == nil {
|
||||
p.Records = make([]T, 0)
|
||||
}
|
||||
return json.Marshal(*p)
|
||||
}
|
||||
|
||||
type JsonTime time.Time
|
||||
|
@ -11,13 +11,13 @@ import (
|
||||
)
|
||||
|
||||
// 查询权限角色信息列表
|
||||
func PageAuthRoleQuery(query *dto.PageQueryDto) *dto.PageDto {
|
||||
func PageAuthRoleQuery(query *dto.PageQueryDto) *dto.PageDto[*dto.AuthRoleRspDto] {
|
||||
d := dbquery.AuthRole
|
||||
records, total, err := d.Debug().Select(d.ID, d.Name).Order(d.CreateTime).FindByPage(query.Offset(), query.Size)
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询权限数据库出错,请联系维护人员", err))
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: *query, Records: dto.ConvertFromAuthRole(records)}
|
||||
return &dto.PageDto[*dto.AuthRoleRspDto]{Total: int(total), PageQueryDto: *query, Records: dto.ConvertFromAuthRole(records)}
|
||||
}
|
||||
|
||||
// 获取角色列表
|
||||
@ -143,7 +143,7 @@ func DeleteAuthRole(rid int32) bool {
|
||||
}
|
||||
|
||||
// 查询接口路径信息列表
|
||||
func PageAuthApiPathQuery(query *dto.AuthApiPathPageReqDto) *dto.PageDto {
|
||||
func PageAuthApiPathQuery(query *dto.AuthApiPathPageReqDto) *dto.PageDto[*model.AuthAPIPath] {
|
||||
d := dbquery.AuthAPIPath
|
||||
dq := d.Where()
|
||||
if query.Name != "" {
|
||||
@ -153,7 +153,7 @@ func PageAuthApiPathQuery(query *dto.AuthApiPathPageReqDto) *dto.PageDto {
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
return &dto.PageDto[*model.AuthAPIPath]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
}
|
||||
|
||||
// 查询接口路径信息列表
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// 查询草稿列表
|
||||
func PageCategoryQuery(query *dto.PageCategoryReqDto) *dto.PageDto {
|
||||
func PageCategoryQuery(query *dto.PageCategoryReqDto) *dto.PageDto[*model.Category] {
|
||||
d := dbquery.Category
|
||||
dq := d.Where()
|
||||
if query.Name != "" {
|
||||
@ -20,7 +20,7 @@ func PageCategoryQuery(query *dto.PageCategoryReqDto) *dto.PageDto {
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
return &dto.PageDto[*model.Category]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
}
|
||||
|
||||
// 查询草稿列表
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// 查询草稿列表
|
||||
func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto {
|
||||
func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto[*dto.DraftingResDto] {
|
||||
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")).
|
||||
@ -24,7 +24,7 @@ func PageDraftingQuery(query *dto.PageDraftingReqDto) *dto.PageDto {
|
||||
if err != nil {
|
||||
panic(sys_error.New("草稿查询错误", err))
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
return &dto.PageDto[*dto.DraftingResDto]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
}
|
||||
|
||||
func ListDraftingQuery(query *dto.ListDraftingReqDto) []*model.Drafting {
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// 查询项目列表
|
||||
func PageProjectQuery(query *dto.PageProjectReqDto) *dto.PageDto {
|
||||
func PageProjectQuery(query *dto.PageProjectReqDto) *dto.PageDto[*model.Project] {
|
||||
d := dbquery.Project
|
||||
dq := d.Where()
|
||||
if query.Name != "" {
|
||||
@ -24,7 +24,7 @@ func PageProjectQuery(query *dto.PageProjectReqDto) *dto.PageDto {
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询失败,数据库异常", err))
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
return &dto.PageDto[*model.Project]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}
|
||||
}
|
||||
|
||||
// 查询项目列表
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// 查询项目运行环境列表带分页
|
||||
func PageProjectRunConfigQuery(query *dto.PageProjectRunConfigReqDto) *dto.PageDto {
|
||||
func PageProjectRunConfigQuery(query *dto.PageProjectRunConfigReqDto) *dto.PageDto[*dto.ProjectRunConfigDto] {
|
||||
d := dbquery.ProjectRunConfig
|
||||
dq := d.Where()
|
||||
if query.Name != "" {
|
||||
@ -21,7 +21,7 @@ func PageProjectRunConfigQuery(query *dto.PageProjectRunConfigReqDto) *dto.PageD
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询失败,数据库错误请联系运维人员", err))
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToRunConfigFromSlice(records)}
|
||||
return &dto.PageDto[*dto.ProjectRunConfigDto]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToRunConfigFromSlice(records)}
|
||||
}
|
||||
|
||||
// 查询项目运行环境列表
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
var publishMapMutex sync.Mutex
|
||||
|
||||
// 查找发布地图分页信息
|
||||
func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto {
|
||||
func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto[*dto.PublishedDto] {
|
||||
p, pv, u := dbquery.Published, dbquery.PublishedVersion, dbquery.User
|
||||
where := p.
|
||||
Select(
|
||||
@ -35,7 +35,7 @@ func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto {
|
||||
if err != nil {
|
||||
panic(sys_error.New("查询发布地图信息失败", err))
|
||||
}
|
||||
return &dto.PageDto{Total: int(count), PageQueryDto: req.PageQueryDto, Records: records}
|
||||
return &dto.PageDto[*dto.PublishedDto]{Total: int(count), PageQueryDto: req.PageQueryDto, Records: records}
|
||||
}
|
||||
|
||||
// 地图信息列表信息
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
var trainDataType = int32(data_proto.PictureType_TrainData)
|
||||
|
||||
// 查询列车信息列表
|
||||
func PageTrainInfoByPublished(query *dto.PageTrainInfoReqDto) *dto.PageDto {
|
||||
func PageTrainInfoByPublished(query *dto.PageTrainInfoReqDto) *dto.PageDto[*dto.TrainInfoDto] {
|
||||
d, dv := dbquery.Published, dbquery.PublishedVersion
|
||||
dq := d.Select(d.ID, d.Code.As("name"), dv.Note, dv.Proto).
|
||||
LeftJoin(dv, d.DataID.EqCol(dv.ID)).
|
||||
@ -30,7 +30,7 @@ func PageTrainInfoByPublished(query *dto.PageTrainInfoReqDto) *dto.PageDto {
|
||||
if err != nil {
|
||||
panic(sys_error.New("列车信息查询错误", err))
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToTrainDto(records)}
|
||||
return &dto.PageDto[*dto.TrainInfoDto]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: dto.ConvertToTrainDto(records)}
|
||||
}
|
||||
|
||||
// 根据项目Id查询列车信息
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// 分页查询用户列表
|
||||
func PagingQueryUser(query *dto.PageUserReqDto) (*dto.PageDto, error) {
|
||||
func PagingQueryUser(query *dto.PageUserReqDto) (*dto.PageDto[*dto.UserRspDto], error) {
|
||||
u := dbquery.User
|
||||
uq := u.Where()
|
||||
if query.Name != "" {
|
||||
@ -25,7 +25,7 @@ func PagingQueryUser(query *dto.PageUserReqDto) (*dto.PageDto, error) {
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()})
|
||||
}
|
||||
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: linkUserRole(records)}, err
|
||||
return &dto.PageDto[*dto.UserRspDto]{Total: int(total), PageQueryDto: query.PageQueryDto, Records: linkUserRole(records)}, err
|
||||
}
|
||||
|
||||
func Register(user *dto.RegisterUser) error {
|
||||
|
Loading…
Reference in New Issue
Block a user