May1145 vor 1 Jahr
Ursprung
Commit
7a1ca2781d

+ 5 - 3
trading-go/config/config.yml

@@ -8,7 +8,9 @@ mysql:
   password: Cherry1145
   charset: utf8
 redis:
-  addr: "localhost:6379"
-  password: ""
+  addr: localhost:6379
+  password:
   db: 0
-  poolsize: 20
+  poolsize: 20
+time:
+  time: 2023-8-16

+ 54 - 0
trading-go/controller/appraisecontroller.go

@@ -0,0 +1,54 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// CreateAppraise
+// @Tags 评论模块
+// @Summary 创建评论
+// @Produce application/json
+// @Param json body model.AppraiseJson true "评价信息"
+// @Success 200 {object} response.Response
+// @Router /appraise/create [post]
+func CreateAppraise(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// DAppraise
+// @Tags 评论模块
+// @Summary 删除评论
+// @Produce application/json
+// @Param id path int64 true "评论id"
+// @Success 200 {object} response.Response
+// @Router /appraise/delete/{id} [delete]
+func DAppraise(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// RAppraise
+// @Tags 评论模块
+// @Summary 修改评论
+// @Produce application/json
+// @Param json body model.Appraise true "评价信息"
+// @Success 200 {object} response.Response
+// @Router /appraise/revise [post]
+func RAppraise(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// GetUserAppraise
+// @Tags 评论模块
+// @Summary 获取用户评价
+// @Produce application/json
+// @Param id query int64 true "用户id"
+// @Success 200 {object} response.Response
+// @Router /appraise/user [get]
+func GetUserAppraise(c *gin.Context) {
+	var appraises []model.Appraise
+	appraises = append(appraises, model.Appraise{})
+	appraises = append(appraises, model.Appraise{})
+	response.Success(c.Writer, "success", appraises)
+}

+ 61 - 0
trading-go/controller/categorycontroller.go

@@ -0,0 +1,61 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"strconv"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// GetAllCategories
+// @Tags 分类模块
+// @Summary 获取所有分类
+// @Accept application/json
+// @Produce application/json
+// @Success 200 {object} response.Response
+// @Router /category [get]
+func GetAllCategories(c *gin.Context) {
+	var categories []model.Category
+	categories = append(categories, model.Category{})
+	categories = append(categories, model.Category{})
+	response.Success(c.Writer, "success", categories)
+}
+
+// CreateCategory
+// @Tags 分类模块
+// @Summary 创建分类
+// @Accept application/json
+// @Produce application/json
+// @Param json body model.CategoryJson true "分类数据"
+// @Success 200 {object} response.Response
+// @Router /category/create [post]
+func CreateCategory(c *gin.Context) {
+	var categoryJson model.CategoryJson
+	err := c.ShouldBindJSON(&categoryJson)
+	if err != nil {
+		msg := err.Error()
+		response.Fail(c.Writer, msg, 500)
+		return
+	}
+	response.Success(c.Writer, "success", nil)
+}
+
+// DCategory
+// @Tags 分类模块
+// @Summary 根据分类id删除某个分类
+// @Produce application/json
+// @Param id path int64 true "分类id"
+// @Success 200 {object} response.Response
+// @Router /category/delete/{id} [delete]
+func DCategory(c *gin.Context) {
+	var category model.Category
+	ids := c.Param("id")
+	id, err := strconv.Atoi(ids)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	category.Id = int64(id)
+	response.Success(c.Writer, "success", nil)
+
+}

+ 21 - 1
trading-go/controller/chatcontroller.go

@@ -63,7 +63,22 @@ func reception(conn *websocket.Conn, uid int64) {
 		if v, ok := Conns[msg.To]; ok {
 			v.pip <- &msg
 		} else {
-			
+
+		}
+	}
+}
+
+func broadcast(data model.Message) {
+	for _, conn := range Conns {
+		msg, err := json.Marshal(data)
+		if err != nil {
+			fmt.Println(err.Error())
+			break
+		}
+		err = conn.conn.WriteMessage(data.MsgType, msg)
+		if err != nil {
+			fmt.Println(err.Error())
+			break
 		}
 	}
 }
@@ -90,6 +105,11 @@ func Chat(w http.ResponseWriter, rq *http.Request, uid int64) {
 	response.Success(w, "success", nil)
 }
 
+// LinkToServer
+// @Tags 聊天模块
+// @Summary 与服务端进行websocket连接,请使用postman测试
+// @Success 200 {object} response.Response
+// @Router /chat [get]
 func LinkToServer(c *gin.Context) {
 	uid, err := strconv.Atoi(c.Query("uid"))
 	if err != nil {

+ 131 - 0
trading-go/controller/goodscontroller.go

@@ -0,0 +1,131 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// GetAllGoods
+// @Tags 商品模块
+// @Summary 获取所有商品
+// @Produce application/json
+// @Success 200 {object} response.Response
+// @Router /goods [get]
+func GetAllGoods(c *gin.Context) {
+	var goods []model.GoodsSurface
+	goods = append(goods, model.GoodsSurface{})
+	goods = append(goods, model.GoodsSurface{})
+	response.Success(c.Writer, "success", goods)
+}
+
+// CreatGoods
+// @Tags 商品模块
+// @Summary 创建商品
+// @Accept application/json
+// @Produce application/json
+// @Param json body model.GoodsJson true "商品信息"
+// @Success 200 {object} response.Response
+// @Router /goods/create [post]
+func CreatGoods(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// DGoods
+// @Tags 商品模块
+// @Summary 删除商品
+// @Produce application/json
+// @Param id path int64 true "商品id"
+// @Success 200 {object} response.Response
+// @Router /goods/delete/{id} [delete]
+func DGoods(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// GetGoodsPage
+// @Tags 商品模块
+// @Summary 获取所有商品
+// @Produce application/json
+// @Param page path int true "页数"
+// @Param pageSize path int true "一页的大小"
+// @Success 200 {object} response.Response
+// @Router /goods/{page}/{pageSize} [get]
+func GetGoodsPage(c *gin.Context) {
+	var goods []model.GoodsSurface
+	var rsp response.PageResponse
+	goods = append(goods, model.GoodsSurface{})
+	goods = append(goods, model.GoodsSurface{})
+	rsp.Data = goods
+	response.Success(c.Writer, "success", rsp)
+}
+
+// GetRecommend
+// @Tags 商品模块
+// @Summary 分页获取推荐商品
+// @Produce application/json
+// @Param id query int64 true "用户id"
+// @Param page path int true "页数"
+// @Param pageSize path int true "一页的大小"
+// @Success 200 {object} response.Response
+// @Router /goods/recommend/{page}/{pageSize} [get]
+func GetRecommend(c *gin.Context) {
+	var goods []model.GoodsSurface
+	var rsp response.PageResponse
+	goods = append(goods, model.GoodsSurface{})
+	goods = append(goods, model.GoodsSurface{})
+	rsp.Data = goods
+	response.Success(c.Writer, "success", rsp)
+}
+
+// ReviseGoods
+// @Tags 商品模块
+// @Summary  修改商品信息
+// @Produce application/json
+// @Param json body model.Goods true "商品信息"
+// @Success 200 {object} response.Response
+// @Router /goods/revise [post]
+func ReviseGoods(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// GetGoodDetail
+// @Tags 商品模块
+// @Summary  获取商品详细信息
+// @Produce application/json
+// @Param id path int64 true "商品id"
+// @Success 200 {object} response.Response
+// @Router /goods/detail/{id} [get]
+func GetGoodDetail(c *gin.Context) {
+	response.Success(c.Writer, "success", model.Goods{})
+}
+
+// GetUserGoods
+// @Tags 商品模块
+// @Summary  获取某个用户的所有商品
+// @Produce application/json
+// @Param id path int64 true "用户id"
+// @Success 200 {object} response.Response
+// @Router /goods/user/{id} [get]
+func GetUserGoods(c *gin.Context) {
+	var data []model.GoodsSurface
+	data = append(data, model.GoodsSurface{})
+	response.Success(c.Writer, "success", data)
+}
+
+// SearchGoods
+// @Tags 商品模块
+// @Summary  搜索商品并分页显示
+// @Produce application/json
+// @Param page path int true "页数"
+// @Param pageSize path int true "一页的大小"
+// @Param keyword query string true "搜素关键词"
+// @Success 200 {object} response.Response
+// @Router /goods/search/{page}/{pageSize} [get]
+func SearchGoods(c *gin.Context) {
+	var goods []model.GoodsSurface
+	var rsp response.PageResponse
+	goods = append(goods, model.GoodsSurface{})
+	goods = append(goods, model.GoodsSurface{})
+	rsp.Data = goods
+	response.Success(c.Writer, "success", rsp)
+}

+ 36 - 0
trading-go/controller/messagecontroller.go

@@ -0,0 +1,36 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// History
+// @Tags 信息模块
+// @Summary 传入用户id获取用户消息记录
+// @Produce application/json
+// @Param uid query int64 true "用户id"
+// @Success 200 {object} response.Response
+// @Router /message [get]
+func History(c *gin.Context) {
+	var messages []model.Message
+	messages = append(messages, model.Message{})
+	messages = append(messages, model.Message{})
+	response.Success(c.Writer, "success", messages)
+}
+
+// ConversationHistory
+// @Tags 信息模块
+// @Summary 传入用户id和聊天对象id获取消息记录
+// @Produce application/json
+// @Param uid query int64 true "用户id"
+// @Param targetId query int64 true "对象id"
+// @Success 200 {object} response.Response
+// @Router /message/conv [get]
+func ConversationHistory(c *gin.Context) {
+	var messages []model.Message
+	messages = append(messages, model.Message{})
+	messages = append(messages, model.Message{})
+	response.Success(c.Writer, "success", messages)
+}

+ 68 - 0
trading-go/controller/ordercontroller.go

@@ -0,0 +1,68 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// GetAllOrder
+// @Tags 订单模块
+// @Summary 获取所有订单
+// @Produce application/json
+// @Success 200 {object} response.Response
+// @Router /order [get]
+func GetAllOrder(c *gin.Context) {
+	var orders []model.Order
+	orders = append(orders, model.Order{})
+	orders = append(orders, model.Order{})
+	response.Success(c.Writer, "success", orders)
+}
+
+// GetUserOrder
+// @Tags 订单模块
+// @Summary 获取用户的所有订单
+// @Produce application/json
+// @Param id query int64 true "用户id"
+// @Success 200 {object} response.Response
+// @Router /order/user [get]
+func GetUserOrder(c *gin.Context) {
+	var orders []model.Order
+	orders = append(orders, model.Order{})
+	orders = append(orders, model.Order{})
+	response.Success(c.Writer, "success", orders)
+}
+
+// ReviseOrder
+// @Tags 订单模块
+// @Summary 修改订单的状态
+// @Produce application/json
+// @Param id formData int64 true "订单id"
+// @Param state formData int true "订单状态"
+// @Success 200 {object} response.Response
+// @Router /order/revise [post]
+func ReviseOrder(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// CreateOrder
+// @Tags 订单模块
+// @Summary 创建订单
+// @Produce application/json
+// @Param json body model.OrderJson true "订单信息"
+// @Success 200 {object} response.Response
+// @Router /order/create [post]
+func CreateOrder(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}
+
+// DeleteOrder
+// @Tags 订单模块
+// @Summary 删除订单
+// @Produce application/json
+// @Param id path int64 true "订单id"
+// @Success 200 {object} response.Response
+// @Router /order/delete/{id} [delete]
+func DeleteOrder(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}

+ 44 - 0
trading-go/controller/piccontrller.go

@@ -0,0 +1,44 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// Upload
+// @Tags 图片模块
+// @Summary 上传图片
+// @Accept multipart/form-data
+// @Produce application/json
+// @Param pic formData file true "图片"
+// @Success 200 {object} response.Response
+// @Router /pic/upload [post]
+func Upload(c *gin.Context) {
+	_, _ = c.FormFile("file")
+	response.Success(c.Writer, "success", model.Pic{})
+}
+
+// GetAllPic
+// @Tags 图片模块
+// @Summary 获取所有图片
+// @Produce application/json
+// @Success 200 {object} response.Response
+// @Router /pic [get]
+func GetAllPic(c *gin.Context) {
+	var pics []model.Pic
+	pics = append(pics, model.Pic{})
+	pics = append(pics, model.Pic{})
+	response.Success(c.Writer, "success", pics)
+}
+
+// DPic
+// @Tags 图片模块
+// @Summary 删除图片
+// @Produce application/json
+// @Param id path int64 true "图片id"
+// @Success 200 {object} response.Response
+// @Router /pic/delete/{id} [delete]
+func DPic(c *gin.Context) {
+	response.Success(c.Writer, "success", nil)
+}

+ 101 - 0
trading-go/controller/relationcontroller.go

@@ -0,0 +1,101 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"strconv"
+	"trading-go/model"
+	"trading-go/response"
+)
+
+// RCreat
+// @Tags 用户关系模块
+// @Summary 添加用户间的关系,关系类型有1:好友关系,2:黑名单关系
+// @Accept application/json
+// @Produce application/json
+// @Param json body model.RelationJson true "关系数据"
+// @Success 200 {object} response.Response
+// @Router /relation/create [post]
+func RCreat(c *gin.Context) {
+	var relation model.Relation
+	err := c.ShouldBindJSON(&relation)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	err = relation.Creat()
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	response.Success(c.Writer, "success", nil)
+}
+
+// GetFriend
+// @Tags 用户关系模块
+// @Summary 传入用户id获取用户好友列表
+// @Produce application/json
+// @Param uid query int64 true "用户id"
+// @Success 200 {object} response.Response
+// @Router /relation/friend [get]
+func GetFriend(c *gin.Context) {
+	var relation model.Relation
+	ids := c.Query("uid")
+	id, err := strconv.Atoi(ids)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	friends, err := relation.Friend(id)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	response.Success(c.Writer, "success", friends)
+}
+
+// GetBadRelation
+// @Tags 用户关系模块
+// @Summary 传入用户id获取用户黑名单列表
+// @Produce application/json
+// @Param uid query int64 true "用户id"
+// @Success 200 {object} response.Response
+// @Router /relation/bad [get]
+func GetBadRelation(c *gin.Context) {
+	var relation model.Relation
+	ids := c.Query("uid")
+	id, err := strconv.Atoi(ids)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	relations, err := relation.BadRelation(id)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	response.Success(c.Writer, "success", relations)
+}
+
+// DRelation
+// @Tags 用户关系模块
+// @Summary 根据关系id删除关系
+// @Produce application/json
+// @Param id path int64 true "关系id"
+// @Success 200 {object} response.Response
+// @Router /relation/delete/{id} [delete]
+func DRelation(c *gin.Context) {
+	var relation model.Relation
+	ids := c.Param("id")
+	id, err := strconv.Atoi(ids)
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	relation.Id = int64(id)
+	err = relation.DRelation()
+	if err != nil {
+		response.Fail(c.Writer, err.Error(), 500)
+		return
+	}
+	response.Success(c.Writer, "success", nil)
+}

+ 39 - 26
trading-go/controller/usercontroller.go

@@ -3,7 +3,6 @@ package controller
 import (
 	"errors"
 	"github.com/gin-gonic/gin"
-	"strconv"
 	"trading-go/model"
 	"trading-go/response"
 	"trading-go/util"
@@ -12,18 +11,31 @@ import (
 // Register
 // @Tags 用户模块
 // @Summary 创建用户
-// @param vid formData string false "微信ID"
-// @param name formData string false "用户名"
-// @param avatar formData string false "头像"
-// @Success 200 {string} json{"code","data","message"}
+// @Accept application/json
+// @Produce application/json
+// @param json body model.UserJson true "用户信息"
+// @Success 200 object response.Response
 // @Router /user/register [post]
 func Register(c *gin.Context) {
-	var user model.User
-	user.Vid = c.PostForm("vid")
-	user.Name = c.PostForm("name")
-	user.Avatar = c.PostForm("avatar")
-	user.Uid = util.GenID()
-	err := user.Register()
+	var userJ model.UserJson
+	err := c.ShouldBindJSON(&userJ)
+	if err != nil {
+		msg := err.Error()
+		response.Fail(c.Writer, msg, 500)
+	}
+	id := util.GenID()
+	if !util.CheckMobile(userJ.Phone) {
+		msg := util.PhoneFormatError.Error()
+		response.Fail(c.Writer, msg, 400)
+	}
+	user := model.User{
+		Uid:    id,
+		Vid:    userJ.Vid,
+		Name:   userJ.Name,
+		Avatar: userJ.Avatar,
+		Phone:  userJ.Phone,
+	}
+	err = user.Register()
 	if err != nil {
 		msg := err.Error()
 		response.Fail(c.Writer, msg, 500)
@@ -36,8 +48,9 @@ func Register(c *gin.Context) {
 // Login
 // @Tags 用户模块
 // @Summary 登录
+// @Produce application/json
 // @param vid formData string false "微信ID"
-// @Success 200 {string} json{"code","data","token"}
+// @Success 200 {object} response.Response
 // @Router /user/login [post]
 func Login(c *gin.Context) {
 	var user model.User
@@ -67,23 +80,22 @@ func Login(c *gin.Context) {
 	response.Success(c.Writer, "success", data)
 }
 
-// Modify
+// ModifyUser
 // @Tags 用户模块
 // @Summary 修改用户信息
-// @param uid formData string false "用户ID"
-// @param avatar formData string false "头像"
-// @param name formData string false "用户名"
-// @param phone formData string false "电话"
-// @Success 200 {string} json{"code","data","token"}
+// @Accept application/json
+// @Produce application/json
+// @param json body model.User true "用户信息"
+// @Success 200 {object} response.Response
 // @Router /user/modify [post]
-func Modify(c *gin.Context) {
+func ModifyUser(c *gin.Context) {
 	var user model.User
-	id := c.PostForm("uid")
-	uid, err := strconv.Atoi(id)
-	user.Uid = int64(uid)
-	user.Phone = c.PostForm("phone")
-	user.Avatar = c.PostForm("avatar")
-	user.Name = c.PostForm("name")
+	err := c.ShouldBindJSON(&user)
+	if err != nil {
+		msg := err.Error()
+		response.Fail(c.Writer, msg, 500)
+		return
+	}
 	//fmt.Printf("%#v", user)
 	if err := user.SPhone(); err != nil {
 		if errors.Is(err, util.PhoneBeUsed) {
@@ -106,7 +118,8 @@ func Modify(c *gin.Context) {
 // UserInfo
 // @Tags 用户模块
 // @Summary 获取用户信息
-// @Success 200 {string} json{"code","data"}
+// @Produce application/json
+// @Success 200 {object} response.Response
 // @Router /user/info [get]
 func UserInfo(c *gin.Context) {
 	var u model.User

Datei-Diff unterdrückt, da er zu groß ist
+ 939 - 28
trading-go/docs/docs.go


Datei-Diff unterdrückt, da er zu groß ist
+ 940 - 29
trading-go/docs/swagger.json


+ 766 - 37
trading-go/docs/swagger.yaml

@@ -1,8 +1,153 @@
 basePath: /WeChatTrading/trading-go
+definitions:
+  model.Appraise:
+    properties:
+      buyerId:
+        type: integer
+      content:
+        type: string
+      goodsId:
+        type: integer
+      id:
+        type: integer
+      star:
+        type: integer
+      time:
+        type: integer
+    type: object
+  model.AppraiseJson:
+    properties:
+      buyerId:
+        type: integer
+      content:
+        type: string
+      goodsId:
+        type: integer
+      star:
+        type: integer
+      time:
+        type: integer
+    type: object
+  model.CategoryJson:
+    properties:
+      name:
+        type: string
+      pic:
+        type: string
+    type: object
+  model.Goods:
+    properties:
+      desc:
+        type: string
+      id:
+        type: integer
+      integrity:
+        type: integer
+      ownerId:
+        type: integer
+      pic:
+        $ref: '#/definitions/model.Pic'
+      place:
+        type: string
+      price:
+        type: integer
+      state:
+        type: integer
+      title:
+        type: string
+    type: object
+  model.GoodsJson:
+    properties:
+      categories:
+        items:
+          type: integer
+        type: array
+      desc:
+        type: string
+      integrity:
+        type: integer
+      ownerId:
+        type: integer
+      pic:
+        $ref: '#/definitions/model.Pic'
+      place:
+        type: string
+      price:
+        type: integer
+      state:
+        type: integer
+      title:
+        type: string
+    type: object
+  model.OrderJson:
+    properties:
+      buyerId:
+        type: integer
+      goodsId:
+        type: integer
+      phone:
+        type: string
+      place:
+        type: string
+      state:
+        type: integer
+      time:
+        type: string
+    type: object
+  model.Pic:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+      url:
+        type: string
+    type: object
+  model.RelationJson:
+    properties:
+      owner:
+        type: integer
+      target:
+        type: integer
+      type:
+        type: integer
+    type: object
+  model.User:
+    properties:
+      avatar:
+        type: string
+      name:
+        type: string
+      phone:
+        type: string
+      uid:
+        type: integer
+      vid:
+        type: string
+    type: object
+  model.UserJson:
+    properties:
+      avatar:
+        type: string
+      name:
+        type: string
+      phone:
+        type: string
+      vid:
+        type: string
+    type: object
+  response.Response:
+    properties:
+      code:
+        type: integer
+      data: {}
+      message:
+        type: string
+    type: object
 host: 127.0.0.1:8084
 info:
   contact: {}
-  description: 一个基于微信小程序的校园二手交易平台的api
+  description: 一个基于微信小程序的校园二手交易平台的api文档
   license:
     name: Apache 2.0
     url: http://www.apache.org/licenses/LICENSE-2.0.html
@@ -10,68 +155,652 @@ info:
   title: 二手交易
   version: "1.0"
 paths:
-  /user/login:
+  /appraise/create:
     post:
       parameters:
-      - description: 用户ID
-        in: formData
-        name: uid
+      - description: 评价信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.AppraiseJson'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 创建评论
+      tags:
+      - 评论模块
+  /appraise/delete/{id}:
+    delete:
+      parameters:
+      - description: 评论id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 删除评论
+      tags:
+      - 评论模块
+  /appraise/revise:
+    post:
+      parameters:
+      - description: 评价信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.Appraise'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 修改评论
+      tags:
+      - 评论模块
+  /appraise/user:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取用户评价
+      tags:
+      - 评论模块
+  /category:
+    get:
+      consumes:
+      - application/json
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取所有分类
+      tags:
+      - 分类模块
+  /category/create:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 分类数据
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.CategoryJson'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 创建分类
+      tags:
+      - 分类模块
+  /category/delete/{id}:
+    delete:
+      parameters:
+      - description: 分类id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 根据分类id删除某个分类
+      tags:
+      - 分类模块
+  /chat:
+    get:
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 与服务端进行websocket连接,请使用postman测试
+      tags:
+      - 聊天模块
+  /goods:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取所有商品
+      tags:
+      - 商品模块
+  /goods/{page}/{pageSize}:
+    get:
+      parameters:
+      - description: 页数
+        in: path
+        name: page
+        required: true
+        type: integer
+      - description: 一页的大小
+        in: path
+        name: pageSize
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取所有商品
+      tags:
+      - 商品模块
+  /goods/create:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 商品信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.GoodsJson'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 创建商品
+      tags:
+      - 商品模块
+  /goods/delete/{id}:
+    delete:
+      parameters:
+      - description: 商品id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 删除商品
+      tags:
+      - 商品模块
+  /goods/detail/{id}:
+    get:
+      parameters:
+      - description: 商品id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取商品详细信息
+      tags:
+      - 商品模块
+  /goods/recommend/{page}/{pageSize}:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: id
+        required: true
+        type: integer
+      - description: 页数
+        in: path
+        name: page
+        required: true
+        type: integer
+      - description: 一页的大小
+        in: path
+        name: pageSize
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 分页获取推荐商品
+      tags:
+      - 商品模块
+  /goods/revise:
+    post:
+      parameters:
+      - description: 商品信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.Goods'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 修改商品信息
+      tags:
+      - 商品模块
+  /goods/search/{page}/{pageSize}:
+    get:
+      parameters:
+      - description: 页数
+        in: path
+        name: page
+        required: true
+        type: integer
+      - description: 一页的大小
+        in: path
+        name: pageSize
+        required: true
+        type: integer
+      - description: 搜素关键词
+        in: query
+        name: keyword
+        required: true
         type: string
+      produces:
+      - application/json
       responses:
         "200":
-          description: code","data","token"}
+          description: OK
           schema:
-            type: string
-      summary: 登录
+            $ref: '#/definitions/response.Response'
+      summary: 搜索商品并分页显示
       tags:
-      - 用户模块
-  /user/modify:
+      - 商品模块
+  /goods/user/{id}:
+    get:
+      parameters:
+      - description: 用户id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取某个用户的所有商品
+      tags:
+      - 商品模块
+  /message:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: uid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 传入用户id获取用户消息记录
+      tags:
+      - 信息模块
+  /message/conv:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: uid
+        required: true
+        type: integer
+      - description: 对象id
+        in: query
+        name: targetId
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 传入用户id和聊天对象id获取消息记录
+      tags:
+      - 信息模块
+  /order:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取所有订单
+      tags:
+      - 订单模块
+  /order/create:
     post:
       parameters:
-      - description: 用户ID
+      - description: 订单信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.OrderJson'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 创建订单
+      tags:
+      - 订单模块
+  /order/delete/{id}:
+    delete:
+      parameters:
+      - description: 订单id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 删除订单
+      tags:
+      - 订单模块
+  /order/revise:
+    post:
+      parameters:
+      - description: 订单id
         in: formData
-        name: uid
-        type: string
-      - description: 头像
+        name: id
+        required: true
+        type: integer
+      - description: 订单状态
         in: formData
-        name: avatar
-        type: string
-      - description: 用户名
+        name: state
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 修改订单的状态
+      tags:
+      - 订单模块
+  /order/user:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取用户的所有订单
+      tags:
+      - 订单模块
+  /pic:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取所有图片
+      tags:
+      - 图片模块
+  /pic/delete/{id}:
+    delete:
+      parameters:
+      - description: 图片id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 删除图片
+      tags:
+      - 图片模块
+  /pic/upload:
+    post:
+      consumes:
+      - multipart/form-data
+      parameters:
+      - description: 图片
         in: formData
-        name: name
-        type: string
-      - description: 电话
+        name: pic
+        required: true
+        type: file
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 上传图片
+      tags:
+      - 图片模块
+  /relation/bad:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: uid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 传入用户id获取用户黑名单列表
+      tags:
+      - 用户关系模块
+  /relation/create:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 关系数据
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.RelationJson'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 添加用户间的关系,关系类型有1:好友关系,2:黑名单关系
+      tags:
+      - 用户关系模块
+  /relation/delete/{id}:
+    delete:
+      parameters:
+      - description: 关系id
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 根据关系id删除关系
+      tags:
+      - 用户关系模块
+  /relation/friend:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: uid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 传入用户id获取用户好友列表
+      tags:
+      - 用户关系模块
+  /user/info:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 获取用户信息
+      tags:
+      - 用户模块
+  /user/login:
+    post:
+      parameters:
+      - description: 微信ID
         in: formData
-        name: phone
+        name: vid
         type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/response.Response'
+      summary: 登录
+      tags:
+      - 用户模块
+  /user/modify:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 用户信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.User'
+      produces:
+      - application/json
       responses:
         "200":
-          description: code","data","token"}
+          description: OK
           schema:
-            type: string
+            $ref: '#/definitions/response.Response'
       summary: 修改用户信息
       tags:
       - 用户模块
   /user/register:
     post:
+      consumes:
+      - application/json
       parameters:
-      - description: 用户ID
-        in: formData
-        name: uid
-        type: string
-      - description: 用户名
-        in: formData
-        name: name
-        type: string
-      - description: 头像
-        in: formData
-        name: avatar
-        type: string
+      - description: 用户信息
+        in: body
+        name: json
+        required: true
+        schema:
+          $ref: '#/definitions/model.UserJson'
+      produces:
+      - application/json
       responses:
         "200":
-          description: code","data","message"}
+          description: OK
           schema:
-            type: string
+            $ref: '#/definitions/response.Response'
       summary: 创建用户
       tags:
       - 用户模块

+ 1 - 1
trading-go/main.go

@@ -8,7 +8,7 @@ import (
 
 // @title 二手交易
 // @version 1.0
-// @description 一个基于微信小程序的校园二手交易平台的api
+// @description 一个基于微信小程序的校园二手交易平台的api文档
 // @termsOfService http://swagger.io/terms/
 
 // @license.name Apache 2.0

+ 1 - 0
trading-go/model/admin.go

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

+ 18 - 0
trading-go/model/appraise.go

@@ -0,0 +1,18 @@
+package model
+
+type Appraise struct {
+	Id      int64  `db:"id"`
+	GoodsId int64  `db:"goods_id"`
+	BuyerId int64  `db:"buyer_id"`
+	Time    int64  `db:"time"`
+	Content string `db:"content"`
+	Star    int    `db:"star"`
+}
+
+type AppraiseJson struct {
+	GoodsId int64  `json:"goodsId"`
+	BuyerId int64  `json:"buyerId"`
+	Time    int64  `json:"time"`
+	Content string `json:"content"`
+	Star    int    `json:"star"`
+}

+ 18 - 0
trading-go/model/category.go

@@ -0,0 +1,18 @@
+package model
+
+type Category struct {
+	Id   int64  `db:"id"`
+	Name string `db:"name"`
+	Pic  string `db:"pic"`
+}
+
+type CategoryJson struct {
+	Name string `json:"name"`
+	Pic  string `json:"pic"`
+}
+
+type CategoryOfGoods struct {
+	Id         int64 `db:"id"`
+	GoodsId    int64 `db:"goods_id"`
+	CategoryId int64 `db:"category_id"`
+}

+ 44 - 0
trading-go/model/goods.go

@@ -0,0 +1,44 @@
+package model
+
+type Goods struct {
+	Id        int64  `db:"id"`
+	Pic       Pic    `db:"pic"`
+	OwnerId   int64  `db:"owner_id"`
+	Desc      string `db:"desc"`
+	Title     string `db:"title"`
+	Price     int64  `db:"price"`
+	Integrity int    `db:"integrity"`
+	Place     string `db:"place"`
+	State     int    `db:"state"`
+}
+
+type GoodsJson struct {
+	Pic        Pic     `json:"pic"`
+	OwnerId    int64   `json:"ownerId"`
+	Desc       string  `json:"desc"`
+	Title      string  `json:"title"`
+	Price      int64   `json:"price"`
+	Integrity  int     `json:"integrity"`
+	Place      string  `json:"place"`
+	Categories []int64 `json:"categories"`
+	State      int     `json:"state"`
+}
+
+type GoodsSurfaceJson struct {
+	Pic       Pic    `json:"pic"`
+	OwnerId   int64  `json:"ownerId"`
+	Title     string `json:"title"`
+	Price     int64  `json:"price"`
+	Integrity int    `json:"integrity"`
+	State     int    `json:"state"`
+}
+
+type GoodsSurface struct {
+	Id        int64  `db:"id"`
+	Pic       Pic    `db:"pic"`
+	OwnerId   int64  `db:"owner_id"`
+	Title     string `db:"title"`
+	Price     int64  `db:"price"`
+	Integrity int    `db:"integrity"`
+	State     int    `db:"state"`
+}

+ 1 - 0
trading-go/model/message.go

@@ -4,5 +4,6 @@ type Message struct {
 	MsgType int   `json:"msgType"`
 	From    int64 `json:"from"`
 	To      int64 `json:"to"`
+	Time    int64 `json:"time"`
 	Content any   `json:"content"`
 }

+ 22 - 0
trading-go/model/orders.go

@@ -0,0 +1,22 @@
+package model
+
+import "time"
+
+type Order struct {
+	Id      int64  `db:"id"`
+	GoodsId int64  `db:"goods_id"`
+	BuyerId int64  `db:"buyer_id"`
+	Time    int64  `db:"time"`
+	Place   string `db:"place"`
+	Phone   string `db:"phone"`
+	State   int    `db:"state"`
+}
+
+type OrderJson struct {
+	GoodsId int64     `json:"goodsId"`
+	BuyerId int64     `json:"buyerId"`
+	Time    time.Time `json:"time"`
+	Place   string    `json:"place"`
+	Phone   string    `json:"phone"`
+	State   int       `json:"state"`
+}

+ 7 - 0
trading-go/model/pic.go

@@ -0,0 +1,7 @@
+package model
+
+type Pic struct {
+	Id   int64  `db:"id"`
+	Name string `db:"name"`
+	Url  string `db:"url"`
+}

+ 55 - 0
trading-go/model/relation.go

@@ -1 +1,56 @@
 package model
+
+import (
+	"trading-go/common"
+	"trading-go/util"
+)
+
+type Relation struct {
+	Id     int64 `db:"id"`
+	Owner  int64 `db:"owner"`
+	Target int64 `db:"target"`
+	Type   int   `db:"type"`
+}
+
+type RelationJson struct {
+	Owner  int64 `json:"owner"`
+	Target int64 `json:"target"`
+	Type   int   `json:"type"`
+}
+
+func (r Relation) Creat() error {
+	db := common.DB
+	sqlStr := "INSERT INTO relations(onwer, target, type) VALUES (:onwer, :target, :type)"
+	rows, err := db.NamedExec(sqlStr, r)
+	if err != nil {
+		return err
+	}
+	affected, err := rows.RowsAffected()
+	if affected != 1 {
+		return util.InsertFailError
+	}
+	return err
+}
+
+func (r Relation) Friend(uid int) ([]int64, error) {
+	var friends []int64
+	db := common.DB
+	sqlStr := "SELECT target From relations WHERE onwer = ? AND type = 1"
+	err := db.Select(&friends, sqlStr, uid)
+	return friends, err
+}
+
+func (r Relation) BadRelation(uid int) ([]int64, error) {
+	var badRelation []int64
+	db := common.DB
+	sqlStr := "SELECT target From relations WHERE onwer = ? AND type = 2"
+	err := db.Select(&badRelation, sqlStr, uid)
+	return badRelation, err
+}
+
+func (r Relation) DRelation() error {
+	db := common.DB
+	sqlStr := "DELETE FROM relations WHERE id = ?"
+	_, err := db.Exec(sqlStr, r.Id)
+	return err
+}

+ 13 - 10
trading-go/model/user.go

@@ -6,21 +6,24 @@ import (
 	"trading-go/util"
 )
 
-// WeChatTrading/trading-go/model/user.go
-
-// User 用户信息模型
 type User struct {
-	Uid    int64  `json:"uid" db:"uid"`
-	Vid    string `json:"vid" db:"vid"`
-	Name   string `json:"name" db:"name"`
-	Avatar string `json:"avatar" db:"avatar"`
-	Email  string `json:"email" db:"email"`
-	Phone  string `json:"phone" db:"phone"`
+	Uid    int64  `db:"uid"`
+	Vid    string `db:"vid"`
+	Name   string `db:"name"`
+	Avatar string `db:"avatar"`
+	Phone  string `db:"phone"`
+}
+
+type UserJson struct {
+	Vid    string `json:"vid"`
+	Name   string `json:"name"`
+	Avatar string `json:"avatar"`
+	Phone  string `json:"phone"`
 }
 
 func (u User) Register() error {
 	db := common.DB
-	sqlStr := "INSERT INTO users(uid, vid,name, avatar) values (:uid, :vid, :name, :avatar)"
+	sqlStr := "INSERT INTO users(uid, vid,name, avatar, phone) values (:uid, :vid, :name, :avatar, :phone)"
 	exec, err := db.NamedExec(sqlStr, u)
 	if err != nil {
 		return err

+ 7 - 0
trading-go/response/message.go

@@ -17,6 +17,13 @@ var response = Response{
 	Data:    nil,
 }
 
+type PageResponse struct {
+	PageSize int         `json:"pageSize"`
+	Page     int         `json:"page"`
+	HNext    bool        `json:"HNext"`
+	Data     interface{} `json:"data"`
+}
+
 func Success(w http.ResponseWriter, message string, data interface{}) {
 	w.Header().Set("Content-Type", "application/json")
 	w.WriteHeader(http.StatusOK)

+ 59 - 1
trading-go/routine/routine.go

@@ -19,11 +19,69 @@ func GetRoutine() *gin.Engine {
 	user := r.Group("user")
 	{
 		user.GET("info", controller.UserInfo)
-		user.POST("modify", controller.Modify)
+		user.POST("modify", controller.ModifyUser)
 		user.POST("login", controller.Login)
 		user.POST("register", controller.Register)
 	}
 
 	r.GET("chat", controller.LinkToServer)
+
+	relation := r.Group("relation")
+	{
+		relation.POST("create", controller.RCreat)
+		relation.GET("friend", controller.GetFriend)
+		relation.GET("bad", controller.GetBadRelation)
+		relation.DELETE("delete/:id", controller.DRelation)
+	}
+
+	message := r.Group("message")
+	{
+		message.GET("", controller.History)
+		message.GET("conv", controller.ConversationHistory)
+	}
+
+	category := r.Group("category")
+	{
+		category.GET("", controller.GetAllCategories)
+		category.POST("create", controller.CreateCategory)
+		category.DELETE("delete/:id", controller.DCategory)
+	}
+
+	pic := r.Group("pic")
+	{
+		pic.POST("upload", controller.Upload)
+		pic.GET("", controller.GetAllPic)
+		pic.DELETE("delete/:id", controller.DPic)
+	}
+
+	goods := r.Group("goods")
+	{
+		goods.GET("", controller.GetAllGoods)
+		goods.POST("create", controller.CreatGoods)
+		goods.DELETE("delete/:id", controller.DGoods)
+		goods.GET("/:page/:pageSize", controller.GetGoodsPage)
+		goods.GET("recommend/:page/:pageSize", controller.GetRecommend)
+		goods.POST("revise", controller.ReviseGoods)
+		goods.GET("detail/:id", controller.GetGoodDetail)
+		goods.GET("user/:id", controller.GetUserGoods)
+		goods.GET("search/:page/:pageSize", controller.SearchGoods)
+	}
+
+	order := r.Group("order")
+	{
+		order.GET("", controller.GetAllOrder)
+		order.GET("user", controller.GetUserOrder)
+		order.POST("revise", controller.ReviseOrder)
+		order.POST("create", controller.CreateOrder)
+		order.DELETE("delete/:id", controller.DeleteOrder)
+	}
+
+	appraise := r.Group("appraise")
+	{
+		appraise.POST("create", controller.CreateAppraise)
+		appraise.DELETE("delete/:id", controller.DAppraise)
+		appraise.POST("revise", controller.RAppraise)
+		appraise.GET("user", controller.GetUserAppraise)
+	}
 	return r
 }

+ 20 - 0
trading-go/util/check.go

@@ -0,0 +1,20 @@
+package util
+
+import "regexp"
+
+// CheckMobile 检验手机号
+func CheckMobile(phone string) bool {
+	// 匹配规则
+	// ^1第一位为一
+	// [345789]{1} 后接一位345789 的数字
+	// \\d \d的转义 表示数字 {9} 接9位
+	// $ 结束符
+	regRuler := "^1[345789]{1}\\d{9}$"
+
+	// 正则调用规则
+	reg := regexp.MustCompile(regRuler)
+
+	// 返回 MatchString 是否匹配
+	return reg.MatchString(phone)
+
+}

+ 5 - 4
trading-go/util/error.go

@@ -3,8 +3,9 @@ package util
 import "errors"
 
 var (
-	InsertFailError = errors.New("fail to insert")
-	NoSuchUserError = errors.New("no such user")
-	PhoneBeUsed     = errors.New("phone number already be used")
-	UpdateFailError = errors.New("fail to update")
+	InsertFailError  = errors.New("fail to insert")
+	NoSuchUserError  = errors.New("no such user")
+	PhoneBeUsed      = errors.New("phone number already be used")
+	UpdateFailError  = errors.New("fail to update")
+	PhoneFormatError = errors.New("phone format error")
 )

+ 3 - 1
trading-go/util/snowflake.go

@@ -3,13 +3,15 @@ package util
 import (
 	"fmt"
 	"github.com/bwmarrin/snowflake"
+	"github.com/spf13/viper"
 	"time"
 )
 
 var node *snowflake.Node
 
 func init() {
-	if err := Init("2021-12-03", 1); err != nil {
+	tie := viper.GetString("time.time")
+	if err := Init(tie, 1); err != nil {
 		fmt.Println("Init() failed, err = ", err)
 		return
 	}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.