123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package controllers
- import (
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- )
- type SearchController struct {
- BaseCommonController
- }
- // @Title 搜索接口
- // @Description 搜索接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.HomeListResp
- // @router /list [get]
- func (this *SearchController) SearchList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- keyWord := this.GetString("KeyWord")
- if keyWord == "" {
- br.Msg = "请输入搜索词"
- br.ErrMsg = "请输入搜索词"
- return
- }
- pageSize := 20
- result, err := services.SearchByKeyWord(keyWord, pageSize)
- if err != nil {
- br.Msg = "检索失败"
- br.ErrMsg = "检索失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = result
- }
- //https://blog.csdn.net/my_miuye/article/details/110496025
|