package com.ningdatech.kqapi.admin.controller;


import com.ningdatech.basic.model.IdVo;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.kqapi.admin.manage.ZoneManage;
import com.ningdatech.kqapi.admin.model.req.ListZoneReq;
import com.ningdatech.kqapi.admin.model.req.ZoneSaveReq;
import com.ningdatech.kqapi.admin.model.vo.ZoneDetailVO;
import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2024-04-20
 */
@Api(tags = "专区管理")
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/zone")
public class ZoneController {

    private final ZoneManage zoneManage;

    @PostMapping("/save")
    @WebLog("专区保存或修改")
    @ApiOperation("专区保存或修改")
    public void zoneSaveOrUpdate(@RequestBody @Valid ZoneSaveReq req) {
        zoneManage.zoneSaveOrUpdate(req);
    }

    @DeleteMapping("/del")
    @WebLog("专区删除")
    @ApiOperation("专区删除")
    public void delete(@RequestBody IdVo<Integer> id) {
        zoneManage.delete(id);
    }

    @GetMapping("/page")
    @WebLog("专区列表")
    @ApiOperation("专区列表")
    public PageVo<ZoneDetailVO> pageZone(ListZoneReq req) {
        return zoneManage.pageZone(req);
    }

    @GetMapping("/option")
    @WebLog("专区下拉选择")
    @ApiOperation("专区下拉选择")
    public List<ZoneDetailVO> zoneOption(ListZoneReq req) {
        return zoneManage.zoneOption(req);
    }

}
