云服务器内容精选

  • 购买扩容包 扩容包仅适用于在购买专业版或企业版的基础上使用,不可单独购买和退订。扩容包的使用截止时间与主资源的截止时间保持一致。 参考购买实例中操作,购买AstroPro企业版实例。 在已购买的实例中,单击“操作”,选择“扩容”。 图4 选择扩容 在购买扩容包页面,设置购买数量,单击“立即购买”。 一个资源扩容包,包含用户数50个、应用数20个、实体个数200个,请按需设置购买数量。 图5 购买扩容包 选择支付方式,单击“确认付款”,完成订单支付。
  • 购买实例 进入购买Astro企业应用实例页面。 “实例规格”选择“企业版”,其他参数按需进行设置,单击“立即购买”。 图1 选择购买规格 确认订单无误后,单击“去支付”。 以购买企业版一年为例,若为基础版,此处配置费用为“0”。 图2 确认订单 选择支付方式,单击“确认付款”,完成支付。 订单支付成功后,单击“返回Astro企业应用控制台”。 在Astro企业应用控制台中,可以查看到Astro企业应用的实例状态。当“实例状态”变为“运行中”时,说明实例已安装完成,可以正常使用Astro企业应用。 图3 查看实例状态
  • 17、x-entity-package 作用: 用于在swagger中指定实体类dto生成的包名。 标签值类型: String 使用位置: x-entity-package(定义在swagger的最外层) 使用示例: swagger: "2.0" info: description: "" version: "v1" title: "testSwagger" termsOfService: "http://www.coarl.org/service.html" host: "git.huawei.com" basePath: "/testswagger" x-entity-package: "customdto" ------------ 使用效果: 使用前: #dto对象生成目录 xxx.xx.xx.dto 使用后: #dto对象生成目录 xxx.xx.xx.customdto
  • 21、x-pom-gav 作用 自定义标签-pom坐标引入。 标签值类型 List 使用位置 x-pom-gav components.schemas.model.x-pom-gav components.schemas.model.properties.property.x-pom-gav paths.path.operation.x-pom-gav paths.path.operation.parameters.name.x-pom-gav x-pom-gav在Swagger文件中的位置可以是类级别、方法级别、参数级别,groupId、artifactId、version按照顺序用:连接,全局有一个地方定义即可,不需要重复定义。 使用示例 swagger: "2.0" info: description: "" version: "v1" title: "testSwagger" termsOfService: "http://www.coarl.org/service.html" host: "git.huawei.com" basePath: "/testswagger" x-entity-package: "customdto" x-interface-name-style: SERVICE_IMPL_AND_NO_I_INTERFACE_PREFIX x-user-defined-consumes: true x-pom-gav: # 手动引入hibernate-validator:依赖 - "org.hibernate.validator:hibernate-validator:8.0.1.Final" ------- 使用效果: 使用前: pom中没有org.hibernate.validator:hibernate-validator:8.0.1.Final的依赖 使用后: pom中生成org.hibernate.validator:hibernate-validator:8.0.1.Final的依赖
  • 18、x-interface-name-style 作用: 控制自定义接口、实现类命名风格。 标签值类型: enum(DEFAULT,SERVICE_IMPL_AND_NO_I_INTERFACE_PREFIX),配置为DEFAULT时和不配置此参数效果相同。 使用位置: x-interface-name-style 使用示例: swagger: "2.0" info: description: "" version: "v1" title: "testSwagger" termsOfService: "http://www.coarl.org/service.html" host: "git.huawei.com" basePath: "/testswagger" x-entity-package: "customdto" x-interface-name-style: SERVICE_IMPL_AND_NO_I_INTERFACE_PREFIX ------------ 使用效果: 使用前: service类的命名为 I+tag驼峰+ service eg: IOrderService 使用后: service类的命名为 tag驼峰+ service eg: OrderService
  • 5、x-class-annotations 作用: 添加指定的注解。 该标签用于在api接口或者dto类上添加指定的注解。 标签值类型: List 使用位置: x-class-annotations(定义在swagger的最外层时,会在所有的api接口上都添加指定的注解) components.schemas.model.x-class-annotations(定义dto对象上时,只在该对象上添加指定的注解) 使用示例: swagger: "2.0" info: description: "" version: "v1" title: "testSwagger" termsOfService: "http://www.coarl.org/service.html" host: "git.huawei.com" basePath: "/testswagger" x-imports: - "org.springframework.stereotype.Controller;" # 使用的时候结尾一定要带上 ; - "org.springframework.transaction.annotation.Transactional;" x-class-annotations: #此处添加的注解,在所有生成的api上都会添加 - "@Controller" # 此处会将 @Controller识别为一个字符串添加到api接口类上,并不会导入相应的包,需要使用 x-imports标签手动导入相应的包 - "@Transactional" # 此处会将 @Transactional识别为一个字符串添加到api接口类上,并不会导入相应的包,需要使用 x-imports标签手动导入相应的包 使用效果: 使用前: package com.huaweicloud.icsl.api; import ------ /** * CARDApi interface */ public interface CARDApi { ----------- } 使用后: package com.huaweicloud.icsl.api; import org.springframework.stereotype.Controller; // 通过x-imports 引入的导包 import org.springframework.transaction.annotation.Transactional; // 通过x-imports 引入的导包 /** * CARDApi interface */ @Controller // 通过x-class-annotations 引入的注解 @Transactional // 通过x-class-annotations 引入的注解 public interface CARDApi { ----------- }
  • 9、x-type 作用: 给dto的字段设置指定的类型。 标签值类型: String 使用位置: components.schemas.model.prorperties.field.x-type(设置在dto的指定字段上时,改变该字段的类型为指定类型) 使用示例: definitions: Contain: type: "object" x-generic: T x-extends: Parent properties: name: type: "string" description: "" example: data: type: "string" x-type: T # 通过x-type指定data的类型为T, 此处是将T当为一个字符串设置上,如果设置为一个对象时,需要使用x-imports手动导入相应的包 xml: name: "Contain" namespace: "com.huaweicloud.icsl.app.dto" --------------- 使用效果: 使用前: public class Contain implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("name") private String name = null; @JsonProperty("data") private String data = null; } 使用后: public class Contain implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("name") private String name = null; @JsonProperty("data") private T data = null; }
  • 16、x-enum-class-name 作用 用于标识查询参数对应的枚举类。 标签值类型 String 使用位置 paths.path.operation.parameters.fields.x-enum-value-type 对应的是swagger中已定义的枚举对象名字。 使用示例 Paths: /v1/orders/{order_id}/order-details: get: tags: - "Order" summary: "查询OrderDetail" description: "Returns OrderDetail" operationId: "ListOrderDetails" x-is-registered: 'N' x-support-sdk: 'N' x-mybatis-paging: true consumes: - "application/json" produces: - "application/json" parameters: - name: "status" in: "query" description: "status" required: false type: "string" x-enum-class-name: "OrderStatus" #此标签只在查询参数中使用 -------- 使用效果: 使用前: public class ListOrderDetailsQo implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("status") private Object status = null; ------------------- } 使用后: public class ListOrderDetailsQo implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("status") private OrderStatus status = null; ------------------- }
  • 4、x-annotations 作用: 添加指定的注解。 该标签用于在api的参数或者dto指定属性上添加注解。 标签值类型: List 使用位置: paths.path.operation.parameters.x-annotations(定义在api中的参数上时,只在此参数上生成对应的注解) definitions.model.properties.property.x-annotations(定义在dto的字段上时,只在此字段上生成对应的注解) 使用示例: Card: type: "object" properties: id: type: "string" description: "id" example: "id" balance: type: "integer" format: "int64" description: "balance" example: 123 address: type: "string" description: "address" example: "address" x-annotations: - "@InjectMocks" # 此处在address属性上添加了一个 @InjectMocks 注解 x-imports: - "org.mockito.InjectMocks;" # x-annotations实际是把 @InjectMocks当做字符串添加到了address上,所以需要自己通过x-imports导入相应的类 creator: type: "string" description: "creator" example: "creator" create_time: type: "string" format: "date-time" default: "CURRENT_TIMESTAMP" description: "create time" example: "2020-02-27 15:00:08" modify_time: type: "string" format: "date-time" default: "CURRENT_TIMESTAMP" description: "modified time" example: "2020-02-27 15:00:08" description: type: "string" description: "description info" example: "description" xml: name: "card" namespace: "com.huaweicloud.icsl.model" 使用效果: 使用前: public class Card implements Serializable { private static final long serialVersionUID = 1L; ----- @JsonProperty("address") private String address = null; ---- } 使用后: public class Card implements Serializable { private static final long serialVersionUID = 1L; ------- @JsonProperty("address") @InjectMocks // 通过 x-annotations 引入的注解 private String address = null; -------- }
  • 2、x-default-empty 作用: 只支持get请求,指定String类型参数生成默认值为""。 需要配合metadata元数据中generatorPolicy的queryParamLimit使用,当将请求参数转换为对象后此标签才会生效。 标签值类型: boolean 使用位置: paths.path.operation.parameters.name.x-default-empty 当该标签置为true时,原定义默认值的default标签失效,该标签只可用于定义String参数为""。 使用示例: paths: /v1/cards: get: # 该接口设置了查询参数转换为对象的功能,最终所有的参数都会自动定义到一个对象中 tags: - "CARD" summary: "查询所有Card" description: "Returns all Card" operationId: "ListCards" x-is-registered: 'N' x-support-sdk: 'N' x-mybatis-paging: true x-query-param-body: CardQo parameters: - name: "creator" in: "query" description: "creator" required: false type: "string" x-default-empty: true # 使用 x-default-empty 指定creator的默认值为 "" ----- 使用效果: 使用前: public class ListCardsQo implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("creator") private String creator = null; // 此处生成的creator默认值为 null ------ } 使用后: public class CardQo implements Serializable { // 该示例使用了x-query-param-body指定了对象名为CardQo,所以和使用前的的示例中类名不一样 private static final long serialVersionUID = 1L; @JsonProperty("creator") private String creator = ""; //此处生成的creator的默认值为 "" ------- }
  • 3、x-imports 作用: 自主定义类中需要添加的 import 引用。 标签值类型: List 使用位置: x-imports(当定义在swagger的最外层时,所有的类中都会引入import) components.schemas.model.properties.property.x-imports(当定义在dto的字段中时,只会在该dto类中引入import) definitions.model.x-imports(当定义在dto上时,只会在该dto类中引入import) paths.path.operation.x-imports(当定义在api中时,只会在该api中引入import) 在生成代码的时候,最终会有格式化的一个步骤,类上的无用import会被消除。 使用示例: swagger: "2.0" info: description: "" version: "v1" title: "testSwagger" termsOfService: "http://www.coarl.org/service.html" host: "git.huawei.com" basePath: "/testswagger" x-imports: - "org.springframework.stereotype.Controller;" # 使用的时候结尾一定要带上 ; - "org.springframework.transaction.annotation.Transactional;" 使用效果: 使用前:api类中不生成org.springframework.stereotype.Controller; 和org.springframework.transaction.annotation.Transactional;引用。 使用后:api类中生成如下引用。 import org.springframework.stereotype.Controller; # 通过x-import引入 import org.springframework.transaction.annotation.Transactional; # 通过x-import引入 public interface CARDApi { ------- );
  • 6、x-controller-annotations 作用: 添加指定的注解。 该标签用于在api实现类上添加指定的注解。 标签值类型: String 使用位置: x-class-annotations(定义在swagger最外层,所有的api实现类上都会添加指定注解) components.schemas.model.x-class-annotations(定义在指定tag下,只会在具体api实现类上添加指定注解) 使用示例: swagger: "2.0" info: description: "" version: "v1" title: "testSwagger" termsOfService: "http://www.coarl.org/service.html" host: "git.huawei.com" basePath: "/testswagger" x-imports: - "org.springframework.context.annotation.Profile;" # 使用的时候结尾一定要带上 ; x-controller-annotations: # 此处添加的注解,在所有生成的api实现类上都会添加,需要使用x-imports手动导入相应的包 - '@Profile("test")' 使用效果: 使用前: public class CardApiController implements CardApi { ------ } 使用后: @Profile("test") // 通过x-controller-annotations引入的注解 public class CardApiController implements CardApi { ------ }
  • DDL文件设计 根据业务模型,完成DDL文件设计,DDL标签使用可参考DDL标签使用指南。 示例: CREATE TABLE `t_value_object` ( `workspace1_id` varchar(200) NOT NULL COMMENT 'relation("t_workspace1","id","AGGREGATE")', `number` int NOT NULL COMMENT 'valueObject', `new_name3` varchar(200) NOT NULL COMMENT 'searchable', `new_name4` varchar(200) NOT NULL COMMENT 'searchable', CONSTRAINT pk_t_value_object PRIMARY KEY (`workspace1_id`, `number`) ) COMMENT = 'primaryKeyType("NONE")'; CREATE TABLE `renameWorkspace` ( `key1` varchar(200) NOT NULL COMMENT 'alias("newName2")', `key2` varchar(200) NOT NULL COMMENT 'alias("newName3")', `renameField` boolean NOT NULL COMMENT 'alias("newName4")', `new_name5` int NOT NULL, `new_name6` bigint(40) NOT NULL, `new_name7` decimal(40, 0) NOT NULL, `new_name8` float(40, 0) NOT NULL, `new_name9` double(40, 0) NOT NULL, `new_name10` date NOT NULL, `new_name11` timestamp NOT NULL, CONSTRAINT pk_renameworkspace PRIMARY KEY (`key1`, `key2`) ) COMMENT = 'alias("renameWeaweae");primaryKeyType("COMPOSITE")'; CREATE TABLE `t_workspace6` ( `parent_id` bigint(40) NULL COMMENT 'parent_id;relation("t_workspace6","id","RECURSIVE")', `id` bigint(40) NOT NULL, `new_name4` varchar(200) NOT NULL, `new_name5` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) COMMENT = 'primaryKeyType("SNOWFLAKE")';
  • 主键标签 在comment中使用函数形式表示主键类型。可选值为:UUID、SNOWFLAKE、AUTO_INCREASE_INT32、AUTO_INCREASE_INT64、USER_DEFINE。 参数说明: 标签名称:valueObject。 数据类型:boolean类型。 默认值:false。 标签规则 UUID时主键应是字符类型。 AUTO_INCREASE_INT32的主键应是int类型。 AUTO_INCREASE_INT64的主键应是bigint类型。 SNOWFLAKE时主键应是数值(int/long)类型。 非USER_DEFINE的主键时,主键名不是“id”。 USER_DEFINE的主键时,未指定主键字段。 同时非USER_DEFINE时,可以不指定主键(即ddl中可以没有primary key的声明语句)。 当未指定标签时,指定主键情况下主键类型默认为USER_DEFINE; 未指定主键默认为UUID。 标签示例: CREATE TABLE `t_workspace4` ( `id` varchar(200) NOT NULL, `new_name3` varchar(200) NOT NULL, `new_name4` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) COMMENT = 'primaryKeyType("UUID")'; 标签使用效果:
  • 值对象标签 在comment中使用函数形式表示Value Object类型BO,标识作用于值对象表的number字段。 参数说明: 标签名称:valueObject。 数据类型:boolean类型。 默认值:false。 标签示例: CREATE TABLE `t_workspace9` ( `id` varchar(40) NOT NULL COMMENT 'id', `name` varchar(200) NOT NULL COMMENT 'name', PRIMARY KEY (`id`) ) COMMENT = 't_workspace9'; CREATE TABLE `t_object1` ( `workspace9_id` varchar(0) NOT NULL COMMENT 'relation("t_workspace9","id","AGGREGATE")', `number` int NOT NULL COMMENT 'valueObject' ) COMMENT = 'object1'; 标签使用效果: