|
@@ -18,10 +18,25 @@ func (m *MessageDAO) GetLocationList(issys, org_id string) ([]model.TdCmsImageLo
|
18
|
18
|
if issys != "" {
|
19
|
19
|
s = s.And("is_sys=?", issys)
|
20
|
20
|
}
|
21
|
|
- err := s.Find(&locations)
|
|
21
|
+ err := s.Asc("order_no").Find(&locations)
|
22
|
22
|
return locations, err
|
23
|
23
|
}
|
24
|
24
|
|
|
25
|
+// GetLocationMaxSort 获取最大的位置
|
|
26
|
+func (m *MessageDAO) GetLocationMaxSort(issys, org_id string) (int, error) {
|
|
27
|
+ var location []map[string][]byte
|
|
28
|
+ sql := `select max(order_no) as order_no from td_cms_image_location where issys=` + issys + ` and org_id ='` + org_id + `'`
|
|
29
|
+ location, err := m.db.Query(sql)
|
|
30
|
+ if err != nil {
|
|
31
|
+ return 0, err
|
|
32
|
+ }
|
|
33
|
+ if len(location) > 0 {
|
|
34
|
+ sortno, err := strconv.Atoi(string(location[0]["order_no"]))
|
|
35
|
+ return sortno, err
|
|
36
|
+ }
|
|
37
|
+ return 0, nil
|
|
38
|
+}
|
|
39
|
+
|
25
|
40
|
// GetLocationById 根据ID获取明细
|
26
|
41
|
func (m *MessageDAO) GetLocationById(id string) (*model.TdCmsImageLocation, error) {
|
27
|
42
|
var location []model.TdCmsImageLocation
|
|
@@ -67,3 +82,20 @@ func (m *MessageDAO) DelLocation(location_id string) error {
|
67
|
82
|
_, err := m.db.Cols(cols...).Where("location_id=?", location.LocationId).Update(location)
|
68
|
83
|
return err
|
69
|
84
|
}
|
|
85
|
+
|
|
86
|
+// UpdateLocationSort 修改顺序
|
|
87
|
+func (m *MessageDAO) UpdateLocationSort(loc []string) error {
|
|
88
|
+ orderno, err := strconv.Atoi(loc[1])
|
|
89
|
+ if err != nil {
|
|
90
|
+ return err
|
|
91
|
+ }
|
|
92
|
+ var location = model.TdCmsImageLocation{
|
|
93
|
+ LocationId: loc[0],
|
|
94
|
+ OrderNo: orderno,
|
|
95
|
+ }
|
|
96
|
+ var cols = []string{
|
|
97
|
+ "order_no",
|
|
98
|
+ }
|
|
99
|
+ _, err = m.db.Cols(cols...).Where("location_id=?", location.LocationId).Update(location)
|
|
100
|
+ return err
|
|
101
|
+}
|