From 656d6f8029f8bf9b2daa9dcc89101a879a70b860 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 03 十二月 2025 23:10:05 +0800
Subject: [PATCH] feat:优先添加执行人
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleInfoController.java | 96 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 89 insertions(+), 7 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleInfoController.java
index b33aea0..253d262 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleInfoController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleInfoController.java
@@ -1,6 +1,8 @@
package com.ruoyi.web.controller.system;
import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -12,9 +14,11 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.VehicleInfo;
import com.ruoyi.system.service.IVehicleInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -32,7 +36,6 @@
/**
* 鏌ヨ杞﹁締淇℃伅鍒楄〃
*/
- @PreAuthorize("@ss.hasPermi('system:vehicle:list')")
@GetMapping("/list")
public TableDataInfo list(VehicleInfo vehicleInfo) {
startPage();
@@ -43,7 +46,6 @@
/**
* 瀵煎嚭杞﹁締淇℃伅鍒楄〃
*/
- @PreAuthorize("@ss.hasPermi('system:vehicle:export')")
@Log(title = "杞﹁締淇℃伅", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(VehicleInfo vehicleInfo) {
@@ -55,16 +57,14 @@
/**
* 鑾峰彇杞﹁締淇℃伅璇︾粏淇℃伅
*/
- @PreAuthorize("@ss.hasPermi('system:vehicle:query')")
@GetMapping(value = "/{vehicleId}")
public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId) {
- return success(vehicleInfoService.selectVehicleInfoById(vehicleId));
+ return success(vehicleInfoService.selectVehicleInfoWithDeptsById(vehicleId));
}
/**
* 鏂板杞﹁締淇℃伅
*/
- @PreAuthorize("@ss.hasPermi('system:vehicle:add')")
@Log(title = "杞﹁締淇℃伅", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody VehicleInfo vehicleInfo) {
@@ -74,7 +74,6 @@
/**
* 淇敼杞﹁締淇℃伅
*/
- @PreAuthorize("@ss.hasPermi('system:vehicle:edit')")
@Log(title = "杞﹁締淇℃伅", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody VehicleInfo vehicleInfo) {
@@ -84,10 +83,93 @@
/**
* 鍒犻櫎杞﹁締淇℃伅
*/
- @PreAuthorize("@ss.hasPermi('system:vehicle:remove')")
@Log(title = "杞﹁締淇℃伅", businessType = BusinessType.DELETE)
@DeleteMapping("/{vehicleIds}")
public AjaxResult remove(@PathVariable Long[] vehicleIds) {
return toAjax(vehicleInfoService.deleteVehicleInfoByIds(vehicleIds));
}
+
+ /**
+ * 缁戝畾杞﹁締鍒扮敤鎴�
+ */
+ @Anonymous
+ @Log(title = "鐢ㄦ埛缁戝畾杞﹁締", businessType = BusinessType.UPDATE)
+ @PostMapping("/bind")
+ public AjaxResult bindVehicle(@RequestBody Map<String, Object> params) {
+ try {
+ Long userId = Long.valueOf(params.get("userId").toString());
+ Long vehicleId = Long.valueOf(params.get("vehicleId").toString());
+
+ // 楠岃瘉杞﹁締鏄惁瀛樺湪
+ VehicleInfo vehicle = vehicleInfoService.selectVehicleInfoById(vehicleId);
+ if (vehicle == null) {
+ return error("杞﹁締涓嶅瓨鍦�");
+ }
+
+ // 楠岃瘉杞﹁締鐘舵�佹槸鍚︽甯�
+ if (!"0".equals(vehicle.getStatus())) {
+ return error("杞﹁締鐘舵�佸紓甯革紝鏃犳硶缁戝畾");
+ }
+
+ // 璋冪敤缁戝畾鏈嶅姟
+ int result = vehicleInfoService.bindVehicleToUser(userId, vehicleId);
+ if (result > 0) {
+ return success("杞﹁締缁戝畾鎴愬姛");
+ } else {
+ return error("杞﹁締缁戝畾澶辫触");
+ }
+ } catch (Exception e) {
+ logger.error("缁戝畾杞﹁締澶辫触", e);
+ return error("缁戝畾杞﹁締澶辫触锛�" + e.getMessage());
+ }
+ }
+
+ /**
+ * 瑙g粦鐢ㄦ埛杞﹁締
+ */
+ @Anonymous
+ @Log(title = "鐢ㄦ埛瑙g粦杞﹁締", businessType = BusinessType.UPDATE)
+ @PostMapping("/unbind")
+ public AjaxResult unbindVehicle(@RequestBody Map<String, Object> params) {
+ try {
+ Long userId = Long.valueOf(params.get("userId").toString());
+ Long vehicleId = Long.valueOf(params.get("vehicleId").toString());
+
+ // 璋冪敤瑙g粦鏈嶅姟
+ int result = vehicleInfoService.unbindVehicleFromUser(userId, vehicleId);
+ if (result > 0) {
+ return success("杞﹁締瑙g粦鎴愬姛");
+ } else {
+ return error("杞﹁締瑙g粦澶辫触");
+ }
+ } catch (Exception e) {
+ logger.error("瑙g粦杞﹁締澶辫触", e);
+ return error("瑙g粦杞﹁締澶辫触锛�" + e.getMessage());
+ }
+ }
+
+ /**
+ * 鑾峰彇鐢ㄦ埛褰撳墠缁戝畾鐨勮溅杈�
+ */
+ @Anonymous
+ @GetMapping("/user/bound/{userId}")
+ public AjaxResult getUserBoundVehicle(@PathVariable("userId") Long userId) {
+ try {
+ VehicleInfo vehicle = vehicleInfoService.getUserBoundVehicle(userId);
+ if (vehicle != null) {
+ Map<String, Object> result = new HashMap<>();
+ result.put("vehicleId", vehicle.getVehicleId());
+ result.put("vehicleNumber", vehicle.getVehicleNo());
+ result.put("vehicleType", vehicle.getVehicleType());
+ result.put("vehicleBrand", vehicle.getVehicleBrand());
+ result.put("vehicleModel", vehicle.getVehicleModel());
+ return success(result);
+ } else {
+ return success(null);
+ }
+ } catch (Exception e) {
+ logger.error("鑾峰彇鐢ㄦ埛缁戝畾杞﹁締澶辫触", e);
+ return error("鑾峰彇鐢ㄦ埛缁戝畾杞﹁締澶辫触锛�" + e.getMessage());
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1