package bus.controller.biz;

import bus.model.dto.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageSerializable;
import bus.model.dto.page.BCourseInfoPageDto;
import bus.model.vo.BCourseInfoVo;
import bus.service.BCourseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.qzwisdom.qzframework.core.tool.base.controller.BaseController;

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


/**
 * @Program: bus
 * @Description: 描述
 * @Author: zy
 * @Date: 2025-03-02 19:53:47
 **/
@Slf4j
@CrossOrigin
@RestController
@Api(tags = "路线接口")
@RequestMapping(value="/bCourseInfo")
public class BCourseInfoController implements BaseController {

    @Autowired
    private BCourseInfoService bCourseInfoService;



    /**
     * 详情
     * @param id
     * @return
     */
    @ApiOperation("详情")
    @GetMapping(value = "getDetailById")
    public BCourseInfoDto getDetailById(@RequestParam String id){
        return bCourseInfoService.getDetailById(id);
    }

	/**
     * 保存
     * @param dto
     * @return
     */
    @ApiOperation("保存")
    @PostMapping(value = "save")
    public String save(@RequestBody @Valid BCourseInfoDto dto){
		bCourseInfoService.save(dto);
        return "保存成功";
    }

    /**
    * 列表
    * @param dto
    * @return
    */
    @ApiOperation("列表")
    @PostMapping(value = "list")
    public PageSerializable<BCourseInfoVo> list(@RequestBody BCourseInfoPageDto dto){
       PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
       return new PageSerializable<>(bCourseInfoService.list(dto));
    }

	/**
     * 修改
     * @param dto
     * @return
     */
    @ApiOperation("修改")
    @PostMapping(value = "update")
    public String update(@RequestBody @Valid  BCourseInfoDto dto){
		bCourseInfoService.update(dto);
        return "修改成功";
    }

	/**
     * 删除
     * @param id
     * @return
     */
    @ApiOperation("删除路线")
    @GetMapping(value = "deleteById")
    public String deleteById(@RequestParam String id){
		bCourseInfoService.delete(id);
        return "删除成功";
    }

    /**
     * 根据站点类型获取路线信息
     * @param stationType
     * @return
     */
    @ApiOperation("根据站点类型获取路线信息")
    @GetMapping(value = "getAllCourseByType")
    List<WStationNameDto> getAllCourseByType(@RequestParam String stationType){
        return bCourseInfoService.getAllCourseByType(stationType);
    }

    /**
     * 根据站点类型获取路线信息
     * @param
     * @return
     */
    @ApiOperation("地图所有线路信息")
    @GetMapping(value = "getMapAllCourse")
    List<WCourseInfoByTypeDto> getMapAllCourse(){
        return bCourseInfoService.getMapAllCourse();
    }


    /**
     * 根据经纬度和半径(米)获取附近的路线

     * @return
     */
    @ApiOperation("根据经纬度和半径(米)获取附近的路线")
    @PostMapping(value = "getNearbyRoutes")
    List<WBusTrackInfoDto> getNearbyRoutes(@RequestBody NearbyRoutesDto nearbyRoutesDto
                                           ){
        return bCourseInfoService.getNearbyRoutes(nearbyRoutesDto);
    }

    @ApiOperation("小程序路线详情")
    @GetMapping(value = "getCourseDetail")
    WCourseDetailDto getCourseDetail(@RequestParam String courseId) {
        WCourseDetailDto courseDetail = bCourseInfoService.getCourseDetail(courseId);
        return courseDetail;
    }
}
