完善行政区划授权信息 控制层实现,统一返回结果JsonResult,list增加过滤条件,返回结果增加行政区划名称
This commit is contained in:
parent
8eb41fce08
commit
aab6980e2f
@ -1,6 +1,8 @@
|
|||||||
package com.cdzy.ebikeoperate.controller;
|
package com.cdzy.ebikeoperate.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cdzy.common.model.JsonResult;
|
||||||
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeOrgZoneDto;
|
||||||
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
||||||
import com.cdzy.ebikeoperate.service.EbikeOrgZoneService;
|
import com.cdzy.ebikeoperate.service.EbikeOrgZoneService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -28,8 +30,9 @@ public class EbikeOrgZoneController {
|
|||||||
* @return {@code true} 添加成功,{@code false} 添加失败
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
||||||
*/
|
*/
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
public boolean save(@RequestBody EbikeOrgZone ebikeOrgZone) {
|
public JsonResult<?> save(@RequestBody EbikeOrgZone ebikeOrgZone) {
|
||||||
return ebikeOrgZoneService.save(ebikeOrgZone);
|
boolean r = ebikeOrgZoneService.save(ebikeOrgZone);
|
||||||
|
return r? JsonResult.success() : JsonResult.failed("添加行政区划授权信息失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,8 +42,9 @@ public class EbikeOrgZoneController {
|
|||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||||
*/
|
*/
|
||||||
@PostMapping("remove")
|
@PostMapping("remove")
|
||||||
public boolean remove(@RequestParam(name = "id") String id) {
|
public JsonResult<?> remove(@RequestParam(name = "id") String id) {
|
||||||
return ebikeOrgZoneService.removeById(id);
|
boolean r = ebikeOrgZoneService.removeById(id);
|
||||||
|
return r? JsonResult.success() : JsonResult.failed("删除行政区划授权信息失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,18 +54,24 @@ public class EbikeOrgZoneController {
|
|||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
||||||
*/
|
*/
|
||||||
@PostMapping("update")
|
@PostMapping("update")
|
||||||
public boolean update(@RequestBody EbikeOrgZone ebikeOrgZone) {
|
public JsonResult<?> update(@RequestBody EbikeOrgZone ebikeOrgZone) {
|
||||||
return ebikeOrgZoneService.updateById(ebikeOrgZone);
|
boolean r = ebikeOrgZoneService.updateById(ebikeOrgZone);
|
||||||
|
return r? JsonResult.success() : JsonResult.failed("更新行政区划授权信息失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有行政区划授权信息。
|
* 查询所有行政区划授权信息。
|
||||||
*
|
*
|
||||||
|
* @param orgId 组织id
|
||||||
|
* @param zoneId 区域id
|
||||||
* @return 所有数据
|
* @return 所有数据
|
||||||
*/
|
*/
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
public List<EbikeOrgZone> list() {
|
public JsonResult<?> list(@RequestParam(name = "orgId", required = false) String orgId
|
||||||
return ebikeOrgZoneService.list();
|
, @RequestParam(name = "zoneId", required = false) String zoneId) {
|
||||||
|
|
||||||
|
List<EbikeOrgZoneDto> list = ebikeOrgZoneService.list(orgId, zoneId);
|
||||||
|
return list==null? JsonResult.failed("查询行政区划授权信息失败") : JsonResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,8 +81,9 @@ public class EbikeOrgZoneController {
|
|||||||
* @return 行政区划授权信息详情
|
* @return 行政区划授权信息详情
|
||||||
*/
|
*/
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public EbikeOrgZone getInfo(@RequestParam(name = "id") String id) {
|
public JsonResult<?> getInfo(@RequestParam(name = "id") String id) {
|
||||||
return ebikeOrgZoneService.getById(id);
|
EbikeOrgZone r = ebikeOrgZoneService.getById(id);
|
||||||
|
return r==null? JsonResult.failed("查询行政区划授权信息失败") : JsonResult.success(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public class EbikeSysExchangePeriodController {
|
|||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
||||||
*/
|
*/
|
||||||
@PostMapping("remove")
|
@PostMapping("remove")
|
||||||
public JsonResult<?> remove(@PathVariable("id") String id) {
|
public JsonResult<?> remove(@RequestParam(name = "id") String id) {
|
||||||
boolean r = ebikeSysExchangePeriodService.removeById(id);
|
boolean r = ebikeSysExchangePeriodService.removeById(id);
|
||||||
return r? JsonResult.success() : JsonResult.failed("删除区域分时间段换电失败");
|
return r? JsonResult.success() : JsonResult.failed("删除区域分时间段换电失败");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.cdzy.ebikeoperate.model.dto.response;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划授权信息 实体类。
|
||||||
|
*
|
||||||
|
* @author dingchao
|
||||||
|
* @since 2025-04-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EbikeOrgZoneDto implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织ID
|
||||||
|
*/
|
||||||
|
private String orgId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划ID
|
||||||
|
*/
|
||||||
|
private String zoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权人
|
||||||
|
*/
|
||||||
|
private String staffId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime assignedTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行政区划名称
|
||||||
|
*/
|
||||||
|
private String zoneName;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,8 +1,11 @@
|
|||||||
package com.cdzy.ebikeoperate.service;
|
package com.cdzy.ebikeoperate.service;
|
||||||
|
|
||||||
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeOrgZoneDto;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行政区划授权信息 服务层。
|
* 行政区划授权信息 服务层。
|
||||||
*
|
*
|
||||||
@ -10,5 +13,12 @@ import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
|||||||
* @since 2025-04-17
|
* @since 2025-04-17
|
||||||
*/
|
*/
|
||||||
public interface EbikeOrgZoneService extends IService<EbikeOrgZone> {
|
public interface EbikeOrgZoneService extends IService<EbikeOrgZone> {
|
||||||
|
/**
|
||||||
|
* 查询所有行政区划授权信息。
|
||||||
|
*
|
||||||
|
* @param orgId 组织id
|
||||||
|
* @param zoneId 区域id
|
||||||
|
* @return 所有数据
|
||||||
|
*/
|
||||||
|
List<EbikeOrgZoneDto> list(String orgId, String zoneId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,20 @@ package com.cdzy.ebikeoperate.service.impl;
|
|||||||
|
|
||||||
import com.cdzy.ebikeoperate.mapper.EbikeOperateAttachmentFileMapper;
|
import com.cdzy.ebikeoperate.mapper.EbikeOperateAttachmentFileMapper;
|
||||||
import com.cdzy.ebikeoperate.mapper.EbikeOrgZoneMapper;
|
import com.cdzy.ebikeoperate.mapper.EbikeOrgZoneMapper;
|
||||||
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeOrgZoneDto;
|
||||||
import com.cdzy.ebikeoperate.model.pojo.EbikeOperateAttachmentFile;
|
import com.cdzy.ebikeoperate.model.pojo.EbikeOperateAttachmentFile;
|
||||||
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
||||||
import com.cdzy.ebikeoperate.service.EbikeOperateAttachmentFileService;
|
import com.cdzy.ebikeoperate.service.EbikeOperateAttachmentFileService;
|
||||||
import com.cdzy.ebikeoperate.service.EbikeOrgZoneService;
|
import com.cdzy.ebikeoperate.service.EbikeOrgZoneService;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.cdzy.ebikeoperate.model.pojo.table.EbikeAdministrationZoneTableDef.EBIKE_ADMINISTRATION_ZONE;
|
||||||
|
import static com.cdzy.ebikeoperate.model.pojo.table.EbikeOrgZoneTableDef.EBIKE_ORG_ZONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行政区划授权信息 服务层实现。
|
* 行政区划授权信息 服务层实现。
|
||||||
*
|
*
|
||||||
@ -19,4 +26,18 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class EbikeOrgZoneServiceImpl extends ServiceImpl<EbikeOrgZoneMapper, EbikeOrgZone> implements EbikeOrgZoneService {
|
public class EbikeOrgZoneServiceImpl extends ServiceImpl<EbikeOrgZoneMapper, EbikeOrgZone> implements EbikeOrgZoneService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EbikeOrgZoneDto> list(String orgId, String zoneId) {
|
||||||
|
QueryWrapper query = QueryWrapper.create()
|
||||||
|
.select(EBIKE_ORG_ZONE.ALL_COLUMNS)
|
||||||
|
.select(EBIKE_ADMINISTRATION_ZONE.FULLNAME.as("zoneName"))
|
||||||
|
.leftJoin(EBIKE_ADMINISTRATION_ZONE).on(EBIKE_ADMINISTRATION_ZONE.ID.eq(EBIKE_ORG_ZONE.ZONE_ID));
|
||||||
|
if (orgId != null&& !orgId.isEmpty()) {
|
||||||
|
query.and(EBIKE_ORG_ZONE.ORG_ID.eq(orgId));
|
||||||
|
}
|
||||||
|
if (zoneId!= null&&!zoneId.isEmpty()) {
|
||||||
|
query.and(EBIKE_ORG_ZONE.ZONE_ID.eq(zoneId));
|
||||||
|
}
|
||||||
|
return this.listAs(query, EbikeOrgZoneDto.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user