2025-10-28 16:53:04 +08:00
|
|
|
|
package com.cdzy.operations.controller;
|
|
|
|
|
|
|
2025-10-29 11:38:18 +08:00
|
|
|
|
import com.cdzy.common.model.request.PageParam;
|
|
|
|
|
|
import com.cdzy.common.model.response.JsonResult;
|
2025-10-28 16:53:04 +08:00
|
|
|
|
import com.cdzy.operations.model.entity.EbikeSite;
|
2025-10-29 11:38:18 +08:00
|
|
|
|
import com.cdzy.operations.model.vo.EbikeSiteVo;
|
2025-10-28 16:53:04 +08:00
|
|
|
|
import com.cdzy.operations.service.EbikeSiteService;
|
|
|
|
|
|
import com.mybatisflex.core.paginate.Page;
|
2025-10-29 11:38:18 +08:00
|
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
|
|
|
import com.mybatisflex.core.util.StringUtil;
|
2025-10-28 16:53:04 +08:00
|
|
|
|
import jakarta.annotation.Resource;
|
2025-10-29 11:38:18 +08:00
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2025-10-28 16:53:04 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
2025-10-29 11:38:18 +08:00
|
|
|
|
import static com.cdzy.operations.model.entity.table.EbikeSiteTableDef.EBIKE_SITE;
|
|
|
|
|
|
|
2025-10-28 16:53:04 +08:00
|
|
|
|
/**
|
2025-10-29 11:38:18 +08:00
|
|
|
|
* 站点控制层。
|
2025-10-28 16:53:04 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @author attiya
|
|
|
|
|
|
* @since 2025-10-28
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/ebikeSite")
|
2025-10-29 11:38:18 +08:00
|
|
|
|
@Validated
|
2025-10-28 16:53:04 +08:00
|
|
|
|
public class EbikeSiteController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
private EbikeSiteService ebikeSiteService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 添加。
|
|
|
|
|
|
*
|
2025-10-29 11:38:18 +08:00
|
|
|
|
* @param ebikeSite 站点信息
|
2025-10-28 16:53:04 +08:00
|
|
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("save")
|
2025-10-29 11:38:18 +08:00
|
|
|
|
public JsonResult<?> save(@RequestBody EbikeSiteVo ebikeSite) {
|
|
|
|
|
|
ebikeSiteService.saveSite(ebikeSite);
|
|
|
|
|
|
return JsonResult.success();
|
2025-10-28 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据主键删除。
|
|
|
|
|
|
*
|
2025-10-29 11:38:18 +08:00
|
|
|
|
* @param siteId 主键
|
2025-10-28 16:53:04 +08:00
|
|
|
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
|
|
|
|
*/
|
2025-10-29 11:38:18 +08:00
|
|
|
|
@GetMapping("remove")
|
|
|
|
|
|
public JsonResult<?> remove(@RequestParam Long siteId) {
|
|
|
|
|
|
ebikeSiteService.removeById(siteId);
|
|
|
|
|
|
return JsonResult.success();
|
2025-10-28 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据主键更新。
|
|
|
|
|
|
*
|
2025-10-29 11:38:18 +08:00
|
|
|
|
* @param ebikeSite 站点信息
|
2025-10-28 16:53:04 +08:00
|
|
|
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PutMapping("update")
|
2025-10-29 11:38:18 +08:00
|
|
|
|
public JsonResult<?> update(@RequestBody EbikeSiteVo ebikeSite) {
|
|
|
|
|
|
ebikeSiteService.updateSite(ebikeSite);
|
|
|
|
|
|
return JsonResult.success();
|
2025-10-28 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询所有。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 所有数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("list")
|
2025-10-29 11:38:18 +08:00
|
|
|
|
public JsonResult<?> list() {
|
|
|
|
|
|
List<EbikeSite> list = ebikeSiteService.list();
|
|
|
|
|
|
return JsonResult.success(list);
|
2025-10-28 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据主键获取详细信息。
|
|
|
|
|
|
*
|
2025-10-29 11:38:18 +08:00
|
|
|
|
* @param siteId 主键
|
2025-10-28 16:53:04 +08:00
|
|
|
|
* @return 详情
|
|
|
|
|
|
*/
|
2025-10-29 11:38:18 +08:00
|
|
|
|
@GetMapping("getInfo")
|
|
|
|
|
|
public JsonResult<?> getInfo(@RequestParam Long siteId) {
|
|
|
|
|
|
EbikeSite ebikeSite = ebikeSiteService.getById(siteId);
|
|
|
|
|
|
return JsonResult.success(ebikeSite);
|
2025-10-28 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 分页查询。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param page 分页对象
|
|
|
|
|
|
* @return 分页对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("page")
|
2025-10-29 11:38:18 +08:00
|
|
|
|
public JsonResult<?> page(PageParam page,String siteName) {
|
|
|
|
|
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
|
|
|
|
|
.where(EBIKE_SITE.SITE_NAME.like(siteName, StringUtil.hasText(siteName)));
|
|
|
|
|
|
Page<EbikeSite> sitePage = ebikeSiteService.page(page.getPage(),queryWrapper);
|
|
|
|
|
|
return JsonResult.success(sitePage);
|
2025-10-28 16:53:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|