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.ZoneSpecialProjectType;
import com.microservices.zone.specialProject.domain.vo.ZoneSpecialProjectTypeInputVo;
import com.microservices.zone.specialProject.domain.vo.ZoneSpecialProjectTypeSearchVo;
import com.microservices.zone.specialProject.domain.vo.ZoneSpecialProjectTypeUpdateVo;
import com.microservices.zone.specialProject.service.IZoneSpecialProjectTypeService;
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.*;

import java.util.List;

/**
 * 特色专区专项项目分类Controller
 * 
 * @author otto
 * @date 2024-10-26
 */
@RestController
@RequestMapping("/specialProjectType")
@Api(tags = "特色专区专项项目分类接口")
public class ZoneSpecialProjectTypeController extends BaseController {
    @Autowired
    private IZoneSpecialProjectTypeService zoneSpecialProjectTypeService;

    /**
     * 查询特色专区专项项目分类列表
     */
    @RequiresPermissions("zone:specialProjectType:list")
    @GetMapping("/list")
    @ApiOperation("查询特色专区专项项目分类列表")
    public GenericsTableDataInfo<ZoneSpecialProjectType> list(@Validated ZoneSpecialProjectTypeSearchVo zoneSpecialProjectTypeSearchVo) {
        startPage();
        List<ZoneSpecialProjectType> list = zoneSpecialProjectTypeService.selectZoneSpecialProjectTypeList(zoneSpecialProjectTypeSearchVo.toZoneSpecialProjectType(), false);
        return getGenericsDataTable(list);
    }

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

    /**
     * 新增特色专区专项项目分类
     */
    @RequiresPermissions("zone:specialProjectType:add")
    @Log(title = "特色专区专项项目分类", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增特色专区专项项目分类")
    public AjaxResult add(@RequestBody @Validated ZoneSpecialProjectTypeInputVo zoneSpecialProjectTypeInputVo) {
        return toAjax(zoneSpecialProjectTypeService.insertZoneSpecialProjectType(zoneSpecialProjectTypeInputVo));
    }

    /**
     * 修改特色专区专项项目分类
     */
    @RequiresPermissions("zone:specialProjectType:edit")
    @Log(title = "特色专区专项项目分类", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改特色专区专项项目分类")
    public AjaxResult edit(@RequestBody @Validated ZoneSpecialProjectTypeUpdateVo zoneSpecialProjectTypeUpdateVo) {
        return toAjax(zoneSpecialProjectTypeService.updateZoneSpecialProjectType(zoneSpecialProjectTypeUpdateVo));
    }

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