Skip to content

Commit

Permalink
refactor: 移除所有的 @accessors(chain = true),并全局配置禁止使用
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Aug 11, 2023
1 parent 2d0e1f4 commit 76c6546
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.Serializable;

import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -30,7 +30,7 @@
* @since 2022/12/11 13:55
*/
@Data
@Accessors(chain = true)
@Builder
@Schema(description = "验证码信息")
public class CaptchaVO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -33,7 +32,6 @@
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@Schema(description = "键值对信息")
public class LabelValueVO<V> implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -39,7 +38,6 @@
* @since 2023/1/14 23:40
*/
@Data
@Accessors(chain = true)
@Schema(description = "分页信息")
public class PageDataVO<V> implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.Serializable;

import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -30,7 +30,7 @@
* @since 2022/12/21 20:42
*/
@Data
@Accessors(chain = true)
@Builder
@Schema(description = "令牌信息")
public class LoginVO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.Serializable;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -30,7 +29,6 @@
* @since 2023/2/26 22:51
*/
@Data
@Accessors(chain = true)
@Schema(description = "元数据信息")
public class MetaVO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.List;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -33,7 +32,6 @@
* @since 2023/2/26 22:51
*/
@Data
@Accessors(chain = true)
@Schema(description = "路由信息")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class RouteVO implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Set;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -39,7 +38,6 @@
* @since 2022/12/29 20:15
*/
@Data
@Accessors(chain = true)
@Schema(description = "用户信息")
public class UserInfoVO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.io.Serializable;

import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -30,7 +30,7 @@
* @since 2023/1/2 16:29
*/
@Data
@Accessors(chain = true)
@Builder
@Schema(description = "头像信息")
public class AvatarVO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package top.charles7c.cnadmin.system.model.vo;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -33,7 +32,6 @@
* @since 2023/1/22 13:53
*/
@Data
@Accessors(chain = true)
@TreeField(value = "id", nameKey = "name")
@Schema(description = "部门信息")
public class DeptVO extends BaseVO {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package top.charles7c.cnadmin.system.model.vo;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -37,7 +36,6 @@
* @since 2023/2/15 20:23
*/
@Data
@Accessors(chain = true)
@TreeField(value = "id")
@ExcelIgnoreUnannotated
@Schema(description = "菜单信息")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package top.charles7c.cnadmin.system.model.vo;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -33,7 +32,6 @@
* @since 2023/2/8 23:05
*/
@Data
@Accessors(chain = true)
@Schema(description = "角色信息")
public class RoleVO extends BaseVO {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Objects;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -38,7 +37,6 @@
* @since 2023/2/20 21:08
*/
@Data
@Accessors(chain = true)
@Schema(description = "用户信息")
public class UserVO extends BaseVO {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -48,9 +47,8 @@
* @since 2023/4/12 20:21
*/
@Data
@TableName("gen_field_config")
@NoArgsConstructor
@Accessors(chain = true)
@TableName("gen_field_config")
@Schema(description = "字段配置信息")
public class FieldConfigDO implements Serializable {

Expand Down Expand Up @@ -144,22 +142,25 @@ public FieldConfigDO(@NonNull Column column) {
String columnType = StrUtil.splitToArray(column.getTypeName(), StringConsts.SPACE)[0].toLowerCase();
boolean isRequired = !column.isPk() && !column.isNullable();
this.tableName = column.getTableName();
this.setColumnName(column.getName()).setColumnType(columnType).setComment(column.getComment())
.setIsRequired(isRequired).setShowInList(true).setShowInForm(isRequired).setShowInQuery(isRequired)
.setFormType(FormTypeEnum.TEXT);
this.setColumnName(column.getName());
this.setColumnType(columnType);
this.setComment(column.getComment());
this.setIsRequired(isRequired);
this.setShowInList(true);
this.setShowInForm(isRequired);
this.setShowInQuery(isRequired);
this.setFormType(FormTypeEnum.TEXT);
this.setQueryType("String".equals(this.getFieldType()) ? QueryTypeEnum.INNER_LIKE : QueryTypeEnum.EQUAL);
}

public FieldConfigDO setColumnName(String columnName) {
public void setColumnName(String columnName) {
this.columnName = columnName;
this.fieldName = StrUtil.toCamelCase(this.columnName);
return this;
}

public FieldConfigDO setColumnType(String columnType) {
public void setColumnType(String columnType) {
this.columnType = columnType;
Props generatorProp = PropsUtil.get("generator");
this.fieldType = generatorProp.getStr(columnType);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -42,9 +41,8 @@
* @since 2023/4/12 20:21
*/
@Data
@TableName("gen_config")
@NoArgsConstructor
@Accessors(chain = true)
@TableName("gen_config")
@Schema(description = "生成配置信息")
public class GenConfigDO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.time.LocalDateTime;

import lombok.Data;
import lombok.experimental.Accessors;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -31,7 +30,6 @@
* @since 2023/4/12 20:21
*/
@Data
@Accessors(chain = true)
@Schema(description = "表信息")
public class TableVO implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public List<FieldConfigDO> listFieldConfig(String tableName, Boolean requireSync
if (null != fieldConfig) {
// 更新已有字段配置
String columnType = StrUtil.splitToArray(column.getTypeName(), StringConsts.SPACE)[0].toLowerCase();
fieldConfig.setColumnType(columnType).setComment(column.getComment());
fieldConfig.setColumnType(columnType);
fieldConfig.setComment(column.getComment());
} else {
// 新增字段配置
fieldConfig = new FieldConfigDO(column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public R<LoginVO> login(@Validated @RequestBody LoginRequest loginRequest) {
ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(loginRequest.getPassword()));
ValidationUtils.throwIfBlank(rawPassword, "密码解密失败");
String token = loginService.login(loginRequest.getUsername(), rawPassword);
return R.ok(new LoginVO().setToken(token));
return R.ok(LoginVO.builder().token(token).build());
}

@SaIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ public R<CaptchaVO> getImageCaptcha() {
String captchaKey = RedisUtils.formatKey(CacheConsts.CAPTCHA_KEY_PREFIX, uuid);
RedisUtils.setCacheObject(captchaKey, captcha.text(),
Duration.ofMinutes(captchaImage.getExpirationInMinutes()));

// 返回验证码
CaptchaVO captchaVO = new CaptchaVO().setUuid(uuid).setImg(captcha.toBase64());
return R.ok(captchaVO);
return R.ok(CaptchaVO.builder().uuid(uuid).img(captcha.toBase64()).build());
}

@Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public R<AvatarVO> uploadAvatar(@NotNull(message = "头像不能为空") Multipa

// 上传头像
String newAvatar = userService.uploadAvatar(avatarFile, LoginHelper.getUserId());
return R.ok("上传成功", new AvatarVO().setAvatar(newAvatar));
return R.ok("上传成功", AvatarVO.builder().avatar(newAvatar).build());
}

@Operation(summary = "修改基础信息", description = "修改用户基础信息")
Expand Down
4 changes: 3 additions & 1 deletion lombok.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ config.stopBubbling=true
lombok.toString.callSuper=CALL
lombok.equalsAndHashCode.callSuper=CALL
clear lombok.val.flagUsage
lombok.val.flagUsage=ERROR
lombok.val.flagUsage=ERROR
clear lombok.accessors.flagUsage
lombok.accessors.flagUsage=ERROR

0 comments on commit 76c6546

Please sign in to comment.