结构调整
这个提交包含在:
父节点
af78e676b7
当前提交
95a4bf8b4e
@ -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.CommonHelper;
|
||||||
import com.xuqm.server.appmanager.common.JWTHelper;
|
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.UserInfo;
|
||||||
import com.xuqm.server.appmanager.entitys.sys.v1.ApplicationEntity;
|
import com.xuqm.server.appmanager.entitys.sys.v1.ApplicationEntity;
|
||||||
import com.xuqm.server.appmanager.http.HttpResult;
|
import com.xuqm.server.appmanager.http.HttpResult;
|
||||||
import com.xuqm.server.appmanager.repository.sys.v1.ApplicationRepository;
|
import com.xuqm.server.appmanager.repository.sys.v1.ApplicationRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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 org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("manager/v1")
|
@RequestMapping("manager/v1")
|
||||||
public class ManagerV1Controller {
|
public class ManagerV1Controller {
|
||||||
@ -22,13 +21,13 @@ public class ManagerV1Controller {
|
|||||||
|
|
||||||
@PostMapping("/manager/create")
|
@PostMapping("/manager/create")
|
||||||
public HttpResult<String> appCreate(@RequestBody ApplicationEntity application, @RequestHeader(name = "token") String token) throws Exception {
|
public HttpResult<String> appCreate(@RequestBody ApplicationEntity application, @RequestHeader(name = "token") String token) throws Exception {
|
||||||
if (null == application.getAppName() || null == application.getPackageName()) {
|
|
||||||
return new HttpResult<>(201, "参数错误", null);
|
|
||||||
} else {
|
|
||||||
UserInfo userInfo = JWTHelper.getUser(token);
|
UserInfo userInfo = JWTHelper.getUser(token);
|
||||||
if (null == userInfo) {
|
if (null == userInfo) {
|
||||||
return new HttpResult<>(401, "登录失效", null);
|
return new HttpResult<>(401, "登录失效", null);
|
||||||
}
|
}
|
||||||
|
if (null == application.getAppName() || null == application.getPackageName()) {
|
||||||
|
return new HttpResult<>(201, "参数错误", null);
|
||||||
|
} else {
|
||||||
ApplicationEntity app = applicationRepository.findFirstByAppNameAndTenantNo(application.getAppName(), userInfo.getTenantNo());
|
ApplicationEntity app = applicationRepository.findFirstByAppNameAndTenantNo(application.getAppName(), userInfo.getTenantNo());
|
||||||
if (null != app) return new HttpResult<>(201, "已创建相关类型的同名应用", null);
|
if (null != app) return new HttpResult<>(201, "已创建相关类型的同名应用", null);
|
||||||
app = new ApplicationEntity();
|
app = new ApplicationEntity();
|
||||||
@ -45,15 +44,17 @@ public class ManagerV1Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/manager/list")
|
@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);
|
UserInfo userInfo = JWTHelper.getUser(token);
|
||||||
if (null == userInfo) {
|
if (null == userInfo) {
|
||||||
return new HttpResult<>(401, "登录失效", null);
|
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);
|
return new HttpResult<>(200, "成功", apps);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.xuqm.server.appmanager.controller.manager.v1.data;
|
||||||
|
|
||||||
|
import com.xuqm.server.appmanager.data.PageData;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ManagerListData extends PageData {
|
||||||
|
}
|
||||||
@ -4,8 +4,6 @@ import com.xuqm.server.appmanager.common.JWTHelper;
|
|||||||
import com.xuqm.server.appmanager.entitys.UserLogin;
|
import com.xuqm.server.appmanager.entitys.UserLogin;
|
||||||
import com.xuqm.server.appmanager.entitys.sys.v1.TenantUserEntity;
|
import com.xuqm.server.appmanager.entitys.sys.v1.TenantUserEntity;
|
||||||
import com.xuqm.server.appmanager.http.HttpResult;
|
import com.xuqm.server.appmanager.http.HttpResult;
|
||||||
import com.xuqm.server.appmanager.repository.sys.v1.ApplicationRepository;
|
|
||||||
import com.xuqm.server.appmanager.repository.sys.v1.TenantRepository;
|
|
||||||
import com.xuqm.server.appmanager.repository.sys.v1.TenantUserRepository;
|
import com.xuqm.server.appmanager.repository.sys.v1.TenantUserRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -17,12 +15,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequestMapping("user/v1")
|
@RequestMapping("user/v1")
|
||||||
public class UserV1Controller {
|
public class UserV1Controller {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TenantRepository tenantRepository;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantUserRepository tenantUserRepository;
|
private TenantUserRepository tenantUserRepository;
|
||||||
@Autowired
|
|
||||||
private ApplicationRepository applicationRepository;
|
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public HttpResult<String> userLogin(@RequestBody UserLogin user) throws Exception {
|
public HttpResult<String> userLogin(@RequestBody UserLogin user) throws Exception {
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.xuqm.server.appmanager.data;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PageData {
|
||||||
|
private int pageNumber;
|
||||||
|
private int pageSize;
|
||||||
|
}
|
||||||
@ -1,7 +1,8 @@
|
|||||||
package com.xuqm.server.appmanager.repository.sys.v1;
|
package com.xuqm.server.appmanager.repository.sys.v1;
|
||||||
|
|
||||||
import com.xuqm.server.appmanager.entitys.sys.v1.ApplicationEntity;
|
import com.xuqm.server.appmanager.entitys.sys.v1.ApplicationEntity;
|
||||||
import com.xuqm.server.appmanager.enums.AppType;
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@ -10,6 +11,10 @@ import java.util.List;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface ApplicationRepository extends JpaRepository<ApplicationEntity, Long> {
|
public interface ApplicationRepository extends JpaRepository<ApplicationEntity, Long> {
|
||||||
ApplicationEntity findFirstByAppNameAndTenantNo(String appName, String tenantNo);
|
ApplicationEntity findFirstByAppNameAndTenantNo(String appName, String tenantNo);
|
||||||
List<ApplicationEntity> findAllByTenantNo(String tenantNo);
|
|
||||||
|
ApplicationEntity findFirstByTenantNoAndPackageNameOrAppName(String tenantNo, String packageName, String appName);
|
||||||
|
|
||||||
|
Page<ApplicationEntity> findAllByTenantNo(String tenantNo, Pageable pageable);
|
||||||
|
|
||||||
boolean existsByAppId(String appId);
|
boolean existsByAppId(String appId);
|
||||||
}
|
}
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户