Browse Source

add signature

animeic 2 years ago
parent
commit
fc7a368fa5

+ 101 - 15
boxcost/api/bill-produce-excel.go

@@ -3,6 +3,7 @@ package api
 import (
 	"box-cost/db/model"
 	"fmt"
+	"strconv"
 
 	"github.com/xuri/excelize/v2"
 )
@@ -18,13 +19,17 @@ type ProduceBillExcel struct {
 
 	AlignCenterStyle int
 
-	Content *model.ProduceBill
+	Content    *model.ProduceBill
+	Signatures []*model.Signature
 }
 
 func (b *ProduceBillExcel) drawTitle() error {
+	// 设置外边距
+	marginLeft := excelize.PageMarginLeft(0.15)
+	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	tileIndex := b.Offset + 1
 	startCell := fmt.Sprintf("A%d", tileIndex)
-	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("I%d", tileIndex))
+	err := b.Excel.MergeCell(b.SheetName, startCell, fmt.Sprintf("L%d", tileIndex))
 	if err != nil {
 		return err
 	}
@@ -78,7 +83,7 @@ func (b *ProduceBillExcel) drawSubTitles() error {
 
 	var drawRight = func(rowIndex int, value string) error {
 		right1Cell := fmt.Sprintf("F%d", rowIndex)
-		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("I%d", rowIndex))
+		err = b.Excel.MergeCell(b.SheetName, right1Cell, fmt.Sprintf("L%d", rowIndex))
 		if err != nil {
 			return err
 		}
@@ -155,9 +160,13 @@ func (b *ProduceBillExcel) drawTableTitle() error {
 	drawCol("D", "来纸尺寸")
 	drawCol("E", "印刷尺寸")
 	drawCol("F", "数量")
-	drawCol("H", "交货时间")
-	drawCol("I", "备注")
-	drawCol2("G", "单价", "元/张")
+	drawCol("G", "完成数量")
+	drawCol2("H", "单价", "元/张")
+	drawCol("I", "预算金额")
+	drawCol("J", "实际金额")
+	drawCol("K", "交货时间")
+	drawCol("L", "备注")
+
 	return nil
 }
 
@@ -165,7 +174,7 @@ func (b *ProduceBillExcel) drawTableContent() error {
 	row := b.Offset + 7
 
 	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"}
 		for i, c := range charas {
 			v := ""
 			if i < len(values) {
@@ -182,8 +191,30 @@ func (b *ProduceBillExcel) drawTableContent() error {
 	produces := b.Content.Produces
 	if len(produces) > 0 {
 		for _, produce := range produces {
+
+			confirmCount := "-"
+			realAmount := "-"
+			price, err := strconv.ParseFloat(produce.Price, 64)
+			if err != nil {
+				price = 0.00
+			}
+
+			// 预算金额
+			budgetAmount := fmt.Sprintf("%.2f", float64(produce.Count)*price)
+			b.FormatToEmpty(&budgetAmount)
+
+			if b.Content.Status == "complete" {
+				// 实际完成数
+				confirmCount = fmt.Sprintf("%d", b.Content.ConfirmCount)
+				b.FormatToEmpty(&confirmCount)
+
+				// 实际金额
+				realAmount = fmt.Sprintf("%.2f", float64(b.Content.ConfirmCount)*price)
+				b.FormatToEmpty(&realAmount)
+			}
+
 			deliveryTime := produce.DeliveryTime.Local().Format("2006-01-02")
-			DrawRow(row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.Count), produce.Price, deliveryTime, produce.Remark)
+			DrawRow(row, produce.Name, produce.Norm, produce.Paper, produce.PaperSize, produce.PrintSize, fmt.Sprintf("%d", produce.Count), confirmCount, produce.Price, budgetAmount, realAmount, deliveryTime, produce.Remark)
 			row++
 		}
 	}
@@ -192,7 +223,7 @@ func (b *ProduceBillExcel) drawTableContent() error {
 }
 
 func (b *ProduceBillExcel) drawTableFooter() error {
-	row := b.Offset + 10
+	row := b.Offset + 8
 
 	left1Cell := fmt.Sprintf("A%d", row)
 
@@ -218,8 +249,8 @@ func (b *ProduceBillExcel) drawTableFooter() error {
 	b.Excel.SetCellValue(b.SheetName, addCel, b.Content.SendTo)
 
 	sureCel := fmt.Sprintf("F%d", row)
-	b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("I%d", row))
-	b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("I%d", row), styleLeft)
+	b.Excel.MergeCell(b.SheetName, sureCel, fmt.Sprintf("L%d", row))
+	b.Excel.SetCellStyle(b.SheetName, sureCel, fmt.Sprintf("L%d", row), styleLeft)
 	b.Excel.SetCellValue(b.SheetName, sureCel, "供应商签字:")
 
 	b.Excel.SetRowHeight(b.SheetName, row, 21)
@@ -227,12 +258,54 @@ func (b *ProduceBillExcel) drawTableFooter() error {
 	return nil
 }
 
+func (b *ProduceBillExcel) drawTableSignature() error {
+	row := b.Offset + 11
+
+	style1, _ := b.Excel.NewStyle(&excelize.Style{
+		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
+		// Border:    border,
+	})
+
+	fontCell := fmt.Sprintf("H%d", row)
+	imageCell1 := fmt.Sprintf("I%d", row)
+	imageCell2 := fmt.Sprintf("K%d", row)
+	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("H%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
+	b.Excel.SetCellValue(b.SheetName, fontCell, "领导签字:")
+
+	// 签字图片1 I10-J12
+	b.Excel.MergeCell(b.SheetName, imageCell1, fmt.Sprintf("J%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell1, "")
+
+	// 签字图片2 K10-L12
+	b.Excel.MergeCell(b.SheetName, imageCell2, fmt.Sprintf("L%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell2, "")
+
+	// 状态为已审核时,签字
+	if b.Content.Reviewed == 1 {
+		imageCells := []string{imageCell1, imageCell2}
+		if len(b.Signatures) > 0 {
+			for k, sign := range b.Signatures {
+				b.Excel.AddPicture(b.SheetName, imageCells[k], sign.Url, sign.Format)
+
+			}
+		}
+	}
+
+	b.Excel.SetRowHeight(b.SheetName, row, 21)
+
+	return nil
+}
+
 func (b *ProduceBillExcel) Draws() {
 	b.drawTitle()
 	b.drawSubTitles()
 	b.drawTableTitle()
 	b.drawTableContent()
 	b.drawTableFooter()
+	b.drawTableSignature()
 }
 
 func NewProduceBill(f *excelize.File) *ProduceBillExcel {
@@ -255,13 +328,26 @@ func NewProduceBill(f *excelize.File) *ProduceBillExcel {
 		Excel:            f,
 		Offset:           0,
 		AlignCenterStyle: styleLeft,
+		Signatures:       make([]*model.Signature, 0),
 	}
 
-	f.SetColWidth(b.SheetName, "A", "A", 17)
-	f.SetColWidth(b.SheetName, "B", "B", 13)
-	f.SetColWidth(b.SheetName, "C", "G", 9.5)
-	f.SetColWidth(b.SheetName, "H", "I", 12)
+	// f.SetColWidth(b.SheetName, "A", "A", 17)
+	// f.SetColWidth(b.SheetName, "B", "B", 13)
+	// f.SetColWidth(b.SheetName, "C", "G", 9.5)
+	// f.SetColWidth(b.SheetName, "H", "I", 12)
+
+	f.SetColWidth(b.SheetName, "A", "A", 12)
+	f.SetColWidth(b.SheetName, "B", "K", 9.5)
+	// f.SetColWidth(b.SheetName, "I", "J", 8)
+	f.SetColWidth(b.SheetName, "L", "L", 10)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 
 	return b
 }
+
+func (b *ProduceBillExcel) FormatToEmpty(str *string) {
+	if *str == "0" || *str == "0.00" {
+		*str = ""
+	}
+
+}

+ 26 - 0
boxcost/api/bill-produce.go

@@ -34,6 +34,32 @@ func BillProduce(r *GinRouter) {
 
 	//下载单据
 	r.GET("/bill/produce/download", DownProduceBill)
+
+	// 审核单据
+	r.POST("/bill/produce/review/:id", ProduceReview)
+}
+
+// 审核单据
+func ProduceReview(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	_id := c.Param("id")
+	userId, err := primitive.ObjectIDFromHex(apictx.User.Parent)
+	if err != nil {
+		return nil, errors.New("用户异常")
+	}
+	user, err := getUserById(apictx, userId)
+	if err != nil {
+		return nil, errors.New("查找用户失败")
+	}
+	if !isManager(user.Roles) {
+		return nil, errors.New("该用户没有权限")
+	}
+	// 更改状态为已审核
+	produce := model.ProduceBill{
+		Reviewed:   1,
+		UpdateTime: time.Now(),
+	}
+	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillProduce, _id, &produce)
+
 }
 
 // 创建生产加工单据

+ 36 - 26
boxcost/api/bill-purchase-excel.go

@@ -2,7 +2,6 @@ package api
 
 import (
 	"box-cost/db/model"
-	"box-cost/log"
 	"fmt"
 	"strconv"
 
@@ -25,10 +24,12 @@ type PurchaseBillExcel struct {
 	AlignCenterStyle int
 
 	Content *model.PurchaseBill
+
+	Signatures []*model.Signature
 }
 
 func (b *PurchaseBillExcel) drawTitle() error {
-	marginLeft := excelize.PageMarginLeft(0.2)
+	marginLeft := excelize.PageMarginLeft(0.15)
 	b.Excel.SetPageMargins(b.SheetName, marginLeft)
 	tileIndex := b.Offset + 1
 	startCell := fmt.Sprintf("A%d", tileIndex)
@@ -304,33 +305,41 @@ func (b *PurchaseBillExcel) drawTableSignature() error {
 		// Border:    border,
 	})
 
-	fontCell := fmt.Sprintf("I%d", row)
-	imageCell := fmt.Sprintf("J%d", row)
-	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("I%d", row+2))
+	fontCell := fmt.Sprintf("H%d", row)
+	imageCell1 := fmt.Sprintf("I%d", row)
+	imageCell2 := fmt.Sprintf("K%d", row)
+	b.Excel.MergeCell(b.SheetName, fontCell, fmt.Sprintf("H%d", row+2))
 	b.Excel.SetCellStyle(b.SheetName, fontCell, fontCell, style1)
 	b.Excel.SetCellValue(b.SheetName, fontCell, "领导签字:")
 
-	// 签字图片 J10-K12
-	b.Excel.MergeCell(b.SheetName, imageCell, fmt.Sprintf("K%d", row+2))
-	b.Excel.SetCellStyle(b.SheetName, imageCell, imageCell, style1)
-	b.Excel.SetCellValue(b.SheetName, imageCell, "")
+	// 签字图片1 I10-J12
+	b.Excel.MergeCell(b.SheetName, imageCell1, fmt.Sprintf("J%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, imageCell1, imageCell1, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell1, "")
+
+	// 签字图片2 K10-L12
+	b.Excel.MergeCell(b.SheetName, imageCell2, fmt.Sprintf("L%d", row+2))
+	b.Excel.SetCellStyle(b.SheetName, imageCell2, imageCell1, style1)
+	b.Excel.SetCellValue(b.SheetName, imageCell2, "")
 
 	// 状态为已审核时,签字
-	if b.Content.Status == "reviewed" || b.Content.Status == "complete" {
-		err := b.Excel.AddPicture(b.SheetName, imageCell, "signature.png", `{
-			"x_scale": 0.35,
-			"y_scale": 0.35,
-			"x_offset": 10,
-			"print_obj": true,
-			"lock_aspect_ratio": false,
-			"locked": false,
-			"positioning": "oneCell"
-		}`)
-		if err != nil {
-			log.Error(err)
-			fmt.Println(err)
-		}
+	// `{
+	// 	"x_scale": 0.12,
+	// 	"y_scale": 0.12,
+	// 	"x_offset": 30,
+	// 	"print_obj": true,
+	// 	"lock_aspect_ratio": false,
+	// 	"locked": false,
+	// 	"positioning": "oncell"
+	// }`
+	if b.Content.Reviewed == 1 {
+		imageCells := []string{imageCell1, imageCell2}
+		if len(b.Signatures) > 0 {
+			for k, sign := range b.Signatures {
+				b.Excel.AddPicture(b.SheetName, imageCells[k], sign.Url, sign.Format)
 
+			}
+		}
 	}
 
 	b.Excel.SetRowHeight(b.SheetName, row, 21)
@@ -368,12 +377,13 @@ func NewPurchaseBill(f *excelize.File) *PurchaseBillExcel {
 		Excel:            f,
 		Offset:           0,
 		AlignCenterStyle: styleLeft,
+		Signatures:       make([]*model.Signature, 0),
 	}
 
-	f.SetColWidth(b.SheetName, "A", "A", 15)
-	f.SetColWidth(b.SheetName, "B", "J", 9)
+	f.SetColWidth(b.SheetName, "A", "A", 12)
+	f.SetColWidth(b.SheetName, "B", "K", 9.5)
 	// f.SetColWidth(b.SheetName, "C", "H", 9.5)
-	f.SetColWidth(b.SheetName, "L", "L", 12)
+	f.SetColWidth(b.SheetName, "L", "L", 10)
 	f.SetPageMargins(b.SheetName, excelize.PageMarginTop(0), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
 	return b
 }

+ 40 - 0
boxcost/api/bill.go

@@ -34,6 +34,32 @@ func Bill(r *GinRouter) {
 
 	// 删除单据
 	r.POST("/bill/purchase/delete/:id", DelBill)
+
+	// 审核单据
+	r.POST("/bill/purchase/review/:id", PurchaseReview)
+}
+
+// 审核单据
+func PurchaseReview(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	_id := c.Param("id")
+	userId, err := primitive.ObjectIDFromHex(apictx.User.Parent)
+	if err != nil {
+		return nil, errors.New("用户异常")
+	}
+	user, err := getUserById(apictx, userId)
+	if err != nil {
+		return nil, errors.New("查找用户失败")
+	}
+	if !isManager(user.Roles) {
+		return nil, errors.New("该用户没有权限")
+	}
+	// 更改状态为已审核
+	purchase := model.PurchaseBill{
+		Reviewed:   1,
+		UpdateTime: time.Now(),
+	}
+	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionBillPurchase, _id, &purchase)
+
 }
 
 type MatBillReq struct {
@@ -149,6 +175,20 @@ func DownLoadBills(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	f.SetDefaultFont("宋体")
 
 	billExcel := NewPurchaseBill(f)
+
+	// 获取已审核的签名数据
+	if bill.Reviewed == 1 {
+		if len(bill.SignUsers) > 0 {
+			signs := []*model.Signature{}
+			repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
+				CollectName: repo.CollectionSignature,
+				Query:       repo.Map{"userId": bson.M{"$in": bill.SignUsers}},
+				Sort:        bson.M{"sort": 1}, // 升序
+			}, &signs)
+			billExcel.Signatures = signs
+		}
+
+	}
 	billExcel.Content = &bill
 	info := model.Setting{}
 	repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{

+ 3 - 0
boxcost/api/router.go

@@ -44,6 +44,9 @@ func RegRouters(svc *Service) {
 
 	//设置
 	Setting(boxcost)
+
+	// 签名管理
+	Signature(boxcost)
 }
 
 func Logger() gin.HandlerFunc {

+ 116 - 0
boxcost/api/signature.go

@@ -0,0 +1,116 @@
+package api
+
+import (
+	"box-cost/db/model"
+	"box-cost/db/repo"
+	"box-cost/log"
+	"errors"
+	"fmt"
+	"time"
+
+	"github.com/gin-gonic/gin"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+// 签名管理
+func Signature(r *GinRouter) {
+
+	// 创建签名
+	r.POST("/signature/create", SignatureAdd)
+
+	// 获取签名详情
+	r.GET("/signature/detail/:id", SignatureDetail)
+
+	// 获取签名列表
+	r.GET("/signature/list", SignatureList)
+
+	// 更新签名
+	r.POST("/signature/update", SignatureUpdate)
+
+	// 删除签名
+	r.POST("/signature/delete/:id", SignatureDel)
+}
+
+// 创建签名
+func SignatureAdd(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+
+	var signature model.Signature
+
+	err := c.ShouldBindJSON(&signature)
+	if err != nil {
+		fmt.Println(err)
+		return nil, errors.New("参数错误!")
+	}
+	ctx := apictx.CreateRepoCtx()
+
+	if signature.UserId.IsZero() {
+		return nil, errors.New("签名用户为空")
+	}
+
+	signature.CreateTime = time.Now()
+	signature.UpdateTime = time.Now()
+
+	return repo.RepoAddDoc(ctx, repo.CollectionSignature, &signature)
+}
+
+// 获取签名详情
+func SignatureDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	signatureId := c.Param("id")
+	id, err := primitive.ObjectIDFromHex(signatureId)
+	if err != nil {
+		return nil, errors.New("非法id")
+	}
+	var signature model.Signature
+	option := &repo.DocSearchOptions{
+		CollectName: repo.CollectionSignature,
+		Query:       repo.Map{"_id": id},
+	}
+
+	found, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), option, &signature)
+	if !found || err != nil {
+		log.Info(err)
+		return nil, errors.New("数据未找到")
+	}
+
+	return signature, nil
+}
+
+// 获取签名列表
+func SignatureList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+
+	page, size, query := UtilQueryPageSize(c)
+
+	option := &repo.PageSearchOptions{
+		CollectName: repo.CollectionSignature,
+		Query:       query,
+		Page:        page,
+		Size:        size,
+		Sort:        bson.M{"sort": 1},
+	}
+	return repo.RepoPageSearch(apictx.CreateRepoCtx(), option)
+}
+
+// 更新签名
+func SignatureUpdate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	var signature model.Signature
+	err := c.ShouldBindJSON(&signature)
+	if err != nil {
+		return nil, errors.New("参数错误")
+	}
+	if signature.Id.Hex() == "" {
+		return nil, errors.New("id的为空")
+	}
+	signature.UpdateTime = time.Now()
+	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionSignature, signature.Id.Hex(), &signature)
+}
+
+// 删除签名
+func SignatureDel(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	signatureId := c.Param("id")
+	if signatureId == "" {
+		return nil, errors.New("id为空")
+	}
+
+	return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionSignature, signatureId)
+}

+ 23 - 0
boxcost/api/utils.go

@@ -81,3 +81,26 @@ func excelToPdf(formBody *bytes.Buffer, pdfHost string) (*http.Response, error)
 	return client.Post(req)
 
 }
+
+func isManager(roles []string) bool {
+
+	if len(roles) > 0 {
+		for _, role := range roles {
+			if role == "manager" {
+				return true
+			}
+		}
+	}
+	return false
+}
+func getUserById(apictx *ApiSession, id primitive.ObjectID) (*model.UserSmaple, error) {
+	fmt.Println(id.Hex())
+	user := &model.UserSmaple{}
+	_, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
+		Db:          "user",
+		CollectName: repo.CollectionUsers,
+		Query:       repo.Map{"_id": id},
+		Project:     []string{"name", "avatar", "city", "loginName"},
+	}, user)
+	return user, err
+}

+ 10 - 6
boxcost/db/model/bill.go

@@ -43,9 +43,11 @@ type PurchaseBill struct {
 	Type string `bson:"type,omitempty" json:"type"`
 
 	// 进行中 created  已完成 complete 已弃用 deprecated  已审核 reviewed
-	Status     string    `bson:"status,omitempty" json:"status"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
+	Status     string               `bson:"status,omitempty" json:"status"`
+	Reviewed   int                  `bson:"reviewed,omitempty" json:"reviewed"`   // -1 代表未审核 1已审核
+	SignUsers  []primitive.ObjectID `bson:"signUsers,omitempty" json:"signUsers"` // 多个签名人
+	CreateTime time.Time            `bson:"createTime,omitempty" json:"createTime"`
+	UpdateTime time.Time            `bson:"updateTime,omitempty" json:"updateTime"`
 
 	//供应商
 	Supplier string `bson:"supplier,omitempty" json:"supplier"`
@@ -107,9 +109,11 @@ type ProduceBill struct {
 	Type string `bson:"type,omitempty" json:"type"`
 
 	// 进行中 created  已完成 complete 已弃用 deprecated  已审核 reviewed
-	Status     string    `bson:"status,omitempty" json:"status"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
+	Status     string               `bson:"status,omitempty" json:"status"`
+	Reviewed   int                  `bson:"reviewed,omitempty" json:"reviewed"`   // -1 代表未审核 1已审核
+	SignUsers  []primitive.ObjectID `bson:"signUsers,omitempty" json:"signUsers"` // 多个签名人
+	CreateTime time.Time            `bson:"createTime,omitempty" json:"createTime"`
+	UpdateTime time.Time            `bson:"updateTime,omitempty" json:"updateTime"`
 
 	//确认收货数量
 	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`

+ 19 - 0
boxcost/db/model/signature.go

@@ -0,0 +1,19 @@
+package model
+
+import (
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+// 签名
+type Signature struct {
+	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
+	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"`
+	Name       string             `bson:"name,omitempty" json:"name"`
+	Url        string             `bson:"url,omitempty" json:"url"`
+	Format     string             `bson:"format,omitempty" json:"format"`
+	Sort       int                `bson:"sort,omitempty" json:"sort"`
+	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
+	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
+}

+ 19 - 0
boxcost/db/model/user.go

@@ -0,0 +1,19 @@
+package model
+
+import (
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+// user简单信息
+type UserSmaple struct {
+	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
+	Name       string             `bson:"name,omitempty" json:"name"`
+	Avatar     string             `bson:"avatar,omitempty" json:"avatar"`
+	LoginName  string             `bson:"loginName,omitempty" json:"loginName"`
+	City       string             `bson:"city,omitempty" json:"city"`
+	Roles      []string           `bson:"roles,omitempty" json:"roles"`
+	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
+	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
+}

+ 2 - 0
boxcost/db/repo/repo.go

@@ -31,6 +31,8 @@ const (
 	CollectionSupplierMatprice   = "supplier-mats"
 	CollectionSupplierCraftprice = "supplier-crafts"
 	CollectionIncrement          = "increment"
+	CollectionSignature          = "signature"
+	CollectionUsers              = "users"
 )
 
 type Map map[string]interface{}

+ 1 - 0
boxcost/main.go

@@ -31,6 +31,7 @@ func BuildApp() *dig.Container {
 }
 
 func main() {
+	comm.AppMongoMiration()
 
 	flag.Parse()
 	app := BuildApp()

+ 0 - 0
boxcost/readme.md


BIN
boxcost/signature.png


BIN
boxcost/signature1.png


BIN
boxcost/signature2.png