|
|
@@ -2,7 +2,7 @@ package com.haha.admin.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.haha.admin.annotation.RequirePermission;
|
|
|
-import com.haha.admin.dto.ShopQueryDTO;
|
|
|
+import com.haha.entity.dto.*;
|
|
|
import com.haha.common.annotation.Log;
|
|
|
import com.haha.common.constant.ResponseEnum;
|
|
|
import com.haha.common.enums.OperationType;
|
|
|
@@ -148,15 +148,14 @@ public class ShopController {
|
|
|
/**
|
|
|
* 切换门店状态
|
|
|
* @param id 门店ID
|
|
|
- * @param params 状态参数
|
|
|
+ * @param dto 状态参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.UPDATE, summary = "切换门店状态")
|
|
|
@PutMapping("/{id}/status")
|
|
|
- public Result<String> toggleStatus(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- Integer status = Integer.valueOf(params.get("status").toString());
|
|
|
- boolean result = shopService.toggleStatus(id, status);
|
|
|
+ public Result<String> toggleStatus(@PathVariable Long id, @RequestBody StatusDTO dto) {
|
|
|
+ boolean result = shopService.toggleStatus(id, dto.getStatus());
|
|
|
|
|
|
if (result) {
|
|
|
return Result.success("状态更新成功");
|
|
|
@@ -180,15 +179,14 @@ public class ShopController {
|
|
|
/**
|
|
|
* 将设备关联到门店
|
|
|
* @param id 门店ID
|
|
|
- * @param params 设备ID参数
|
|
|
+ * @param dto 设备ID参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.UPDATE, summary = "关联设备到门店")
|
|
|
@PostMapping("/{id}/devices")
|
|
|
- public Result<String> linkDevice(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- Long deviceId = Long.valueOf(params.get("deviceId").toString());
|
|
|
- boolean result = shopService.linkDevice(id, deviceId);
|
|
|
+ public Result<String> linkDevice(@PathVariable Long id, @RequestBody LinkDeviceDTO dto) {
|
|
|
+ boolean result = shopService.linkDevice(id, dto.getDeviceId());
|
|
|
if (result) {
|
|
|
return Result.success("关联成功");
|
|
|
} else {
|
|
|
@@ -199,24 +197,18 @@ public class ShopController {
|
|
|
/**
|
|
|
* 批量将设备关联到门店
|
|
|
* @param id 门店ID
|
|
|
- * @param params 设备ID列表参数
|
|
|
+ * @param dto 设备ID列表参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.UPDATE, summary = "批量关联设备到门店")
|
|
|
@PostMapping("/{id}/devices/batch")
|
|
|
- public Result<Map<String, Object>> batchLinkDevices(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Integer> deviceIdInts = (List<Integer>) params.get("deviceIds");
|
|
|
- List<Long> deviceIds = deviceIdInts.stream()
|
|
|
- .map(Integer::longValue)
|
|
|
- .toList();
|
|
|
-
|
|
|
- int count = shopService.batchLinkDevices(id, deviceIds);
|
|
|
+ public Result<Map<String, Object>> batchLinkDevices(@PathVariable Long id, @RequestBody BatchIdsDTO dto) {
|
|
|
+ int count = shopService.batchLinkDevices(id, dto.getIds());
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("success", count);
|
|
|
- result.put("total", deviceIds.size());
|
|
|
+ result.put("total", dto.getIds().size());
|
|
|
|
|
|
return Result.success("批量关联完成", result);
|
|
|
}
|
|
|
@@ -242,24 +234,18 @@ public class ShopController {
|
|
|
/**
|
|
|
* 批量移除设备关联
|
|
|
* @param id 门店ID
|
|
|
- * @param params 设备ID列表参数
|
|
|
+ * @param dto 设备ID列表参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.UPDATE, summary = "批量移除设备关联")
|
|
|
@DeleteMapping("/{id}/devices/batch")
|
|
|
- public Result<Map<String, Object>> batchUnlinkDevices(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Integer> deviceIdInts = (List<Integer>) params.get("deviceIds");
|
|
|
- List<Long> deviceIds = deviceIdInts.stream()
|
|
|
- .map(Integer::longValue)
|
|
|
- .toList();
|
|
|
-
|
|
|
- int count = shopService.batchUnlinkDevices(id, deviceIds);
|
|
|
+ public Result<Map<String, Object>> batchUnlinkDevices(@PathVariable Long id, @RequestBody BatchIdsDTO dto) {
|
|
|
+ int count = shopService.batchUnlinkDevices(id, dto.getIds());
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("success", count);
|
|
|
- result.put("total", deviceIds.size());
|
|
|
+ result.put("total", dto.getIds().size());
|
|
|
|
|
|
return Result.success("批量移除完成", result);
|
|
|
}
|
|
|
@@ -292,38 +278,31 @@ public class ShopController {
|
|
|
/**
|
|
|
* 添加补货员
|
|
|
* @param id 门店ID
|
|
|
- * @param params 管理员ID参数
|
|
|
+ * @param dto 管理员ID参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.INSERT, summary = "添加门店补货员")
|
|
|
@PostMapping("/{id}/replenishers")
|
|
|
- public Result<Void> addReplenisher(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- Long adminId = Long.valueOf(params.get("adminId").toString());
|
|
|
- return shopReplenisherService.addReplenisher(id, adminId);
|
|
|
+ public Result<Void> addReplenisher(@PathVariable Long id, @RequestBody AddReplenisherDTO dto) {
|
|
|
+ return shopReplenisherService.addReplenisher(id, dto.getAdminId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量添加补货员
|
|
|
* @param id 门店ID
|
|
|
- * @param params 管理员ID列表参数
|
|
|
+ * @param dto 管理员ID列表参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.INSERT, summary = "批量添加门店补货员")
|
|
|
@PostMapping("/{id}/replenishers/batch")
|
|
|
- public Result<Map<String, Object>> batchAddReplenishers(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Integer> adminIdInts = (List<Integer>) params.get("adminIds");
|
|
|
- List<Long> adminIds = adminIdInts.stream()
|
|
|
- .map(Integer::longValue)
|
|
|
- .toList();
|
|
|
-
|
|
|
- int count = shopReplenisherService.batchAddReplenishers(id, adminIds);
|
|
|
+ public Result<Map<String, Object>> batchAddReplenishers(@PathVariable Long id, @RequestBody BatchIdsDTO dto) {
|
|
|
+ int count = shopReplenisherService.batchAddReplenishers(id, dto.getIds());
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("success", count);
|
|
|
- result.put("total", adminIds.size());
|
|
|
+ result.put("total", dto.getIds().size());
|
|
|
|
|
|
return Result.success("批量添加完成", result);
|
|
|
}
|
|
|
@@ -344,24 +323,18 @@ public class ShopController {
|
|
|
/**
|
|
|
* 批量移除补货员
|
|
|
* @param id 门店ID
|
|
|
- * @param params 管理员ID列表参数
|
|
|
+ * @param dto 管理员ID列表参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.DELETE, summary = "批量移除门店补货员")
|
|
|
@DeleteMapping("/{id}/replenishers/batch")
|
|
|
- public Result<Map<String, Object>> batchRemoveReplenishers(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Integer> adminIdInts = (List<Integer>) params.get("adminIds");
|
|
|
- List<Long> adminIds = adminIdInts.stream()
|
|
|
- .map(Integer::longValue)
|
|
|
- .toList();
|
|
|
-
|
|
|
- int count = shopReplenisherService.batchRemoveReplenishers(id, adminIds);
|
|
|
+ public Result<Map<String, Object>> batchRemoveReplenishers(@PathVariable Long id, @RequestBody BatchIdsDTO dto) {
|
|
|
+ int count = shopReplenisherService.batchRemoveReplenishers(id, dto.getIds());
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("success", count);
|
|
|
- result.put("total", adminIds.size());
|
|
|
+ result.put("total", dto.getIds().size());
|
|
|
|
|
|
return Result.success("批量移除完成", result);
|
|
|
}
|
|
|
@@ -369,15 +342,14 @@ public class ShopController {
|
|
|
/**
|
|
|
* 更新补货员状态
|
|
|
* @param id 补货员关联ID
|
|
|
- * @param params 状态参数
|
|
|
+ * @param dto 状态参数
|
|
|
* @return 操作结果
|
|
|
*/
|
|
|
@RequirePermission("shop:update")
|
|
|
@Log(module = "门店管理", operation = OperationType.UPDATE, summary = "更新补货员状态")
|
|
|
@PutMapping("/replenishers/{id}/status")
|
|
|
- public Result<Void> updateReplenisherStatus(@PathVariable Long id, @RequestBody Map<String, Object> params) {
|
|
|
- Integer status = Integer.valueOf(params.get("status").toString());
|
|
|
- return shopReplenisherService.updateStatus(id, status);
|
|
|
+ public Result<Void> updateReplenisherStatus(@PathVariable Long id, @RequestBody StatusDTO dto) {
|
|
|
+ return shopReplenisherService.updateStatus(id, dto.getStatus());
|
|
|
}
|
|
|
|
|
|
/**
|