12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package sandbox
- import (
- "eta/eta_mobile/controllers"
- "eta/eta_mobile/models"
- "eta/eta_mobile/models/sandbox"
- "eta/eta_mobile/models/sandbox/response"
- "eta/eta_mobile/utils"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- type SandboxController struct {
- controllers.BaseAuthController
- }
- func (this *SandboxController) ListByQuote() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- keyword := this.GetString("Keyword")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- if chartPermissionId > 0 {
- condition += " AND a.chart_permission_id=? "
- pars = append(pars, chartPermissionId)
- }
- if keyword != "" {
- condition += ` AND ( a.name LIKE '%` + keyword + `%' OR a.chart_permission_name LIKE '%` + keyword + `%' )`
- }
-
- total, list, err := sandbox.GetList(condition, pars, startSize, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Success = true
- br.Msg = "获取沙盘列表失败"
- br.ErrMsg = "获取沙盘列表失败,Err:" + err.Error()
- return
- }
- if list == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
- list = make([]*sandbox.Sandbox, 0)
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := response.SandboxListResp{
- Paging: page,
- List: list,
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|