package com.microservices.zone.resource.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.resource.domain.ZoneResourceDomain;
import com.microservices.zone.resource.domain.vo.ZoneResourceDomainInputVo;
import com.microservices.zone.resource.domain.vo.ZoneResourceDomainSearchVo;
import com.microservices.zone.resource.domain.vo.ZoneResourceDomainUpdateVo;
import com.microservices.zone.resource.service.IZoneResourceDomainService;
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-27
 */
@RestController
@RequestMapping("/resourceDomain")
@Api(tags = "特色专区资源领域接口")
public class ZoneResourceDomainController extends BaseController {
    @Autowired
    private IZoneResourceDomainService zoneResourceDomainService;

    /**
     * 查询特色专区资源领域列表
     */
    @RequiresPermissions("zone:resourceDomain:list")
    @GetMapping("/list")
    @ApiOperation("查询特色专区资源领域列表")
    public GenericsTableDataInfo<ZoneResourceDomain> list(ZoneResourceDomainSearchVo zoneResourceDomainSearchVo) {
        startPage();
        List<ZoneResourceDomain> list = zoneResourceDomainService.selectZoneResourceDomainList(zoneResourceDomainSearchVo.toZoneResourceDomain());
        return getGenericsDataTable(list);
    }
    /**
     * 获取特色专区资源领域详细信息
     */
    @RequiresPermissions("zone:resourceDomain:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取特色专区资源领域详细信息")
    public GenericsAjaxResult<ZoneResourceDomain> getInfo(@PathVariable("id") Long id) {
        return genericsSuccess(zoneResourceDomainService.selectZoneResourceDomainById(id));
    }

    /**
     * 新增特色专区资源领域
     */
    @RequiresPermissions("zone:resourceDomain:add")
    @Log(title = "特色专区资源领域", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增特色专区资源领域")
    public AjaxResult add(@RequestBody ZoneResourceDomainInputVo zoneResourceDomainInputVo) {
        return toAjax(zoneResourceDomainService.insertZoneResourceDomain(zoneResourceDomainInputVo));
    }

    /**
     * 修改特色专区资源领域
     */
    @RequiresPermissions("zone:resourceDomain:edit")
    @Log(title = "特色专区资源领域", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改特色专区资源领域")
    public AjaxResult edit(@RequestBody ZoneResourceDomainUpdateVo zoneResourceDomainUpdateVo) {
        return toAjax(zoneResourceDomainService.updateZoneResourceDomain(zoneResourceDomainUpdateVo));
    }

    /**
     * 删除特色专区资源领域
     */
    @RequiresPermissions("zone:resourceDomain:remove")
    @Log(title = "特色专区资源领域", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除特色专区资源领域")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(zoneResourceDomainService.deleteZoneResourceDomainByIds(ids));
    }
}
