package com.ruoyi.ibs.grid.controller;

import com.github.pagehelper.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataPageInfo;
import com.ruoyi.ibs.grid.domain.dto.GridTeamBuildDTO;
import com.ruoyi.ibs.grid.domain.entity.GridTeamBuild;
import com.ruoyi.ibs.grid.domain.vo.GridTeamBuildListVO;
import com.ruoyi.ibs.grid.service.GridTeamBuildService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "网格队伍建设接口")
@RestController
@RequestMapping("/grid/team")
public class GridTeamBuildController extends BaseController {

    @Resource
    private GridTeamBuildService gridTeamBuildService;

    @ApiOperation("查询网格队伍建设列表")
    @Log(title = "网格队伍建设-查询网格队伍建设列表")
    @GetMapping("/list")
    public TableDataPageInfo<GridTeamBuildListVO> getTopGridList(GridTeamBuildDTO gridTeamBuildDTO) {
        Page<Object> page = startPage();
        List<GridTeamBuildListVO> gridTeamBuildListVOS = gridTeamBuildService.getGridTeamBuildList(gridTeamBuildDTO);
        return getDataTable(gridTeamBuildListVOS, page);
    }

    @ApiOperation("新增网格队伍建设")
    @Log(title = "网格队伍建设-新增网格队伍建设")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody GridTeamBuild gridTeamBuild) {
        return success(gridTeamBuildService.addGridTeamBuild(gridTeamBuild));
    }

    @ApiOperation("修改网格队伍建设")
    @Log(title = "网格队伍建设-修改网格队伍建设")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody GridTeamBuild gridTeamBuild) {
        return success(gridTeamBuildService.updateGridTeamBuild(gridTeamBuild));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除网格队伍建设")
    @Log(title = "网格队伍建设-删除网格队伍建设")
    public AjaxResult delete(@PathVariable Long id) {
        return success(gridTeamBuildService.deleteById(id));
    }

}
