package com.microservices.zone.specialProject.controller;

import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.domain.GenericsAjaxResult;
import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.zone.specialProject.domain.ZoneSpecialProject;
import com.microservices.zone.specialProject.domain.vo.ZoneSpecialProjectInputVo;
import com.microservices.zone.specialProject.domain.vo.ZoneSpecialProjectSearchVo;
import com.microservices.zone.specialProject.domain.vo.ZoneSpecialProjectUpdateVo;
import com.microservices.zone.specialProject.service.IZoneSpecialProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 特色专区专项项目Controller
 *
 * @author otto
 * @date 2024-10-26
 */
@RestController
@RequestMapping("/specialProject")
@Api(tags = " 特色专区专项项目接口")
public class ZoneSpecialProjectController extends BaseController {
    @Autowired
    private IZoneSpecialProjectService zoneSpecialProjectService;

    /**
     * 查询特色专区专项项目列表
     */
    @RequiresPermissions("zone:specialProject:list")
    @GetMapping("/list")
    @ApiOperation("查询特色专区专项项目列表")
    public GenericsTableDataInfo<ZoneSpecialProject> list(@Validated ZoneSpecialProjectSearchVo zoneSpecialProjectSearchVo) {
        startPage();
        return getGenericsDataTable(zoneSpecialProjectService.selectZoneSpecialProjectList(zoneSpecialProjectSearchVo.toZoneSpecialProjectSearchVo()));
    }

    /**
     * 获取特色专区专项项目详细信息
     */
    @RequiresPermissions("zone:specialProject:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取特色专区专项项目详细信息")
    public GenericsAjaxResult<ZoneSpecialProject> getInfo(@PathVariable("id") Long id) {
        return genericsSuccess(zoneSpecialProjectService.selectZoneSpecialProjectById(id));
    }

    /**
     * 新增特色专区专项项目
     */
    @RequiresPermissions("zone:specialProject:add")
    @Log(title = "特色专区专项项目", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增特色专区专项项目")
    public AjaxResult add(@RequestBody @Validated ZoneSpecialProjectInputVo zoneSpecialProjectInputVo) {
        return toAjax(zoneSpecialProjectService.insertZoneSpecialProject(zoneSpecialProjectInputVo));
    }

    /**
     * 修改特色专区专项项目
     */
    @RequiresPermissions("zone:specialProject:edit")
    @Log(title = "特色专区专项项目", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改特色专区专项项目")
    public AjaxResult edit(@RequestBody @Validated ZoneSpecialProjectUpdateVo zoneSpecialProjectUpdateVo) {
        return toAjax(zoneSpecialProjectService.updateZoneSpecialProject(zoneSpecialProjectUpdateVo));
    }

    /**
     * 删除特色专区专项项目
     */
    @RequiresPermissions("zone:specialProject:remove")
    @Log(title = "特色专区专项项目", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除特色专区专项项目")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(zoneSpecialProjectService.deleteZoneSpecialProjectByIds(ids));
    }
}
