package shop.alien.store.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.dto.AccountLogoutCompleteRequestDTO;
import shop.alien.entity.store.vo.AccountLogoutCompleteResultVo;
import shop.alien.store.service.AccountLogoutCompleteService;

/**
 * 注销冷静期完成（供 XXL-JOB Feign 调用，遵守 7 天规则）
 */
@Slf4j
@Api(tags = "账号注销-定时任务")
@RestController
@RequestMapping("/account/logout/job")
@RequiredArgsConstructor
public class AccountLogoutJobController {

    private final AccountLogoutCompleteService accountLogoutCompleteService;

    @ApiOperation("执行注销冷静期到期处理（满7天才会处理，与 cancellationOfBusinessJob 一致）")
    @PostMapping("/completeCooling")
    public R<AccountLogoutCompleteResultVo> completeCooling() {
        log.info("AccountLogoutJobController.completeCooling");
        AccountLogoutCompleteResultVo result = accountLogoutCompleteService.completeCoolingPeriod(false);
        return R.data(result);
    }
}
