package com.ruoyi.web.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.areaSub.domain.AreaSubQuery;
import com.ruoyi.bst.areaSub.domain.enums.AreaSubStatus;
import com.ruoyi.bst.areaSub.service.AreaSubService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/app/areaSub")
public class AppAreaSubController extends BaseController {
    
    @Autowired
    private AreaSubService areaSubService;

    @ApiOperation("获取运营区的子区域列表")
    @GetMapping("/listByArea")
    @Anonymous
    public AjaxResult getAreaSubList(AreaSubQuery query) {
        if (query.getAreaId() == null) {
            return error("areaId不能为空");
        }
        query.setStatus(AreaSubStatus.ENABLED.getCode());
        return success(areaSubService.selectAreaSubList(query));
    }

    @ApiOperation("获取子区域详情")
    @GetMapping("/detail")
    @Anonymous
    public AjaxResult getAreaSubDetail(Long id) {
        AreaSubQuery query = new AreaSubQuery();
        query.setId(id);
        query.setStatus(AreaSubStatus.ENABLED.getCode());
        return success(areaSubService.selectOne(query));
    }
}
