Bläddra i källkod

更新接口调整

fangq 4 år sedan
förälder
incheckning
a4cd561b9e
1 ändrade filer med 36 tillägg och 10 borttagningar
  1. 36 10
      src/main/java/org/springblade/ship/open/OpenController.java

+ 36 - 10
src/main/java/org/springblade/ship/open/OpenController.java

@@ -17,30 +17,29 @@
 package org.springblade.ship.open;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
 import org.springblade.core.boot.ctrl.BladeController;
-import org.springblade.core.mp.support.Condition;
-import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.system.entity.Dict;
 import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IDictService;
 import org.springblade.modules.system.service.IUserService;
 import org.springblade.ship.cable.entity.Cable;
 import org.springblade.ship.cable.service.ICableService;
 import org.springblade.ship.device.entity.Device;
 import org.springblade.ship.device.service.IDeviceService;
-import org.springblade.ship.device.vo.DeviceVO;
-import org.springblade.ship.device.wrapper.DeviceWrapper;
 import org.springframework.util.Assert;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
-import javax.validation.Valid;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -60,6 +59,7 @@ public class OpenController extends BladeController {
 	private final IDeviceService deviceService;
 	private final IUserService userService;
 	private final ICableService cableService;
+	private final IDictService dictService;
 
 	/**
 	 * 设备更新信息(用户、电缆、设备)
@@ -94,14 +94,40 @@ public class OpenController extends BladeController {
 	@GetMapping("/device/updateTime")
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "详情", notes = "传入device")
-	public R updateTime(@RequestParam String deviceCode) {
+	public R updateTime(@RequestParam String deviceCode, Boolean reset) {
 		Device device = deviceService.getOne(new QueryWrapper<>(new Device()).lambda().eq(Device::getCode, deviceCode));
 		Assert.notNull(device, "系统找不到编码为【" + deviceCode + "】的设备!");
-		device.setLastUpdateTime(DateUtil.now());
+
+		if (reset != null && reset){
+			device.setLastUpdateTime(DateUtil.parse("2020-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss"));
+		}else{
+			device.setLastUpdateTime(DateUtil.now());
+		}
+
 		return R.status(deviceService.updateById(device));
 	}
 
+	/**
+	 * 获取字典
+	 */
+	@GetMapping("/system/dictionary")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "获取字典", notes = "获取字典")
+	public R dictionary(@RequestParam String codes) {
+		List<Map<String, Object>> list = new ArrayList<>();
+		List<String> codeList = Func.toStrList(codes);
+		codeList.forEach(code -> {
+			List<Dict> tree = dictService.getList(code);
+			if (tree != null && tree.size() > 0){
+				Map<String, Object> map = new HashMap<>();
+				map.put(code, tree);
+				list.add(map);
+			}
+
+		});
 
+		return R.data(list);
+	}