subscribeupdatelogic.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. it "jyBXSubscribe/api/init"
  6. "jyBXSubscribe/api/internal/svc"
  7. "jyBXSubscribe/api/internal/types"
  8. "jyBXSubscribe/rpc/model/service"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type SubscribeUpdateLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewSubscribeUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubscribeUpdateLogic {
  17. return &SubscribeUpdateLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. //
  24. func (l *SubscribeUpdateLogic) SubscribeUpdate(req *types.SubscribeUpdateReq) (resp *types.CommonResp, err error) {
  25. resp = &types.CommonResp{} //出参
  26. if req.UserId == "" {
  27. return
  28. }
  29. subService := &service.SubseribeService{
  30. UserId: req.UserId,
  31. Mgo: it.Mgo,
  32. }
  33. if req.Area != nil {
  34. subService.Area = req.Area
  35. }
  36. if req.Apppush != "" {
  37. subService.Apppush = req.Apppush
  38. }
  39. if req.Buyerclass != nil {
  40. subService.Buyerclass = req.Buyerclass
  41. }
  42. if req.Infotype != nil {
  43. subService.Infotype = req.Infotype
  44. }
  45. if req.Items != nil {
  46. subService.Items = req.Items
  47. }
  48. if req.Mail != "" {
  49. subService.Mail = req.Mail
  50. }
  51. if req.Mailpush != "" {
  52. subService.Mailpush = req.Mailpush
  53. }
  54. if req.Matchway != "" {
  55. subService.Matchway = req.Matchway
  56. }
  57. if req.Otherbuyerclass != "" {
  58. subService.Otherbuyerclass = req.Otherbuyerclass
  59. }
  60. if req.Projectmatch != "" {
  61. subService.Projectmatch = req.Projectmatch
  62. }
  63. if req.Ratemode != "" {
  64. subService.Ratemode = req.Ratemode
  65. }
  66. status, err := subService.Update()
  67. if err != nil {
  68. resp.Err_code, resp.Err_msg = -1, "修改失败"
  69. l.Error(fmt.Sprintf("%+v", req), resp.Err_msg)
  70. } else {
  71. resp.Data = map[string]interface{}{
  72. "status": status,
  73. }
  74. }
  75. return
  76. }