package cust import ( "context" "github.com/gogf/gf/errors/gerror" "github.com/gogf/gf/frame/g" "github.com/gogf/gf/util/gconv" "dashoo.cn/micro/app/dao/cust" model "dashoo.cn/micro/app/model/cust" "dashoo.cn/micro/app/service" ) type CustomerbelongService struct { *service.ContextService Dao *cust.CustCustomerBelongDao } func NewCustomerBelongService(ctx context.Context) (svc *CustomerbelongService, err error) { svc = new(CustomerbelongService) if svc.ContextService, err = svc.Init(ctx); err != nil { return nil, err } svc.Dao = cust.NewCustCustomerBelongDao(svc.Tenant) return svc, nil } //获取客户归属信息 func (c *CustomerbelongService) GetList(CustId int) (Info []*model.CustomerBelongInfo, err error) { Model := c.Dao err = Model.Where(c.Dao.Columns.CustId, CustId).Where(c.Dao.Columns.DeletedTime + " is null ").Scan(&Info) if err != nil { g.Log().Error(err) err = gerror.New("获取联系人信息失败") return } return } //插入归属销售 func (c *CustomerbelongService) Create(req *model.AddCustomerBelong) (err error) { Model := c.Dao cusTomerBelong := new(model.CustCustomerBelong) if err = gconv.Struct(req, cusTomerBelong); err != nil { g.Log().Info("error", err) return } service.SetCreatedInfo(cusTomerBelong, c.GetCxtUserId(), c.GetCxtUserName()) _, err = Model.Insert(cusTomerBelong) if err != nil { g.Log().Error(err) err = gerror.New("创建失败") return } return nil }