112 lines
3.8 KiB
Java
112 lines
3.8 KiB
Java
package com.cdzy.ebikeoperate.controller;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import com.cdzy.common.model.JsonResult;
|
|
import com.cdzy.common.model.StaffDto;
|
|
import com.cdzy.ebikeoperate.model.dto.response.EbikeOrgZoneDto;
|
|
import com.cdzy.ebikeoperate.model.pojo.EbikeOrgZone;
|
|
import com.cdzy.ebikeoperate.service.EbikeOrgZoneService;
|
|
import com.ebike.feign.clients.StaffFeignClient;
|
|
import com.ebike.feign.model.rsp.StaffFeign;
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 行政区划授权信息 控制层。
|
|
*
|
|
* @author dingchao
|
|
* @since 2025-04-17
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/ebikeOrgZone")
|
|
public class EbikeOrgZoneController {
|
|
|
|
@Autowired
|
|
private EbikeOrgZoneService ebikeOrgZoneService;
|
|
@Resource
|
|
private StaffFeignClient staffFeignClient;
|
|
|
|
/**
|
|
* 添加行政区划授权信息。
|
|
*
|
|
* @param ebikeOrgZone 行政区划授权信息
|
|
* @return {@code true} 添加成功,{@code false} 添加失败
|
|
*/
|
|
@PostMapping("save")
|
|
public JsonResult<?> save(@RequestBody EbikeOrgZone ebikeOrgZone) {
|
|
boolean r = ebikeOrgZoneService.save(ebikeOrgZone);
|
|
return r ? JsonResult.success() : JsonResult.failed("添加行政区划授权信息失败");
|
|
}
|
|
|
|
/**
|
|
* 根据主键删除行政区划授权信息。
|
|
*
|
|
* @param id 主键
|
|
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
*/
|
|
@PostMapping("remove")
|
|
public JsonResult<?> remove(@RequestParam(name = "id") String id) {
|
|
boolean r = ebikeOrgZoneService.removeById(id);
|
|
return r ? JsonResult.success() : JsonResult.failed("删除行政区划授权信息失败");
|
|
}
|
|
|
|
/**
|
|
* 根据主键更新行政区划授权信息。
|
|
*
|
|
* @param ebikeOrgZone 行政区划授权信息
|
|
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
*/
|
|
@PostMapping("update")
|
|
public JsonResult<?> update(@RequestBody EbikeOrgZone ebikeOrgZone) {
|
|
boolean r = ebikeOrgZoneService.updateById(ebikeOrgZone);
|
|
return r ? JsonResult.success() : JsonResult.failed("更新行政区划授权信息失败");
|
|
}
|
|
|
|
/**
|
|
* 查询所有行政区划授权信息。
|
|
*
|
|
* @param orgId 组织id
|
|
* @param zoneId 区域id
|
|
* @return 所有数据
|
|
*/
|
|
@GetMapping("list")
|
|
public JsonResult<?> list(@RequestParam(name = "orgId", required = false) String orgId
|
|
, @RequestParam(name = "zoneId", required = false) String zoneId) {
|
|
|
|
List<EbikeOrgZoneDto> list = ebikeOrgZoneService.list(orgId, zoneId);
|
|
return list == null ? JsonResult.failed("查询行政区划授权信息失败") : JsonResult.success(list);
|
|
}
|
|
|
|
/**
|
|
* 根据行政区划授权信息主键获取详细信息。
|
|
*
|
|
* @param id 行政区划授权信息主键
|
|
* @return 行政区划授权信息详情
|
|
*/
|
|
@GetMapping("getInfo")
|
|
public JsonResult<?> getInfo(@RequestParam(name = "id") String id) {
|
|
EbikeOrgZone r = ebikeOrgZoneService.getById(id);
|
|
return r == null ? JsonResult.failed("查询行政区划授权信息失败") : JsonResult.success(r);
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询所有行政区划授权信息。
|
|
*
|
|
* @return 所有数据
|
|
*/
|
|
@GetMapping("listZoneByLogin")
|
|
public JsonResult<?> listZoneByLogin() {
|
|
|
|
String token = StpUtil.getTokenValue();
|
|
JsonResult<StaffFeign> jsonResult = staffFeignClient.getInfoByToken(token);
|
|
List<EbikeOrgZoneDto> list = ebikeOrgZoneService.list(String.valueOf(jsonResult.getData().getOrgId()), null);
|
|
return list == null ? JsonResult.failed("查询行政区划授权信息失败") : JsonResult.success(list);
|
|
}
|
|
|
|
} |