package com.red.circle.other.app.command.dynamic;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 动态-将我的消息置为已读.
 * </p>
 *
 * @author pengshigang
 * @since 2022-04-22
 */
@Component
@RequiredArgsConstructor
public class DynamicMessageUpdateReadCmdExe {

  private final DynamicMessageService dynamicMessageService;

  public void execute(AppExtCommand cmd) {

    dynamicMessageService.update()
        .set(DynamicMessage::getReading, Boolean.TRUE)
        .eq(DynamicMessage::getToUserId, cmd.getReqUserId())
        .execute();
  }


}
