package com.microservices.zone.partners.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.partners.domain.ZonePartnersType;
import com.microservices.zone.partners.domain.vo.ZonePartnersTypeInputVo;
import com.microservices.zone.partners.domain.vo.ZonePartnersTypeSearchVo;
import com.microservices.zone.partners.domain.vo.ZonePartnersTypeUpdateVo;
import com.microservices.zone.partners.service.IZonePartnersTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 特色专区合作伙伴分类Controller
 *
 * @author otto
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/partnersType")
@Api(tags = "特色专区合作伙伴分类相关接口")
public class ZonePartnersTypeController extends BaseController {
    @Autowired
    private IZonePartnersTypeService zonePartnersTypeService;

    /**
     * 查询特色专区合作伙伴分类列表
     */
    @RequiresPermissions("zone:partnersType:list")
    @GetMapping("/list")
    @ApiOperation("查询特色专区合作伙伴分类列表")
    public GenericsTableDataInfo<ZonePartnersType> list(ZonePartnersTypeSearchVo zonePartnersType) {
        startPage();
        List<ZonePartnersType> list = zonePartnersTypeService.selectZonePartnersTypeList(zonePartnersType.toZonePartnersType());
        return getGenericsDataTable(list);
    }

    /**
     * 获取特色专区合作伙伴分类详细信息
     */
    @RequiresPermissions("zone:partnersType:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取特色专区合作伙伴分类详细信息")
    public GenericsAjaxResult<ZonePartnersType> getInfo(@PathVariable("id") Long id) {
        return genericsSuccess(zonePartnersTypeService.selectZonePartnersTypeById(id));
    }

    /**
     * 新增特色专区合作伙伴分类
     */
    @RequiresPermissions("zone:partnersType:add")
    @Log(title = "特色专区合作伙伴分类", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增特色专区合作伙伴分类")
    public AjaxResult add(@RequestBody ZonePartnersTypeInputVo zonePartnersTypeInputVo) {
        return toAjax(zonePartnersTypeService.insertZonePartnersType(zonePartnersTypeInputVo));
    }

    /**
     * 修改特色专区合作伙伴分类
     */
    @RequiresPermissions("zone:partnersType:edit")
    @Log(title = "特色专区合作伙伴分类", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改特色专区合作伙伴分类")
    public AjaxResult edit(@RequestBody ZonePartnersTypeUpdateVo zonePartnersTypeUpdateVo) {
        return toAjax(zonePartnersTypeService.updateZonePartnersType(zonePartnersTypeUpdateVo));
    }

    /**
     * 删除特色专区合作伙伴分类
     */
    @RequiresPermissions("zone:partnersType:remove")
    @Log(title = "特色专区合作伙伴分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除特色专区合作伙伴分类")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(zonePartnersTypeService.deleteZonePartnersTypeByIds(ids));
    }
}
