sandbox.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package sandbox
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/paging"
  4. "hongze/hongze_ETA_mobile_api/controllers"
  5. "hongze/hongze_ETA_mobile_api/models"
  6. "hongze/hongze_ETA_mobile_api/models/sandbox"
  7. "hongze/hongze_ETA_mobile_api/models/sandbox/response"
  8. "hongze/hongze_ETA_mobile_api/utils"
  9. )
  10. //SandboxController 逻辑导图
  11. type SandboxController struct {
  12. controllers.BaseAuthController
  13. }
  14. // ListByQuote
  15. // @Title 逻辑导图列表(其他地方引用到的,莫名其妙要根据输入的关键字匹配品种)
  16. // @Description 逻辑导图列表接口(其他地方引用到的,莫名其妙要根据输入的关键字匹配品种)
  17. // @Param PageSize query int true "每页数据条数"
  18. // @Param CurrentIndex query int true "当前页页码,从1开始"
  19. // @Param ChartPermissionId query int true "权限编号id"
  20. // @Param Keyword query string false "搜索关键词:沙盘名称/编辑人名称"
  21. // @Success 200 {object} response.ListResp
  22. // @router /list_by_quote [get]
  23. func (this *SandboxController) ListByQuote() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  30. keyword := this.GetString("Keyword")
  31. pageSize, _ := this.GetInt("PageSize")
  32. currentIndex, _ := this.GetInt("CurrentIndex")
  33. var startSize int
  34. if pageSize <= 0 {
  35. pageSize = utils.PageSize20
  36. }
  37. if currentIndex <= 0 {
  38. currentIndex = 1
  39. }
  40. startSize = paging.StartIndex(currentIndex, pageSize)
  41. var condition string
  42. var pars []interface{}
  43. if chartPermissionId > 0 {
  44. condition += " AND a.chart_permission_id=? "
  45. pars = append(pars, chartPermissionId)
  46. }
  47. if keyword != "" {
  48. condition += ` AND ( a.name LIKE '%` + keyword + `%' OR b.name LIKE '%` + keyword + `%' OR a.chart_permission_name LIKE '%` + keyword + `%' )`
  49. }
  50. //获取指标信息
  51. total, list, err := sandbox.GetList(condition, pars, startSize, pageSize)
  52. if err != nil && err.Error() != utils.ErrNoRow() {
  53. br.Success = true
  54. br.Msg = "获取沙盘列表失败"
  55. br.ErrMsg = "获取沙盘列表失败,Err:" + err.Error()
  56. return
  57. }
  58. if list == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  59. list = make([]*sandbox.SandboxListItem, 0)
  60. }
  61. page := paging.GetPaging(currentIndex, pageSize, total)
  62. resp := response.SandboxListResp{
  63. Paging: page,
  64. List: list,
  65. }
  66. br.Ret = 200
  67. br.Success = true
  68. br.Msg = "获取成功"
  69. br.Data = resp
  70. }