Compare commits

...

12 Commits

Author SHA1 Message Date
thinkgem
da5dbdf23b update README.md 2023-02-07 11:53:05 +08:00
thinkgem
4866a13365 Merge remote-tracking branch 'origin/v4.temp' into v4.temp 2023-02-07 11:50:07 +08:00
thinkgem
9d4f849371 4.6.1 2023-02-07 11:49:56 +08:00
thinkgem
5dd679eb24 update DaoMapperTest.java 2023-02-02 23:17:25 +08:00
thinkgem
f788cb7e78 update README.md 2023-01-31 15:25:34 +08:00
thinkgem
9ec99230ad update 2023-01-31 15:25:13 +08:00
thinkgem
9c390d7cb1 mybatis 3.5.11 2023-01-29 14:16:03 +08:00
thinkgem
28aef61cea spring boot 2.7.8、shiro 1.11.0 2023-01-23 22:47:48 +08:00
thinkgem
15ae96b04a update 2022-12-30 15:29:20 +08:00
thinkgem
a8764cf247 copyrightYear: 2023 2022-12-30 11:25:09 +08:00
thinkgem
e5842b42f4 remove JaxbMapper.java 2022-12-23 10:41:57 +08:00
thinkgem
4d7a40d30f update 2022-12-20 23:29:02 +08:00
13 changed files with 173 additions and 282 deletions

View File

@@ -4,8 +4,8 @@
</p>
<h3 align="center" style="margin:30px 0 30px;font-weight:bold;font-size:30px;">快速开发平台 - Spring Boot</h3>
<p align="center">
<a href="https://jeesite.com/docs/upgrade/" target="__blank"><img alt="JeeSite-V4.5" src="https://img.shields.io/badge/JeeSite-V4.5-success.svg"></a>
<a href="https://spring.io/projects/spring-boot#learn" target="__blank"><img alt="SpringBoot-2.6" src="https://img.shields.io/badge/SpringBoot-2.6-blue.svg"></a>
<a href="https://jeesite.com/docs/upgrade/" target="__blank"><img alt="JeeSite-V4.6" src="https://img.shields.io/badge/JeeSite-V4.6-success.svg"></a>
<a href="https://spring.io/projects/spring-boot#learn" target="__blank"><img alt="SpringBoot-2.7" src="https://img.shields.io/badge/SpringBoot-2.7-blue.svg"></a>
<a href="https://gitee.com/thinkgem/jeesite4/stargazers" target="__blank"><img alt="star" src="https://gitee.com/thinkgem/jeesite4/badge/star.svg?theme=dark"></a>
<a href="https://gitee.com/thinkgem/jeesite4/members" target="__blank"><img alt="fork" src="https://gitee.com/thinkgem/jeesite4/badge/fork.svg?theme=dark"></a>
</p>
@@ -51,7 +51,7 @@ JeeSite 是一个低代码开发平台,具有较高的封装度、扩展性,
## 技术选型
* 主框架Spring Boot 2.6、Spring Framework 5.3、Apache Shiro 1.9、J2Cache
* 主框架Spring Boot 2.7、Spring Framework 5.3、Apache Shiro 1.11、J2Cache
* 持久层Apache MyBatis 3.5、Hibernate Validator 6.2、Alibaba Druid 1.2
* 视图层Spring MVC 5.3、Beetl 3.3替换JSP、Bootstrap 3.3、AdminLTE 2.4
* 前端组件jQuery 3.5、jqGrid 4.7、layer 3.5、zTree 3.5、jQuery Validation
@@ -88,7 +88,7 @@ JeeSite 是一个低代码开发平台,具有较高的封装度、扩展性,
### 本地运行
1. 环境准备:`JDK 1.8 or 11、17``Maven 3.6+`、使用 `MySQL 5.7 or 8.0` 数据库、[其它数据库](https://jeesite.com/docs/technology/#_8、已支持数据库)
2. 下载源码:<https://gitee.com/thinkgem/jeesite4/repository/archive/v4.5.zip> 并解压
2. 下载源码:<https://gitee.com/thinkgem/jeesite4/repository/archive/v4.6.zip> 并解压
3. 打开文件:`/web/src/main/resources/config/application.yml` 配置JDBC连接
4. 执行脚本:`/web/bin/init-data.bat` 初始化数据库
5. 执行脚本:`/web/bin/run-tomcat.bat` 启动服务即可

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

View File

@@ -1,168 +0,0 @@
/**
* Copyright (c) 2005-2012 springside.org.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package com.jeesite.common.mapper;
import com.jeesite.common.lang.ExceptionUtils;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.reflect.ReflectUtils;
import javax.xml.bind.*;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.namespace.QName;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* 使用Jaxb2.0实现XML<->Java Object的Mapper.
*
* 在创建时需要设定所有需要序列化的Root对象的Class.
* 特别支持Root对象是Collection的情形.
*
* @author calvin
* @version 2013-01-15
*/
@Deprecated
@SuppressWarnings("rawtypes")
public class JaxbMapper {
private static ConcurrentMap<Class, JAXBContext> jaxbContexts = new ConcurrentHashMap<Class, JAXBContext>();
/**
* Java Object->Xml without encoding.
*/
public static String toXml(Object root) {
Class clazz = ReflectUtils.getUserClass(root);
return toXml(root, clazz, null);
}
/**
* Java Object->Xml with encoding.
*/
public static String toXml(Object root, String encoding) {
Class clazz = ReflectUtils.getUserClass(root);
return toXml(root, clazz, encoding);
}
/**
* Java Object->Xml with encoding.
*/
public static String toXml(Object root, Class clazz, String encoding) {
try {
StringWriter writer = new StringWriter();
createMarshaller(clazz, encoding).marshal(root, writer);
return writer.toString();
} catch (JAXBException e) {
throw ExceptionUtils.unchecked(e);
}
}
/**
* Java Collection->Xml without encoding, 特别支持Root Element是Collection的情形.
*/
public static String toXml(Collection<?> root, String rootName, Class clazz) {
return toXml(root, rootName, clazz, null);
}
/**
* Java Collection->Xml with encoding, 特别支持Root Element是Collection的情形.
*/
public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) {
try {
CollectionWrapper wrapper = new CollectionWrapper();
wrapper.collection = root;
JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
CollectionWrapper.class, wrapper);
StringWriter writer = new StringWriter();
createMarshaller(clazz, encoding).marshal(wrapperElement, writer);
return writer.toString();
} catch (JAXBException e) {
throw ExceptionUtils.unchecked(e);
}
}
/**
* Xml->Java Object.
*/
@SuppressWarnings("unchecked")
public static <T> T fromXml(String xml, Class<T> clazz) {
try {
StringReader reader = new StringReader(xml);
return (T) createUnmarshaller(clazz).unmarshal(reader);
} catch (JAXBException e) {
throw ExceptionUtils.unchecked(e);
}
}
/**
* 创建Marshaller并设定encoding(可为null).
* 线程不安全需要每次创建或pooling。
*/
public static Marshaller createMarshaller(Class clazz, String encoding) {
try {
JAXBContext jaxbContext = getJaxbContext(clazz);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
if (StringUtils.isNotBlank(encoding)) {
marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding);
}
return marshaller;
} catch (JAXBException e) {
throw ExceptionUtils.unchecked(e);
}
}
/**
* 创建UnMarshaller.
* 线程不安全需要每次创建或pooling。
*/
public static Unmarshaller createUnmarshaller(Class clazz) {
try {
JAXBContext jaxbContext = getJaxbContext(clazz);
return jaxbContext.createUnmarshaller();
} catch (JAXBException e) {
throw ExceptionUtils.unchecked(e);
}
}
protected static JAXBContext getJaxbContext(Class clazz) {
if (clazz == null){
throw new RuntimeException("'clazz' must not be null");
}
JAXBContext jaxbContext = jaxbContexts.get(clazz);
if (jaxbContext == null) {
try {
jaxbContext = JAXBContext.newInstance(clazz, CollectionWrapper.class);
jaxbContexts.putIfAbsent(clazz, jaxbContext);
} catch (JAXBException ex) {
// throw new HttpMessageConversionException("Could not instantiate JAXBContext for class [" + clazz
// + "]: " + ex.getMessage(), ex);
throw new RuntimeException("Could not instantiate JAXBContext for class [" + clazz
+ "]: " + ex.getMessage(), ex);
}
}
return jaxbContext;
}
/**
* 封装Root Element 是 Collection的情况.
*/
public static class CollectionWrapper {
@XmlAnyElement
protected Collection<?> collection;
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

View File

@@ -14,4 +14,5 @@
4.4.0
4.4.1
4.5.0
4.6.0
4.6.0
4.6.1

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
@@ -21,8 +21,8 @@
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Oracle 11g -->

View File

@@ -4,34 +4,24 @@
*/
package com.jeesite.test;
import java.util.Date;
import java.util.List;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataScope;
import com.jeesite.common.entity.Page;
import com.jeesite.common.idgen.IdGen;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.tests.BaseSpringContextTests;
import com.jeesite.modules.file.dao.FileUploadDao;
import com.jeesite.modules.file.entity.FileUpload;
import com.jeesite.modules.sys.dao.*;
import com.jeesite.modules.sys.entity.*;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataScope;
import com.jeesite.common.entity.Page;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.tests.BaseSpringContextTests;
import com.jeesite.modules.file.dao.FileUploadDao;
import com.jeesite.modules.file.entity.FileUpload;
import com.jeesite.modules.sys.dao.AreaDao;
import com.jeesite.modules.sys.dao.CompanyDao;
import com.jeesite.modules.sys.dao.ConfigDao;
import com.jeesite.modules.sys.dao.DictDataDao;
import com.jeesite.modules.sys.dao.EmpUserDao;
import com.jeesite.modules.sys.dao.UserDao;
import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.Company;
import com.jeesite.modules.sys.entity.Config;
import com.jeesite.modules.sys.entity.DictData;
import com.jeesite.modules.sys.entity.EmpUser;
import com.jeesite.modules.sys.entity.User;
import java.util.Date;
import java.util.List;
/**
* Mapper测试
@@ -56,67 +46,110 @@ public class DaoMapperTest extends BaseSpringContextTests {
private FileUploadDao fileUploadDao;
@Autowired
private EmpUserDao empUserDao;
@Test
public void testTableAnnotation() throws Exception{
try{
System.out.println("============ 插入和批量插入测试 ============");
System.out.println("============ 插入测试 ============");
Config config = new Config();
config.setId("1");
config.setConfigKey("test");
config.setConfigName("test");
config.setConfigValue("1");
config.setIsSys("1");
long configInsertNum = configDao.insert(config);
Assert.assertEquals("configDao.insert", configInsertNum , 1);
Config configInsertRes = configDao.get(config);
Assert.assertEquals("configDao.insert result", configInsertRes.getId() , "1");
System.out.println("============ 批量插入测试 ============");
Config config2 = (Config)config.clone();
config2.setId("2");
config.setConfigKey("test2");
config2.setConfigKey("test2");
Config config3 = (Config)config.clone();
config3.setId("3");
config.setConfigKey("test3");
System.out.println(configDao.insert(config));
System.out.println(configDao.insertBatch(ListUtils.newArrayList(config2, config3)));
System.out.println("============ 更新测试 ============");
config3.setConfigKey("test3");
long configinsertBatchNum = configDao.insertBatch(ListUtils.newArrayList(config2, config3));
Assert.assertEquals("configDao.insertBatch", configinsertBatchNum , 2);
Config configInsertBatchRes2 = configDao.get(config2);
Assert.assertEquals("configDao.insertBatch result", configInsertBatchRes2.getId() , "2");
Config configInsertBatchRes3 = configDao.get(config3);
Assert.assertEquals("configDao.insertBatch result", configInsertBatchRes3.getId() , "3");
System.out.println("============ 按主键更新测试 ============");
Area area = new Area();
area.setAreaCode("1");
area.setAreaName("你好");
area.setParentCode("0");
area.setParentCodes("0,");
area.setTreeSort(1);
area.setTreeSorts("1,");
area.setTreeLevel(0);
area.setTreeLeaf("1");
area.setTreeNames(area.getAreaName());
area.setStatus("0");
Area area2 = (Area) area.clone();
area2.setAreaCode("2");
Area area3 = (Area) area.clone();
area3.setAreaCode("3");
long areaInsertNum = areaDao.insertBatch(ListUtils.newArrayList(area, area2, area3));
Assert.assertEquals("areaDao.insert", areaInsertNum , 3);
area.setAreaName("你好2");
long areaUpdateNum = areaDao.update(area);
Assert.assertEquals("areaDao.update", areaUpdateNum , 1);
Area areaUpdateRes = areaDao.get(area);
Assert.assertEquals("areaDao.update result", areaUpdateRes.getAreaName() , "你好2");
System.out.println("============ 按主键批量更新测试 ============");
long areaUpdateBatchNum = areaDao.updateBatch(ListUtils.newArrayList(area2, area3));
Assert.assertEquals("areaDao.update", areaUpdateBatchNum , 2);
System.out.println("============ 自定义更新条件测试 ============");
Area where = new Area();
where.setId("2");
where.setId_in(new String[]{"1","2"});
where.setAreaName("你好2");
where.setStatus("0");
System.out.println(areaDao.update(area));
System.out.println(areaDao.updateByEntity(area, where));
System.out.println(areaDao.updateStatus(area));
System.out.println(areaDao.updateStatusByEntity(area, where));
where.setId(areaUpdateRes.getId());
where.setId_in(new String[]{areaUpdateRes.getId()});
where.setAreaName(areaUpdateRes.getAreaName());
where.setStatus(areaUpdateRes.getStatus());
long areaUpdateByEntityNum = areaDao.updateByEntity(area, where);
Assert.assertEquals("areaDao.updateByEntity", areaUpdateByEntityNum , 1);
System.out.println("============ 更新数据状态测试 ============");
long areaStatusNum = areaDao.updateStatus(area);
Assert.assertEquals("areaDao.updateStatus", areaUpdateByEntityNum , 1);
long areaStatusByEntityNum = areaDao.updateStatusByEntity(area, where);
Assert.assertEquals("areaDao.updateStatusByEntity", areaUpdateByEntityNum , 1);
System.out.println("============ 逻辑删除测试 ============");
System.out.println(areaDao.delete(area));
System.out.println(areaDao.delete((Area)where.clone()));
System.out.println(areaDao.deleteByEntity((Area)where.clone()));
long areaDeleteNum = areaDao.delete(area);
Assert.assertEquals("areaDao.delete", areaDeleteNum , 1);
where.setStatus("1");
long areaDeleteByEntityNum = areaDao.deleteByEntity(where);
Assert.assertEquals("areaDao.deleteByEntity", areaDeleteByEntityNum , 1);
System.out.println("============ 物理删除测试 ============");
System.out.println(areaDao.phyDelete((Area)where.clone()));
System.out.println(areaDao.phyDeleteByEntity((Area)where.clone()));
long areaPhyDeleteNum = areaDao.phyDelete(area2);
Assert.assertEquals("areaDao.phyDelete", areaPhyDeleteNum , 1);
long areaPhyDeleteByEntityNum = areaDao.phyDeleteByEntity(area3);
Assert.assertEquals("areaDao.phyDeleteByEntity", areaPhyDeleteByEntityNum , 1);
System.out.println("============ 基本信息查询测试 ============");
System.out.println(areaDao.findList(area));
System.out.println("============ 基本查询测试 ============");
List<Area> areaList = areaDao.findList(area);
Assert.assertEquals("areaDao.findList", areaList.size() , 1);
User user = new User();
user.setUserType(User.USER_TYPE_NONE);
System.out.println(userDao.findList(user));
List<User> userList = userDao.findList(user);
Assert.assertTrue("userDao.findList", userList.size() > 0);
System.out.println("============ 条件嵌套日期范围自定义sqlMap测试 ============");
Company company = new Company("1");
company.setCompanyName("a");
company.setCreateDate_gte(new Date());
company.setCreateDate_lte(new Date());
company.setArea(new Area("2"));
company.getArea().setAreaName("a");
company.getArea().setCreateDate_gte(new Date());
company.getArea().setCreateDate_lte(new Date());
company.setFullName("a");
company.setArea(areaList.get(0));
company.getArea().setCreateDate_gte(company.getCreateDate_gte());
company.getArea().setCreateDate_lte(company.getCreateDate_gte());
company.setFullName(IdGen.nextId());
company.setViewCode("1");
company.setParentCode("0");
company.setParentCodes("0,");
@@ -124,47 +157,73 @@ public class DaoMapperTest extends BaseSpringContextTests {
company.setTreeSorts("1,");
company.setTreeLevel(0);
company.setTreeLeaf("1");
company.setTreeNames("a");
System.out.println(companyDao.insert(company));
System.out.println(companyDao.get(company));
System.out.println(companyDao.findCount(company));
company.setTreeNames(company.getCompanyName());
Company company2 = (Company) company.clone();
company2.setParentCode(company.getCompanyCode());
company2.setParentCodes("0,1," + company.getCompanyCode());
company2.setCompanyCode("12");
Company company3 = (Company) company.clone();
company3.setParentCode(company.getCompanyCode());
company3.setParentCodes("0,1," + company.getCompanyCode());
company3.setCompanyCode("13");
company3.setCompanyName("b");
long companyInsertNum = companyDao.insertBatch(ListUtils.newArrayList(company, company2, company3));
Assert.assertEquals("advanced query init", companyInsertNum , 3);
Company companyWhere = (Company) company.clone();
companyWhere.setCompanyCode(null);
companyWhere.setParentCode(null);
long companyFindCount = companyDao.findCount(companyWhere);
Assert.assertEquals("advanced query list", companyFindCount , 2);
System.out.println("============ 分页测试,查询子节点 ============");
company.setPage(new Page<Company>(1, 20));
company.setIsQueryChildren(true);
System.out.println(companyDao.findList(company));
Company company4 = new Company("1");
company4.setFullName(company.getFullName());
company4.setPage(new Page<Company>(1, 2));
company4.setIsQueryChildren(true);
List<Company> companyListPage = companyDao.findList(company4);
Assert.assertEquals("find page list size", companyListPage.size(), 2);
Assert.assertEquals("find page list get(1)", companyListPage.get(1).getCompanyCode(), company2.getCompanyCode());
Assert.assertEquals("find page count", company4.getPage().getCount(), 3);
System.out.println("============ 扩展条件语句前带AND容错测试 ============");
Company company2 = new Company();
company2.getSqlMap().getWhere().disableAutoAddStatusWhere();
company2.getSqlMap().getDataScope().addFilter("dsf",
Company company5 = new Company();
company5.getSqlMap().getWhere().disableAutoAddStatusWhere();
company5.getSqlMap().getDataScope().addFilter("dsf",
"Company", "a.`company_code`", DataScope.CTRL_PERMI_HAVE);
System.out.println(companyDao.findList(company2));
List<Company> companyList = companyDao.findList(company5);
System.out.println(companyList);
Assert.assertEquals("companyDao.findList extWhere", companyList.size(), 0);
System.out.println("============ 联合查询未设定columns和attrName为this时测试 ============");
FileUpload fileUpload = new FileUpload();
fileUpload.getSqlMap().getWhere().and("u.`user_name`", QueryType.EQ, "user1");
System.out.println(fileUploadDao.findList(fileUpload));
List<FileUpload> fileUploadList = fileUploadDao.findList(fileUpload);
System.out.println(fileUploadList);
Assert.assertEquals("fileUploadDao.findList attrName this", fileUploadList.size(), 0);
System.out.println("============ 树结构基本查询测试 ============");
DictData dictData = new DictData();
dictData.setParentCodes("0,");
System.out.println(dictDataDao.findByParentCodesLike(dictData));
System.out.println(dictDataDao.findList(dictData));
List<DictData> dictDataList = dictDataDao.findByParentCodesLike(dictData);
Assert.assertTrue("dictDataDao.findByParentCodesLike", dictDataList.size() > 0);
List<DictData> dictDataList2 = dictDataDao.findList(dictData);
System.out.println(dictDataList2);
Assert.assertTrue("dictDataDao.findList", dictDataList2.size() > 0);
System.out.println("============ 分页情况下foreach测试 ============");
EmpUser empUser = new EmpUser();
empUser.setCodes(new String[]{"SDJN01","SDJN02"});
empUser.setPage(new Page<>(1, 3));
List<EmpUser> list = empUserDao.findUserListByOfficeCodes(empUser);
System.out.println(list);
List<EmpUser> empUserList = empUserDao.findUserListByOfficeCodes(empUser);
System.out.println(empUserList);
Assert.assertTrue("empUserDao.findUserListByOfficeCodes", empUserList.size() > 0);
}catch(Exception e){
e.printStackTrace();
throw new Exception(e);
}
}
public static void main(String[] args) {
String a = null, b = null;
System.out.println("============ 基本测试 ============");
@@ -172,25 +231,25 @@ public class DaoMapperTest extends BaseSpringContextTests {
.getWhere().and("name", QueryType.EQ, "abc").toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND a.name = #{sqlMap.where.name#EQ1.val}";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config("1").getSqlMap().getWhere()
.and("name", QueryType.IN, new String[]{"1", "2", "3"}).toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND a.name IN ( #{sqlMap.where.name#IN1.val[0]},"
+ " #{sqlMap.where.name#IN1.val[1]}, #{sqlMap.where.name#IN1.val[2]} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config("1").getSqlMap().getWhere()
.or("name", QueryType.IN, new String[]{"1", "2", "3"}).toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} OR a.name IN ( #{sqlMap.where.name#IN1.val[0]},"
+ " #{sqlMap.where.name#IN1.val[1]}, #{sqlMap.where.name#IN1.val[2]} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 重复赋值测试 ============");
a = new Config("1").getSqlMap().getWhere()
.and("name", QueryType.LIKE, "abc").and("name", QueryType.LIKE, "def").toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND a.name LIKE #{sqlMap.where.name#LIKE1.val}";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ IN、NOT IN 测试 ============");
a = new Config("1").getSqlMap().getWhere()
.and("name", QueryType.IN, new String[]{"abc","def"})
@@ -198,21 +257,21 @@ public class DaoMapperTest extends BaseSpringContextTests {
b = "a.`id` = #{sqlMap.where#id#EQ1} AND a.name IN ( #{sqlMap.where.name#IN1.val[0]}, #{sqlMap.where.name#IN1.val[1]} )"
+ " AND a.name2 NOT IN ( #{sqlMap.where.name2#NOT_IN1.val[0]}, #{sqlMap.where.name2#NOT_IN1.val[1]} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config("1").getSqlMap().getWhere()
.and("name", QueryType.IN, null).and("name2", QueryType.IN, new String[]{})
.and("name3", QueryType.NOT_IN, ListUtils.newArrayList()).toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1}";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 带括号测试 ============");
a = new Config("1").getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "abc", 1).or("name", QueryType.EQ, "def", 2)
.or("name", QueryType.EQ, "ghi", 3).endBracket().toSql();
.or("name", QueryType.EQ, "ghi", 3).endBracket().toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND ( a.name = #{sqlMap.where.name#EQ1.val}"
+ " OR a.name = #{sqlMap.where.name#EQ2.val} OR a.name = #{sqlMap.where.name#EQ3.val} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config().getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "val1", 1).and("name", QueryType.NE, "val2", 11).endBracket(1)
.orBracket("name", QueryType.NE, "val3", 2).and("name", QueryType.NE, "val4", 22).endBracket(2)
@@ -222,41 +281,41 @@ public class DaoMapperTest extends BaseSpringContextTests {
+ " OR ( a.name != #{sqlMap.where.name#NE2.val} AND a.name != #{sqlMap.where.name#NE22.val} )"
+ " OR ( a.name != #{sqlMap.where.name#NE3.val} AND a.name = #{sqlMap.where.name#EQ33.val} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 带括号部分空值测试 ============");
a = new Config("1").getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "", 1).or("name", QueryType.EQ, "def", 2)
.or("name", QueryType.EQ, "", 3).endBracket().toSql();
.or("name", QueryType.EQ, "", 3).endBracket().toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND ( a.name = #{sqlMap.where.name#EQ2.val} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config("1").getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "abc", 1).or("name", QueryType.EQ, "def", 2)
.or("name", QueryType.EQ, "", 3).endBracket().toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND ( a.name = #{sqlMap.where.name#EQ1.val}"
+ " OR a.name = #{sqlMap.where.name#EQ2.val} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config("1").getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "", 1).or("name", QueryType.EQ, "def", 2)
.or("name", QueryType.EQ, "ghi", 3).endBracket().toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} AND ( a.name = #{sqlMap.where.name#EQ2.val}"
+ " OR a.name = #{sqlMap.where.name#EQ3.val} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 带括号全部空值测试 ============");
a = new Config("1").getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "", 1).or("name", QueryType.EQ, "", 2)
.or("name", QueryType.EQ, "", 3).endBracket().toSql();
b = "a.`id` = #{sqlMap.where#id#EQ1} ";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
a = new Config().getSqlMap().getWhere()
.andBracket("name", QueryType.EQ, "", 1).or("name", QueryType.EQ, "", 2)
.or("name", QueryType.EQ, "", 3).endBracket().toSql();
b = "";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 实体嵌套测试 ============");
Company company = new Company("1");
company.setCreateDate_gte(new Date());
@@ -280,7 +339,7 @@ public class DaoMapperTest extends BaseSpringContextTests {
a = new FileUpload().getSqlMap().getWhere().and("u.`user_name`", QueryType.EQ, "user1").toSql();
b = "a.`status` != #{STATUS_DELETE} AND u.`user_name` = #{sqlMap.where.u#_user_name_#EQ1.val}";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 联合查询,返回到当前实体测试 ============");
FileUpload fileUpload = new FileUpload();
fileUpload.getSqlMap().getWhere().and("create_by", QueryType.IN, new String[]{"user1","user2"});
@@ -288,7 +347,7 @@ public class DaoMapperTest extends BaseSpringContextTests {
b = "a.`status` != #{STATUS_DELETE} AND a.create_by IN ( #{sqlMap.where.create_by#IN1.val[0]},"
+ " #{sqlMap.where.create_by#IN1.val[1]} )";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.out.println("============ 联合查询属性为this时也可作为查询条件 ============");
FileUpload fileUpload2 = new FileUpload();
fileUpload2.setCreateByName("ThinkGem/JeeSite");
@@ -297,7 +356,7 @@ public class DaoMapperTest extends BaseSpringContextTests {
b = "a.`status` != #{STATUS_DELETE} AND a.create_by IN ( #{sqlMap.where.create_by#IN1.val[0]},"
+ " #{sqlMap.where.create_by#IN1.val[1]} ) AND u.`user_name` LIKE #{sqlMap.where#user_name#LIKE1}";
System.out.println("a >> "+a);System.out.println("b >> "+b);Assert.assertEquals(a, b);
System.exit(0);
}
}

View File

@@ -5,7 +5,7 @@ companyName: ThinkGem
# 产品版本、版权年份
productVersion: V4.6
copyrightYear: 2022
copyrightYear: 2023
# 数据库连接
jdbc:

View File

@@ -6,13 +6,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<version>2.7.8</version>
<relativePath />
</parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JeeSite Parent</name>
@@ -42,18 +42,17 @@
<groovy.version>3.0.10</groovy.version>
<!-- framework version setting -->
<mybatis.version>3.5.10</mybatis.version>
<mybatis.version>3.5.11</mybatis.version>
<mybatis-spring.version>2.0.7</mybatis-spring.version>
<jsqlparser.version>4.5</jsqlparser.version>
<druid.version>1.2.11</druid.version>
<shiro.version>1.10.0</shiro.version>
<shiro.version>1.11.0</shiro.version>
<j2cache.version>2.8.0-release</j2cache.version>
<swagger.version>1.6.6</swagger.version>
<log4j2.version>2.18.0</log4j2.version>
<!-- jdbc setting -->
<!-- <mysql.version>5.1.49</mysql.version> -->
<!-- <mysql.version>8.0.29</mysql.version> -->
<h2.version>1.4.200</h2.version>
<!-- environment setting -->
<java.version>1.8</java.version>

View File

@@ -5,7 +5,7 @@
<groupId>com.jeesite</groupId>
<artifactId>jeesite</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JeeSite</name>

View File

@@ -5,7 +5,7 @@
<groupId>com.jeesite</groupId>
<artifactId>jeesite-root</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JeeSite Root</name>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>4.6.0-SNAPSHOT</version>
<version>4.6.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

View File

@@ -9,7 +9,7 @@ companyName: ThinkGem
# 产品版本、版权年份
productVersion: V4.6
copyrightYear: 2022
copyrightYear: 2023
# 是否演示模式
demoMode: false