package com.weather.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.weather.common.utils.StringUtils;
import com.weather.entity.GuizhouRegion;
import com.weather.entity.WeaRotaInfo;
import com.weather.service.IGuizhouRegionService;
import com.weather.vo.ApiResult;
import com.weather.vo.res.GuizhouRegionRes;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
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 java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 行政区划 前端控制器
 * </p>
 *
 * @author : fengyuhao
 * @since 2021-02-02
 */
@RestController
@RequestMapping("/region")
public class GuizhouRegionController {

    @Autowired
    IGuizhouRegionService guizhouRegionService;

    @GetMapping("list")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "行政区划")
    public ApiResult list() {
        QueryWrapper<GuizhouRegion> wrapper=new QueryWrapper<>();
        wrapper.lambda().orderByAsc(GuizhouRegion::getId);
        List<GuizhouRegion> list = guizhouRegionService.list();
        if (list==null||list.size()<=0){
            return ApiResult.noData();
        }
        List<GuizhouRegionRes>resList=new ArrayList<>();
        GuizhouRegionRes model;
        for (GuizhouRegion item : list) {
            model=new GuizhouRegionRes();
            BeanUtils.copyProperties(item,model);
            model.setAddName(item.getAddName());
            resList.add(model);
        }
        return ApiResult.success(resList);
    }





}
