ctr_contract_invoice.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package contract
  2. import (
  3. "context"
  4. model "dashoo.cn/micro/app/model/contract"
  5. service "dashoo.cn/micro/app/service/contract"
  6. "dashoo.cn/common_definition/comm_def"
  7. "github.com/gogf/gf/frame/g"
  8. )
  9. type CtrContractInvoice struct{}
  10. // Swagger:CtrContractInvoice 合同发票 查询合同发票
  11. func (c *CtrContractInvoice) List(ctx context.Context, req *model.CtrContractInvoiceListReq, rsp *comm_def.CommonMsg) error {
  12. g.Log().Infof("CtrContractInvoice.List request %#v ", *req)
  13. s, err := service.NewCtrContractInvoiceService(ctx)
  14. if err != nil {
  15. return err
  16. }
  17. total, ent, err := s.List(ctx, req)
  18. //_, err, code, msg := myerrors.CheckError(err)
  19. if err != nil {
  20. return err
  21. }
  22. if ent == nil {
  23. ent = []*model.CtrContractInvoice{}
  24. }
  25. //rsp.Code = code
  26. //rsp.Msg = msg
  27. rsp.Data = map[string]interface{}{
  28. "total": total,
  29. "list": ent,
  30. }
  31. return nil
  32. }
  33. // Swagger:CtrContractInvoice 合同发票 添加合同发票
  34. func (c *CtrContractInvoice) Add(ctx context.Context, req *model.CtrContractInvoiceAddReq, rsp *comm_def.CommonMsg) error {
  35. g.Log().Infof("CtrContractInvoice.Add request %#v ", *req)
  36. s, err := service.NewCtrContractInvoiceService(ctx)
  37. if err != nil {
  38. return err
  39. }
  40. id, err := s.Add(ctx, req)
  41. //_, err, code, msg := myerrors.CheckError(err)
  42. if err != nil {
  43. return err
  44. }
  45. //rsp.Code = code
  46. //rsp.Msg = msg
  47. rsp.Data = id
  48. return nil
  49. }
  50. // Swagger:CtrContractInvoice 合同发票 更新合同发票
  51. func (c *CtrContractInvoice) Update(ctx context.Context, req *model.CtrContractInvoiceUpdateReq, rsp *comm_def.CommonMsg) error {
  52. g.Log().Infof("CtrContractInvoice.Update request %#v ", *req)
  53. s, err := service.NewCtrContractInvoiceService(ctx)
  54. if err != nil {
  55. return err
  56. }
  57. err = s.Update(ctx, req)
  58. if err != nil {
  59. return err
  60. }
  61. return nil
  62. }
  63. // Swagger:CtrContractInvoice 合同发票 提交发票申请
  64. func (c *CtrContractInvoice) InvoiceApply(ctx context.Context, req *model.CtrContractInvoiceInvoiceApplyReq, rsp *comm_def.CommonMsg) error {
  65. g.Log().Infof("CtrContractInvoice.InvoiceApply request %#v ", *req)
  66. s, err := service.NewCtrContractInvoiceService(ctx)
  67. if err != nil {
  68. return err
  69. }
  70. err = s.InvoiceApply(ctx, req)
  71. if err != nil {
  72. return err
  73. }
  74. return nil
  75. }
  76. // Swagger:CtrContractInvoice 合同发票 删除合同发票
  77. func (c *CtrContractInvoice) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error {
  78. g.Log().Infof("CtrContractInvoice.Delete request %#v ", *req)
  79. s, err := service.NewCtrContractInvoiceService(ctx)
  80. if err != nil {
  81. return err
  82. }
  83. err = s.Delete(ctx, req.Id)
  84. if err != nil {
  85. return err
  86. }
  87. return nil
  88. }