business_contact.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package base
  2. import (
  3. "context"
  4. "dashoo.cn/common_definition/comm_def"
  5. "dashoo.cn/opms_libary/myerrors"
  6. "github.com/gogf/gf/frame/g"
  7. "github.com/gogf/gf/util/gvalid"
  8. projModel "dashoo.cn/micro/app/model/proj"
  9. projSrv "dashoo.cn/micro/app/service/proj"
  10. )
  11. type BusinessContactHandler struct{}
  12. // Swagger:BusinessContact 项目联系人 列表
  13. func (p *BusinessContactHandler) GetList(ctx context.Context, req *projModel.BusinessContactSearchReq, rsp *comm_def.CommonMsg) error {
  14. if req.BusId == 0 {
  15. return myerrors.ValidError("项目参数有误!")
  16. }
  17. contactService, err := projSrv.NewBusinessContactService(ctx)
  18. if err != nil {
  19. return err
  20. }
  21. total, list, err := contactService.GetList(req)
  22. if err != nil {
  23. return err
  24. }
  25. rsp.Data = g.Map{"list": list, "total": total}
  26. return nil
  27. }
  28. // Swagger:BusinessContact 项目联系人 创建
  29. func (p *BusinessContactHandler) Create(ctx context.Context, req *projModel.BusinessContactReq, rsp *comm_def.CommonMsg) error {
  30. // 参数校验
  31. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  32. return err
  33. }
  34. contactService, err := projSrv.NewBusinessContactService(ctx)
  35. if err != nil {
  36. return err
  37. }
  38. err = contactService.Create(req)
  39. if err != nil {
  40. return err
  41. }
  42. return nil
  43. }
  44. // Swagger:BusinessContact 项目联系人 删除
  45. func (p *BusinessContactHandler) DeleteByIds(ctx context.Context, req *projModel.DeleteBusinessContactReq, rsp *comm_def.CommonMsg) error {
  46. // 参数校验
  47. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  48. return err
  49. }
  50. contactService, err := projSrv.NewBusinessContactService(ctx)
  51. if err != nil {
  52. return err
  53. }
  54. err = contactService.DeleteByIds(req)
  55. return err
  56. }