sandbox.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package sandbox
  2. import (
  3. "eta/eta_mobile/controllers"
  4. "eta/eta_mobile/models"
  5. "eta/eta_mobile/models/sandbox"
  6. "eta/eta_mobile/models/sandbox/response"
  7. "eta/eta_mobile/utils"
  8. "github.com/rdlucklib/rdluck_tools/paging"
  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 a.chart_permission_name LIKE '%` + keyword + `%' )`
  49. likeKey := `%` + keyword + `%`
  50. condition += ` AND ( a.name LIKE ? OR a.chart_permission_name LIKE ? )`
  51. pars = append(pars, likeKey)
  52. pars = append(pars, likeKey)
  53. }
  54. //获取指标信息
  55. total, list, err := sandbox.GetList(condition, pars, startSize, pageSize)
  56. if err != nil && err.Error() != utils.ErrNoRow() {
  57. br.Success = true
  58. br.Msg = "获取沙盘列表失败"
  59. br.ErrMsg = "获取沙盘列表失败,Err:" + err.Error()
  60. return
  61. }
  62. if list == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  63. list = make([]*sandbox.Sandbox, 0)
  64. }
  65. page := paging.GetPaging(currentIndex, pageSize, total)
  66. resp := response.SandboxListResp{
  67. Paging: page,
  68. List: list,
  69. }
  70. br.Ret = 200
  71. br.Success = true
  72. br.Msg = "获取成功"
  73. br.Data = resp
  74. }