package com.microservices.dms.achievementLibrary.controller;

import com.microservices.common.core.utils.poi.ExcelUtil;
import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.TableDataInfo;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.dms.achievementLibrary.domain.SchoolEnterpriseAchievements;
import com.microservices.dms.achievementLibrary.service.ISchoolEnterpriseAchievementsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 校企成果Controller
 * 
 * @author microservices
 * @date 2025-04-03
 */
@Api(tags = "数据管理体系-校企成果接口")
@RestController
@RequestMapping("/schoolEnterpriseAchievements")
public class SchoolEnterpriseAchievementsController extends BaseController
{
    @Autowired
    private ISchoolEnterpriseAchievementsService schoolEnterpriseAchievementsService;

    /**
     * 查询校企成果列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SchoolEnterpriseAchievements schoolEnterpriseAchievements)
    {
        startPage();
        List<SchoolEnterpriseAchievements> list = schoolEnterpriseAchievementsService.selectSchoolEnterpriseAchievementsList(schoolEnterpriseAchievements);
        return getDataTable(list);
    }

    /**
     * 查询校企成果列表
     */
    @GetMapping("/listFront")
    public TableDataInfo listFront(SchoolEnterpriseAchievements schoolEnterpriseAchievements)
    {
        startPage();
        List<SchoolEnterpriseAchievements> list = schoolEnterpriseAchievementsService.listFront(schoolEnterpriseAchievements);
        return getDataTable(list);
    }

    /**
     * 导出校企成果列表
     */
    @Log(title = "校企成果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SchoolEnterpriseAchievements schoolEnterpriseAchievements)
    {
        List<SchoolEnterpriseAchievements> list = schoolEnterpriseAchievementsService.selectSchoolEnterpriseAchievementsList(schoolEnterpriseAchievements);
        ExcelUtil<SchoolEnterpriseAchievements> util = new ExcelUtil<SchoolEnterpriseAchievements>(SchoolEnterpriseAchievements.class);
        util.exportExcel(response, list, "校企成果数据");
    }

    /**
     * 获取校企成果详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(schoolEnterpriseAchievementsService.selectSchoolEnterpriseAchievementsById(id));
    }

    /**
     * 新增校企成果
     */
    @Log(title = "校企成果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchoolEnterpriseAchievements schoolEnterpriseAchievements)
    {
        return AjaxResult.success(schoolEnterpriseAchievementsService.insertSchoolEnterpriseAchievements(schoolEnterpriseAchievements));
    }

    /**
     * 修改校企成果
     */
    @Log(title = "校企成果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchoolEnterpriseAchievements schoolEnterpriseAchievements)
    {
        return AjaxResult.success(schoolEnterpriseAchievementsService.updateSchoolEnterpriseAchievements(schoolEnterpriseAchievements));
    }

    /**
     * 删除校企成果
     */
    @Log(title = "校企成果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return AjaxResult.success(schoolEnterpriseAchievementsService.deleteSchoolEnterpriseAchievementsByIds(ids));
    }

    /**
     * 顶部统计
     */
    @GetMapping("/topStatistic")
    @ApiOperation(value = "顶部统计数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tags", value = "成果标签", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "status", value = "成果状态", paramType = "query", dataTypeClass = Integer.class),
    })
    public AjaxResult topStatistic(SchoolEnterpriseAchievements schoolEnterpriseAchievements)
    {

        Long value = schoolEnterpriseAchievementsService.topStatistic(schoolEnterpriseAchievements);
        return AjaxResult.success(value);
    }
}
