package com.red.circle.other.app.inner.endpoint.task;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskProgressUpdateCmd;
import com.red.circle.other.app.service.task.RoomDailyTaskProgressService;
import com.red.circle.other.inner.endpoint.task.RoomDailyTaskClientApi;
import com.red.circle.other.inner.model.cmd.task.RoomDailyTaskProgressUpdateInnerCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 每日任务进度 ClientEndpoint.
 *
 * @author tf
 */
@Validated
@RestController
@RequestMapping(value = RoomDailyTaskClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class RoomDailyTaskClientEndpoint implements RoomDailyTaskClientApi {

    private final RoomDailyTaskProgressService roomDailyTaskProgressService;

    @Override
    public ResultResponse<Void> updateTaskProgress(RoomDailyTaskProgressUpdateInnerCmd cmd) {
        roomDailyTaskProgressService.updateTaskProgress(
                new RoomDailyTaskProgressUpdateCmd()
                        .setUserId(cmd.getUserId())
                        .setTaskCode(cmd.getTaskCode())
                        .setProgressValue(cmd.getProgressValue())
        );
        return ResultResponse.success(null);
    }
}
