Subversion Repositories SmartDukaan

Rev

Rev 35610 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
34554 tejus.loha 1
package com.smartdukaan.cron.controller;
2
 
35610 amit 3
import com.smartdukaan.cron.migrations.RunOnceTasks;
4
import org.apache.logging.log4j.LogManager;
5
import org.apache.logging.log4j.Logger;
6
import org.springframework.beans.factory.annotation.Autowired;
34554 tejus.loha 7
import org.springframework.http.ResponseEntity;
8
import org.springframework.web.bind.annotation.GetMapping;
35610 amit 9
import org.springframework.web.bind.annotation.RequestParam;
34554 tejus.loha 10
import org.springframework.web.bind.annotation.RestController;
11
 
12
@RestController
13
public class ExposeController {
14
 
35610 amit 15
    private static final Logger LOGGER = LogManager.getLogger(ExposeController.class);
16
 
17
    @Autowired
18
    private RunOnceTasks runOnceTasks;
19
 
34554 tejus.loha 20
    @GetMapping("/expose")
21
    public ResponseEntity<?> expose() {
22
        return ResponseEntity.ok("This is use for Expose");
23
    }
35610 amit 24
 
25
    /**
26
     * Resolve old Sales/RBM Escalation tickets created before September 30, 2025.
27
     * Usage: GET /resolveOldEscalationTickets?dryRun=true (preview only)
28
     *        GET /resolveOldEscalationTickets?dryRun=false (actual execution)
29
     */
30
    @GetMapping("/resolveOldEscalationTickets")
31
    public ResponseEntity<?> resolveOldEscalationTickets(@RequestParam(defaultValue = "true") boolean dryRun) {
32
        try {
33
            LOGGER.info("resolveOldEscalationTickets called with dryRun={}", dryRun);
34
            String result = runOnceTasks.resolveOldEscalationTickets(dryRun);
35
            return ResponseEntity.ok(result);
36
        } catch (Exception e) {
37
            LOGGER.error("Error in resolveOldEscalationTickets", e);
35611 amit 38
            return ResponseEntity.status(500).body("Error: " + e.getMessage());
35610 amit 39
        }
40
    }
34554 tejus.loha 41
}