package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.fire.domain.DemFileLabel;
import com.usky.fire.service.DemFileLabelService;
import com.usky.fire.service.DemFireStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-09-14
 */
@RestController
@RequestMapping("/demFileLabel")
public class DemFileLabelController {

    @Autowired
    private DemFileLabelService demFileLabelService;

    @Autowired
    private DemFireStatisticsService demFireStatisticsService;

    /**
     * 标签-列表/下拉框查询
     *
     * @param fid       父ID
     * @param labelName 标签ID
     * @return
     */
    @GetMapping("demFileLabelList")
    public ApiResult<List<DemFileLabel>> demFileLabelList(@RequestParam(value = "fid", required = false) Integer fid,
                                                          @RequestParam(value = "labelName", required = false) String labelName) {
        return ApiResult.success(demFileLabelService.demFileLabelList(fid, labelName, null));
    }

    /**
     * 标签-删除
     *
     * @param id 主键ID
     * @return
     */
    @Log(title = "标签-删除", businessType = BusinessType.DELETE)
    @DeleteMapping("delDemFileLabel")
    public ApiResult<Void> delDemFireStatistics(@RequestParam(value = "id") Integer id) {
        demFireStatisticsService.delDemFileLabel(id);
        return ApiResult.success();
    }
}

