|
@@ -3,6 +3,7 @@ package sandbox
|
|
|
import (
|
|
|
"eta/eta_api/models/system"
|
|
|
"eta/eta_api/utils"
|
|
|
+ "fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"time"
|
|
@@ -28,18 +29,18 @@ import (
|
|
|
//}
|
|
|
|
|
|
type Sandbox struct {
|
|
|
- SandboxId int `orm:"column(sandbox_id);pk" description:"沙盘id"`
|
|
|
- Name string `description:"沙盘名称"`
|
|
|
- Code string `description:"沙盘code"`
|
|
|
- Content string `description:"沙盘数据"`
|
|
|
- PicUrl string `description:"沙盘图片地址"`
|
|
|
- SysUserId int `description:"作者id"`
|
|
|
- SysUserName string `description:"作者名称"`
|
|
|
- IsDelete int8 `description:"是否删除,0:未删除,1:已删除"`
|
|
|
- ModifyTime time.Time `description:"修改时间"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- SandboxClassifyId int `description:"分类id"`
|
|
|
- Sort int `description:"排序"`
|
|
|
+ SandboxId int `orm:"column(sandbox_id);pk" description:"沙盘id"`
|
|
|
+ Name string `description:"沙盘名称"`
|
|
|
+ Code string `description:"沙盘code"`
|
|
|
+ Content string `description:"沙盘数据"`
|
|
|
+ PicUrl string `description:"沙盘图片地址"`
|
|
|
+ SysUserId int `description:"作者id"`
|
|
|
+ SysUserName string `description:"作者名称"`
|
|
|
+ IsDelete int8 `description:"是否删除,0:未删除,1:已删除"`
|
|
|
+ ModifyTime time.Time `description:"修改时间"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+ SandboxClassifyId int `description:"分类id"`
|
|
|
+ Sort int `description:"排序"`
|
|
|
}
|
|
|
|
|
|
// Update 沙盘字段变更
|
|
@@ -272,6 +273,7 @@ type SandboxListItems struct {
|
|
|
Sandbox
|
|
|
ParentIds string
|
|
|
}
|
|
|
+
|
|
|
func GetSandboxListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*SandboxListItems, err error) {
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := ` SELECT * FROM sandbox WHERE 1=1 `
|
|
@@ -307,8 +309,8 @@ func AddSandbox(item *Sandbox) (lastId int64, err error) {
|
|
|
func GetSandboxItemsByClassifyId(sandboxClassifyId int) (list []*SandboxClassifyItems, err error) {
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
|
sql := `SELECT sandbox_id,sandbox_classify_id,name AS sandbox_classify_name, sort
|
|
|
- FROM sandbox WHERE sandbox_classify_id = ? AND is_delete = 0 `
|
|
|
- _, err = o.Raw(sql,sandboxClassifyId).QueryRows(&list)
|
|
|
+ FROM sandbox WHERE sandbox_classify_id = ? AND is_delete = 0 ORDER BY sort `
|
|
|
+ _, err = o.Raw(sql, sandboxClassifyId).QueryRows(&list)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -345,6 +347,58 @@ FROM
|
|
|
INNER JOIN sandbox_classify m
|
|
|
WHERE
|
|
|
sandbox_classify_id = vm._id `
|
|
|
- err = o.Raw(sql,sandboxClassifyId).QueryRow(&ids)
|
|
|
+ err = o.Raw(sql, sandboxClassifyId).QueryRow(&ids)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type MoveSandboxReq struct {
|
|
|
+ SandboxId int `description:"沙盘ID"`
|
|
|
+ PrevSandboxId int `description:"上一个沙盘ID"`
|
|
|
+ NextSandboxId int `description:"下一个沙盘ID"`
|
|
|
+ SandboxClassifyId int `description:"分类id"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetSandboxClassifyCountById(classifyId int) (count int, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := `SELECT count(1) AS count FROM sandbox_classify WHERE sandbox_classify_id=? `
|
|
|
+ err = o.Raw(sql, classifyId).QueryRow(&count)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetSandboxByClassifyIdAndName 根据分类id和沙盘名获取图表信息
|
|
|
+func GetSandboxByClassifyIdAndName(classifyId int, name string) (item *Sandbox, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM sandbox WHERE sandbox_classify_id = ? and name=? `
|
|
|
+ err = o.Raw(sql, classifyId, name).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func MoveSandbox(sandboxId, classifyId int) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` UPDATE sandbox
|
|
|
+ SET
|
|
|
+ sandbox_classify_id = ?
|
|
|
+ WHERE sandbox_id = ?`
|
|
|
+ _, err = o.Raw(sql, classifyId, sandboxId).Exec()
|
|
|
return
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// UpdateSandboxSortByClassifyId 根据沙盘id更新排序
|
|
|
+func UpdateSandboxSortByClassifyId(classifyId, nowSort, prevChartInfoId int, updateSort string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` update sandbox set sort = ` + updateSort + ` WHERE sandbox_classify_id=? AND `
|
|
|
+ if prevChartInfoId > 0 {
|
|
|
+ sql += ` (sort > ? or (sandbox_id > ` + fmt.Sprint(prevChartInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `))`
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql, classifyId, nowSort).Exec()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetFirstSandboxByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
|
|
|
+func GetFirstSandboxByClassifyId(classifyId int) (item *Sandbox, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM sandbox WHERE sandbox_classify_id=? order by sort asc,sandbox_id asc limit 1`
|
|
|
+ err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|