Kaynağa Gözat

更新

master
huangjiajun 5 ay önce
ebeveyn
işleme
f09c1fcfc1
8 değiştirilmiş dosya ile 167 ekleme ve 2 silme
  1. +9
    -0
      app/admin/hdl/order/hdl_order_list.go
  2. +73
    -1
      app/admin/svc/order/svc_order_list.go
  3. +10
    -0
      app/bigData/hdl/hdl_notice.go
  4. +19
    -0
      app/bigData/svc/svc_notice.go
  5. +40
    -0
      app/db/db_notice.go
  6. +12
    -0
      app/db/model/notice.go
  7. +3
    -0
      app/router/admin_router.go
  8. +1
    -1
      app/router/big_data_router.go

+ 9
- 0
app/admin/hdl/order/hdl_order_list.go Dosyayı Görüntüle

@@ -46,3 +46,12 @@ func OrderAddNum(c *gin.Context) {
func OrderDeductNum(c *gin.Context) {
order.OrderDeductNum(c)
}
func NoticeList(c *gin.Context) {
order.NoticeList(c)
}
func NoticeSave(c *gin.Context) {
order.NoticeSave(c)
}
func NoticeDel(c *gin.Context) {
order.NoticeDel(c)
}

+ 73
- 1
app/admin/svc/order/svc_order_list.go Dosyayı Görüntüle

@@ -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
}

+ 10
- 0
app/bigData/hdl/hdl_notice.go Dosyayı Görüntüle

@@ -0,0 +1,10 @@
package hdl

import (
"applet/app/bigData/svc"
"github.com/gin-gonic/gin"
)

func Notice(c *gin.Context) {
svc.Notice(c)
}

+ 19
- 0
app/bigData/svc/svc_notice.go Dosyayı Görüntüle

@@ -0,0 +1,19 @@
package svc

import (
"applet/app/db"
"applet/app/e"
"github.com/gin-gonic/gin"
"time"
)

func Notice(c *gin.Context) {
date := time.Now().Format("2006-01-02")
data := db.GetNoticeByDate(db.Db, date)
var res = make([]string, 0)
if data != nil {
res = append(res, data.Content)
}
e.OutSuc(c, res, nil)
return
}

+ 40
- 0
app/db/db_notice.go Dosyayı Görüntüle

@@ -0,0 +1,40 @@
package db

import (
"applet/app/db/model"
"applet/app/utils"
"xorm.io/xorm"
)

func GetNotice(eg *xorm.Engine, param map[string]string) (*[]model.Notice, int64) {
var order []model.Notice
sess := eg.Where("1=1")
size := utils.StrToInt(param["limit"])
start := (utils.StrToInt(param["page"]) - 1) * size
count, err := sess.Limit(size, start).OrderBy("id desc").FindAndCount(&order)
if err != nil {
return nil, count
}
return &order, count
}

func GetNoticeById(eg *xorm.Engine, id string) *model.Notice {
var data model.Notice
get, err := eg.Where("id=?", id).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}
func GetNoticeByDateCount(eg *xorm.Engine, date string) int64 {
count, _ := eg.Where("date=?", date).Count(&model.Notice{})
return count
}
func GetNoticeByDate(eg *xorm.Engine, date string) *model.Notice {
var data model.Notice
get, err := eg.Where("date=?", date).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 12
- 0
app/db/model/notice.go Dosyayı Görüntüle

@@ -0,0 +1,12 @@
package model

import (
"time"
)

type Notice struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Date string `json:"date" xorm:"VARCHAR(1000)"`
Content string `json:"content" xorm:"VARCHAR(1000)"`
UpdateAt time.Time `json:"update_at" xorm:"DATETIME"`
}

+ 3
- 0
app/router/admin_router.go Dosyayı Görüntüle

@@ -148,6 +148,9 @@ func rOrder(r *gin.RouterGroup) {
r.POST("/addNum", orderHdl.OrderAddNum) //用户订单增加数量
r.POST("/deductNum", orderHdl.OrderDeductNum) //用户订单减少数量
r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
r.POST("/notice", orderHdl.NoticeList) //公告
r.POST("/notice_save", orderHdl.NoticeSave) //公告
r.POST("/notice_del", orderHdl.NoticeDel) //公告
}

func rDataStatistics(r *gin.RouterGroup) {


+ 1
- 1
app/router/big_data_router.go Dosyayı Görüntüle

@@ -30,5 +30,5 @@ func rData(r *gin.RouterGroup) {

r.GET("/new_sorting_goods_cate", hdl.NewSortingGoodsCate) //分拣区 按商品
r.POST("/new_sorting_goods_data", hdl.NewSortingGoodsData) //分拣区 按商品 数据
r.POST("/notice", hdl.Notice)
}

Yükleniyor…
İptal
Kaydet