package com.sqx.modules.trip.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.common.utils.DateUtils;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.dao.UserMoneyDao;
import com.sqx.modules.app.entity.UserEntity;
import com.sqx.modules.app.service.UserService;
import com.sqx.modules.artificer.entity.*;
import com.sqx.modules.artificer.service.*;
import com.sqx.modules.trip.entity.Trip;
import com.sqx.modules.trip.service.TripService;
import com.sqx.modules.utils.excel.ExcelData;
import com.sqx.modules.utils.excel.ExportExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/trip")
@Api(value = "出行方式", tags = {"出行方式"})
public class TripController {

    @Autowired
    private TripService tripService;

    @GetMapping("/selectTripList")
    @ApiOperation("查询出行方式列表")
    public Result selectTripList(Integer page,Integer limit,String city){
        return Result.success().put("data",new PageUtils(tripService.page(new Page<>(page,limit),new QueryWrapper<Trip>().like(StringUtils.isNotBlank(city),"city",city))));
    }

    @PostMapping("/insertTrip")
    @ApiOperation("添加出行方式")
    public Result insertTrip(@RequestBody Trip trip){
        trip.setCreateTime(DateUtils.format(new Date()));
        tripService.save(trip);
        return Result.success();
    }

    @PostMapping("/updateTrip")
    @ApiOperation("修改出行方式")
    public Result updateTrip(@RequestBody Trip trip){
        tripService.updateById(trip);
        return Result.success();
    }

    @PostMapping("/deleteTripById")
    @ApiOperation("删除出行方式")
    public Result deleteTripById(Long tripId){
        tripService.removeById(tripId);
        return Result.success();
    }






}
