ebike-share/ebike-operate/src/main/java/com/cdzy/ebikeoperate/controller/EbikeSysExchangePeriodController.java

86 lines
3.0 KiB
Java
Raw Normal View History

package com.cdzy.ebikeoperate.controller;
import com.cdzy.common.model.JsonResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.cdzy.ebikeoperate.model.pojo.EbikeSysExchangePeriod;
import com.cdzy.ebikeoperate.service.EbikeSysExchangePeriodService;
import java.util.List;
/**
* 区域分时间段换电 控制层
*
* @author dingchao
* @since 2025-04-15
*/
@RestController
@RequestMapping("/ebikeSysExchangePeriod")
public class EbikeSysExchangePeriodController {
@Autowired
private EbikeSysExchangePeriodService ebikeSysExchangePeriodService;
/**
* 添加区域分时间段换电
*
* @param ebikeSysExchangePeriod 区域分时间段换电
* @return {@code true} 添加成功{@code false} 添加失败
*/
@PostMapping("save")
public JsonResult<?> save(@RequestBody EbikeSysExchangePeriod ebikeSysExchangePeriod) {
boolean r = ebikeSysExchangePeriodService.save(ebikeSysExchangePeriod);
return r? JsonResult.success() : JsonResult.failed("添加区域分时间段换电失败");
}
/**
* 根据主键删除区域分时间段换电
*
* @param id 主键
* @return {@code true} 删除成功{@code false} 删除失败
*/
@PostMapping("remove")
public JsonResult<?> remove(@PathVariable String id) {
boolean r = ebikeSysExchangePeriodService.removeById(id);
return r? JsonResult.success() : JsonResult.failed("删除区域分时间段换电失败");
}
/**
* 根据主键更新区域分时间段换电
*
* @param ebikeSysExchangePeriod 区域分时间段换电
* @return {@code true} 更新成功{@code false} 更新失败
*/
@PostMapping("update")
public JsonResult<?> update(@RequestBody EbikeSysExchangePeriod ebikeSysExchangePeriod) {
boolean r = ebikeSysExchangePeriodService.updateById(ebikeSysExchangePeriod);
return r? JsonResult.success() : JsonResult.failed("更新区域分时间段换电失败");
}
/**
* 查询所有区域分时间段换电
*
* @param regionId 区域ID
* @return 所有数据
*/
@GetMapping("list")
public JsonResult<?> list(@RequestParam(name = "regionId") String regionId) {
List<EbikeSysExchangePeriod> list = ebikeSysExchangePeriodService.getListByReginId(regionId);
return list==null||list.isEmpty()? JsonResult.failed("查询区域分时间段换电失败") : JsonResult.success(list);
}
/**
* 根据区域分时间段换电主键获取详细信息
*
* @param id 区域分时间段换电主键
* @return 区域分时间段换电详情
*/
@GetMapping("getInfo")
public JsonResult<?> getInfo(@RequestParam(name = "id") String id) {
EbikeSysExchangePeriod r = ebikeSysExchangePeriodService.getById(id);
return r != null ? JsonResult.success(r) : JsonResult.failed("查询区域分时间段换电失败");
}
}