1. 新增SysOrgService业务数据隔离工具方法(applyBusinessOrgScope/getUserOrgMpath) 2. 10个Controller接入组织数据隔离(设备/订单/退款/统计/定价/支付配置/激活码/用户) 3. 统一响应结构:写操作从R.ok()改为R.dataSuccess(data) 4. 修复5处data.data双层嵌套 5. 修复SysUserController.info()不一致 6. 修复循环依赖(@Lazy) 7. 新增交接文档HANDOVER.md
121 lines
3.6 KiB
Java
121 lines
3.6 KiB
Java
package io.as.modules.device.controller;
|
|
|
|
import io.as.common.annotation.AuditAction;
|
|
import io.as.common.utils.PageUtils;
|
|
import io.as.common.utils.R;
|
|
import io.as.modules.device.entity.DeviceEntity;
|
|
import io.as.modules.device.service.DeviceService;
|
|
import io.as.modules.sys.controller.AbstractController;
|
|
import io.as.modules.sys.service.SysOrgService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 终端管理
|
|
*/
|
|
@Api(tags = "终端管理")
|
|
@RestController
|
|
@RequestMapping("/manage/device")
|
|
public class DeviceController extends AbstractController {
|
|
|
|
@Autowired
|
|
private DeviceService deviceService;
|
|
|
|
@Autowired
|
|
private SysOrgService sysOrgService;
|
|
|
|
/**
|
|
* 分页查询设备列表
|
|
*/
|
|
@ApiOperation("分页查询设备列表")
|
|
@GetMapping("/list")
|
|
public R list(@RequestParam Map<String, Object> params) {
|
|
PageUtils page = deviceService.queryPage(params, getUserId());
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("page", page);
|
|
return R.dataSuccess(data);
|
|
}
|
|
|
|
/**
|
|
* 设备详情
|
|
*/
|
|
@ApiOperation("设备详情")
|
|
@GetMapping("/info/{id}")
|
|
public R info(@PathVariable("id") Long id) {
|
|
DeviceEntity device = deviceService.getById(id);
|
|
if (device != null && !sysOrgService.isOrgInScope(device.getStoreOrgId(), getUserId())) {
|
|
return R.error(403, "无权限查看该设备");
|
|
}
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("device", device);
|
|
return R.dataSuccess(data);
|
|
}
|
|
|
|
/**
|
|
* 新增设备
|
|
*/
|
|
@ApiOperation("新增设备")
|
|
@AuditAction(value = "DEVICE_SAVE", description = "新增设备")
|
|
@PostMapping("/save")
|
|
public R save(@RequestBody DeviceEntity device) {
|
|
if (device.getStoreOrgId() != null && !sysOrgService.isOrgInScope(device.getStoreOrgId(), getUserId())) {
|
|
return R.error(403, "无权限操作该门店");
|
|
}
|
|
deviceService.saveDevice(device);
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("id", device.getId());
|
|
return R.dataSuccess(data);
|
|
}
|
|
|
|
/**
|
|
* 修改设备
|
|
*/
|
|
@ApiOperation("修改设备")
|
|
@AuditAction(value = "DEVICE_UPDATE", description = "修改设备")
|
|
@PostMapping("/update")
|
|
public R update(@RequestBody DeviceEntity device) {
|
|
DeviceEntity existing = deviceService.getById(device.getId());
|
|
if (existing != null && !sysOrgService.isOrgInScope(existing.getStoreOrgId(), getUserId())) {
|
|
return R.error(403, "无权限操作该设备");
|
|
}
|
|
deviceService.updateDevice(device);
|
|
return R.dataSuccess(new HashMap<>());
|
|
}
|
|
|
|
/**
|
|
* 删除设备(软删除)
|
|
*/
|
|
@ApiOperation("删除设备")
|
|
@AuditAction(value = "DEVICE_DELETE", description = "删除设备")
|
|
@PostMapping("/delete")
|
|
public R delete(@RequestBody Long[] ids) {
|
|
for (Long id : ids) {
|
|
DeviceEntity device = deviceService.getById(id);
|
|
if (device != null && !sysOrgService.isOrgInScope(device.getStoreOrgId(), getUserId())) {
|
|
return R.error(403, "无权限删除该设备");
|
|
}
|
|
}
|
|
deviceService.delete(ids);
|
|
return R.dataSuccess(new HashMap<>());
|
|
}
|
|
|
|
/**
|
|
* 绑定门店
|
|
*/
|
|
@ApiOperation("绑定门店")
|
|
@AuditAction(value = "DEVICE_BIND_STORE", description = "设备绑定门店")
|
|
@PostMapping("/bindStore")
|
|
public R bindStore(@RequestParam("deviceId") Long deviceId, @RequestParam("storeOrgId") Long storeOrgId) {
|
|
if (!sysOrgService.isOrgInScope(storeOrgId, getUserId())) {
|
|
return R.error(403, "无权限绑定到此门店");
|
|
}
|
|
deviceService.bindStore(deviceId, storeOrgId);
|
|
return R.dataSuccess(new HashMap<>());
|
|
}
|
|
}
|