|
|
@@ -0,0 +1,44 @@
|
|
|
+package org.dromara.server.consume.controller.v2;
|
|
|
+
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.common.core.constant.ApiErrorTypeConstants;
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.domain.model.ErrorInfo;
|
|
|
+import org.dromara.common.core.domain.model.ErrorResult;
|
|
|
+import org.dromara.server.consume.business.TermBusiness;
|
|
|
+import org.dromara.server.consume.domain.vo.yc.TermToken;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping(path = { "/v2/Auth" })
|
|
|
+public class AuthControllerV2 {
|
|
|
+
|
|
|
+ private final TermBusiness termBusiness;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取设备Token
|
|
|
+ *
|
|
|
+ * @param termId 设备的机号(兼容UP)
|
|
|
+ * @return token
|
|
|
+ */
|
|
|
+ @GetMapping("/token/term/{termId}")
|
|
|
+ public Object getTermToken(@PathVariable("termId") Long termId, @RequestHeader(name = "admin") String admin,
|
|
|
+ @RequestHeader(name = "pwd") String pwd) {
|
|
|
+
|
|
|
+ R<TermToken> mapResult = termBusiness.getTermToken(termId, admin, pwd);
|
|
|
+
|
|
|
+ if (R.isError(mapResult)) {
|
|
|
+ ErrorResult result = new ErrorResult();
|
|
|
+ result.setStatusCode(HttpStatus.BAD_REQUEST.value());
|
|
|
+ result.setMessage("获取Token失败");
|
|
|
+ result.getErrors().add(new ErrorInfo(1, "获取设备Token失败", ApiErrorTypeConstants.BAD_REQUEST, mapResult.getMsg()));
|
|
|
+
|
|
|
+ return new ResponseEntity<Object>(result, null, HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+
|
|
|
+ return mapResult.getData();
|
|
|
+ }
|
|
|
+}
|