|
@@ -2,17 +2,16 @@ package com.xuqm.server.appmanager.controller.manager.v1;
|
|
|
|
|
|
import com.xuqm.server.appmanager.common.CommonHelper;
|
|
|
import com.xuqm.server.appmanager.common.JWTHelper;
|
|
|
-import com.xuqm.server.appmanager.common.TimeHelper;
|
|
|
+import com.xuqm.server.appmanager.controller.manager.v1.data.ManagerListData;
|
|
|
import com.xuqm.server.appmanager.entitys.UserInfo;
|
|
|
import com.xuqm.server.appmanager.entitys.sys.v1.ApplicationEntity;
|
|
|
import com.xuqm.server.appmanager.http.HttpResult;
|
|
|
import com.xuqm.server.appmanager.repository.sys.v1.ApplicationRepository;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Random;
|
|
|
-
|
|
|
@RestController
|
|
|
@RequestMapping("manager/v1")
|
|
|
public class ManagerV1Controller {
|
|
@@ -22,13 +21,13 @@ public class ManagerV1Controller {
|
|
|
|
|
|
@PostMapping("/manager/create")
|
|
|
public HttpResult<String> appCreate(@RequestBody ApplicationEntity application, @RequestHeader(name = "token") String token) throws Exception {
|
|
|
+ UserInfo userInfo = JWTHelper.getUser(token);
|
|
|
+ if (null == userInfo) {
|
|
|
+ return new HttpResult<>(401, "登录失效", null);
|
|
|
+ }
|
|
|
if (null == application.getAppName() || null == application.getPackageName()) {
|
|
|
return new HttpResult<>(201, "参数错误", null);
|
|
|
} else {
|
|
|
- UserInfo userInfo = JWTHelper.getUser(token);
|
|
|
- if (null == userInfo) {
|
|
|
- return new HttpResult<>(401, "登录失效", null);
|
|
|
- }
|
|
|
ApplicationEntity app = applicationRepository.findFirstByAppNameAndTenantNo(application.getAppName(), userInfo.getTenantNo());
|
|
|
if (null != app) return new HttpResult<>(201, "已创建相关类型的同名应用", null);
|
|
|
app = new ApplicationEntity();
|
|
@@ -45,15 +44,17 @@ public class ManagerV1Controller {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/manager/list")
|
|
|
- public HttpResult<List<ApplicationEntity>> appList(@RequestBody ApplicationEntity application, @RequestHeader(name = "token") String token) throws Exception {
|
|
|
+ public HttpResult<Page<ApplicationEntity>> appList(@RequestBody ManagerListData data, @RequestHeader(name = "token") String token) throws Exception {
|
|
|
|
|
|
UserInfo userInfo = JWTHelper.getUser(token);
|
|
|
if (null == userInfo) {
|
|
|
return new HttpResult<>(401, "登录失效", null);
|
|
|
}
|
|
|
+ if (data.getPageNumber() < 0) return new HttpResult<>(201, "参数错误", null);
|
|
|
+ if (data.getPageSize() < 0) return new HttpResult<>(201, "参数错误", null);
|
|
|
|
|
|
|
|
|
- List<ApplicationEntity> apps = applicationRepository.findAllByTenantNo(userInfo.getTenantNo());
|
|
|
+ Page<ApplicationEntity> apps = applicationRepository.findAllByTenantNo(userInfo.getTenantNo(), PageRequest.of(data.getPageNumber(), data.getPageSize()));
|
|
|
|
|
|
return new HttpResult<>(200, "成功", apps);
|
|
|
}
|