站点功能
This commit is contained in:
parent
4f64538c9a
commit
81d67d2989
@ -1,21 +1,30 @@
|
||||
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.EbikeSite;
|
||||
import com.cdzy.operations.model.vo.EbikeSiteVo;
|
||||
import com.cdzy.operations.service.EbikeSiteService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.cdzy.operations.model.entity.table.EbikeSiteTableDef.EBIKE_SITE;
|
||||
|
||||
/**
|
||||
* 站点控制层。
|
||||
* 站点控制层。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ebikeSite")
|
||||
@Validated
|
||||
public class EbikeSiteController {
|
||||
|
||||
@Resource
|
||||
@ -24,34 +33,37 @@ public class EbikeSiteController {
|
||||
/**
|
||||
* 添加。
|
||||
*
|
||||
* @param ebikeSite
|
||||
* @param ebikeSite 站点信息
|
||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||
*/
|
||||
@PostMapping("save")
|
||||
public boolean save(@RequestBody EbikeSite ebikeSite) {
|
||||
return ebikeSiteService.save(ebikeSite);
|
||||
public JsonResult<?> save(@RequestBody EbikeSiteVo ebikeSite) {
|
||||
ebikeSiteService.saveSite(ebikeSite);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键删除。
|
||||
*
|
||||
* @param id 主键
|
||||
* @param siteId 主键
|
||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||
*/
|
||||
@DeleteMapping("remove/{id}")
|
||||
public boolean remove(@PathVariable Long id) {
|
||||
return ebikeSiteService.removeById(id);
|
||||
@GetMapping("remove")
|
||||
public JsonResult<?> remove(@RequestParam Long siteId) {
|
||||
ebikeSiteService.removeById(siteId);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键更新。
|
||||
*
|
||||
* @param ebikeSite
|
||||
* @param ebikeSite 站点信息
|
||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
||||
*/
|
||||
@PutMapping("update")
|
||||
public boolean update(@RequestBody EbikeSite ebikeSite) {
|
||||
return ebikeSiteService.updateById(ebikeSite);
|
||||
public JsonResult<?> update(@RequestBody EbikeSiteVo ebikeSite) {
|
||||
ebikeSiteService.updateSite(ebikeSite);
|
||||
return JsonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,19 +72,21 @@ public class EbikeSiteController {
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public List<EbikeSite> list() {
|
||||
return ebikeSiteService.list();
|
||||
public JsonResult<?> list() {
|
||||
List<EbikeSite> list = ebikeSiteService.list();
|
||||
return JsonResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键获取详细信息。
|
||||
*
|
||||
* @param id 主键
|
||||
* @param siteId 主键
|
||||
* @return 详情
|
||||
*/
|
||||
@GetMapping("getInfo/{id}")
|
||||
public EbikeSite getInfo(@PathVariable Long id) {
|
||||
return ebikeSiteService.getById(id);
|
||||
@GetMapping("getInfo")
|
||||
public JsonResult<?> getInfo(@RequestParam Long siteId) {
|
||||
EbikeSite ebikeSite = ebikeSiteService.getById(siteId);
|
||||
return JsonResult.success(ebikeSite);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,8 +96,11 @@ public class EbikeSiteController {
|
||||
* @return 分页对象
|
||||
*/
|
||||
@GetMapping("page")
|
||||
public Page<EbikeSite> page(Page<EbikeSite> page) {
|
||||
return ebikeSiteService.page(page);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class EbikeBikeInfo implements Serializable {
|
||||
/**
|
||||
* 运营区ID
|
||||
*/
|
||||
private Long areaId;
|
||||
private Long regionId;
|
||||
|
||||
/**
|
||||
* 车辆编号(与车辆二维码编号相同
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
package com.cdzy.operations.model.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import org.postgresql.geometric.PGpolygon;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.postgresql.geometric.PGpolygon;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 站点基础信息实体类。
|
||||
@ -35,6 +35,11 @@ public class EbikeSite implements Serializable {
|
||||
@Id
|
||||
private Long siteId;
|
||||
|
||||
/**
|
||||
* 站点名称
|
||||
*/
|
||||
private String siteName;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
@ -55,11 +60,13 @@ public class EbikeSite implements Serializable {
|
||||
*/
|
||||
private Integer siteType;
|
||||
|
||||
private Timestamp createAt;
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createAt;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
private Timestamp updatedAt;
|
||||
@Column(onUpdateValue = "now()")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
private Long updatedBy;
|
||||
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
package com.cdzy.operations.model.vo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.postgresql.geometric.PGpolygon;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 站点基础信息实体类。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-28
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EbikeSiteVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 站点ID
|
||||
*/
|
||||
private Long siteId;
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
@NotNull(message = "运营商ID不能为空")
|
||||
private Long operatorId;
|
||||
|
||||
|
||||
/**
|
||||
* 运营商ID
|
||||
*/
|
||||
@NotNull(message = "站点名称不能为空")
|
||||
private String siteName;
|
||||
|
||||
/**
|
||||
* 运营区ID
|
||||
*/
|
||||
@NotNull(message = "运营区ID不能为空")
|
||||
private Long regionId;
|
||||
|
||||
/**
|
||||
* 站点区域
|
||||
*/
|
||||
@NotNull(message = "站点区域不能为空")
|
||||
private PGpolygon sitePolygon;
|
||||
|
||||
/**
|
||||
* 站点类型:1-普通站点(停车) 2-禁停区 3-仓库区
|
||||
*/
|
||||
@NotNull(message = "站点类型不能为空")
|
||||
private Integer siteType;
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.cdzy.operations.service;
|
||||
|
||||
import com.cdzy.operations.model.vo.EbikeSiteVo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cdzy.operations.model.entity.EbikeSite;
|
||||
|
||||
@ -11,4 +12,7 @@ import com.cdzy.operations.model.entity.EbikeSite;
|
||||
*/
|
||||
public interface EbikeSiteService extends IService<EbikeSite> {
|
||||
|
||||
void saveSite(EbikeSiteVo ebikeSite);
|
||||
|
||||
void updateSite(EbikeSiteVo ebikeSite);
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.cdzy.operations.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.cdzy.common.ex.EbikeException;
|
||||
import com.cdzy.operations.model.vo.EbikeSiteVo;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cdzy.operations.model.entity.EbikeSite;
|
||||
import com.cdzy.operations.mapper.EbikeSiteMapper;
|
||||
@ -7,12 +10,40 @@ import com.cdzy.operations.service.EbikeSiteService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author attiya
|
||||
* @since 2025-10-28
|
||||
*/
|
||||
@Service
|
||||
public class EbikeSiteServiceImpl extends ServiceImpl<EbikeSiteMapper, EbikeSite> implements EbikeSiteService{
|
||||
public class EbikeSiteServiceImpl extends ServiceImpl<EbikeSiteMapper, EbikeSite> implements EbikeSiteService {
|
||||
|
||||
@Override
|
||||
public void saveSite(EbikeSiteVo ebikeSite) {
|
||||
EbikeSite site = EbikeSite.builder()
|
||||
.siteName(ebikeSite.getSiteName())
|
||||
.sitePolygon(ebikeSite.getSitePolygon())
|
||||
.operatorId(ebikeSite.getOperatorId())
|
||||
.regionId(ebikeSite.getRegionId())
|
||||
.siteType(ebikeSite.getSiteType())
|
||||
.createdBy(StpUtil.getLoginIdAsLong())
|
||||
.build();
|
||||
this.mapper.insert(site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSite(EbikeSiteVo ebikeSite) {
|
||||
Long siteId = ebikeSite.getSiteId();
|
||||
EbikeSite site = this.mapper.selectOneById(siteId);
|
||||
if (site == null) {
|
||||
throw new EbikeException("站点不存在");
|
||||
}
|
||||
site.setSiteName(ebikeSite.getSiteName());
|
||||
site.setSitePolygon(ebikeSite.getSitePolygon());
|
||||
site.setOperatorId(ebikeSite.getOperatorId());
|
||||
site.setRegionId(ebikeSite.getRegionId());
|
||||
site.setSiteType(ebikeSite.getSiteType());
|
||||
site.setUpdatedBy(StpUtil.getLoginIdAsLong());
|
||||
this.mapper.update(site);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user