123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package company
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CompanyHistoryRemark struct {
- HistoryId int `orm:"column(history_id);pk" comment:"备注id"`
- CompanyId int `comment:"客户ID"`
- ProductId int `comment:"产品id"`
- Content string `comment:"备注内容"`
- SysAdminId int `comment:"创建人ID"`
- SysAdminName string `comment:"创建人姓名"`
- CreateTime time.Time `comment:"创建时间"`
- ModifyTime time.Time `comment:"更新时间"`
- TableName string `comment:"表名"`
- TableId int `comment:"表ID"`
- UserId int `comment:"用户ID"`
- Mobile string `comment:"手机号"`
- Email string `comment:"邮箱"`
- RealName string `comment:"用户实际名称"`
- ShowTime time.Time `comment:"对外展示的创建时间"`
- }
- // CompanyHistoryRemarkReq 新增历史备注请求
- type CompanyHistoryRemarkReq struct {
- CompanyId int `description:"客户id"`
- Content string `description:"备注内容"`
- }
- // 新增
- func AddCompanyHistoryRemark(remark *CompanyHistoryRemark) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(remark)
- return
- }
- type CompanyHistoryRemarkResp struct {
- CompanyId int `comment:"客户ID"`
- Content string `comment:"备注内容"`
- SysAdminName string `comment:"创建人姓名"`
- RemarkType string `comment:"备注类型"`
- CreateTime string `comment:"对外展示的创建时间"`
- }
- type CompanyHistoryRemarkListResp struct {
- List []*CompanyHistoryRemarkResp
- }
- // GetCompanyHistoryRemarkList 获取备注列表
- func GetCompanyHistoryRemarkList(CompanyId, ProductId string) (items []*CompanyHistoryRemark, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM company_history_remark WHERE company_id=? AND product_id=? ORDER BY show_time DESC "
- _, err = o.Raw(sql, CompanyId, ProductId).QueryRows(&items)
- return
- }
- func GetCompanyHistoryRemarkListInitExport() (items []*CompanyHistoryRemark, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM company_history_remark WHERE product_id=2 AND show_time >= '2024-07-24' AND show_time < '2024-09-23' AND table_name IN ('company_service_record','company_history_remark') ORDER BY show_time DESC "
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- func GetCompanyHistoryRemarkListInitExportinit() (items []*CompanyHistoryRemark, err error) {
- o := orm.NewOrm()
- sql := "SELECT\n\t* \nFROM\n\tcompany_history_remark \nWHERE\n\tproduct_id = 2 \n\tAND show_time >= '2024-07-01' \n\tAND show_time < '2024-10-01' \n\tAND table_name IN ( 'company_service_record', 'company_history_remark' ) \n\tAND \tsys_admin_id IN ( SELECT admin_id FROM admin WHERE group_id IN ( 68, 72 ) ) \nORDER BY\n\tshow_time DESC "
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // DelCompanyHistoryRemark 删除客户历史备注
- func DelCompanyHistoryRemark(tableName string, tableId int) (err error) {
- o := orm.NewOrm()
- sql := `DELETE FROM company_history_remark WHERE table_name = ? AND table_id = ? `
- _, err = o.Raw(sql, tableName, tableId).Exec()
- return
- }
- // GetCompanyHistoryRemarkList 获取备注列表
- func GetCompanyHistoryRemarkListinit() (items []*CompanyHistoryRemark, err error) {
- o := orm.NewOrm()
- sql := "SELECT * FROM company_history_remark WHERE table_id > 0 "
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // AddCompanyHistoryRemarkMultiinit 批量添加
- func AddCompanyHistoryRemarkMultiinit(items []*CompanyHistoryRemark) (err error) {
- if len(items) == 0 {
- return
- }
- o, err := orm.NewOrm().Begin()
- if err != nil {
- return
- }
- defer func() {
- if err == nil {
- o.Commit()
- } else {
- o.Rollback()
- }
- }()
- if len(items) > 0 {
- //批量添加流水信息
- _, err = o.InsertMulti(len(items), items)
- }
- return
- }
|