package com.njcn.csharmonic.controller;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.common.service.ISysExcelService;
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
import com.njcn.harmonic.pojo.po.excel.SysExcel;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xy
 * @since 2026-01-27
 */
@Slf4j
@RestController
@RequestMapping("/sysExcel")
@Api(tags = "模板类型配置")
@AllArgsConstructor
public class SysExcelController extends BaseController {

    private final ISysExcelService sysExcelService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addSysExcel")
    @ApiOperation("新增")
    @ApiImplicitParam(name = "param", value = "设备数据趋势参数", required = true)
    public HttpResult<Boolean> addSysExcel(@RequestBody ExcelParam param) {
        String methodDescribe = getMethodDescribe("addSysExcel");
        Boolean result = sysExcelService.addSysExcel(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateSysExcel")
    @ApiOperation("修改")
    public HttpResult<Boolean> updateSysExcel(@RequestBody ExcelParam.UpdateExcelParam param) {
        String methodDescribe = getMethodDescribe("updateSysExcel");
        Boolean result = sysExcelService.updateSysExcel(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/deleteSysExcel")
    @ApiOperation("删除")
    public HttpResult<Boolean> deleteSysExcel(@RequestParam("id") String id) {
        String methodDescribe = getMethodDescribe("deleteSysExcel");
        Boolean result = sysExcelService.deleteSysExcel(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/querySysExcel")
    @ApiOperation("查询")
    public HttpResult<List<SysExcel>> querySysExcel() {
        String methodDescribe = getMethodDescribe("querySysExcel");
        List<SysExcel> result = sysExcelService.querySysExcel();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}

