file.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "database/sql"
  4. "time"
  5. "app.yhyue.com/moapp/jybase/date"
  6. cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. //文件相关
  10. type File struct {
  11. Name string //附件名称
  12. Suffix string //文件后缀
  13. FileType string //文件类型,产品介绍、项目方案、立项报告、报价文件、招标文件、投标文件、中标通知书、合同、发票、其他文件
  14. Size string //文件大小
  15. Oss string //oss地址
  16. BusinessId int64 //业务id
  17. Types int64 //类型;1:跟进记录-线下 2:跟进记录-线上 3:跟进记录-备忘 4:销售机会-项目文档 5:客户-客户档案
  18. }
  19. //Add 文件上传
  20. func (this *File) Add() bool {
  21. //存库
  22. return cm.CrmMysql.ExecTx("上传文件", func(tx *sql.Tx) bool {
  23. attachmentId := cm.CrmMysql.InsertByTx(tx, "attachment", map[string]interface{}{
  24. "name": this.Name,
  25. "suffix": this.Suffix,
  26. "type": this.FileType,
  27. "size": this.Size,
  28. "oss": this.Oss,
  29. "create_time": time.Now().Format(date.Date_Full_Layout),
  30. })
  31. pointId := cm.CrmMysql.InsertByTx(tx, "anchor_point", map[string]interface{}{
  32. "attachment_id": attachmentId,
  33. "business_id": this.BusinessId,
  34. "type": this.Types,
  35. })
  36. if attachmentId > 0 && pointId > 0 {
  37. return true
  38. }
  39. logx.Info("file add err:", attachmentId, pointId)
  40. return false
  41. })
  42. }