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