【增加列车尺寸、轮径、型号列表查询】

This commit is contained in:
weizhihong 2023-08-28 09:56:34 +08:00
parent e228486dda
commit 92d1410624
7 changed files with 562 additions and 2 deletions

View File

@ -69,7 +69,7 @@ func pageQueryPublishedGi(c *gin.Context) {
func listQueryPublishedGi(c *gin.Context) {
user, _ := c.Get(middleware.IdentityKey)
zap.S().Debug("列表查询发布的图形数据", user)
req := publishedGi.PublishedGiReqDto{}
req := publishedGi.PublishedGiListReqDto{}
if err := c.ShouldBindQuery(&req); err != nil {
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
}

View File

@ -15,16 +15,19 @@ import (
func InitTrainManageRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
authed := api.Group("/v1/trainManage").Use(authMiddleware.MiddlewareFunc())
authed.GET("/model/paging", pageQueryTrainModel)
authed.GET("/model/list", queryTrainModelList)
authed.POST("/model", createTrainModel)
authed.GET("/model/:id", queryTrainModel)
authed.PUT("/model/:id", updateTrainModel)
authed.DELETE("/model/:id", deleteTrainModel)
authed.GET("/size/paging", pageQueryTrainSize)
authed.GET("/size/list", queryTrainSizeList)
authed.POST("/size", createTrainSize)
authed.GET("/size/:id", queryTrainSize)
authed.PUT("/size/:id", updateTrainSize)
authed.DELETE("/size/:id", deleteTrainSize)
authed.GET("/wheelDiameter/paging", pageQueryTrainWheelDiameter)
authed.GET("/wheelDiameter/list", queryTrainWheelDiameterList)
authed.POST("/wheelDiameter", createTrainWheelDiameter)
authed.GET("/wheelDiameter/:id", queryTrainWheelDiameter)
authed.PUT("/wheelDiameter/:id", updateTrainWheelDiameter)
@ -186,6 +189,36 @@ func deleteTrainModel(c *gin.Context) {
c.JSON(http.StatusOK, true)
}
// 查询列车型号列表
//
// @Summary 查询列车型号信息列表
//
// @Security JwtAuth
//
// @Description 可以通过列车型号名称过滤,查询列车型号信息列表
// @Tags 列车管理Api
// @Accept json
// @Produce json
// @Param trainManageReqDto query dto.TrainManageReqDto true "列车型号查询条件"
// @Success 200 {object} dto.PageDto
// @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/trainManage/model/list [get]
func queryTrainModelList(c *gin.Context) {
req := dto.TrainManageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
}
zap.S().Debug("分页查列车信号参数", req)
models, err := service.ListTrainModelQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
c.JSON(http.StatusOK, models)
}
// 分页查询列车尺寸列表
//
// @Summary 分页查询列车尺寸信息列表
@ -217,6 +250,36 @@ func pageQueryTrainSize(c *gin.Context) {
c.JSON(http.StatusOK, page)
}
// 查询列车尺寸列表
//
// @Summary 查询列车尺寸信息列表
//
// @Security JwtAuth
//
// @Description 可以通过列车尺寸名称过滤,查询列车尺寸信息列表
// @Tags 列车管理Api
// @Accept json
// @Produce json
// @Param trainManageReqDto query dto.TrainManageReqDto true "列车尺寸查询条件"
// @Success 200 {object} dto.PageDto
// @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/trainManage/size/list [get]
func queryTrainSizeList(c *gin.Context) {
req := dto.TrainManageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
}
zap.S().Debug("分页查列车尺寸参数", req)
sizeList, err := service.ListTrainSizeQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
c.JSON(http.StatusOK, sizeList)
}
// 创建列车尺寸
//
// @Summary 创建列车尺寸
@ -372,6 +435,36 @@ func pageQueryTrainWheelDiameter(c *gin.Context) {
c.JSON(http.StatusOK, page)
}
// 查询列车轮径列表
//
// @Summary 查询列车轮径信息列表
//
// @Security JwtAuth
//
// @Description 可以通过列车轮径名称过滤,查询列车轮径信息列表
// @Tags 列车管理Api
// @Accept json
// @Produce json
// @Param pageTrainManageReqDto query dto.PageTrainManageReqDto true "列车轮径查询条件"
// @Success 200 {object} dto.PageDto
// @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/trainManage/wheelDiameter/list [get]
func queryTrainWheelDiameterList(c *gin.Context) {
req := dto.TrainManageReqDto{}
if err := c.ShouldBind(&req); err != nil {
zap.S().Warn("查询参数绑定错误,使用默认参数", err)
}
zap.S().Debug("分页查列车轮径参数", req)
wheels, err := service.ListTrainWheelDiameterQuery(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, err.Error())
return
}
c.JSON(http.StatusOK, wheels)
}
// 创建列车轮径
//
// @Summary 创建列车轮径

View File

@ -2333,6 +2333,59 @@ const docTemplate = `{
}
}
},
"/api/v1/trainManage/model/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过列车型号名称过滤,查询列车型号信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"列车管理Api"
],
"summary": "查询列车型号信息列表",
"parameters": [
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/model/paging": {
"get": {
"security": [
@ -2652,6 +2705,59 @@ const docTemplate = `{
}
}
},
"/api/v1/trainManage/size/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过列车尺寸名称过滤,查询列车尺寸信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"列车管理Api"
],
"summary": "查询列车尺寸信息列表",
"parameters": [
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/size/paging": {
"get": {
"security": [
@ -2991,6 +3097,75 @@ const docTemplate = `{
}
}
},
"/api/v1/trainManage/wheelDiameter/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过列车轮径名称过滤,查询列车轮径信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"列车管理Api"
],
"summary": "查询列车轮径信息列表",
"parameters": [
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"example": 1,
"description": "页码",
"name": "current",
"in": "query",
"required": true
},
{
"type": "integer",
"example": 10,
"description": "页面行数",
"name": "size",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/wheelDiameter/paging": {
"get": {
"security": [

View File

@ -2326,6 +2326,59 @@
}
}
},
"/api/v1/trainManage/model/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过列车型号名称过滤,查询列车型号信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"列车管理Api"
],
"summary": "查询列车型号信息列表",
"parameters": [
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/model/paging": {
"get": {
"security": [
@ -2645,6 +2698,59 @@
}
}
},
"/api/v1/trainManage/size/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过列车尺寸名称过滤,查询列车尺寸信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"列车管理Api"
],
"summary": "查询列车尺寸信息列表",
"parameters": [
{
"type": "string",
"name": "name",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/size/paging": {
"get": {
"security": [
@ -2984,6 +3090,75 @@
}
}
},
"/api/v1/trainManage/wheelDiameter/list": {
"get": {
"security": [
{
"JwtAuth": []
}
],
"description": "可以通过列车轮径名称过滤,查询列车轮径信息列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"列车管理Api"
],
"summary": "查询列车轮径信息列表",
"parameters": [
{
"type": "string",
"name": "name",
"in": "query"
},
{
"type": "integer",
"example": 1,
"description": "页码",
"name": "current",
"in": "query",
"required": true
},
{
"type": "integer",
"example": 10,
"description": "页面行数",
"name": "size",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.PageDto"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/wheelDiameter/paging": {
"get": {
"security": [

View File

@ -1853,6 +1853,39 @@ paths:
summary: 修改列车型号信息
tags:
- 列车管理Api
/api/v1/trainManage/model/list:
get:
consumes:
- application/json
description: 可以通过列车型号名称过滤,查询列车型号信息列表
parameters:
- in: query
name: name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PageDto'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 查询列车型号信息列表
tags:
- 列车管理Api
/api/v1/trainManage/model/paging:
get:
consumes:
@ -2055,6 +2088,39 @@ paths:
summary: 修改列车尺寸信息
tags:
- 列车管理Api
/api/v1/trainManage/size/list:
get:
consumes:
- application/json
description: 可以通过列车尺寸名称过滤,查询列车尺寸信息列表
parameters:
- in: query
name: name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PageDto'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 查询列车尺寸信息列表
tags:
- 列车管理Api
/api/v1/trainManage/size/paging:
get:
consumes:
@ -2269,6 +2335,51 @@ paths:
summary: 修改列车轮径信息
tags:
- 列车管理Api
/api/v1/trainManage/wheelDiameter/list:
get:
consumes:
- application/json
description: 可以通过列车轮径名称过滤,查询列车轮径信息列表
parameters:
- in: query
name: name
type: string
- description: 页码
example: 1
in: query
name: current
required: true
type: integer
- description: 页面行数
example: 10
in: query
name: size
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PageDto'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/dto.ErrorDto'
"404":
description: Not Found
schema:
$ref: '#/definitions/dto.ErrorDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 查询列车轮径信息列表
tags:
- 列车管理Api
/api/v1/trainManage/wheelDiameter/paging:
get:
consumes:

View File

@ -12,6 +12,12 @@ type PublishedGiReqDto struct {
Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"`
}
type PublishedGiListReqDto struct {
Name string `json:"name" form:"name"`
Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"`
}
type PublishReqDto struct {
//发布后的名称
Name string `json:"name" form:"name"`

View File

@ -30,7 +30,7 @@ func PageQueryPublishedGi(req *publishedGi.PublishedGiReqDto) *dto.PageDto {
}
}
func ListQueryPublishedGi(req *publishedGi.PublishedGiReqDto) []*publishedGi.PublishedGiDto {
func ListQueryPublishedGi(req *publishedGi.PublishedGiListReqDto) []*publishedGi.PublishedGiDto {
where := dbquery.PublishedGi.Where(dbquery.PublishedGi.Status.Eq(1))
if req.Name != "" {
where = where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name)))