package com.cool.store.controller.webb;

import com.cool.store.common.InsertGroup;
import com.cool.store.common.UpdateGroup;
import com.cool.store.request.plan.CityPlanningUpdateRequest;
import com.cool.store.request.plan.CityPlanningQueryRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.plan.CityPlanningService;
import com.cool.store.vo.plan.CityPlanningStatisticsVO;
import com.cool.store.vo.plan.CityPlanningVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 城市规划控制器
 */
@Api(tags = "城市规划")
@RestController
@RequestMapping("/pc/cityPlanning")
@RequiredArgsConstructor
public class CityPlanningController {
    private final CityPlanningService cityPlanningService;

    @ApiOperation("新增城市规划")
    @PostMapping("/add")
    public ResponseResult<Boolean> add(@RequestBody @Validated(InsertGroup.class) CityPlanningUpdateRequest request) {
        return ResponseResult.success(cityPlanningService.add(request));
    }

    @ApiOperation("编辑城市规划")
    @PostMapping("/update")
    public ResponseResult<Boolean> update(@RequestBody @Validated(UpdateGroup.class) CityPlanningUpdateRequest request) {
        return ResponseResult.success(cityPlanningService.update(request));
    }

    @ApiOperation("分页查询城市规划")
    @PostMapping("/queryPage")
    public ResponseResult<PageInfo<CityPlanningVO>> queryPage(@RequestBody CityPlanningQueryRequest request) {
        return ResponseResult.success(cityPlanningService.queryPage(request));
    }

    @ApiOperation("批量删除城市规划")
    @PostMapping("/deleteByIds")
    public ResponseResult<Boolean> deleteByIds(@RequestBody List<Long> ids) {
        return ResponseResult.success(cityPlanningService.deleteByIds(ids));
    }

    @ApiOperation("规划进度")
    @PostMapping("/cityPlanningSchedule")
    public ResponseResult<PageInfo<CityPlanningVO>> cityPlanningSchedule(@RequestBody CityPlanningQueryRequest request) {
        return ResponseResult.success(cityPlanningService.cityPlanningSchedule(request));
    }

    @ApiOperation("规划进度总计")
    @PostMapping("/cityPlanningStatistics")
    public ResponseResult<CityPlanningStatisticsVO> cityPlanningStatistics(@RequestBody CityPlanningQueryRequest request) {
        return ResponseResult.success(cityPlanningService.cityPlanningStatistics(request));
    }
}

