123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package sandbox
- import (
- "hongze/hongze_yb/global"
- )
- func GetBySandboxId(id uint32) (item *Sandbox, err error) {
- err = global.MYSQL["data"].Where("sandbox_id = ? and is_delete=0 ", id).Order("sandbox_id desc").First(&item).Error
- return
- }
- func GetPageListByWhere(condition string, pars []interface{}, startSize, pageSize int) (total int64, list []*Sandbox, err error) {
-
- sql := "select count(1) from sandbox AS s JOIN sandbox_classify AS c ON c.sandbox_classify_id = s.sandbox_classify_id WHERE " + condition + " order by s.modify_time desc,s.sandbox_id desc"
- err = global.MYSQL["data"].Raw(sql, pars...).Scan(&total).Error
- if err != nil {
- return
- }
-
- sql = "select s.* from sandbox AS s JOIN sandbox_classify AS c ON c.sandbox_classify_id = s.sandbox_classify_id WHERE " + condition + " order by s.modify_time desc,s.sandbox_id desc"
- sql += " limit ?,? "
- pars = append(pars, startSize, pageSize)
- err = global.MYSQL["data"].Raw(sql, pars...).Find(&list).Error
- return
- }
- type PermissionSandboxCount struct {
- ChartPermissionID uint32 `gorm:"column:chart_permission_id;type:int(9) unsigned;not null;default:0" json:"chart_permission_id"`
- ChartPermissionName string `gorm:"index:idx_chart_permission_name;column:chart_permission_name;type:varchar(32);not null;default:''" json:"chart_permission_name"`
- Total int64 `json:"total"`
- }
- func GetPermissionCountListByWhere(condition string, pars []interface{}) (list []*PermissionSandboxCount, err error) {
-
-
- err = global.MYSQL["data"].Model(Sandbox{}).Select("chart_permission_id,chart_permission_name,count(1) total").Where(condition, pars...).Order("modify_time desc,sandbox_id desc").Group("chart_permission_id").Scan(&list).Error
- return
- }
|