fix:Invalid post search criteria

This commit is contained in:
zhangwenjian
2020-07-11 06:34:51 +08:00
parent 494ee18b9f
commit 2280ce2b57
2 changed files with 18 additions and 14 deletions
+15 -14
View File
@@ -7,12 +7,13 @@ import (
"go-admin/tools/app" "go-admin/tools/app"
) )
// @Summary 位列表数据 // @Summary 位列表数据
// @Description 获取JSON // @Description 获取JSON
// @Tags // @Tags
// @Param name query string false "name" // @Param postName query string false "postName"
// @Param id query string false "id" // @Param postCode query string false "postCode"
// @Param position query string false "position" // @Param postId query string false "postId"
// @Param status query string false "status"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}" // @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post [get] // @Router /api/v1/post [get]
// @Security // @Security
@@ -30,7 +31,7 @@ func GetPostList(c *gin.Context) {
pageIndex = tools.StrToInt(err, index) pageIndex = tools.StrToInt(err, index)
} }
data.PostName = c.Request.FormValue("postName") data.PostCode = c.Request.FormValue("postCode")
id := c.Request.FormValue("postId") id := c.Request.FormValue("postId")
data.PostId, _ = tools.StringToInt(id) data.PostId, _ = tools.StringToInt(id)
@@ -41,9 +42,9 @@ func GetPostList(c *gin.Context) {
app.PageOK(c, result, count, pageIndex, pageSize, "") app.PageOK(c, result, count, pageIndex, pageSize, "")
} }
// @Summary 获取字典数据 // @Summary 获取岗位信息
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典数据 // @Tags 岗位
// @Param postId path int true "postId" // @Param postId path int true "postId"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}" // @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post/{postId} [get] // @Router /api/v1/post/{postId} [get]
@@ -56,9 +57,9 @@ func GetPost(c *gin.Context) {
app.OK(c,result,"") app.OK(c,result,"")
} }
// @Summary 添加 // @Summary 添加
// @Description 获取JSON // @Description 获取JSON
// @Tags // @Tags
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param data body models.Post true "data" // @Param data body models.Post true "data"
@@ -76,9 +77,9 @@ func InsertPost(c *gin.Context) {
app.OK(c,result,"") app.OK(c,result,"")
} }
// @Summary 修改 // @Summary 修改
// @Description 获取JSON // @Description 获取JSON
// @Tags // @Tags
// @Accept application/json // @Accept application/json
// @Product application/json // @Product application/json
// @Param data body models.Dept true "body" // @Param data body models.Dept true "body"
@@ -97,9 +98,9 @@ func UpdatePost(c *gin.Context) {
app.OK(c,result,"修改成功") app.OK(c,result,"修改成功")
} }
// @Summary 删除 // @Summary 删除
// @Description 删除数据 // @Description 删除数据
// @Tags // @Tags
// @Param id path int true "id" // @Param id path int true "id"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
+3
View File
@@ -90,6 +90,9 @@ func (e *Post) GetPage(pageSize int, pageIndex int) ([]Post, int, error) {
if e.PostName != "" { if e.PostName != "" {
table = table.Where("post_name = ?", e.PostName) table = table.Where("post_name = ?", e.PostName)
} }
if e.PostCode != "" {
table = table.Where("post_code = ?", e.PostCode)
}
if e.Status != "" { if e.Status != "" {
table = table.Where("status = ?", e.Status) table = table.Where("status = ?", e.Status)
} }