package com.zhongzheng.controller.base;

import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.base.bo.ApplyAreasAddBo;
import com.zhongzheng.modules.base.bo.ApplyAreasEditBo;
import com.zhongzheng.modules.base.bo.ApplyAreasQueryBo;
import com.zhongzheng.modules.base.domain.ApplyAreas;
import com.zhongzheng.modules.base.service.IApplyAreasService;
import com.zhongzheng.modules.base.vo.ApplyAreasVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 报考地区Controller
 *
 * @author hjl
 * @date 2021-10-08
 */
@Api(value = "报考省市控制器", tags = {"报考省市管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/apply/areas")
public class ApplyAreasController extends BaseController {

    private final IApplyAreasService iApplyAreasService;

    /**
     * 查询报考省地区列表
     */
    @ApiOperation("查询报考省地区列表")
    @GetMapping("/list")
    public TableDataInfo<ApplyAreasVo> list(ApplyAreasQueryBo bo) {
        bo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
        bo.setParentId(0L);
        startPage();
        List<ApplyAreasVo> list = iApplyAreasService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 查询报考市地区列表
     */
    @ApiOperation("查询报考市地区列表")
    @GetMapping("/cityList")
    public TableDataInfo<ApplyAreas> cityList(ApplyAreasQueryBo bo) {
        startPage();
        List<ApplyAreas> list = iApplyAreasService.selectCityList(bo);
        return getDataTable(list);
    }


}
