delete_label_relationship_logic.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package label_relationship
  2. import (
  3. "context"
  4. "wechat-api/ent/labelrelationship"
  5. "wechat-api/internal/svc"
  6. "wechat-api/internal/types"
  7. "wechat-api/internal/utils/dberrorhandler"
  8. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type DeleteLabelRelationshipLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewDeleteLabelRelationshipLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLabelRelationshipLogic {
  17. return &DeleteLabelRelationshipLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. func (l *DeleteLabelRelationshipLogic) DeleteLabelRelationship(req *types.IDsReq) (*types.BaseMsgResp, error) {
  24. organizationId := l.ctx.Value("organizationId").(uint64)
  25. _, err := l.svcCtx.DB.LabelRelationship.Delete().Where(labelrelationship.IDIn(req.Ids...), labelrelationship.OrganizationIDEQ(organizationId)).Exec(l.ctx)
  26. if err != nil {
  27. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  28. }
  29. return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
  30. }