2025-10-22 10:18:32 +08:00
|
|
|
|
package com.cdzy.operations.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.cdzy.common.model.request.PageParam;
|
|
|
|
|
|
import com.cdzy.common.model.response.JsonResult;
|
|
|
|
|
|
import com.cdzy.operations.model.entity.EbikeRegion;
|
|
|
|
|
|
import com.cdzy.operations.model.vo.EbikeRegionVo;
|
|
|
|
|
|
import com.cdzy.operations.service.EbikeRegionService;
|
|
|
|
|
|
import com.mybatisflex.core.paginate.Page;
|
|
|
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
|
|
|
import com.mybatisflex.core.util.StringUtil;
|
|
|
|
|
|
import jakarta.annotation.Resource;
|
2025-10-22 10:23:13 +08:00
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2025-10-22 10:18:32 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.cdzy.operations.model.entity.table.EbikeRegionTableDef.EBIKE_REGION;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 运营区域表 控制层。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author attiya
|
|
|
|
|
|
* @since 2025-10-22
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/ebikeRegion")
|
2025-10-22 10:23:13 +08:00
|
|
|
|
@Validated
|
2025-10-22 10:18:32 +08:00
|
|
|
|
public class EbikeRegionController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
private EbikeRegionService ebikeRegionService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加运营区域。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param ebikeRegion 运营区域
|
|
|
|
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("save")
|
2025-10-22 10:23:13 +08:00
|
|
|
|
public JsonResult<?> save(@Validated @RequestBody EbikeRegionVo ebikeRegion) {
|
2025-10-22 10:18:32 +08:00
|
|
|
|
ebikeRegionService.save(ebikeRegion);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据主键删除运营区域表。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param regionId 主键
|
|
|
|
|
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("remove")
|
2025-10-22 10:23:13 +08:00
|
|
|
|
public JsonResult<?> remove(@Validated @RequestParam Long regionId) {
|
2025-10-22 10:18:32 +08:00
|
|
|
|
ebikeRegionService.removeById(regionId);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据主键更新运营区域表。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param ebikeRegion 运营区域表
|
|
|
|
|
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PutMapping("update")
|
|
|
|
|
|
public JsonResult<?> update(@RequestBody EbikeRegionVo ebikeRegion) {
|
|
|
|
|
|
ebikeRegionService.update(ebikeRegion);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询所有运营区域表。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 所有数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("list")
|
|
|
|
|
|
public JsonResult<?> list() {
|
|
|
|
|
|
List<EbikeRegion> list = ebikeRegionService.list();
|
|
|
|
|
|
return JsonResult.success(list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据运营区域表主键获取详细信息。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param regionId 运营区域表主键
|
|
|
|
|
|
* @return 运营区域表详情
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("getInfo")
|
|
|
|
|
|
public JsonResult<?> getInfo(@RequestParam Long regionId) {
|
|
|
|
|
|
EbikeRegion ebikeRegion = ebikeRegionService.getById(regionId);
|
|
|
|
|
|
return JsonResult.success(ebikeRegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 分页查询运营区域表。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param pageParam 分页对象
|
|
|
|
|
|
* @param regionName 运营区名称
|
|
|
|
|
|
* @param regionSimpleName 运营区简称
|
|
|
|
|
|
* @return 分页对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("page")
|
|
|
|
|
|
public JsonResult<?> page(PageParam pageParam, String regionName, String regionSimpleName) {
|
|
|
|
|
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
|
|
|
|
|
.where(EBIKE_REGION.REGION_NAME.like(regionName, StringUtil.hasText(regionName)))
|
|
|
|
|
|
.where(EBIKE_REGION.REGION_SIMPLE_NAME.like(regionSimpleName, StringUtil.hasText(regionSimpleName)));
|
|
|
|
|
|
Page<EbikeRegion> page = ebikeRegionService.page(pageParam.getPage(), queryWrapper);
|
|
|
|
|
|
return JsonResult.success(page);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|