feat: [manager]feature:App/Account Controller compatible with Chinese and English #wqh (#90)
This commit is contained in:
@@ -29,17 +29,20 @@ import static com.usthe.common.util.CommonConstants.MONITOR_LOGIN_FAILED_CODE;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Authentication registration TOKEN management API
|
||||
* 认证注册TOKEN管理API
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 13:11 2019-05-26
|
||||
*/
|
||||
@Api(tags = "认证注册TOKEN管理API")
|
||||
@Api(tags = "en: Authentication registration TOKEN management API,zh: 认证注册TOKEN管理API")
|
||||
@RestController()
|
||||
@RequestMapping(value = "/account/auth", produces = {APPLICATION_JSON_VALUE})
|
||||
@Slf4j
|
||||
public class AccountController {
|
||||
|
||||
/**
|
||||
* Token validity time in seconds
|
||||
* TOKEN有效期时间 单位秒
|
||||
*/
|
||||
private static final long PERIOD_TIME = 3600L;
|
||||
@@ -50,7 +53,7 @@ public class AccountController {
|
||||
private SurenessAccountProvider accountProvider = new DocumentAccountProvider();
|
||||
|
||||
@PostMapping("/form")
|
||||
@ApiOperation(value = "账户登录", notes = "账户密码登录获取关联用户信息")
|
||||
@ApiOperation(value = "Account password login to obtain associated user information", notes = "账户密码登录获取关联用户信息")
|
||||
public ResponseEntity<Message<Map<String, String>>> authGetToken(@RequestBody LoginDto loginDto) {
|
||||
|
||||
SurenessAccount account = accountProvider.loadAccount(loginDto.getIdentifier());
|
||||
@@ -76,7 +79,7 @@ public class AccountController {
|
||||
}
|
||||
// Get the roles the user has - rbac
|
||||
List<String> roles = account.getOwnRoles();
|
||||
// 签发TOKEN
|
||||
// Issue TOKEN 签发TOKEN
|
||||
String issueToken = JsonWebTokenUtil.issueJwt(loginDto.getIdentifier(), PERIOD_TIME, roles);
|
||||
Map<String, Object> customClaimMap = new HashMap<>(1);
|
||||
customClaimMap.put("refresh", true);
|
||||
@@ -88,9 +91,9 @@ public class AccountController {
|
||||
}
|
||||
|
||||
@GetMapping("/refresh/{refreshToken}")
|
||||
@ApiOperation(value = "TOKEN刷新", notes = "使用刷新TOKEN重新获取TOKEN")
|
||||
@ApiOperation(value = "Use refresh TOKEN to re-acquire TOKEN", notes = "使用刷新TOKEN重新获取TOKEN")
|
||||
public ResponseEntity<Message<Map<String, String>>> refreshToken(
|
||||
@ApiParam(value = "刷新TOKEN", example = "xxx")
|
||||
@ApiParam(value = "en: Refresh TOKEN,zh: 刷新TOKEN", example = "xxx")
|
||||
@PathVariable("refreshToken") @NotNull final String refreshToken) {
|
||||
String userId;
|
||||
boolean isRefresh;
|
||||
@@ -116,7 +119,7 @@ public class AccountController {
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
List<String> roles = account.getOwnRoles();
|
||||
// 签发TOKEN
|
||||
// Issue TOKEN 签发TOKEN
|
||||
String issueToken = JsonWebTokenUtil.issueJwt(userId, PERIOD_TIME, roles);
|
||||
Map<String, Object> customClaimMap = new HashMap<>(1);
|
||||
customClaimMap.put("refresh", true);
|
||||
|
||||
@@ -21,11 +21,13 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Monitoring Type Management API
|
||||
* 监控类型管理API
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 16:47
|
||||
*/
|
||||
@Api(tags = "监控类型管理API")
|
||||
@Api(tags = "en: Monitoring Type Management API,zh: 监控类型管理API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/apps", produces = {APPLICATION_JSON_VALUE})
|
||||
public class AppController {
|
||||
@@ -34,31 +36,32 @@ public class AppController {
|
||||
private AppService appService;
|
||||
|
||||
@GetMapping(path = "/{app}/params")
|
||||
@ApiOperation(value = "查询监控类型的参数结构", notes = "根据app查询指定监控类型的需要输入参数的结构")
|
||||
@ApiOperation(value = "The structure of the input parameters required to specify the monitoring type according to the app query", notes = "根据app查询指定监控类型的需要输入参数的结构")
|
||||
public ResponseEntity<Message<List<ParamDefine>>> queryAppParamDefines(
|
||||
@ApiParam(value = "监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
@ApiParam(value = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
List<ParamDefine> paramDefines = appService.getAppParamDefines(app.toLowerCase());
|
||||
return ResponseEntity.ok(new Message<>(paramDefines));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{app}/define")
|
||||
@ApiOperation(value = "查询监控类型的结构定义", notes = "根据app查询指定监控类型的定义结构")
|
||||
@ApiOperation(value = "The definition structure of the specified monitoring type according to the app query", notes = "根据app查询指定监控类型的定义结构")
|
||||
public ResponseEntity<Message<Job>> queryAppDefine(
|
||||
@ApiParam(value = "监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
@ApiParam(value = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
Job define = appService.getAppDefine(app.toLowerCase());
|
||||
return ResponseEntity.ok(new Message<>(define));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/hierarchy")
|
||||
@ApiOperation(value = "查询全部监控指标层级", notes = "查询所有监控的类型-指标组-指标层级,以层级结构输出")
|
||||
@ApiOperation(value = "Query all monitored types-indicator group-indicator level, output in a hierarchical structure", notes = "查询所有监控的类型-指标组-指标层级,以层级结构输出")
|
||||
public ResponseEntity<Message<List<Hierarchy>>> queryAppsHierarchy(
|
||||
@ApiParam(value = "语言类型", example = "zh-CN", defaultValue = "zh-CN")
|
||||
@ApiParam(value = "en: language type,zh: 语言类型",
|
||||
example = "zh-CN", defaultValue = "zh-CN")
|
||||
@RequestParam(name = "lang", required = false) String lang) {
|
||||
if (lang == null || "".equals(lang)) {
|
||||
lang = "zh-CN";
|
||||
}
|
||||
lang = "zh-cn".equalsIgnoreCase(lang)? "zh-CN" : lang;
|
||||
lang = "en-us".equalsIgnoreCase(lang)? "en-US" : lang;
|
||||
lang = "zh-cn".equalsIgnoreCase(lang) ? "zh-CN" : lang;
|
||||
lang = "en-us".equalsIgnoreCase(lang) ? "en-US" : lang;
|
||||
List<Hierarchy> appHierarchies = appService.getAllAppHierarchy(lang);
|
||||
return ResponseEntity.ok(new Message<>(appHierarchies));
|
||||
}
|
||||
|
||||
@@ -6,16 +6,20 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Param Define Database Operations
|
||||
* ParamDefine数据库操作
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:27
|
||||
*/
|
||||
public interface ParamDefineDao extends JpaRepository<ParamDefine, Long> {
|
||||
|
||||
/**
|
||||
* Query the parameter definitions under it according to the monitoring type
|
||||
* 根据监控类型查询其下的参数定义
|
||||
* @param app 监控类型
|
||||
* @return 参数定义列表
|
||||
*
|
||||
* @param app Monitoring type 监控类型
|
||||
* @return parameter definition list 参数定义列表
|
||||
*/
|
||||
List<ParamDefine> findParamDefinesByApp(String app);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,11 @@ import java.util.List;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Hierarchical structure
|
||||
* 层级关系结构
|
||||
* eg: Monitoring Type Indicator Group Indicator Information Hierarchy Relationship
|
||||
* eg: 监控类型指标组指标信息层级关系
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/12 16:23
|
||||
*/
|
||||
@@ -21,18 +24,33 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Data
|
||||
public class Hierarchy {
|
||||
|
||||
/**
|
||||
* Category value
|
||||
*/
|
||||
@ApiModelProperty(value = "类别值", example = "os", accessMode = READ_WRITE, position = 0)
|
||||
String category;
|
||||
|
||||
/**
|
||||
* Attribute value
|
||||
*/
|
||||
@ApiModelProperty(value = "属性值", example = "linux", accessMode = READ_WRITE, position = 1)
|
||||
String value;
|
||||
|
||||
/**
|
||||
* Attribute internationalization tag
|
||||
*/
|
||||
@ApiModelProperty(value = "属性国际化标签", example = "Linux系统", accessMode = READ_WRITE, position = 2)
|
||||
String label;
|
||||
|
||||
/**
|
||||
* Is it a leaf node
|
||||
*/
|
||||
@ApiModelProperty(value = "是否是叶子节点", example = "true", accessMode = READ_WRITE, position = 3)
|
||||
Boolean isLeaf = false;
|
||||
|
||||
/**
|
||||
* Next level of association
|
||||
*/
|
||||
@ApiModelProperty(value = "下一关联层级", accessMode = READ_WRITE, position = 4)
|
||||
private List<Hierarchy> children;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ import javax.validation.constraints.NotBlank;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
|
||||
/**
|
||||
* Login registered account information transfer body username phone email
|
||||
* 登录注册账户信息传输体 username phone email
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 20:36 2019-08-01
|
||||
*/
|
||||
@@ -21,17 +23,27 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "账户信息传输体")
|
||||
@ApiModel(description = "en: Account information transfer body,zh: 账户信息传输体")
|
||||
public class LoginDto {
|
||||
|
||||
/**
|
||||
* type
|
||||
* 1. Account (email username and mobile phone number) password login 2. github login 3. WeChat login
|
||||
*/
|
||||
@ApiModelProperty(value = "类型", example = "1", accessMode = READ_ONLY, position = 0)
|
||||
@Range(min = 0, max = 4, message = "1.账户(邮箱用户名手机号)密码登录 2.github登录 3.微信登录")
|
||||
private Byte type;
|
||||
|
||||
/**
|
||||
* User ID
|
||||
*/
|
||||
@ApiModelProperty(value = "用户标识", example = "1", accessMode = READ_ONLY, position = 0)
|
||||
@NotBlank(message = "Identifier can not null")
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* key
|
||||
*/
|
||||
@ApiModelProperty(value = "密钥", example = "1", accessMode = READ_ONLY, position = 0)
|
||||
@NotBlank(message = "Credential can not null")
|
||||
private String credential;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Monitoring Type Management Interface
|
||||
* 监控类型管理接口
|
||||
*
|
||||
* @author tomsun28
|
||||
@@ -16,10 +17,11 @@ import java.util.Map;
|
||||
public interface AppService {
|
||||
|
||||
/**
|
||||
* Query the defined parameter structure based on the monitoring type
|
||||
* 根据监控类型查询定义的参数结构
|
||||
*
|
||||
* @param app 监控类型
|
||||
* @return 参数结构列表
|
||||
* @param app Monitoring type 监控类型
|
||||
* @return list of parameter structures 参数结构列表
|
||||
*/
|
||||
List<ParamDefine> getAppParamDefines(String app);
|
||||
|
||||
@@ -35,18 +37,20 @@ public interface AppService {
|
||||
Job getAppDefine(String app) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get defined monitoring I 18 N resources
|
||||
* 获取定义的监控I18N资源
|
||||
*
|
||||
* @param lang 语言类型
|
||||
* @return I18N资源
|
||||
* @param lang Language type 语言类型
|
||||
* @return I18N Resources I18N资源
|
||||
*/
|
||||
Map<String, String> getI18nResources(String lang);
|
||||
|
||||
/**
|
||||
* Query all types of monitoring - indicator group - indicator level
|
||||
* 查询所有监控的类型-指标组-指标层级
|
||||
*
|
||||
* @param lang 语言
|
||||
* @return 层级信息
|
||||
* @param lang language 语言
|
||||
* @return level information 层级信息
|
||||
*/
|
||||
List<Hierarchy> getAllAppHierarchy(String lang);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user