package contract import ( "context" model "dashoo.cn/micro/app/model/contract" service "dashoo.cn/micro/app/service/contract" "dashoo.cn/common_definition/comm_def" "dashoo.cn/opms_libary/myerrors" "github.com/gogf/gf/frame/g" ) type CtrContractInvoice struct{} func (c *CtrContractInvoice) List(ctx context.Context, req *model.CtrContractInvoiceListReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("CtrContractInvoice.List request %#v ", *req) s, err := service.NewCtrContractInvoiceService(ctx) if err != nil { return err } total, ent, err := s.List(ctx, req) _, err, code, msg := myerrors.CheckError(err) if err != nil { return err } if ent == nil { ent = []*model.CtrContractInvoice{} } rsp.Code = code rsp.Msg = msg rsp.Data = map[string]interface{}{ "total": total, "list": ent, } return nil } func (c *CtrContractInvoice) Add(ctx context.Context, req *model.CtrContractInvoiceAddReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("CtrContractInvoice.Add request %#v ", *req) s, err := service.NewCtrContractInvoiceService(ctx) if err != nil { return err } id, err := s.Add(ctx, req) _, err, code, msg := myerrors.CheckError(err) if err != nil { return err } rsp.Code = code rsp.Msg = msg rsp.Data = id return nil } func (c *CtrContractInvoice) Update(ctx context.Context, req *model.CtrContractInvoiceUpdateReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("CtrContractInvoice.Update request %#v ", *req) s, err := service.NewCtrContractInvoiceService(ctx) if err != nil { return err } err = s.Update(ctx, req) _, err, code, msg := myerrors.CheckError(err) if err != nil { return err } rsp.Code = code rsp.Msg = msg return nil } func (c *CtrContractInvoice) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("CtrContractInvoice.Delete request %#v ", *req) s, err := service.NewCtrContractInvoiceService(ctx) if err != nil { return err } err = s.Delete(ctx, req.Id) _, err, code, msg := myerrors.CheckError(err) if err != nil { return err } rsp.Code = code rsp.Msg = msg return nil }