fix:Invalid post search criteria

This commit is contained in:
zhangwenjian committed 2020-07-11 06:29:07 +08:00
1 parent 4f7e22a6f2
commit 2195c7a944
2 files changed
+10 -4

No files matched your search

+7 -4
View File
@@ -10,9 +10,10 @@ import (
// @Summary 职位列表数据
// @Description 获取JSON
// @Tags 职位
// @Param name query string false "name"
// @Param id query string false "id"
// @Param position query string false "position"
// @Param postName query string false "postName"
// @Param postCode query string false "postCode"
// @Param postId query string false "postId"
// @Param status query string false "status"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post [get]
// @Security
@@ -30,11 +31,13 @@ func GetPostList(c *gin.Context) {
pageIndex = tools.StrToInt(err, index)
}
data.PostName = c.Request.FormValue("postName")
id := c.Request.FormValue("postId")
data.PostId, _ = tools.StringToInt(id)
data.PostCode = c.Request.FormValue("postCode")
data.PostName = c.Request.FormValue("postName")
data.Status = c.Request.FormValue("status")
data.DataScope = tools.GetUserIdStr(c)
result, count, err := data.GetPage(pageSize, pageIndex)
tools.HasError(err, "", -1)
+3
View File
@@ -90,6 +90,9 @@ func (e *Post) GetPage(pageSize int, pageIndex int) ([]Post, int, error) {
if e.PostName != "" {
table = table.Where("post_name = ?", e.PostName)
}
if e.PostCode != "" {
table = table.Where("post_code = ?", e.PostCode)
}
if e.Status != "" {
table = table.Where("status = ?", e.Status)
}