Subversion Repositories SmartDukaan

Rev

Rev 34554 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.smartdukaan.cron.controller;

import com.smartdukaan.cron.migrations.RunOnceTasks;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ExposeController {

    private static final Logger LOGGER = LogManager.getLogger(ExposeController.class);

    @Autowired
    private RunOnceTasks runOnceTasks;

    @GetMapping("/expose")
    public ResponseEntity<?> expose() {
        return ResponseEntity.ok("This is use for Expose");
    }

    /**
     * Resolve old Sales/RBM Escalation tickets created before September 30, 2025.
     * Usage: GET /resolveOldEscalationTickets?dryRun=true (preview only)
     *        GET /resolveOldEscalationTickets?dryRun=false (actual execution)
     */
    @GetMapping("/resolveOldEscalationTickets")
    public ResponseEntity<?> resolveOldEscalationTickets(@RequestParam(defaultValue = "true") boolean dryRun) {
        try {
            LOGGER.info("resolveOldEscalationTickets called with dryRun={}", dryRun);
            String result = runOnceTasks.resolveOldEscalationTickets(dryRun);
            return ResponseEntity.ok(result);
        } catch (Exception e) {
            LOGGER.error("Error in resolveOldEscalationTickets", e);
            return ResponseEntity.internalServerError().body("Error: " + e.getMessage());
        }
    }
}