update files.
This commit is contained in:
@@ -1,124 +1,124 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.tests.BaseSpringContextTests;
|
||||
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.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.User;
|
||||
|
||||
/**
|
||||
* Mapper测试
|
||||
* @author ThinkGem
|
||||
* @version 2017年2月25日
|
||||
*/
|
||||
public class DaoTest extends BaseSpringContextTests {
|
||||
|
||||
@Autowired
|
||||
private ConfigDao configDao;
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
@Autowired
|
||||
private AreaDao areaDao;
|
||||
@Autowired
|
||||
private CompanyDao companyDao;
|
||||
@Autowired
|
||||
private DictDataDao dictDataDao;
|
||||
|
||||
@Test
|
||||
public void testTableAnnotation() throws Exception{
|
||||
try{
|
||||
|
||||
Config config = new Config();
|
||||
config.setId("1");
|
||||
config.setConfigKey("test");
|
||||
config.setConfigName("test");
|
||||
config.setConfigValue("1");
|
||||
config.setIsSys("1");
|
||||
Config config2 = (Config)BeanUtils.cloneBean(config);
|
||||
config2.setId("2");
|
||||
Config config3 = (Config)BeanUtils.cloneBean(config);
|
||||
config3.setId("3");
|
||||
|
||||
System.out.println(configDao.insert(config));
|
||||
System.out.println(configDao.insertBatch(ListUtils.newArrayList(config2, config3)));
|
||||
|
||||
User user = new User();
|
||||
user.setUserType(User.USER_TYPE_NONE);
|
||||
System.out.println(userDao.findList(user));
|
||||
|
||||
Area area = new Area();
|
||||
area.setAreaCode("1");
|
||||
area.setAreaName("你好");
|
||||
area.setStatus("0");
|
||||
|
||||
Area where = new Area();
|
||||
where.setAreaCode("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));
|
||||
System.out.println(areaDao.delete(area));
|
||||
System.out.println(areaDao.delete(where));
|
||||
System.out.println(areaDao.deleteByEntity(where));
|
||||
System.out.println(areaDao.findList(area));
|
||||
|
||||
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.setViewCode("1");
|
||||
company.setParentCode("0");
|
||||
company.setParentCodes("0,");
|
||||
company.setTreeSort(1);
|
||||
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.setPage(new Page<Company>(1, 20));
|
||||
company.setIsQueryChildren(true);
|
||||
System.out.println(companyDao.findList(company));
|
||||
|
||||
DictData dictData = new DictData();
|
||||
dictData.setParentCodes("0,");
|
||||
System.out.println(dictDataDao.findByParentCodesLike(dictData));
|
||||
System.out.println(dictDataDao.findList(dictData));
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.tests.BaseSpringContextTests;
|
||||
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.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.User;
|
||||
|
||||
/**
|
||||
* Mapper测试
|
||||
* @author ThinkGem
|
||||
* @version 2017年2月25日
|
||||
*/
|
||||
public class DaoTest extends BaseSpringContextTests {
|
||||
|
||||
@Autowired
|
||||
private ConfigDao configDao;
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
@Autowired
|
||||
private AreaDao areaDao;
|
||||
@Autowired
|
||||
private CompanyDao companyDao;
|
||||
@Autowired
|
||||
private DictDataDao dictDataDao;
|
||||
|
||||
@Test
|
||||
public void testTableAnnotation() throws Exception{
|
||||
try{
|
||||
|
||||
Config config = new Config();
|
||||
config.setId("1");
|
||||
config.setConfigKey("test");
|
||||
config.setConfigName("test");
|
||||
config.setConfigValue("1");
|
||||
config.setIsSys("1");
|
||||
Config config2 = (Config)BeanUtils.cloneBean(config);
|
||||
config2.setId("2");
|
||||
Config config3 = (Config)BeanUtils.cloneBean(config);
|
||||
config3.setId("3");
|
||||
|
||||
System.out.println(configDao.insert(config));
|
||||
System.out.println(configDao.insertBatch(ListUtils.newArrayList(config2, config3)));
|
||||
|
||||
User user = new User();
|
||||
user.setUserType(User.USER_TYPE_NONE);
|
||||
System.out.println(userDao.findList(user));
|
||||
|
||||
Area area = new Area();
|
||||
area.setAreaCode("1");
|
||||
area.setAreaName("你好");
|
||||
area.setStatus("0");
|
||||
|
||||
Area where = new Area();
|
||||
where.setAreaCode("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));
|
||||
System.out.println(areaDao.delete(area));
|
||||
System.out.println(areaDao.delete(where));
|
||||
System.out.println(areaDao.deleteByEntity(where));
|
||||
System.out.println(areaDao.findList(area));
|
||||
|
||||
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.setViewCode("1");
|
||||
company.setParentCode("0");
|
||||
company.setParentCodes("0,");
|
||||
company.setTreeSort(1);
|
||||
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.setPage(new Page<Company>(1, 20));
|
||||
company.setIsQueryChildren(true);
|
||||
System.out.println(companyDao.findList(company));
|
||||
|
||||
DictData dictData = new DictData();
|
||||
dictData.setParentCodes("0,");
|
||||
System.out.println(dictDataDao.findByParentCodesLike(dictData));
|
||||
System.out.println(dictDataDao.findList(dictData));
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
package com.jeesite.test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.mapper.JsonMapper;
|
||||
import com.jeesite.common.security.DesUtils;
|
||||
import com.jeesite.common.web.http.HttpClientUtils;
|
||||
|
||||
/**
|
||||
* 手机接入测试类
|
||||
* @author ThinkGem
|
||||
* @version 2016-10-21
|
||||
*/
|
||||
public class MobileAppTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String url = null;
|
||||
|
||||
// 获取权限信息
|
||||
url = "/index?permi=true";
|
||||
System.out.println("result: " + post(url, null));
|
||||
|
||||
// 获取部门列表数据
|
||||
url = "/sys/office/treeData";
|
||||
System.out.println("result: " + post(url, null));
|
||||
|
||||
// 获取用户列表数据
|
||||
url = "/sys/empUser/treeData";
|
||||
System.out.println("result: " + post(url, null));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务器地址
|
||||
*/
|
||||
private static String servUrl = "http://127.0.0.1:8980/js/a";
|
||||
|
||||
/**
|
||||
* 登录地址及登录信息
|
||||
*/
|
||||
private static String loginUrl = "/login"
|
||||
+ "?username=" + DesUtils.encode("thinkgem", "thinkgem,jeesite,com")
|
||||
+ "&password=" + DesUtils.encode("admin", "thinkgem,jeesite,com")
|
||||
+ "¶m_deviceType=mobileApp";
|
||||
|
||||
/**
|
||||
* 存储的会话编号,则通过getSid()获取。
|
||||
*/
|
||||
private static String __sid = "";
|
||||
|
||||
|
||||
/**
|
||||
* 获取有效的会话编号
|
||||
*/
|
||||
public static void refreshSid(){
|
||||
List<Map<String, Object>> result = post(loginUrl, null);
|
||||
if (result.size() == 1){
|
||||
Map<String, Object> res = result.get(0);
|
||||
if ("true".equals(res.get("result"))){
|
||||
__sid = (String)res.get("sessionid");
|
||||
}else{
|
||||
throw new RuntimeException("操作失败!错误信息:" + res.get("message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送post请求
|
||||
*/
|
||||
public static List<Map<String, Object>> post(String url, Map<String, String> data){
|
||||
List<Map<String, Object>> result = ListUtils.newArrayList();
|
||||
for (int i = 0; i < 2; i++){
|
||||
if (data == null){
|
||||
data = MapUtils.newHashMap();
|
||||
}
|
||||
data.put("__sid", __sid); // 设置 SessionID
|
||||
String body = HttpClientUtils.ajaxPost(servUrl + url, data);
|
||||
System.out.println("post: " + servUrl + url + ", param: " + data + " , body: " + body);
|
||||
result = JsonMapper.fromJsonForMapList(body);
|
||||
if (result.size() == 1 && "login".equals(result.get(0).get("result"))){
|
||||
refreshSid(); // 刷新SessionID再重新尝试
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
package com.jeesite.test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.mapper.JsonMapper;
|
||||
import com.jeesite.common.security.DesUtils;
|
||||
import com.jeesite.common.web.http.HttpClientUtils;
|
||||
|
||||
/**
|
||||
* 手机接入测试类
|
||||
* @author ThinkGem
|
||||
* @version 2016-10-21
|
||||
*/
|
||||
public class MobileAppTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String url = null;
|
||||
|
||||
// 获取权限信息
|
||||
url = "/index?permi=true";
|
||||
System.out.println("result: " + post(url, null));
|
||||
|
||||
// 获取部门列表数据
|
||||
url = "/sys/office/treeData";
|
||||
System.out.println("result: " + post(url, null));
|
||||
|
||||
// 获取用户列表数据
|
||||
url = "/sys/empUser/treeData";
|
||||
System.out.println("result: " + post(url, null));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务器地址
|
||||
*/
|
||||
private static String servUrl = "http://127.0.0.1:8980/js/a";
|
||||
|
||||
/**
|
||||
* 登录地址及登录信息
|
||||
*/
|
||||
private static String loginUrl = "/login"
|
||||
+ "?username=" + DesUtils.encode("thinkgem", "thinkgem,jeesite,com")
|
||||
+ "&password=" + DesUtils.encode("admin", "thinkgem,jeesite,com")
|
||||
+ "¶m_deviceType=mobileApp";
|
||||
|
||||
/**
|
||||
* 存储的会话编号,则通过getSid()获取。
|
||||
*/
|
||||
private static String __sid = "";
|
||||
|
||||
|
||||
/**
|
||||
* 获取有效的会话编号
|
||||
*/
|
||||
public static void refreshSid(){
|
||||
List<Map<String, Object>> result = post(loginUrl, null);
|
||||
if (result.size() == 1){
|
||||
Map<String, Object> res = result.get(0);
|
||||
if ("true".equals(res.get("result"))){
|
||||
__sid = (String)res.get("sessionid");
|
||||
}else{
|
||||
throw new RuntimeException("操作失败!错误信息:" + res.get("message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送post请求
|
||||
*/
|
||||
public static List<Map<String, Object>> post(String url, Map<String, String> data){
|
||||
List<Map<String, Object>> result = ListUtils.newArrayList();
|
||||
for (int i = 0; i < 2; i++){
|
||||
if (data == null){
|
||||
data = MapUtils.newHashMap();
|
||||
}
|
||||
data.put("__sid", __sid); // 设置 SessionID
|
||||
String body = HttpClientUtils.ajaxPost(servUrl + url, data);
|
||||
System.out.println("post: " + servUrl + url + ", param: " + data + " , body: " + body);
|
||||
result = JsonMapper.fromJsonForMapList(body);
|
||||
if (result.size() == 1 && "login".equals(result.get(0).get("result"))){
|
||||
refreshSid(); // 刷新SessionID再重新尝试
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user