getAccessibleIds(String entityClass, String fieldName)
}
else if("regionId".equals(fieldName)){
return null;
- } else if ("orgId".equals(fieldName)) {
- accessibleIds.add(100001L);
}
// ... 其他类型字段
return accessibleIds;
}
+
}
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/DataAccessPermissionTestImplForDepartment.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/DataAccessPermissionTestImplForDepartment.java
new file mode 100644
index 000000000..b7bfd18d4
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/DataAccessPermissionTestImplForDepartment.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015-2020, www.dibo.ltd (service@dibo.ltd).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package diboot.core.test.binder;
+
+import com.diboot.core.data.access.DataScopeManager;
+import diboot.core.test.binder.entity.Department;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 数据访问控制测试
+ * @author Mazc@dibo.ltd
+ * @version v2.0
+ * @date 2020/04/24
+ */
+public class DataAccessPermissionTestImplForDepartment implements DataScopeManager {
+
+ @Override
+ public List getAccessibleIds(String fieldName) {
+ // 提取其可访问ids
+ List accessibleIds = new ArrayList<>();
+ if("parentId".equals(fieldName)){
+ accessibleIds.add(10001L);
+ }
+ // ... 其他类型字段
+ return accessibleIds;
+ }
+
+ @Override
+ public List> getEntityClasses() {
+ return Arrays.asList(Department.class);
+ }
+
+}
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/TestBindWithMultiFlds.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/TestBindWithMultiFlds.java
new file mode 100644
index 000000000..f7ed322fb
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/TestBindWithMultiFlds.java
@@ -0,0 +1,53 @@
+package diboot.core.test.binder;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import diboot.core.test.StartupApplication;
+import diboot.core.test.binder.entity.PetAdopt;
+import diboot.core.test.binder.service.PetAdoptService;
+import diboot.core.test.binder.vo.PetAdoptListVO;
+import diboot.core.test.config.SpringMvcConfig;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.List;
+
+/**
+ * 测试多字段关联条件绑定
+ * @author JerryMa
+ * @version v3.5.0
+ * @date 2024/9/3
+ */
+@RunWith(SpringRunner.class)
+@ContextConfiguration(classes = {SpringMvcConfig.class})
+@SpringBootTest(classes = {StartupApplication.class})
+public class TestBindWithMultiFlds {
+
+ @Autowired
+ private PetAdoptService petAdoptService;
+
+ /**
+ * 验证多个字段关联的绑定
+ */
+ @Test
+ public void testMultiFldsConditionBinder(){
+ LambdaQueryWrapper queryWrapper = new QueryWrapper().lambda()
+ .eq(PetAdopt::getRealname, "张三");
+ List petAdoptListVOS = petAdoptService.getViewObjectList(queryWrapper, null, PetAdoptListVO.class);
+ Assert.assertEquals(petAdoptListVOS.size(), 2);
+ for (PetAdoptListVO vo : petAdoptListVOS) {
+ if(vo.getPetCategory().equals("CAT")) {
+ Assert.assertEquals("#1", vo.getPetCode());
+ }
+ else {
+ Assert.assertEquals("#2", vo.getPetCode());
+ }
+ }
+ }
+
+}
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/TestDataAccessControl.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/TestDataAccessControl.java
index fda6e4281..242905afc 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/binder/TestDataAccessControl.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/TestDataAccessControl.java
@@ -2,10 +2,13 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diboot.core.data.access.DataScopeManager;
+import com.diboot.core.handler.DataAccessControlHandler;
import com.diboot.core.util.ContextHolder;
import diboot.core.test.StartupApplication;
import diboot.core.test.binder.entity.CcCityInfo;
+import diboot.core.test.binder.entity.Department;
import diboot.core.test.binder.service.CcCityInfoService;
+import diboot.core.test.binder.service.DepartmentService;
import diboot.core.test.config.SpringMvcConfig;
import org.junit.Assert;
import org.junit.Test;
@@ -31,11 +34,25 @@ public class TestDataAccessControl {
@Autowired
private CcCityInfoService ccCityInfoService;
+ @Autowired(required = false)
+ private DataAccessControlHandler dataAccessControlHandler;
+
+ @Autowired
+ private DepartmentService departmentService;
+
@Test
public void testDataControl(){
- DataScopeManager checkImpl = ContextHolder.getBean(DataScopeManager.class);
+ DataScopeManager checkImpl = dataAccessControlHandler.getDataScopeManager(CcCityInfo.class);
Assert.assertNotNull(checkImpl);
+ // 默认拦截器
List ccCityInfoList = ccCityInfoService.list(new QueryWrapper<>());
Assert.assertEquals(2, ccCityInfoList.size());
+
+ // 指定拦截器
+ checkImpl = dataAccessControlHandler.getDataScopeManager(Department.class);
+ Assert.assertNotNull(checkImpl);
+ // 默认拦截器
+ List departments = departmentService.getEntityList(new QueryWrapper<>());
+ Assert.assertEquals(3, departments.size());
}
}
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/DepartmentDTO.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/DepartmentDTO.java
index 410cf4d4d..fd074b26c 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/DepartmentDTO.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/DepartmentDTO.java
@@ -47,27 +47,27 @@ public class DepartmentDTO implements Serializable {
private String name;
// 绑定join查询
- @BindQuery(comparison = Comparison.STARTSWITH, strategy = Strategy.INCLUDE_NULL, entity = Organization.class, column = "name", condition = "this.org_id=id")
+ @BindQuery(comparison = Comparison.STARTSWITH, strategy = Strategy.INCLUDE_NULL, entity = Organization.class, field = "name", condition = "this.org_id=id")
private String orgName;
// 绑定join查询
- @BindQuery(entity = Department.class, column = "name", condition = "this.parent_id=id")
+ @BindQuery(entity = Department.class, field = "name", condition = "this.parent_id=id")
private String parentName;
// 多绑定or连接
- @BindQuery(comparison = Comparison.CONTAINS, column = "name")
- @BindQuery(comparison = Comparison.STARTSWITH, column = "`character`")
- @BindQuery(comparison = Comparison.ENDSWITH, entity = Organization.class, column = "name", condition = "this.org_id=id")
+ @BindQuery(comparison = Comparison.CONTAINS, field = "name")
+ @BindQuery(comparison = Comparison.STARTSWITH, field = "character")
+ @BindQuery(comparison = Comparison.ENDSWITH, entity = Organization.class, field = "name", condition = "this.org_id=id")
private String search;
// 查询单个日期
- @BindQuery(comparison = Comparison.GE, column = "create_time")
+ @BindQuery(comparison = Comparison.GE)
private LocalDateTime createTime;
- @BindQuery(comparison = Comparison.LT, column = "create_time")
+ @BindQuery(comparison = Comparison.LT, field = "createTime")
private LocalDateTime createTimeEnd;
- @BindQuery(column = "parent_id", comparison = Comparison.IN)
+ @BindQuery(field = "parentId", comparison = Comparison.IN)
private List parentIds;
@BindQuery(comparison = Comparison.LIKE)
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/ProblemDTO.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/ProblemDTO.java
index 88e0b1499..9902352d7 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/ProblemDTO.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/ProblemDTO.java
@@ -9,7 +9,7 @@
@Getter @Setter
public class ProblemDTO extends Problem {
- @BindQuery(entity = StatusInfo.class, column = "user_id", condition = "this.id=problem_id")
+ @BindQuery(entity = StatusInfo.class, condition = "this.id=problem_id")
private String userId;
}
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/PurchaseFormPlanQueryDto.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/PurchaseFormPlanQueryDto.java
index 99e3bb989..f2b4c6563 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/PurchaseFormPlanQueryDto.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/PurchaseFormPlanQueryDto.java
@@ -20,7 +20,7 @@ public class PurchaseFormPlanQueryDto extends DbPurchaseFormPlan {
private Long purchaseFormPlanId;
@BindQuery(comparison = Comparison.EQ,
- entity= DbGoodsGoodsInfo.class, column ="goods_nm",
+ entity= DbGoodsGoodsInfo.class, field ="goodsNm",
condition="this.purchase_form_plan_id = db_purchase_rel_plan_goods.purchase_form_plan_id and "
+ "db_purchase_rel_plan_goods.goods_id=goods_id"
)
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/UserDTO.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/UserDTO.java
index 2515361d0..5f19c5579 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/UserDTO.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/dto/UserDTO.java
@@ -38,27 +38,27 @@
public class UserDTO extends User {
// 字段关联
- @BindQuery(entity= Department.class, column = "name", condition="this.department_id=id") // AND parent_id >= 0
+ @BindQuery(entity= Department.class, field = "name", condition="this.department_id=id") // AND parent_id >= 0
private String deptName;
// 字段关联
- @BindQuery(entity= Department.class, column = "id", condition="this.department_id=id") // AND parent_id >= 0
+ @BindQuery(entity= Department.class, field = "id", condition="this.department_id=id") // AND parent_id >= 0
private String deptId;
// 通过中间表关联Entity
- @BindQuery(comparison = Comparison.ENDSWITH, entity = Organization.class, column = "name",
+ @BindQuery(comparison = Comparison.ENDSWITH, entity = Organization.class, field = "name",
condition = "this.department_id=department.id AND department.org_id=id AND parent_id=0", strategy = Strategy.INCLUDE_EMPTY)
private String orgName;
// LEFT JOIN department r2m ON self.department_id = r2m.id
// LEFT JOIN organization r1 ON r2m.org_id=r2.id
- @BindQuery(comparison = Comparison.IN, entity = Role.class, column = "code", condition = "this.id=user_role.user_id AND user_role.role_id=id")
+ @BindQuery(comparison = Comparison.IN, entity = Role.class, field = "code", condition = "this.id=user_role.user_id AND user_role.role_id=id")
private List roleCodes;
//private String[] roleCodes;
// LEFT JOIN user_role r3m ON self.id = r3m.user_id
// LEFT JOIN role r3 ON r3m.role_id = r3.id
- @BindQuery(entity = Role.class, column = "id", condition = "this.id=user_role.user_id AND user_role.role_id=id")
+ @BindQuery(entity = Role.class, field = "id", condition = "this.id=user_role.user_id AND user_role.role_id=id")
private Long roleId;
}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Department.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Department.java
index 070e47613..133fbfe3f 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Department.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Department.java
@@ -45,10 +45,10 @@ public class Department extends BaseEntity {
@BindQuery(comparison = Comparison.EQ, strategy = Strategy.INCLUDE_NULL)
@TableField
+ @DataAccessCheckpoint()
private String parentId;
@TableField
- @DataAccessCheckpoint()
private String orgId;
@BindQuery(comparison = Comparison.STARTSWITH)
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Pet.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Pet.java
new file mode 100644
index 000000000..cd7097a48
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/Pet.java
@@ -0,0 +1,48 @@
+package diboot.core.test.binder.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.diboot.core.binding.query.BindQuery;
+import com.diboot.core.binding.query.Comparison;
+import com.diboot.core.entity.BaseModel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+/**
+* 宠物 Entity 定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+
+@TableName("mdl_pet")
+@Getter @Setter @Accessors(chain = true)
+public class Pet extends BaseModel {
+ private static final long serialVersionUID = 1537809466056333722L;
+ /**
+ * 品类
+ */
+ @TableField()
+ private String category;
+
+ /**
+ * 编号
+ */
+ @Length(max=100, message="编号长度应小于100")
+ @BindQuery(comparison = Comparison.LIKE)
+ @TableField()
+ private String code;
+
+ /**
+ * 备注
+ */
+ @Length(max=100, message="备注长度应小于100")
+ @BindQuery(comparison = Comparison.LIKE)
+ @TableField()
+ private String remark;
+
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/PetAdopt.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/PetAdopt.java
new file mode 100644
index 000000000..325cdf636
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/entity/PetAdopt.java
@@ -0,0 +1,58 @@
+package diboot.core.test.binder.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.diboot.core.binding.query.BindQuery;
+import com.diboot.core.binding.query.Comparison;
+import com.diboot.core.entity.BaseModel;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+/**
+* 领养 Entity 定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+
+@TableName("mdl_pet_adopt")
+@Getter @Setter @Accessors(chain = true)
+public class PetAdopt extends BaseModel {
+ private static final long serialVersionUID = 1140534725406040048L;
+ /**
+ * 姓名
+ */
+ @Length(max=100, message="姓名长度应小于100")
+ @BindQuery(comparison = Comparison.LIKE)
+ @TableField()
+ private String realname;
+
+ /**
+ * 宠物品类
+ */
+ @Length(max=100, message="宠物品类长度应小于100")
+ @BindQuery(comparison = Comparison.LIKE)
+ @TableField()
+ private String petCategory;
+
+ /**
+ * 宠物编号
+ */
+ @Length(max=100, message="宠物编号长度应小于100")
+ @BindQuery(comparison = Comparison.LIKE)
+ @TableField()
+ private String petCode;
+
+ /**
+ * 备注
+ */
+ @Length(max=100, message="备注长度应小于100")
+ @BindQuery(comparison = Comparison.LIKE)
+ @TableField()
+ private String remark;
+
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/mapper/PetAdoptMapper.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/mapper/PetAdoptMapper.java
new file mode 100644
index 000000000..004b75afe
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/mapper/PetAdoptMapper.java
@@ -0,0 +1,17 @@
+package diboot.core.test.binder.mapper;
+
+import com.diboot.core.mapper.BaseCrudMapper;
+import diboot.core.test.binder.entity.PetAdopt;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* 领养 相关Mapper层接口定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+@Mapper
+public interface PetAdoptMapper extends BaseCrudMapper {
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/mapper/PetMapper.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/mapper/PetMapper.java
new file mode 100644
index 000000000..8a862975a
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/mapper/PetMapper.java
@@ -0,0 +1,17 @@
+package diboot.core.test.binder.mapper;
+
+import com.diboot.core.mapper.BaseCrudMapper;
+import diboot.core.test.binder.entity.Pet;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* 宠物 相关Mapper层接口定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+@Mapper
+public interface PetMapper extends BaseCrudMapper {
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/service/PetAdoptService.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/PetAdoptService.java
new file mode 100644
index 000000000..1b2ef6837
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/PetAdoptService.java
@@ -0,0 +1,16 @@
+package diboot.core.test.binder.service;
+
+
+import com.diboot.core.service.BaseService;
+import diboot.core.test.binder.entity.PetAdopt;
+
+/**
+* 领养 相关Service接口定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+public interface PetAdoptService extends BaseService {
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/service/PetService.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/PetService.java
new file mode 100644
index 000000000..9cbdd4643
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/PetService.java
@@ -0,0 +1,15 @@
+package diboot.core.test.binder.service;
+
+import com.diboot.core.service.BaseService;
+import diboot.core.test.binder.entity.Pet;
+
+/**
+* 宠物 相关Service接口定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+public interface PetService extends BaseService {
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/service/impl/PetAdoptServiceImpl.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/impl/PetAdoptServiceImpl.java
new file mode 100644
index 000000000..837a8fee3
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/impl/PetAdoptServiceImpl.java
@@ -0,0 +1,21 @@
+package diboot.core.test.binder.service.impl;
+
+import com.diboot.core.service.impl.BaseServiceImpl;
+import diboot.core.test.binder.entity.PetAdopt;
+import diboot.core.test.binder.mapper.PetAdoptMapper;
+import diboot.core.test.binder.service.PetAdoptService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+* 领养 相关Service实现类
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+@Slf4j
+@Service
+public class PetAdoptServiceImpl extends BaseServiceImpl implements PetAdoptService {
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/service/impl/PetServiceImpl.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/impl/PetServiceImpl.java
new file mode 100644
index 000000000..9541e4255
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/service/impl/PetServiceImpl.java
@@ -0,0 +1,21 @@
+package diboot.core.test.binder.service.impl;
+
+import com.diboot.core.service.impl.BaseServiceImpl;
+import diboot.core.test.binder.entity.Pet;
+import diboot.core.test.binder.mapper.PetMapper;
+import diboot.core.test.binder.service.PetService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+* 宠物 相关Service实现类
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+@Slf4j
+@Service
+public class PetServiceImpl extends BaseServiceImpl implements PetService {
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/vo/PetAdoptListVO.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/vo/PetAdoptListVO.java
new file mode 100644
index 000000000..f3d73c57f
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/vo/PetAdoptListVO.java
@@ -0,0 +1,27 @@
+package diboot.core.test.binder.vo;
+
+import com.diboot.core.binding.annotation.BindEntityList;
+import com.diboot.core.binding.annotation.BindField;
+import diboot.core.test.binder.entity.Pet;
+import diboot.core.test.binder.entity.PetAdopt;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+* 领养 VO定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+@Getter @Setter @Accessors(chain = true)
+public class PetAdoptListVO extends PetAdopt {
+private static final long serialVersionUID = 1900231745123606236L;
+
+ @BindEntityList(entity = Pet.class, condition = "this.pet_category=category AND this.pet_code=code")
+ private List pets;
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/binder/vo/PetListVO.java b/diboot-core-starter/src/test/java/diboot/core/test/binder/vo/PetListVO.java
new file mode 100644
index 000000000..79e4a09e9
--- /dev/null
+++ b/diboot-core-starter/src/test/java/diboot/core/test/binder/vo/PetListVO.java
@@ -0,0 +1,27 @@
+package diboot.core.test.binder.vo;
+
+import com.diboot.core.binding.annotation.BindDict;
+import com.diboot.core.binding.annotation.BindField;
+import com.diboot.core.vo.LabelValue;
+import diboot.core.test.binder.entity.Pet;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+/**
+* 宠物 VO定义
+* @author MyName
+* @version 1.0
+* @date 2024-09-03
+* Copyright © MyCorp
+*/
+@Getter @Setter @Accessors(chain = true)
+public class PetListVO extends Pet {
+private static final long serialVersionUID = 1125570722268444471L;
+ /**
+ * 品类 关联字典选项
+ */
+ @BindDict(type = "PET_CATEGORY", field = "category")
+ private LabelValue categoryLabel;
+
+}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/config/SpringMvcConfig.java b/diboot-core-starter/src/test/java/diboot/core/test/config/SpringMvcConfig.java
index f15901471..14be65383 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/config/SpringMvcConfig.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/config/SpringMvcConfig.java
@@ -19,6 +19,7 @@
import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.diboot.core.converter.*;
+import com.diboot.core.data.access.DataScopeManager;
import com.diboot.core.data.protect.DataEncryptHandler;
import com.diboot.core.data.protect.DataMaskHandler;
import com.diboot.core.data.protect.DefaultDataEncryptHandler;
@@ -36,6 +37,7 @@
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
+import diboot.core.test.binder.DataAccessPermissionTestImplForDepartment;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,6 +49,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -60,9 +63,10 @@
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
+import java.util.List;
import java.util.TimeZone;
-/***
+/**
* Spring配置文件
* @author mazc@dibo.ltd
* @version v2.0
@@ -74,7 +78,6 @@
public class SpringMvcConfig implements WebMvcConfigurer {
private static final Logger log = LoggerFactory.getLogger(SpringMvcConfig.class);
-
@Value("${spring.jackson.date-format:"+D.FORMAT_DATETIME_Y4MDHMS+"}")
private String defaultDatePattern;
@@ -169,19 +172,10 @@ public DataMaskHandler dataMaskHandler() {
*/
@Override
public void addFormatters(FormatterRegistry registry) {
- registry.addConverter(new Date2LocalDateConverter());
- registry.addConverter(new Date2LocalDateTimeConverter());
- registry.addConverter(new LocalDate2DateConverter());
- registry.addConverter(new LocalDateTime2DateConverter());
- registry.addConverter(new LocalDateTime2StringConverter());
- registry.addConverter(new SqlDate2LocalDateConverter());
- registry.addConverter(new SqlDate2LocalDateTimeConverter());
- registry.addConverter(new String2DateConverter());
- registry.addConverter(new String2LocalDateConverter());
- registry.addConverter(new String2LocalDateTimeConverter());
- registry.addConverter(new String2BooleanConverter());
- registry.addConverter(new String2MapConverter());
- registry.addConverter(new Timestamp2LocalDateTimeConverter());
+ List converterList = ContextHolder.getBeans(Converter.class);
+ if (converterList != null && !converterList.isEmpty()) {
+ converterList.forEach(registry::addConverter);
+ }
}
/**
@@ -196,4 +190,17 @@ public MybatisPlusInterceptor mybatisPlusInterceptor() {
return interceptor;
}
+ @Bean
+ public DataAccessControlHandler dataAccessControlHandler() {
+ return new DataAccessControlHandler();
+ }
+
+ /**
+ * 通过spring初始化一个实例
+ * @return
+ */
+ @Bean
+ public DataScopeManager dataScopeManager() {
+ return new DataAccessPermissionTestImplForDepartment();
+ }
}
\ No newline at end of file
diff --git a/diboot-core-starter/src/test/java/diboot/core/test/service/BaseServiceTest.java b/diboot-core-starter/src/test/java/diboot/core/test/service/BaseServiceTest.java
index 57bbdc9f9..e3ab4e942 100644
--- a/diboot-core-starter/src/test/java/diboot/core/test/service/BaseServiceTest.java
+++ b/diboot-core-starter/src/test/java/diboot/core/test/service/BaseServiceTest.java
@@ -27,6 +27,7 @@
import com.diboot.core.binding.cache.BindingCacheManager;
import com.diboot.core.binding.parser.EntityInfoCache;
import com.diboot.core.binding.query.dynamic.ExtQueryWrapper;
+import com.diboot.core.cache.DictionaryCacheManager;
import com.diboot.core.config.BaseConfig;
import com.diboot.core.config.Cons;
import com.diboot.core.data.access.DataScopeManager;
@@ -70,6 +71,9 @@ public class BaseServiceTest {
@Autowired
DictionaryServiceExtImpl dictionaryService;
+ @Autowired
+ DictionaryCacheManager dictionaryCacheManager;
+
@Autowired
UserService userService;
@@ -86,6 +90,8 @@ public class BaseServiceTest {
RegionService regionService;
@Autowired
private UserRoleMapper userRoleMapper;
+ @Autowired
+ DataScopeManager dataScopeManager;
@Test
public void testGet(){
@@ -546,8 +552,7 @@ public void testDictExtdata(){
@Test
public void testGetEntityList(){
- DataScopeManager checkImpl = ContextHolder.getBean(DataScopeManager.class);
- Assert.assertTrue(checkImpl != null);
+ Assert.assertTrue(dataScopeManager != null);
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.select("id", "item_name", "item_value")
.eq("id", -1L);
@@ -642,4 +647,72 @@ public void testDeleteEntityAndRelations() {
userRoles = userRoleMapper.selectList(queryWrapper);
Assert.assertTrue(V.isEmpty(userRoles));
}
+
+
+ /**
+ * 测试字典缓存
+ */
+ @Transactional
+ @Test
+ public void testDictionaryCache(){
+ // 创建
+ String TYPE = "ID_TYPE";
+ // 定义
+ DictionaryVO dictionary = new DictionaryVO();
+ dictionary.setType(TYPE);
+ dictionary.setItemName("证件类型");
+ dictionary.setParentId(Cons.ID_PREVENT_NULL);
+ dictionary.setCreateTime(LocalDateTime.now());
+ // 子项
+ List dictionaryList = new ArrayList<>();
+ String[] itemNames = {"身份证", "驾照", "护照"}, itemValues = {"SFZ","JZ","HZ"};
+ for(int i=0; i labelValueList = dictionaryService.getLabelValueList(TYPE);
+ Assert.assertTrue(labelValueList != null && labelValueList.size() == itemNames.length);
+ // 检查缓存
+ List cacheList = dictionaryCacheManager.getCachedItems(TYPE);
+ Assert.assertTrue(cacheList != null && cacheList.size() == itemNames.length);
+
+ Dictionary dict = new Dictionary();
+ dict.setType(TYPE);
+ dict.setItemName("追加");
+ dict.setItemValue("ZJ");
+ dict.setParentId(dictionary.getId());
+ dict.setCreateTime(LocalDateTime.now());
+
+ dictionaryService.createEntity(dict);
+ // 检查缓存
+ cacheList = dictionaryCacheManager.getCachedItems(TYPE);
+ Assert.assertTrue(cacheList == null);
+
+ dict.setItemValue("追加测试");
+ dict.setItemName("ZJCS");
+ dictionary.getChildren().add(dict);
+ dictionaryService.updateDictAndChildren(dictionary);
+ // 检查缓存
+ cacheList = dictionaryCacheManager.getCachedItems(TYPE);
+ Assert.assertTrue(cacheList == null);
+
+ dictionaryService.getLabelValueList(TYPE);
+ // 检查缓存
+ cacheList = dictionaryCacheManager.getCachedItems(TYPE);
+ Assert.assertTrue(cacheList != null && cacheList.size() > itemNames.length);
+
+ dictionaryService.deleteDictAndChildren(dictionary.getId());
+ // 检查缓存
+ cacheList = dictionaryCacheManager.getCachedItems(TYPE);
+ Assert.assertTrue(cacheList == null);
+ }
+
}
diff --git a/diboot-core-starter/src/test/resources/unittest-mysql.sql b/diboot-core-starter/src/test/resources/unittest-mysql.sql
index 16e9e6396..cfec9d97c 100644
--- a/diboot-core-starter/src/test/resources/unittest-mysql.sql
+++ b/diboot-core-starter/src/test/resources/unittest-mysql.sql
@@ -188,6 +188,33 @@ CREATE TABLE `status_info` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='问题状态';
+-- 宠物及领养表,验证非id的多字段关联条件绑定
+CREATE TABLE `mdl_pet` (
+ `id` varchar(32) NOT NULL COMMENT '唯一标识',
+ `category` varchar(20) DEFAULT NULL COMMENT '品类',
+ `code` varchar(100) DEFAULT NULL COMMENT '编号',
+ `remark` varchar(100) DEFAULT NULL COMMENT '备注',
+ `is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT '是否删除',
+ `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+ `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+ `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+ `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='宠物';
+CREATE TABLE `mdl_pet_adopt` (
+ `id` varchar(32) NOT NULL COMMENT '唯一标识',
+ `realname` varchar(100) DEFAULT NULL COMMENT '姓名',
+ `pet_category` varchar(100) DEFAULT NULL COMMENT '宠物品类',
+ `pet_code` varchar(100) DEFAULT NULL COMMENT '宠物编号',
+ `remark` varchar(100) DEFAULT NULL COMMENT '备注',
+ `is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT '是否删除',
+ `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+ `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+ `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+ `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='领养';
+
INSERT INTO customer (id, realname, cellphone, extjsonarr)
VALUES (10001, '张三', '13800001111', '["WEBSOCKET","EMAIL"]'), (10002, '李四', '13800002222', '["TEXT_MESSAGE"]');
@@ -266,3 +293,6 @@ INSERT INTO region (`id`, `name`, `code`, `parent_id`, `level`) values('3197','
UPDATE region SET `parent_ids_path` = '0' WHERE `parent_id` = '0';
UPDATE region SET `parent_ids_path` = '0,1' WHERE `parent_id` = '1';
UPDATE region SET `parent_ids_path` = '0,1,2' WHERE `parent_id` = '2';
+
+INSERT INTO mdl_pet (id, category, code, remark, is_deleted) VALUES ('1000001', 'CAT', '#1', '1号猫咪', 0), ('1000002', 'DOG', '#1', '1号狗狗', 0), ('1000003', 'CAT', '#2', '2号猫咪', 0), ('1000004', 'DOG', '#2', '2号狗狗', 0), ('1000005', 'DOG', '#3', '3号狗狗', 0);
+INSERT INTO mdl_pet_adopt (id, realname, pet_category, pet_code, remark, is_deleted) VALUES('122222221', '张三', 'CAT', '#1', '张三领养1号猫', 0), ('122222222', '张三', 'DOG', '#2', '张三领养2号狗', 0), ('122222223', '李四', 'CAT', '#2', '李四领养2号猫', 0);
diff --git a/diboot-core/pom.xml b/diboot-core/pom.xml
index 0dd605928..189ad0429 100644
--- a/diboot-core/pom.xml
+++ b/diboot-core/pom.xml
@@ -7,11 +7,11 @@
com.diboot
diboot-root
- 3.4.0
+ 3.5.0
diboot-core
- 3.4.0
+ 3.5.0
jar
diboot core project
@@ -54,12 +54,12 @@
org.mybatis
mybatis-spring
- 3.0.3
+ 3.0.4
org.apache.commons
commons-lang3
- 3.14.0
+ 3.17.0
commons-io
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/JoinsBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/JoinsBinder.java
index ff6c9ddaf..d44ff56f6 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/JoinsBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/JoinsBinder.java
@@ -167,7 +167,7 @@ private static List executeJoinQuery(QueryWrapper queryWrapper,
}
// 绑定map到entity
try{
- T entityInst = entityClazz.newInstance();
+ T entityInst = entityClazz.getConstructor().newInstance();
BeanUtils.bindProperties(entityInst, fieldValueMap);
entityList.add(entityInst);
}
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/QueryBuilder.java b/diboot-core/src/main/java/com/diboot/core/binding/QueryBuilder.java
index d4edd0f77..c4778ce9e 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/QueryBuilder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/QueryBuilder.java
@@ -169,7 +169,7 @@ private static QueryWrapper> dtoToWrapper(DTO dto, Collection fi
// 转换
LinkedHashMap fieldValuesMap = extractNotNullValues(dto, fields, pagination);
if (V.isEmpty(fieldValuesMap)) {
- return new QueryWrapper<>();
+ return new ExtQueryWrapper<>();
}
// 只解析有值的
fields = fieldValuesMap.keySet();
@@ -205,7 +205,17 @@ private static QueryWrapper> dtoToWrapper(DTO dto, Collection fi
// 获取Class类型
Function> getClass = bindQuery -> bindQuery == null || bindQuery.entity() == NullType.class ? dto.getClass() : bindQuery.entity();
// 获取属性名类型
- BiFunction getFieldName = (bindQuery, defFieldName) -> bindQuery == null || S.isEmpty(bindQuery.column()) ? defFieldName : bindQuery.column();
+ BiFunction getFieldName = (bindQuery, defFieldName) ->{
+ if(bindQuery != null) {
+ if(V.notEmpty(bindQuery.field())) {
+ return bindQuery.field();
+ }
+ if (V.notEmpty(bindQuery.column())) {
+ return S.toLowerCaseCamel(bindQuery.column());
+ }
+ }
+ return defFieldName;
+ };
// 保护字段处理器
DataEncryptHandler protectFieldHandler = ContextHolder.getBean(DataEncryptHandler.class);
// 构建QueryWrapper
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/RelationsBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/RelationsBinder.java
index 0d090b00f..e1e75f262 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/RelationsBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/RelationsBinder.java
@@ -20,6 +20,7 @@
import com.diboot.core.binding.parser.BindAnnotationGroup;
import com.diboot.core.binding.parser.FieldAnnotation;
import com.diboot.core.binding.parser.ParserCache;
+import com.diboot.core.service.I18nConfigService;
import com.diboot.core.util.BeanUtils;
import com.diboot.core.util.ContextHolder;
import com.diboot.core.util.V;
@@ -138,7 +139,6 @@ public static void bind(List voList, boolean enableDeepBind){
}
// 绑定Entity实体
List entityAnnoList = bindAnnotationGroup.getBindEntityAnnotations();
-
if(entityAnnoList != null){
for(FieldAnnotation anno : entityAnnoList){
// 绑定关联对象entity
@@ -173,12 +173,15 @@ public static void bind(List voList, boolean enableDeepBind){
binderFutures.add(bindCountFuture);
}
}
- // 绑定国际化翻译
- List i18nAnnoList = bindAnnotationGroup.getBindI18nAnnotations();
- if(i18nAnnoList != null){
- for(FieldAnnotation anno : i18nAnnoList){
- // 绑定关联对象count计数
- parallelBindingManager.doBindingI18n(voList, anno);
+ // 开启国际化
+ if(isEnableI18N()) {
+ // 绑定国际化翻译
+ List i18nAnnoList = bindAnnotationGroup.getBindI18nAnnotations();
+ if(i18nAnnoList != null){
+ for(FieldAnnotation anno : i18nAnnoList){
+ // 绑定关联对象count计数
+ parallelBindingManager.doBindingI18n(voList, anno);
+ }
}
}
// 执行绑定
@@ -203,4 +206,19 @@ public static void bind(List voList, boolean enableDeepBind){
}
}
+ /**
+ * 是否启用 i18n
+ * @return
+ */
+ private static Boolean ENABLE_I18N = null;
+ private static boolean isEnableI18N() {
+ if(ENABLE_I18N == null){
+ ENABLE_I18N = ContextHolder.getBean(I18nConfigService.class) != null;
+ if(ENABLE_I18N){
+ log.info("启用 i8n 国际化翻译转换");
+ }
+ }
+ return ENABLE_I18N;
+ }
+
}
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindCount.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindCount.java
index b2f6a8f7b..662931e09 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindCount.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindCount.java
@@ -29,13 +29,13 @@
@Inherited
@Documented
public @interface BindCount {
- /***
+ /**
* 绑定的Entity类
* @return
*/
Class entity();
- /***
+ /**
* JOIN连接条件
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindDict.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindDict.java
index 9413e39d6..85e23d53c 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindDict.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindDict.java
@@ -29,13 +29,13 @@
@Documented
public @interface BindDict {
- /***
+ /**
* 绑定数据字典类型
* @return
*/
String type();
- /***
+ /**
* 数据字典项取值字段
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntity.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntity.java
index b6d1450fb..1ffadaad1 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntity.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntity.java
@@ -28,13 +28,13 @@
@Inherited
@Documented
public @interface BindEntity {
- /***
+ /**
* 对应的service类
* @return
*/
Class entity();
- /***
+ /**
* JOIN连接条件
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntityList.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntityList.java
index edfd8c29b..762c8d322 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntityList.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindEntityList.java
@@ -28,13 +28,13 @@
@Inherited
@Documented
public @interface BindEntityList {
- /***
+ /**
* 对应的entity类
* @return
*/
Class entity();
- /***
+ /**
* JOIN连接条件
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindField.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindField.java
index 4c6d9b92a..58a85667a 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindField.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindField.java
@@ -28,19 +28,19 @@
@Inherited
@Documented
public @interface BindField {
- /***
+ /**
* 绑定的Entity类
* @return
*/
Class entity();
- /***
+ /**
* 绑定字段
* @return
*/
String field();
- /***
+ /**
* JOIN连接条件
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindFieldList.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindFieldList.java
index 5e2f71407..7cd94cb83 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindFieldList.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/BindFieldList.java
@@ -28,19 +28,19 @@
@Inherited
@Documented
public @interface BindFieldList {
- /***
+ /**
* 绑定的Entity类
* @return
*/
Class entity();
- /***
+ /**
* 绑定字段
* @return
*/
String field();
- /***
+ /**
* JOIN连接条件
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/annotation/Module.java b/diboot-core/src/main/java/com/diboot/core/binding/annotation/Module.java
index ca3a5dece..29ac3eced 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/annotation/Module.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/annotation/Module.java
@@ -29,7 +29,7 @@
@Documented
public @interface Module {
- /***
+ /**
* 指定模块名
* @return
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/BaseBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/BaseBinder.java
index c06188fe0..646ae2afc 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/BaseBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/BaseBinder.java
@@ -46,19 +46,19 @@
*/
public abstract class BaseBinder {
private static final Logger log = LoggerFactory.getLogger(BaseBinder.class);
- /***
+ /**
* 需要绑定到的VO注解对象List
*/
protected List> annoObjectList;
- /***
+ /**
* VO注解对象中的join on对象列名集合
*/
protected List annoObjJoinCols;
- /***
+ /**
* VO注解对象中的join on对象附加过滤条件
*/
protected List annoObjJoinFieldComparisons;
- /***
+ /**
* DO对象中的关联join on对象列名集合
*/
protected List refObjJoinCols;
@@ -106,7 +106,7 @@ public abstract class BaseBinder {
*/
protected RemoteBindDTO remoteBindDTO;
- /***
+ /**
* 构造方法
* @param entityClass
* @param voList
@@ -302,7 +302,7 @@ public List getRefObjJoinCols(){
return this.refObjJoinCols;
}
- /***
+ /**
* 执行绑定, 交由子类实现
*/
public abstract void bind();
@@ -568,7 +568,7 @@ private Object formatValue(String fieldName, Object value){
return value;
}
- /***
+ /**
* 筛选list
* @param objectList
* @param filterConditions 附加过滤条件
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/CountBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/CountBinder.java
index a7c95b28d..905a3fc0f 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/CountBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/CountBinder.java
@@ -39,7 +39,7 @@
public class CountBinder extends EntityListBinder {
private static final Logger log = LoggerFactory.getLogger(CountBinder.class);
- /***
+ /**
* 构造方法
* @param annotation
* @param voList
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityBinder.java
index d24929e5e..2f6e13486 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityBinder.java
@@ -43,16 +43,16 @@
public class EntityBinder extends BaseBinder {
private static final Logger log = LoggerFactory.getLogger(EntityBinder.class);
- /***
+ /**
* 给待绑定list中VO对象赋值的setter属性名
*/
protected String annoObjectField;
- /***
+ /**
* 给待绑定list中VO对象赋值的setter属性class类型
*/
protected Class> annoObjectFieldClass;
- /***
+ /**
* 构造方法
* @param entityClass
* @param voList
@@ -61,7 +61,7 @@ public EntityBinder(Class entityClass, List voList){
super(entityClass, voList);
}
- /***
+ /**
* 构造方法
* @param annotation
* @param voList
@@ -70,7 +70,7 @@ public EntityBinder(BindEntity annotation, List voList){
super(annotation.entity(), voList);
}
- /***
+ /**
* 指定VO绑定属性赋值的setter方法
* @param voSetter VO中调用赋值的setter方法
* @param VO类型
@@ -81,7 +81,7 @@ public BaseBinder set(ISetter voSetter, Class annoObjectFieldCl
return set(BeanUtils.convertToFieldName(voSetter), annoObjectFieldClass);
}
- /***
+ /**
* 指定VO绑定属性赋值的set属性
* @param annoObjectField VO中调用赋值的setter属性
* @return
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityListBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityListBinder.java
index 2dbd100f2..ebcf83729 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityListBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/EntityListBinder.java
@@ -37,7 +37,7 @@
public class EntityListBinder extends EntityBinder {
private static final Logger log = LoggerFactory.getLogger(EntityListBinder.class);
- /***
+ /**
* 构造方法
* @param annotation
* @param voList
@@ -52,7 +52,7 @@ public EntityListBinder(BindEntityList annotation, List voList){
}
}
- /***
+ /**
* 构造方法
* @param entityClass
* @param voList
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldBinder.java
index 5163fea3e..ef8abc192 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldBinder.java
@@ -45,7 +45,7 @@ public class FieldBinder extends BaseBinder {
*/
protected List referencedGetterFieldNameList;
- /***
+ /**
* 构造方法
* @param entityClass
* @param voList
@@ -54,7 +54,7 @@ public FieldBinder(Class entityClass, List voList){
super(entityClass, voList);
}
- /***
+ /**
* 构造方法
* @param annotation
* @param voList
@@ -63,7 +63,7 @@ public FieldBinder(BindField annotation, List voList){
super(annotation.entity(), voList);
}
- /***
+ /**
* 指定VO绑定属性赋值的setter和DO/Entity取值的getter方法
* @param toVoSetter VO中调用赋值的setter方法
* @param VO类型
@@ -75,7 +75,7 @@ public FieldBinder link(IGetter fromDoGetter, ISetter to
return link(BeanUtils.convertToFieldName(fromDoGetter), BeanUtils.convertToFieldName(toVoSetter));
}
- /***
+ /**
* 指定VO绑定赋值的setter属性名和DO/Entity取值的getter属性名
* @param toVoField VO中调用赋值的setter属性名
* @return
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldListBinder.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldListBinder.java
index 623386fa4..4b9f4eb8d 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldListBinder.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/FieldListBinder.java
@@ -40,7 +40,7 @@
public class FieldListBinder extends FieldBinder {
private static final Logger log = LoggerFactory.getLogger(FieldListBinder.class);
- /***
+ /**
* 构造方法
* @param annotation
* @param voList
@@ -164,7 +164,7 @@ else if(V.notEmpty(splitBy) && valStr.contains(splitBy)){
}
}
- /***
+ /**
* 从对象集合提取某个属性值到list中
* @param fromList
* @param trunkObjColMapping
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/binder/parallel/ParallelBindingManager.java b/diboot-core/src/main/java/com/diboot/core/binding/binder/parallel/ParallelBindingManager.java
index 69362db0e..1df3bfd49 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/binder/parallel/ParallelBindingManager.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/binder/parallel/ParallelBindingManager.java
@@ -70,7 +70,7 @@ public void doBindingDict(List voList, FieldAnnotation fieldAnno){
}
}
- /***
+ /**
* 绑定Field
* @param voList
* @param fieldAnnotations
@@ -87,7 +87,7 @@ public CompletableFuture doBindingField(List voList, List doBindingFieldList(List voList, List doBindingEntity(List voList, FieldAnnotation f
return doBinding(binder, annotation.condition());
}
- /***
+ /**
* 绑定EntityList
* @param voList
* @param fieldAnnotation
@@ -135,7 +135,7 @@ public CompletableFuture doBindingEntityList(List voList, FieldAnnotati
return doBinding(binder, annotation.condition());
}
- /***
+ /**
* 绑定count计数
* @param voList
* @param fieldAnnotation
@@ -164,7 +164,7 @@ public void doBindingI18n(List voList, FieldAnnotation fieldAnnotation) {
// 国际化绑定接口化
i18nConfigService.bindI18nContent(voList, i18nCodeField, fieldAnnotation.getFieldName());
} else {
- log.debug("I18nConfigService未初始化,无法翻译I18n注解: {}", i18nCodeField);
+ log.warn("I18nConfigService未初始化,无法翻译I18n注解: {}", i18nCodeField);
}
}
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/cache/BindingCacheManager.java b/diboot-core/src/main/java/com/diboot/core/binding/cache/BindingCacheManager.java
index 6561cdf47..e84a38041 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/cache/BindingCacheManager.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/cache/BindingCacheManager.java
@@ -218,7 +218,7 @@ public static Map getFieldsMap(Class> beanClazz) {
Set uniqueEntitySet = new HashSet<>();
if (V.notEmpty(serviceMap)) {
for (Map.Entry entry : serviceMap.entrySet()) {
- Class entityClass = BeanUtils.getGenericityClass(entry.getValue(), 1);
+ Class entityClass = entry.getValue().getEntityClass();
if (entityClass != null) {
IService entityIService = entry.getValue();
if (uniqueEntitySet.contains(entityClass.getName())) {
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/helper/ResultAssembler.java b/diboot-core/src/main/java/com/diboot/core/binding/helper/ResultAssembler.java
index 12dd30c17..51b99bc24 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/helper/ResultAssembler.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/helper/ResultAssembler.java
@@ -34,7 +34,7 @@
@Slf4j
public class ResultAssembler {
- /***
+ /**
* 从对象集合提取某个属性值到list中
* @param setterFieldName
* @param fromList
@@ -92,7 +92,7 @@ public static void bindCountPropValue(String setterFieldName, List fromLi
}
}
- /***
+ /**
* 从对象集合提取某个属性值到list中
* @param setterFieldName
* @param fromList
@@ -168,7 +168,7 @@ public static void bindPropValue(String setterFieldName, List fromList, S
}
}
- /***
+ /**
* 从对象集合提取某个属性值到list中
* @param setterFieldName
* @param fromList
@@ -215,7 +215,7 @@ public static void bindEntityPropValue(String setterFieldName, List fromL
}
- /***
+ /**
* 从对象集合提取某个属性值到list中
* @param fromList
* @param getterFields
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/parser/BindAnnotationGroup.java b/diboot-core/src/main/java/com/diboot/core/binding/parser/BindAnnotationGroup.java
index 4442bb596..be263f5db 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/parser/BindAnnotationGroup.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/parser/BindAnnotationGroup.java
@@ -87,14 +87,7 @@ public void addBindAnnotation(String fieldName, Class> fieldClass, Annotation
bindDictAnnotations = new ArrayList<>(4);
}
bindDictAnnotations.add(fieldAnnotation);
- if(!requireSequential && bindFieldGroupMap != null){
- // 是否存在重复的字段
- // 只要任意一个符合条件,即可结束遍历
- requireSequential = bindFieldGroupMap.values().stream().anyMatch(list ->
- list.stream().anyMatch(item ->
- item.getFieldName().equals(fieldName) && item.getFieldClass().equals(fieldClass)
- ));
- }
+ requireSequential = true;
return;
}
String key = null;
@@ -126,12 +119,6 @@ else if (annotation instanceof BindEntity) {
}
List list = bindFieldGroupMap.computeIfAbsent(key, k -> new ArrayList<>(4));
list.add(fieldAnnotation);
- if(!requireSequential && bindDictAnnotations != null){
- // 是否存在重复的字段
- requireSequential = bindDictAnnotations.stream().anyMatch(item ->
- item.getFieldName().equals(fieldName) && item.getFieldClass().equals(fieldClass)
- );
- }
}
else if(annotation instanceof BindEntity){
if(bindEntityAnnotations == null){
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/parser/ConditionParser.java b/diboot-core/src/main/java/com/diboot/core/binding/parser/ConditionParser.java
index 743bd28e3..21258465d 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/parser/ConditionParser.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/parser/ConditionParser.java
@@ -15,19 +15,13 @@
*/
package com.diboot.core.binding.parser;
-import com.diboot.core.util.S;
-import com.diboot.core.util.V;
+import com.diboot.core.exception.InvalidUsageException;
import net.sf.jsqlparser.expression.*;
-import net.sf.jsqlparser.expression.operators.arithmetic.*;
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
import net.sf.jsqlparser.expression.operators.conditional.XorExpression;
import net.sf.jsqlparser.expression.operators.relational.*;
import net.sf.jsqlparser.schema.Column;
-import net.sf.jsqlparser.statement.select.AllColumns;
-import net.sf.jsqlparser.statement.select.AllTableColumns;
-import net.sf.jsqlparser.statement.select.ParenthesedSelect;
-import net.sf.jsqlparser.statement.select.Select;
import java.util.ArrayList;
import java.util.List;
@@ -38,25 +32,20 @@
* @version v2.0
* @date 2019/3/30
*/
-public class ConditionParser implements ExpressionVisitor {
+public class ConditionParser extends ExpressionVisitorAdapter {
+
+ private List expressList = new ArrayList<>(4);
public ConditionParser() {
+ this.expressList.clear();
}
- private List errorMsgList = null;
- private List expressList = new ArrayList<>(4);
-
/**
* 添加错误信息
* @param errorMsg
*/
- private void addError(String errorMsg){
- if(errorMsgList == null){
- errorMsgList = new ArrayList<>();
- }
- if(!errorMsgList.contains(errorMsg)){
- errorMsgList.add(errorMsg);
- }
+ private void throwError(String errorMsg) {
+ throw new InvalidUsageException(errorMsg);
}
/**
@@ -64,403 +53,119 @@ private void addError(String errorMsg){
* @return
* @throws Exception
*/
- public List getExpressList() throws Exception{
- if(V.notEmpty(errorMsgList)){
- throw new Exception(S.join(errorMsgList, "; "));
- }
+ public List getExpressList() {
return expressList;
}
@Override
- public void visit(AndExpression andExpression) {
+ public Void visit(AndExpression andExpression, Object o) {
andExpression.getLeftExpression().accept(this);
andExpression.getRightExpression().accept(this);
+ return null;
}
// ----- 支持的条件
@Override
- public void visit(EqualsTo equalsTo) {
+ public Void visit(EqualsTo equalsTo, Object o) {
if(!(equalsTo.getLeftExpression() instanceof Column)){
- addError("=条件左侧必须为字段/列名");
+ throwError("= 条件左侧必须为字段/列名");
}
expressList.add(equalsTo);
- }
- @Override
- public void visit(NotEqualsTo notEqualsTo) {
- if(!(notEqualsTo.getLeftExpression() instanceof Column)){
- addError("!=条件左侧必须为字段/列名");
- }
- expressList.add(notEqualsTo);
- }
-
- @Override
- public void visit(DoubleAnd doubleAnd) {
-
+ return null;
}
@Override
- public void visit(Contains contains) {
-
- }
-
- @Override
- public void visit(ContainedBy containedBy) {
-
+ public Void visit(GreaterThan greaterThan, Object o) {
+ if(!(greaterThan.getLeftExpression() instanceof Column)){
+ throwError("> 条件左侧必须为字段/列名");
+ }
+ expressList.add(greaterThan);
+ return null;
}
@Override
- public void visit(ParenthesedSelect parenthesedSelect) {
-
+ public Void visit(NotEqualsTo notEqualsTo, Object o) {
+ if(!(notEqualsTo.getLeftExpression() instanceof Column)){
+ throwError("!= 条件左侧必须为字段/列名");
+ }
+ expressList.add(notEqualsTo);
+ return null;
}
@Override
- public void visit(GreaterThan greaterThan) {
- if(!(greaterThan.getLeftExpression() instanceof Column)){
- addError(">条件左侧必须为字段/列名");
+ public Void visit(GreaterThanEquals greaterThanEquals, Object o) {
+ if(!(greaterThanEquals.getLeftExpression() instanceof Column)){
+ throwError(">= 条件左侧必须为字段/列名");
}
- expressList.add(greaterThan);
+ expressList.add(greaterThanEquals);
+ return null;
}
+
@Override
- public void visit(GreaterThanEquals greaterThanEquals) {
- if(!(greaterThanEquals.getLeftExpression() instanceof Column)){
- addError(">=条件左侧必须为字段/列名");
+ public Void visit(InExpression inExpression, Object o) {
+ if(!(inExpression.getLeftExpression() instanceof Column)){
+ throwError("IN 条件左侧必须为字段/列名");
}
- expressList.add(greaterThanEquals);
+ expressList.add(inExpression);
+ return null;
}
+
@Override
- public void visit(MinorThan minorThan) {
+ public Void visit(MinorThan minorThan, Object o) {
if(!(minorThan.getLeftExpression() instanceof Column)){
- addError("<条件左侧必须为字段/列名");
+ throwError("< 条件左侧必须为字段/列名");
}
expressList.add(minorThan);
+ return null;
}
+
@Override
- public void visit(MinorThanEquals minorThanEquals) {
+ public Void visit(MinorThanEquals minorThanEquals, Object o) {
if(!(minorThanEquals.getLeftExpression() instanceof Column)){
- addError("<=条件左侧必须为字段/列名");
+ throwError("<= 条件左侧必须为字段/列名");
}
expressList.add(minorThanEquals);
+ return null;
}
+
@Override
- public void visit(IsNullExpression isNullExpression) {
+ public Void visit(IsNullExpression isNullExpression, Object o) {
if(!(isNullExpression.getLeftExpression() instanceof Column)){
- addError("IsNull条件左侧必须为字段/列名");
+ throwError("Is Null 条件左侧必须为字段/列名");
}
expressList.add(isNullExpression);
+ return null;
}
@Override
- public void visit(IsBooleanExpression isBooleanExpression) {
-
- }
-
- @Override
- public void visit(InExpression inExpression) {
- if(!(inExpression.getLeftExpression() instanceof Column)){
- addError("IN条件左侧必须为字段/列名");
+ public Void visit(LikeExpression likeExpression, Object o) {
+ if(!(likeExpression.getLeftExpression() instanceof Column)){
+ throwError("Like 条件左侧必须为字段/列名");
}
- expressList.add(inExpression);
- }
-
- @Override
- public void visit(FullTextSearch fullTextSearch) {
-
+ expressList.add(likeExpression);
+ return null;
}
@Override
- public void visit(Between between) {
+ public Void visit(Between between, Object o) {
if(!(between.getLeftExpression() instanceof Column)){
- addError("Between条件左侧必须为字段/列名");
+ throwError("Between 条件左侧必须为字段/列名");
}
expressList.add(between);
- }
-
- @Override
- public void visit(OverlapsCondition overlapsCondition) {
-
- }
-
- @Override
- public void visit(LikeExpression likeExpression) {
- if(!(likeExpression.getLeftExpression() instanceof Column)){
- addError("Like条件左侧必须为字段/列名");
- }
- expressList.add(likeExpression);
+ return null;
}
//------- 暂不支持的条件
@Override
- public void visit(OrExpression orExpression) {
- addError("暂不支持 OR 关联条件");
- }
-
- @Override
- public void visit(XorExpression xorExpression) {
- addError("暂不支持 XOR 关联条件");
- }
-
- // ------ 忽略的条件
- @Override
- public void visit(Column tableColumn) {
- }
-
- @Override
- public void visit(ExpressionList expressionList) {
- }
-
-
- @Override
- public void visit(CaseExpression caseExpression) {
- }
- @Override
- public void visit(WhenClause whenClause) {
- }
- @Override
- public void visit(ExistsExpression existsExpression) {
+ public Void visit(OrExpression orExpression, Object o) {
+ throwError("暂不支持 OR 连接条件: " + orExpression.toString());
+ return null;
}
@Override
- public void visit(MemberOfExpression memberOfExpression) {
-
- }
-
- @Override
- public void visit(AnyComparisonExpression anyComparisonExpression) {
- }
- @Override
- public void visit(Concat concat) {
- }
- @Override
- public void visit(Matches matches) {
- }
- @Override
- public void visit(BitwiseAnd bitwiseAnd) {
- }
- @Override
- public void visit(BitwiseOr bitwiseOr) {
- }
- @Override
- public void visit(BitwiseXor bitwiseXor) {
- }
- @Override
- public void visit(CastExpression cast) {
- }
-
- @Override
- public void visit(Modulo modulo) {
- }
- @Override
- public void visit(AnalyticExpression aexpr) {
- }
- @Override
- public void visit(ExtractExpression eexpr) {
- }
- @Override
- public void visit(IntervalExpression iexpr) {
- }
- @Override
- public void visit(OracleHierarchicalExpression oexpr) {
- }
- @Override
- public void visit(RegExpMatchOperator rexpr) {
- }
- @Override
- public void visit(JsonExpression jsonExpr) {
- }
- @Override
- public void visit(JsonOperator jsonExpr) {
- }
- @Override
- public void visit(UserVariable var) {
- }
- @Override
- public void visit(NumericBind bind) {
- }
- @Override
- public void visit(KeepExpression aexpr) {
- }
- @Override
- public void visit(MySQLGroupConcat groupConcat) {
- }
- @Override
- public void visit(RowConstructor rowConstructor) {
- }
-
- @Override
- public void visit(RowGetExpression rowGetExpression) {
-
+ public Void visit(XorExpression xorExpression, Object o) {
+ throwError("暂不支持 XOR 关联条件: " + xorExpression.toString());
+ return null;
}
- @Override
- public void visit(OracleHint hint) {
- }
- @Override
- public void visit(TimeKeyExpression timeKeyExpression) {
- }
- @Override
- public void visit(DateTimeLiteralExpression literal) {
- }
- @Override
- public void visit(NotExpression aThis) {
- }
-
- @Override
- public void visit(NextValExpression aThis) {
- }
-
- @Override
- public void visit(CollateExpression aThis) {
- }
-
- @Override
- public void visit(SimilarToExpression aThis) {
- }
-
- @Override
- public void visit(ArrayExpression arrayExpression) {
- }
-
- @Override
- public void visit(ArrayConstructor arrayConstructor) {
-
- }
-
- @Override
- public void visit(VariableAssignment variableAssignment) {
- }
-
- @Override
- public void visit(XMLSerializeExpr xmlSerializeExpr) {
- }
-
- @Override
- public void visit(TimezoneExpression timezoneExpression) {
- }
- @Override
- public void visit(JsonAggregateFunction jsonAggregateFunction) {
- }
- @Override
- public void visit(JsonFunction jsonFunction) {
- }
- @Override
- public void visit(ConnectByRootOperator connectByRootOperator) {
- }
- @Override
- public void visit(OracleNamedFunctionParameter oracleNamedFunctionParameter) {
- }
-
- @Override
- public void visit(AllColumns allColumns) {
-
- }
-
- @Override
- public void visit(AllTableColumns allTableColumns) {
-
- }
-
- @Override
- public void visit(AllValue allValue) {
-
- }
-
- @Override
- public void visit(IsDistinctExpression isDistinctExpression) {
- }
-
- @Override
- public void visit(GeometryDistance geometryDistance) {
- }
-
- @Override
- public void visit(Select select) {
-
- }
-
- @Override
- public void visit(TranscodingFunction transcodingFunction) {
-
- }
-
- @Override
- public void visit(TrimFunction trimFunction) {
-
- }
-
- @Override
- public void visit(RangeExpression rangeExpression) {
-
- }
-
- @Override
- public void visit(TSQLLeftJoin tsqlLeftJoin) {
-
- }
-
- @Override
- public void visit(TSQLRightJoin tsqlRightJoin) {
-
- }
-
- @Override
- public void visit(BitwiseRightShift aThis) {
- }
- @Override
- public void visit(BitwiseLeftShift aThis) {
- }
- @Override
- public void visit(NullValue nullValue) {
- }
- @Override
- public void visit(Function function) {
- }
- @Override
- public void visit(SignedExpression signedExpression) {
- }
- @Override
- public void visit(JdbcParameter jdbcParameter) {
- }
- @Override
- public void visit(JdbcNamedParameter jdbcNamedParameter) {
- }
- @Override
- public void visit(DoubleValue doubleValue) {
- }
- @Override
- public void visit(LongValue longValue) {
- }
- @Override
- public void visit(HexValue hexValue) {
- }
- @Override
- public void visit(DateValue dateValue) {
- }
- @Override
- public void visit(TimeValue timeValue) {
- }
- @Override
- public void visit(TimestampValue timestampValue) {
- }
- @Override
- public void visit(Parenthesis parenthesis) {
- }
- @Override
- public void visit(StringValue stringValue) {
- }
- @Override
- public void visit(Addition addition) {
- }
- @Override
- public void visit(Division division) {
- }
-
- @Override
- public void visit(IntegerDivision integerDivision) {
- }
- @Override
- public void visit(Multiplication multiplication) {
- }
- @Override
- public void visit(Subtraction subtraction) {
- }
}
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/parser/ParserCache.java b/diboot-core/src/main/java/com/diboot/core/binding/parser/ParserCache.java
index 1d0b69f62..3fdc552ec 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/parser/ParserCache.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/parser/ParserCache.java
@@ -33,6 +33,7 @@
import org.apache.ibatis.type.TypeHandler;
import org.springframework.core.annotation.AnnotationUtils;
+import javax.lang.model.type.NullType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
@@ -214,7 +215,8 @@ public static List getBindQueryAnnos(Class> dtoClass){
Map joinOn2Alias = new HashMap<>(8);
// 构建AnnoJoiner
BiConsumer buildAnnoJoiner = (field, query) -> {
- AnnoJoiner annoJoiner = new AnnoJoiner(field, query);
+ PropInfo propInfo = BindingCacheManager.getPropInfoByClass(query.entity() != null && !NullType.class.equals(query.entity())? query.entity() : dtoClass);
+ AnnoJoiner annoJoiner = new AnnoJoiner(propInfo, field, query);
// 关联对象,设置别名
if (V.notEmpty(annoJoiner.getJoin())) {
String key = annoJoiner.getJoin() + ":" + annoJoiner.getCondition();
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/query/BindQuery.java b/diboot-core/src/main/java/com/diboot/core/binding/query/BindQuery.java
index 12d0d780c..dfe956d37 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/query/BindQuery.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/query/BindQuery.java
@@ -39,8 +39,15 @@
/**
* 数据库字段,默认为空,自动根据驼峰转下划线
*/
+ @Deprecated
String column() default "";
+ /**
+ * entity字段名,不指定默认为当前Entity同名属性名
+ * @return
+ */
+ String field() default "";
+
/**
* 绑定的Entity类
*/
diff --git a/diboot-core/src/main/java/com/diboot/core/binding/query/dynamic/AnnoJoiner.java b/diboot-core/src/main/java/com/diboot/core/binding/query/dynamic/AnnoJoiner.java
index 69bcf1ad0..c6825dc2b 100644
--- a/diboot-core/src/main/java/com/diboot/core/binding/query/dynamic/AnnoJoiner.java
+++ b/diboot-core/src/main/java/com/diboot/core/binding/query/dynamic/AnnoJoiner.java
@@ -17,12 +17,14 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.diboot.core.binding.parser.ParserCache;
+import com.diboot.core.binding.parser.PropInfo;
import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
-import com.diboot.core.util.S;
+import com.diboot.core.exception.InvalidUsageException;
import com.diboot.core.util.V;
import lombok.Getter;
import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
import javax.lang.model.type.NullType;
import java.io.Serializable;
@@ -34,23 +36,33 @@
* @version v2.0
* @date 2020/04/16
*/
+@Slf4j
@Getter @Setter
public class AnnoJoiner implements Serializable {
private static final long serialVersionUID = 5998965277333389063L;
- public AnnoJoiner(Field field, BindQuery query){
+ public AnnoJoiner(PropInfo propInfo, Field field, BindQuery query){
this.key = field.getName() + query;
this.fieldName = field.getName();
this.comparison = query.comparison();
// 列名
- if (V.notEmpty(query.column())) {
+ if (V.notEmpty(query.field())) {
+ this.columnName = propInfo.getColumnByField(query.field());
+ if(V.isEmpty(this.columnName)){
+ throw new InvalidUsageException("@BindQuery 注解配置异常,filed={} 无法解析出对应的列名!", query.field());
+ }
+ }
+ else if (V.notEmpty(query.column())) {
this.columnName = query.column();
}
else if (field.isAnnotationPresent(TableField.class)) {
this.columnName = field.getAnnotation(TableField.class).value();
}
if(V.isEmpty(this.columnName)){
- this.columnName = S.toSnakeCase(field.getName());
+ this.columnName = propInfo.getColumnByField(field.getName());
+ if(V.isEmpty(this.columnName)){
+ throw new InvalidUsageException("@BindQuery 注解配置异常,filed={} 无法解析出对应的列名!", query.field());
+ }
}
// join 表名
if(!NullType.class.equals(query.entity())){
diff --git a/diboot-core/src/main/java/com/diboot/core/config/BaseConfig.java b/diboot-core/src/main/java/com/diboot/core/config/BaseConfig.java
index 6f23a2fa9..56b8899ee 100644
--- a/diboot-core/src/main/java/com/diboot/core/config/BaseConfig.java
+++ b/diboot-core/src/main/java/com/diboot/core/config/BaseConfig.java
@@ -21,7 +21,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/***
+/**
* 系统默认配置
* @author mazc@dibo.ltd
* @version 2.0
@@ -50,7 +50,7 @@ public static String getProperty(String key, String defaultValue){
return value != null? value : defaultValue;
}
- /***
+ /**
* 从默认的/指定的 Properties文件获取boolean值
* @param key
* @return
@@ -59,7 +59,7 @@ public static boolean isTrue(String key){
return PropertiesUtils.getBoolean(key);
}
- /***
+ /**
* 获取int类型
* @param key
* @return
@@ -68,7 +68,7 @@ public static Integer getInteger(String key){
return PropertiesUtils.getInteger(key);
}
- /***
+ /**
* 获取int类型
* @param key
* @return
@@ -79,7 +79,7 @@ public static Integer getInteger(String key, int defaultValue){
}
private static Integer cutLength = null;
- /***
+ /**
* 获取截取长度
* @return
*/
@@ -94,7 +94,7 @@ public static int getCutLength(){
}
private static Integer pageSize = null;
- /***
+ /**
* 默认页数
* @return
*/
@@ -109,7 +109,7 @@ public static int getPageSize() {
}
private static Integer batchSize = null;
- /***
+ /**
* 获取批量插入的每批次数量
* @return
*/
@@ -159,7 +159,7 @@ else if(S.containsIgnoreCase(activeValue, "true")) {
private static Long workerId = null, dataCenterId = null;
- /***
+ /**
* 获取workerId
* @return
*/
@@ -173,7 +173,7 @@ public static long getWorkerId(){
return workerId;
}
- /***
+ /**
* 获取DataCenterId
* @return
*/
@@ -187,4 +187,16 @@ public static long getDataCenterId() {
return dataCenterId;
}
+ /**
+ * 默认页数
+ * @return
+ */
+ private static Boolean enableI18n = null;
+ public static boolean isEnabledI18n() {
+ if(enableI18n == null){
+ enableI18n = PropertiesUtils.getBoolean("diboot.i18n");
+ }
+ return enableI18n;
+ }
+
}
diff --git a/diboot-core/src/main/java/com/diboot/core/config/Cons.java b/diboot-core/src/main/java/com/diboot/core/config/Cons.java
index dc76639d1..d8e35bb52 100644
--- a/diboot-core/src/main/java/com/diboot/core/config/Cons.java
+++ b/diboot-core/src/main/java/com/diboot/core/config/Cons.java
@@ -75,7 +75,7 @@ public class Cons {
*/
public static final String ID_PREVENT_NULL = "0";
- /***
+ /**
* 常用字段名定义
*/
public enum FieldName{
@@ -129,7 +129,7 @@ public enum FieldName{
parentIdsPath
}
- /***
+ /**
* 常用列名定义
*/
public enum ColumnName{
diff --git a/diboot-core/src/main/java/com/diboot/core/controller/BaseController.java b/diboot-core/src/main/java/com/diboot/core/controller/BaseController.java
index b0b5527a1..8a00582fe 100644
--- a/diboot-core/src/main/java/com/diboot/core/controller/BaseController.java
+++ b/diboot-core/src/main/java/com/diboot/core/controller/BaseController.java
@@ -43,7 +43,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-/***
+/**
* Controller的父类
* @author mazc@dibo.ltd
* @version 2.0
@@ -55,7 +55,7 @@ public class BaseController {
@Autowired
protected HttpServletRequest request;
- /***
+ /**
* 根据DTO构建查询QueryWrapper (根据BindQuery注解构建相应的查询条件,DTO中的非空属性均参与构建)
* @param entityOrDto Entity对象或者DTO对象 (属性若无BindQuery注解,默认构建为为EQ相等条件)
* @return
@@ -64,7 +64,7 @@ protected QueryWrapper buildQueryWrapperByDTO(DTO entityOrDto) throws
return QueryBuilder.toQueryWrapper(entityOrDto);
}
- /***
+ /**
* 根据DTO构建查询QueryWrapper (根据BindQuery注解构建相应的查询条件,DTO中的非空属性均参与构建)
* @param entityOrDto Entity对象或者DTO对象 (属性若无BindQuery注解,默认构建为为EQ相等条件)
* @param pagination 分页,如按关联表中的字段排序时需传入pagination
@@ -74,7 +74,7 @@ protected QueryWrapper buildQueryWrapperByDTO(DTO entityOrDto, Pagina
return QueryBuilder.toQueryWrapper(entityOrDto, pagination);
}
- /***
+ /**
* 根据请求参数构建查询QueryWrapper (根据BindQuery注解构建相应的查询条件,url中的请求参数参与构建)
* @param entityOrDto Entity对象或者DTO对象 (属性若无BindQuery注解,默认构建为为EQ相等条件)
* @return
@@ -84,7 +84,7 @@ protected QueryWrapper buildQueryWrapperByQueryParams(DTO entityOrDto
return QueryBuilder.toQueryWrapper(entityOrDto, extractQueryParams());
}
- /***
+ /**
* 根据请求参数构建查询QueryWrapper (根据BindQuery注解构建相应的查询条件,url中的请求参数参与构建)
* @param entityOrDto Entity对象或者DTO对象 (属性若无BindQuery注解,默认构建为为EQ相等条件)
* @param pagination 分页,如按关联表中的字段排序时需传入pagination
@@ -95,7 +95,7 @@ protected QueryWrapper buildQueryWrapperByQueryParams(DTO entityOrDto
return QueryBuilder.toQueryWrapper(entityOrDto, extractQueryParams(), pagination);
}
- /***
+ /**
* 获取请求参数Map
* @return
*/
@@ -103,7 +103,7 @@ protected Map getParamsMap() throws Exception{
return getParamsMap(null);
}
- /***
+ /**
* 获取请求参数Map
* @return
*/
@@ -138,7 +138,7 @@ private Map getParamsMap(List paramList) throws Exceptio
return result;
}
- /***
+ /**
* 获取请求URI (去除contextPath)
* @return
*/
@@ -162,7 +162,7 @@ protected Set extractQueryParams(){
return Collections.EMPTY_SET;
}
- /***
+ /**
* 将请求参数值转换为Map
* @return
*/
@@ -224,8 +224,6 @@ protected List loadRelatedData(RelatedDataDTO relatedDataDTO) {
* @return labelValue集合
*/
protected List loadRelatedData(RelatedDataDTO relatedDataDTO, @Nullable String parentId, @Nullable String keyword) {
- V.securityCheck(relatedDataDTO.getType(), relatedDataDTO.getLabel(), relatedDataDTO.getExt(),
- relatedDataDTO.getOrderBy(), relatedDataDTO.getParent(), relatedDataDTO.getParentPath());
if (!relatedDataSecurityCheck(relatedDataDTO)) {
log.warn("relatedData安全检查不通过: {}", JSON.stringify(relatedDataDTO));
return Collections.emptyList();
@@ -311,7 +309,7 @@ protected List loadRelatedData(RelatedDataDTO relatedDataDTO, @Nulla
.map(map -> S.split(S.valueOf(map.get(parentPathColumn)))).flatMap(Stream::of)
.filter(V::notEmpty).map(parentIdTypeConversion).collect(Collectors.toList()));
}});
- columns.add(S.joinWith(" as ", parentColumn, Cons.FieldName.parentId.name()));
+ columns.add(parentColumn);
} else if (relatedDataDTO.isLazyChild()) {
if (isDynamicRoot) {
queryWrapper.eq(idColumn, rootId);
@@ -326,7 +324,7 @@ protected List loadRelatedData(RelatedDataDTO relatedDataDTO, @Nulla
}
} else {
// 加载整个Tree结构数据
- columns.add(S.joinWith(" as ", parentColumn, Cons.FieldName.parentId.name()));
+ columns.add(parentColumn);
}
} else {
// list 模糊搜索
@@ -361,6 +359,9 @@ protected Serializable getTreeRootId(Class> entityClass, Class> parentFieldT
* @return 是否允许访问该类型接口
*/
protected boolean relatedDataSecurityCheck(RelatedDataDTO relatedDataDTO) {
+ V.securityCheck(relatedDataDTO.getType(), relatedDataDTO.getLabel(), relatedDataDTO.getExt(),
+ relatedDataDTO.getOrderBy(), relatedDataDTO.getParent(), relatedDataDTO.getParentPath());
+ V.securityCheck(relatedDataDTO.getCondition(), relatedDataDTO.getConditions());
return true;
}
@@ -382,7 +383,7 @@ protected void buildRelatedDataCondition(RelatedDataDTO relatedDataDTO, QueryWra
});
}
- /***
+ /**
* 打印所有参数信息
*/
protected void dumpParams(){
@@ -437,7 +438,7 @@ protected int getInt(String param, Integer defaultValue){
return S.toInt(request.getParameter(param), defaultValue);
}
- /***
+ /**
* 从request中获取boolean值
* @param param
* @return
@@ -446,7 +447,7 @@ protected boolean getBoolean(String param){
return S.toBoolean(request.getParameter(param));
}
- /***
+ /**
* 从request中获取boolean值
* @param param
* @param defaultBoolean
@@ -518,7 +519,7 @@ protected String[] getStringArray(String param){
return null;
}
- /***
+ /**
* 从request里获取String列表
* @param param
* @return
@@ -531,7 +532,7 @@ protected List getStringList(String param){
return Arrays.asList(strArray);
}
- /***
+ /**
* 从request里获取Long列表
* @param param
* @return
diff --git a/diboot-core/src/main/java/com/diboot/core/controller/BaseCrudRestController.java b/diboot-core/src/main/java/com/diboot/core/controller/BaseCrudRestController.java
index efdf97880..117a5d769 100644
--- a/diboot-core/src/main/java/com/diboot/core/controller/BaseCrudRestController.java
+++ b/diboot-core/src/main/java/com/diboot/core/controller/BaseCrudRestController.java
@@ -35,7 +35,7 @@
import java.util.Collection;
import java.util.List;
-/***
+/**
* CRUD增删改查通用RestController-父类
* @author mazc@dibo.ltd
* @version 2.0
@@ -71,7 +71,7 @@ protected E getEntity(Serializable id) throws Exception {
return getService().getEntity(id);
}
- /***
+ /**
* 获取某VO资源的集合,用于子类重写的方法
*
* url参数示例: /${bindURL}?pageSize=20&pageIndex=1&orderBy=itemValue&type=GENDAR
@@ -91,7 +91,7 @@ protected JsonResult> getViewObjectList(E entity, Pagination pagin
return JsonResult.OK(voList).bindPagination(pagination);
}
- /***
+ /**
* 获取某VO资源的集合,用于子类重写的方法
*
* url参数示例: /${bindURL}?pageSize=20&pageIndex=1&orderBy=itemValue&type=GENDAR
@@ -123,7 +123,7 @@ protected JsonResult> getEntityList(Wrapper> queryWrapper) throws Exce
return JsonResult.OK(entityList);
}
- /***
+ /**
* 获取符合查询条件的某页数据(有分页)
*
* url参数示例: /${bindURL}?pageSize=20&pageIndex=1
@@ -138,7 +138,7 @@ protected JsonResult> getEntityListWithPaging(Wrapper> queryWrapper, P
return JsonResult.OK(entityList).bindPagination(pagination);
}
- /***
+ /**
* 创建资源对象,用于子类重写的方法
* @param entity
* @return JsonResult
@@ -161,7 +161,7 @@ protected JsonResult> createEntity(E entity) throws Exception {
}
}
- /***
+ /**
* 根据ID更新资源对象,用于子类重写的方法
* @param entity
* @return JsonResult
@@ -192,7 +192,7 @@ protected JsonResult> updateEntity(Serializable id, E entity) throws Exception
}
}
- /***
+ /**
* 根据id删除资源对象,用于子类重写的方法
* @param id
* @return
@@ -217,7 +217,7 @@ protected JsonResult> deleteEntity(Serializable id) throws Exception {
}
}
- /***
+ /**
* 根据id批量删除资源对象,用于子类重写的方法
* @param ids
* @return
@@ -274,7 +274,7 @@ protected JsonResult> fail(Status status, String msg) {
//============= 供子类继承重写的方法 =================
- /***
+ /**
* 创建前的相关处理
* @param entityOrDto
* @return
@@ -282,7 +282,7 @@ protected JsonResult> fail(Status status, String msg) {
protected void beforeCreate(E entityOrDto) throws Exception {
}
- /***
+ /**
* 创建成功后的相关处理
* @param entityOrDto
* @return
@@ -290,7 +290,7 @@ protected void beforeCreate(E entityOrDto) throws Exception {
protected void afterCreated(E entityOrDto) throws Exception {
}
- /***
+ /**
* 更新前的相关处理
* @param entityOrDto
* @return
@@ -299,7 +299,7 @@ protected void beforeUpdate(E entityOrDto) throws Exception {
BeanUtils.clearFieldValue(entityOrDto, BindingCacheManager.getPropInfoByClass(getEntityClass()).getFillUpdateFieldList());
}
- /***
+ /**
* 更新成功后的相关处理
* @param entityOrDto
* @return
@@ -307,7 +307,7 @@ protected void beforeUpdate(E entityOrDto) throws Exception {
protected void afterUpdated(E entityOrDto) throws Exception {
}
- /***
+ /**
* 是否有删除权限,如不可删除返回错误提示信息
* @param id
* @return
@@ -315,7 +315,7 @@ protected void afterUpdated(E entityOrDto) throws Exception {
protected void beforeDelete(Serializable id) throws Exception {
}
- /***
+ /**
* 删除成功后的相关处理
* @param id
* @return
@@ -323,7 +323,7 @@ protected void beforeDelete(Serializable id) throws Exception {
protected void afterDeleted(Serializable id) throws Exception {
}
- /***
+ /**
* 是否有批量删除权限,如不可删除返回错误提示信息,如 Status.FAIL_NO_PERMISSION.label()
* @param ids
* @return
@@ -331,7 +331,7 @@ protected void afterDeleted(Serializable id) throws Exception {
protected void beforeBatchDelete(Collection extends Serializable> ids) throws Exception {
}
- /***
+ /**
* 批量删除成功后的相关处理
* @param ids
* @return
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateConverter.java
index 5074a7d8e..a78de8f93 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -30,7 +31,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class Date2LocalDateConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateTimeConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateTimeConverter.java
index 6ee26c84e..c55913d88 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateTimeConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/Date2LocalDateTimeConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -30,7 +31,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class Date2LocalDateTimeConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/Integer2BooleanConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/Integer2BooleanConverter.java
index 02b8f6953..1e5a98b24 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/Integer2BooleanConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/Integer2BooleanConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
/**
* Integer - Boolean 转换器
@@ -26,7 +27,7 @@
* @date 2024/2/28
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class Integer2BooleanConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/LocalDate2DateConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/LocalDate2DateConverter.java
index 35dda80ec..affbe2f1a 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/LocalDate2DateConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/LocalDate2DateConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.time.Instant;
import java.time.LocalDate;
@@ -30,7 +31,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class LocalDate2DateConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2DateConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2DateConverter.java
index dcbff1013..911c0b71f 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2DateConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2DateConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.time.Instant;
import java.time.LocalDateTime;
@@ -30,7 +31,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class LocalDateTime2DateConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2StringConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2StringConverter.java
index 3c75c763c..7bb6ca07b 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2StringConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/LocalDateTime2StringConverter.java
@@ -18,6 +18,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import com.diboot.core.util.D;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
@@ -28,7 +29,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class LocalDateTime2StringConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/Short2BooleanConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/Short2BooleanConverter.java
index a2b9a6e7e..13cfc73b7 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/Short2BooleanConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/Short2BooleanConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
/**
* Short - Boolean 转换器
@@ -26,7 +27,7 @@
* @date 2024/2/28
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class Short2BooleanConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateConverter.java
index 81273df4a..6748d143f 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.sql.Date;
import java.time.LocalDate;
@@ -28,7 +29,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class SqlDate2LocalDateConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateTimeConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateTimeConverter.java
index 2bcfed5d3..843946122 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateTimeConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/SqlDate2LocalDateTimeConverter.java
@@ -17,6 +17,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.sql.Date;
import java.sql.Timestamp;
@@ -29,7 +30,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class SqlDate2LocalDateTimeConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/String2BooleanConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/String2BooleanConverter.java
index be8bdcc15..e94ab44b3 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/String2BooleanConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/String2BooleanConverter.java
@@ -18,6 +18,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import com.diboot.core.util.V;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
/**
* String - boolean 转换器
@@ -26,7 +27,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class String2BooleanConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/String2DateConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/String2DateConverter.java
index b4c5440ea..8075ab938 100644
--- a/diboot-core/src/main/java/com/diboot/core/converter/String2DateConverter.java
+++ b/diboot-core/src/main/java/com/diboot/core/converter/String2DateConverter.java
@@ -18,6 +18,7 @@
import com.diboot.core.converter.annotation.CollectThisConvertor;
import com.diboot.core.util.D;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
import java.util.Date;
@@ -28,7 +29,7 @@
* @date 2022/5/11
* Copyright © diboot.com
*/
-@CollectThisConvertor
+@Component
public class String2DateConverter implements Converter {
@Override
diff --git a/diboot-core/src/main/java/com/diboot/core/converter/String2ListBooleanConverter.java b/diboot-core/src/main/java/com/diboot/core/converter/String2ListBooleanConverter.java
new file mode 100644
index 000000000..d1ed26280
--- /dev/null
+++ b/diboot-core/src/main/java/com/diboot/core/converter/String2ListBooleanConverter.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015-2029, www.dibo.ltd (service@dibo.ltd).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.diboot.core.converter;
+
+import com.diboot.core.util.JSON;
+import com.diboot.core.util.S;
+import com.diboot.core.util.V;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * String - List 转换器
+ *
+ * @author wind
+ * @version v3.5.0
+ * @date 2024/07/29
+ * Copyright © diboot.com
+ */
+@Component
+public class String2ListBooleanConverter implements Converter