|
@@ -1,14 +1,41 @@
|
|
|
package cn.seecoder.devmanage.controller;
|
|
package cn.seecoder.devmanage.controller;
|
|
|
|
|
|
|
|
|
|
+import cn.seecoder.devmanage.model.po.LocalLog;
|
|
|
|
|
+import cn.seecoder.devmanage.model.vo.LocalLogVo;
|
|
|
import cn.seecoder.devmanage.model.vo.Response;
|
|
import cn.seecoder.devmanage.model.vo.Response;
|
|
|
|
|
+import cn.seecoder.devmanage.service.HelloService;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.springframework.context.annotation.Profile;
|
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * For test purpose only.
|
|
|
|
|
+ * This controller does not go valid in production.
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
|
|
+@Profile("lyy")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@RequestMapping("/test")
|
|
|
public class HelloController {
|
|
public class HelloController {
|
|
|
|
|
+ private final HelloService helloService;
|
|
|
|
|
+
|
|
|
@GetMapping("/hello")
|
|
@GetMapping("/hello")
|
|
|
- public Response<String> hello() {
|
|
|
|
|
- return Response.buildSuccess("Hello Seecoder");
|
|
|
|
|
|
|
+ public ResponseEntity<Response<String>> hello() {
|
|
|
|
|
+ return ResponseEntity.accepted().body(Response.buildSuccess("Hello Seecoder"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/log")
|
|
|
|
|
+ public ResponseEntity<Response<LocalLogVo>> putLog(@RequestBody LocalLogVo localLogVo) {
|
|
|
|
|
+ LocalLog localLog = helloService.putLog(localLogVo);
|
|
|
|
|
+ if (localLog == null) {
|
|
|
|
|
+ return ResponseEntity.badRequest().body(
|
|
|
|
|
+ Response.buildFailure(400, "Error: invalid date format.", null)
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return ResponseEntity.accepted().body(Response.buildSuccess(new LocalLogVo(localLog)));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|