package com.microservices.dms.achievementLibrary.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.dms.achievementLibrary.domain.AchievementTeam;
import com.microservices.dms.achievementLibrary.service.IAchievementTeamService;
import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.utils.poi.ExcelUtil;
import com.microservices.common.core.web.page.TableDataInfo;

/**
 * 成果团队Controller
 * 
 * @author microservices
 * @date 2025-04-23
 */
@RestController
@Api(tags = "数据管理体系-成果团队接口")
@RequestMapping("/achievementsTeam")
public class AchievementTeamController extends BaseController
{
    @Autowired
    private IAchievementTeamService achievementTeamService;

    /**
     * 查询成果团队列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AchievementTeam achievementTeam)
    {
        startPage();
        List<AchievementTeam> list = achievementTeamService.selectAchievementTeamList(achievementTeam);
        return getDataTable(list);
    }

    /**
     * 导出成果团队列表
     */
    @Log(title = "成果团队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AchievementTeam achievementTeam)
    {
        List<AchievementTeam> list = achievementTeamService.selectAchievementTeamList(achievementTeam);
        ExcelUtil<AchievementTeam> util = new ExcelUtil<AchievementTeam>(AchievementTeam.class);
        util.exportExcel(response, list, "成果团队数据");
    }

    /**
     * 获取成果团队详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(achievementTeamService.selectAchievementTeamById(id));
    }

    /**
     * 新增成果团队
     */
    @Log(title = "成果团队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AchievementTeam achievementTeam)
    {
        return toAjax(achievementTeamService.insertAchievementTeam(achievementTeam));
    }

    /**
     * 修改成果团队
     */
    @Log(title = "成果团队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AchievementTeam achievementTeam)
    {
        return toAjax(achievementTeamService.updateAchievementTeam(achievementTeam));
    }

    /**
     * 删除成果团队
     */
    @Log(title = "成果团队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(achievementTeamService.deleteAchievementTeamByIds(ids));
    }
}
