work.baiyun.chronicdiseaseappSpringAPP、WeChatController、UserServicegetOpenid、generateToken、addInterceptorsweChatService、username、authInterceptorTOKEN_TTL_HOURS、REFRESH_THRESHOLD_HOURSMALE、FEMALE示例:
public class Example {
public void method() {
// code
}
}
a + b。method(a, b, c)。if (condition)。/** */。示例:
/**
* 性别枚举,数据库存储为整数:1=男, 2=女
*/
public enum Gender {
示例:
/**
* 获取用户OpenID
*/
public R<?> getOpenid(GetOpenidRequest req) {
/** */ 注释字段,描述字段含义。示例:
/** 用户名;用户名 */
@Schema(description = "用户名(可选)")
private String username;
// 进行单行注释,解释复杂逻辑。示例:
// role is required now
if (req.getRole() == null) {
private。public、private 或 protected。@Autowired 注解进行依赖注入。示例:
@Autowired
public WebMvcConfig(AuthInterceptor authInterceptor) {
this.authInterceptor = authInterceptor;
}
Exception。示例:
public class CustomException extends Exception {
public CustomException(String message) {
super(message);
}
}
public static final 修饰。示例:
public static final long TOKEN_TTL_HOURS = 72L;
@EnumValue 注解指定数据库存储值。getCode()、getDescription() 等方法。示例:
public enum Gender {
MALE(1, "男"),
FEMALE(2, "女");
@EnumValue
private final int code;
private final String description;
// constructor and methods
}