|
@@ -4,12 +4,14 @@ import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.ops.api.constants.OpsApiConstants;
|
|
|
import com.qmth.ops.api.dto.CodeNameBean;
|
|
|
+import com.qmth.ops.api.dto.EnvVO;
|
|
|
import com.qmth.ops.api.security.AdminSession;
|
|
|
import com.qmth.ops.biz.domain.Env;
|
|
|
import com.qmth.ops.biz.domain.EnvType;
|
|
|
import com.qmth.ops.biz.domain.Role;
|
|
|
import com.qmth.ops.biz.service.AppService;
|
|
|
import com.qmth.ops.biz.service.EnvService;
|
|
|
+import com.qmth.ops.biz.service.UserService;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestAttribute;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(OpsApiConstants.ADMIN_URI_PREFIX + "/env")
|
|
@@ -29,6 +32,9 @@ public class EnvController {
|
|
|
@Resource
|
|
|
private EnvService envService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
@RequestMapping("/types")
|
|
|
@Aac(auth = BOOL.FALSE)
|
|
|
public Object types() {
|
|
@@ -36,21 +42,24 @@ public class EnvController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/insert")
|
|
|
- public Env insert(@RequestAttribute AdminSession adminSession, Env env) {
|
|
|
+ public EnvVO insert(@RequestAttribute AdminSession adminSession, Env env) {
|
|
|
adminSession.validateRole(Role.ADMIN);
|
|
|
- return envService.insert(env);
|
|
|
+ env = envService.insert(env);
|
|
|
+ return new EnvVO(env, userService.getById(env.getUserId()));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
- public Env update(@RequestAttribute AdminSession adminSession, Env env) {
|
|
|
+ public EnvVO update(@RequestAttribute AdminSession adminSession, Env env) {
|
|
|
adminSession.validateRole(Role.ADMIN);
|
|
|
- return envService.update(env);
|
|
|
+ env = envService.update(env);
|
|
|
+ return new EnvVO(env, userService.getById(env.getUserId()));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
- public List<Env> list(@RequestAttribute AdminSession adminSession, Long appId) {
|
|
|
+ public List<EnvVO> list(@RequestAttribute AdminSession adminSession, Long appId) {
|
|
|
adminSession.validateApp(appService.getById(appId));
|
|
|
- return envService.list(appId);
|
|
|
+ return envService.list(appId).stream().map(env -> new EnvVO(env, userService.getById(env.getUserId())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
}
|