package com.phm.manage.controller;

import com.phm.common.annotation.Log;
import com.phm.common.core.controller.BaseController;
import com.phm.common.core.domain.AjaxResult;
import com.phm.common.core.page.TableDataInfo;
import com.phm.common.enums.BusinessType;
import com.phm.common.utils.poi.ExcelUtil;
import com.phm.manage.domain.AnalyzeCourseLog;
import com.phm.manage.service.IAnalyzeCourseLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 分析过程日志Controller
 *
 * @author phm
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/manage/analyzeCourseLog")
public class AnalyzeCourseLogController extends BaseController {
    @Autowired
    private IAnalyzeCourseLogService analyzeCourseLogService;

    /**
     * 查询分析过程日志列表
     */
    @PreAuthorize("@ss.hasPermi('manage:analyzeCourseLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(AnalyzeCourseLog analyzeCourseLog) {
        startPage();
        List<AnalyzeCourseLog> list = analyzeCourseLogService.selectAnalyzeCourseLogList(analyzeCourseLog);
        return getDataTable(list);
    }

    /**
     * 导出分析过程日志列表
     */
    @PreAuthorize("@ss.hasPermi('manage:analyzeCourseLog:export')")
    @Log(title = "分析过程日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnalyzeCourseLog analyzeCourseLog) {
        List<AnalyzeCourseLog> list = analyzeCourseLogService.selectAnalyzeCourseLogList(analyzeCourseLog);
        ExcelUtil<AnalyzeCourseLog> util = new ExcelUtil<AnalyzeCourseLog>(AnalyzeCourseLog.class);
        util.exportExcel(response, list, "分析过程日志数据");
    }

    /**
     * 获取分析过程日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:analyzeCourseLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(analyzeCourseLogService.selectAnalyzeCourseLogById(id));
    }

    /**
     * 新增分析过程日志
     */
    @PreAuthorize("@ss.hasPermi('manage:analyzeCourseLog:add')")
    @Log(title = "分析过程日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnalyzeCourseLog analyzeCourseLog) {
        return toAjax(analyzeCourseLogService.insertAnalyzeCourseLog(analyzeCourseLog));
    }

    /**
     * 修改分析过程日志
     */
    @PreAuthorize("@ss.hasPermi('manage:analyzeCourseLog:edit')")
    @Log(title = "分析过程日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnalyzeCourseLog analyzeCourseLog) {
        return toAjax(analyzeCourseLogService.updateAnalyzeCourseLog(analyzeCourseLog));
    }

    /**
     * 删除分析过程日志
     */
    @PreAuthorize("@ss.hasPermi('manage:analyzeCourseLog:remove')")
    @Log(title = "分析过程日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(analyzeCourseLogService.deleteAnalyzeCourseLogByIds(ids));
    }
}
