package com.fs.his.controller;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.page.TableDataInfo;
import com.fs.his.service.IFsPromotionalActiveLogService;
import com.fs.his.vo.FsPromotionalActiveStatVO;
import lombok.AllArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/his/promotionActiveLog")
@AllArgsConstructor
public class FsPromotionalActiveLogController extends BaseController {

    private final IFsPromotionalActiveLogService promotionalActiveLogService;

    @PreAuthorize("@ss.hasPermi('his:promotionActiveLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String name,
                              @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startTime,
                              @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endTime) {
        Map<String, Object> params = new HashMap<>();
        params.put("name", name);
        params.put("startTime", startTime);
        params.put("endTime", endTime);

        startPage();
        List<FsPromotionalActiveStatVO> list = promotionalActiveLogService.getPromotionalActiveLogStatByMap(params);
        return getDataTable(list);
    }
}
