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.ZonePartners;
import com.microservices.zone.partners.domain.vo.ZonePartnersInputVo;
import com.microservices.zone.partners.domain.vo.ZonePartnersSearchVo;
import com.microservices.zone.partners.domain.vo.ZonePartnersUpdateVo;
import com.microservices.zone.partners.service.IZonePartnersService;
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 2023-06-07
 */
@RestController
@RequestMapping("/partners")
@Api(tags = "特色专区合作伙伴接口")
public class ZonePartnersController extends BaseController
{
    @Autowired
    private IZonePartnersService zonePartnersService;

    /**
     * 查询特色专区合作伙伴列表
     */
    @RequiresPermissions("zone:partners:list")
    @GetMapping("/list")
    @ApiOperation("查询特色专区合作伙伴列表")
    public GenericsTableDataInfo<ZonePartners> list(ZonePartnersSearchVo zonePartnersSearchVo)
    {
        startPage();
        return zonePartnersService.selectZonePartnersList(zonePartnersSearchVo.toZonePartners());
    }

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

    /**
     * 新增特色专区合作伙伴
     */
    @RequiresPermissions("zone:partners:add")
    @Log(title = "特色专区合作伙伴", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增特色专区合作伙伴")
    public AjaxResult add(@RequestBody @Validated ZonePartnersInputVo zonePartnersInputVo) {
        return toAjax(zonePartnersService.insertZonePartners(zonePartnersInputVo.toZonePartners()));
    }

    /**
     * 修改特色专区合作伙伴
     */
    @RequiresPermissions("zone:partners:edit")
    @Log(title = "特色专区合作伙伴", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改特色专区合作伙伴")
    public AjaxResult edit(@RequestBody @Validated ZonePartnersUpdateVo zonePartnersUpdateVo) {
        return toAjax(zonePartnersService.updateZonePartners(zonePartnersUpdateVo));
    }

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