package com.microservices.zone.project.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.project.domain.ZoneProjectType;
import com.microservices.zone.project.domain.vo.ZoneProjectTypeInputVo;
import com.microservices.zone.project.domain.vo.ZoneProjectTypeUpdateVo;
import com.microservices.zone.project.service.IZoneProjectTypeService;
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 2023-05-05
 */
@RestController
@RequestMapping("/projectType")
@Api(tags = "特色专区项目分类接口")
public class ZoneProjectTypeController extends BaseController {
    @Autowired
    private IZoneProjectTypeService zoneProjectTypeService;

    /**
     * 查询特色专区项目分类列表
     */
    @RequiresPermissions("zone:projectType:list")
    @GetMapping("/list")
    @ApiOperation("查询特色专区项目分类列表")
    public GenericsTableDataInfo<ZoneProjectType> list(ZoneProjectType zoneProjectType) {
        startPage();
        List<ZoneProjectType> list = zoneProjectTypeService.selectZoneProjectTypeList(zoneProjectType);
        return getGenericsDataTable(list);
    }

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

    /**
     * 新增特色专区项目分类
     */
    @RequiresPermissions("zone:projectType:add")
    @Log(title = "特色专区项目分类", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增特色专区项目分类")
    public AjaxResult add(@RequestBody @Validated ZoneProjectTypeInputVo zoneProjectTypeInputVo) {
        return toAjax(zoneProjectTypeService.insertZoneProjectType(zoneProjectTypeInputVo));
    }

    /**
     * 修改特色专区项目分类
     */
    @RequiresPermissions("zone:projectType:edit")
    @Log(title = "特色专区项目分类", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改特色专区项目分类")
    public AjaxResult edit(@RequestBody @Validated ZoneProjectTypeUpdateVo zoneProjectTypeUpdateVo) {
        return toAjax(zoneProjectTypeService.updateZoneProjectType(zoneProjectTypeUpdateVo));
    }

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