|
|
@@ -14,6 +14,7 @@ import ( |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/tidwall/gjson" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
@@ -82,7 +83,6 @@ func OrderList(c *gin.Context) { |
|
|
|
e.OutSuc(c, res, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func OrderExport(c *gin.Context) { |
|
|
|
var args map[string]string |
|
|
|
if err := c.ShouldBindJSON(&args); err != nil { |
|
|
@@ -1184,3 +1184,75 @@ func OrderDeductNum(c *gin.Context) { |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
func NoticeSave(c *gin.Context) { |
|
|
|
var args map[string]string |
|
|
|
if err := c.ShouldBindJSON(&args); err != nil { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
return |
|
|
|
} |
|
|
|
eg := db.Db |
|
|
|
date := time.Now().Format("2006-01-02") |
|
|
|
if args["id"] == "" { |
|
|
|
count := db.GetNoticeByDateCount(eg, date) |
|
|
|
if count > 0 { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "请到记录列表找到今天记录编辑")) |
|
|
|
return |
|
|
|
} |
|
|
|
data := &model.Notice{ |
|
|
|
Date: date, |
|
|
|
Content: args["content"], |
|
|
|
UpdateAt: time.Now(), |
|
|
|
} |
|
|
|
eg.InsertOne(data) |
|
|
|
} else { |
|
|
|
data := db.GetNoticeById(eg, args["id"]) |
|
|
|
if data == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "记录不存在")) |
|
|
|
return |
|
|
|
} |
|
|
|
data.Content = args["content"] |
|
|
|
data.UpdateAt = time.Now() |
|
|
|
} |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
func NoticeDel(c *gin.Context) { |
|
|
|
var args map[string]string |
|
|
|
if err := c.ShouldBindJSON(&args); err != nil { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
return |
|
|
|
} |
|
|
|
eg := db.Db |
|
|
|
eg.Where("id=?", args["id"]).Delete(&model.Notice{}) |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
func NoticeList(c *gin.Context) { |
|
|
|
var args map[string]string |
|
|
|
if err := c.ShouldBindJSON(&args); err != nil { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
return |
|
|
|
} |
|
|
|
eg := db.Db |
|
|
|
list, total := db.GetNotice(eg, args) |
|
|
|
data := make([]map[string]interface{}, 0) |
|
|
|
if list != nil { |
|
|
|
for _, v := range *list { |
|
|
|
var tmp = map[string]interface{}{ |
|
|
|
"id": utils.IntToStr(v.Id), |
|
|
|
"content": v.Content, |
|
|
|
"date": v.Date, |
|
|
|
"update_at": v.UpdateAt.Format("2006-01-02 15:04:05"), |
|
|
|
} |
|
|
|
data = append(data, tmp) |
|
|
|
} |
|
|
|
} |
|
|
|
res := map[string]interface{}{ |
|
|
|
"total": total, |
|
|
|
"list": data, |
|
|
|
} |
|
|
|
e.OutSuc(c, res, nil) |
|
|
|
return |
|
|
|
} |