Search in sources :

Example 1 with StaffInfoVO

use of org.sagacity.sqltoy.demo.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class SqlLoopTest method testSqlLoop.

@Test
public void testSqlLoop() {
    List<StaffInfoVO> staffInfos = new ArrayList<StaffInfoVO>();
    for (int i = 0; i < 5; i++) {
        StaffInfoVO staff = new StaffInfoVO();
        staff.setStaffId("S000" + (i + 1));
        staff.setBirthday(LocalDate.now());
        staffInfos.add(staff);
    }
    SqlLoop sqlLoop = new SqlLoop();
    String[] params = { "staffInfos", "(staffId=':staffInfos[i].staffId' and birthDay=':staffInfos[i].birthday')", "or" };
    IgnoreKeyCaseMap<String, Object> keyValues = new IgnoreKeyCaseMap<String, Object>();
    keyValues.put("staffInfos", staffInfos);
    String result = sqlLoop.execute(params, keyValues);
    System.err.print(result);
}
Also used : ArrayList(java.util.ArrayList) StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) SqlLoop(org.sagacity.sqltoy.plugins.id.macro.impl.SqlLoop) IgnoreKeyCaseMap(org.sagacity.sqltoy.model.IgnoreKeyCaseMap) Test(org.junit.jupiter.api.Test)

Example 2 with StaffInfoVO

use of org.sagacity.sqltoy.demo.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class BeanUtilTest method testReflect.

@Test
public void testReflect() {
    StaffInfoVO staff = new StaffInfoVO();
    staff.setEmail("zhongxuchen@gmail.com");
    staff.setStaffId("S001");
    staff.setResType(1);
    try {
        System.err.println(JSON.toJSONString(BeanUtil.reflectBeanToAry(staff, new String[] { "resType", "staffId" })));
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) Test(org.junit.jupiter.api.Test)

Example 3 with StaffInfoVO

use of org.sagacity.sqltoy.demo.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class BeanUtilTest method testBeanWrapper.

@Test
public void testBeanWrapper() {
    List<StaffInfoVO> staffInfos = new ArrayList<StaffInfoVO>();
    StaffInfoVO staff = new StaffInfoVO();
    staff.setEmail("zhongxuchen@gmail.com");
    staff.setStaffId("S001");
    staff.setResType(1);
    StaffInfoVO staff1 = new StaffInfoVO();
    staff1.setEmail("zhongxuchen@gmail.com");
    staff1.setStaffId("S001");
    staff1.setResType(1);
    staffInfos.add(staff);
    staffInfos.add(staff1);
    BeanWrapper.create().names("staffName").values("陈").mappingSet(staffInfos);
    System.err.println(JSON.toJSONString(staffInfos));
}
Also used : ArrayList(java.util.ArrayList) StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) Test(org.junit.jupiter.api.Test)

Example 4 with StaffInfoVO

use of org.sagacity.sqltoy.demo.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class BeanUtilTest method testMultLevelMapListReflect.

@Test
public void testMultLevelMapListReflect() {
    StaffInfoVO staff = new StaffInfoVO();
    staff.setEmail("zhongxuchen@gmail.com");
    staff.setStaffId("S001");
    DataRange dataRange = new DataRange();
    dataRange.setBeginDate(DateUtil.getDate("2020-10-01"));
    dataRange.setEndDate(LocalDate.now());
    staff.setDataRange(dataRange);
    HashMap params = new HashMap();
    params.put("companyId", "C0001");
    params.put("companyName", "xxx企业集团");
    staff.setParams(params);
    Map map = new HashMap();
    map.put("staff", staff);
    List<Map> listMap = new ArrayList<Map>();
    listMap.add(map);
    List result = null;
    try {
        result = BeanUtil.reflectBeansToList(listMap, new String[] { "staff.staffid", "staff.email", "staff.dataRange.beginDate", "staff.dataRange.enddate", "staff.params.companyId", "staff.params.companyName" }, null);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    for (Object tmp : result) {
        System.err.println(tmp);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) DataRange(org.sagacity.sqltoy.demo.vo.DataRange) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) IgnoreKeyCaseMap(org.sagacity.sqltoy.model.IgnoreKeyCaseMap) IgnoreCaseLinkedMap(org.sagacity.sqltoy.model.IgnoreCaseLinkedMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 5 with StaffInfoVO

use of org.sagacity.sqltoy.demo.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class MapperUtilsTest method testVOToPO.

@Test
public void testVOToPO() {
    StaffInfoVO staffInfoVO = new StaffInfoVO();
    staffInfoVO.setStaffId("S2007");
    staffInfoVO.setStaffCode("S2007");
    staffInfoVO.setPostType("MASTER");
    staffInfoVO.setStaffName("测试员工9");
    staffInfoVO.setSexType("M");
    staffInfoVO.setEmail("test3@aliyun.com");
    staffInfoVO.setEntryDate(LocalDate.now());
    staffInfoVO.setStatus(1);
    staffInfoVO.setOrganId("100007");
    // staffInfoVO.setPhoto(FileUtil.readAsBytes("classpath:/mock/staff_photo.jpg"));
    staffInfoVO.setCountry("86");
    SqlToyContext context = new SqlToyContext();
    try {
        context.initialize();
        StaffInfo staffInfo = MapperUtils.map(context, staffInfoVO, StaffInfo.class);
        System.err.println(JSON.toJSONString(staffInfo));
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : StaffInfoVO(org.sagacity.sqltoy.demo.vo.StaffInfoVO) SqlToyContext(org.sagacity.sqltoy.SqlToyContext) StaffInfo(org.sagacity.sqltoy.demo.domain.StaffInfo) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)8 StaffInfoVO (org.sagacity.sqltoy.demo.vo.StaffInfoVO)8 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DataRange (org.sagacity.sqltoy.demo.vo.DataRange)3 IgnoreKeyCaseMap (org.sagacity.sqltoy.model.IgnoreKeyCaseMap)3 Map (java.util.Map)2 SqlToyContext (org.sagacity.sqltoy.SqlToyContext)2 StaffInfo (org.sagacity.sqltoy.demo.domain.StaffInfo)2 IgnoreCaseLinkedMap (org.sagacity.sqltoy.model.IgnoreCaseLinkedMap)2 List (java.util.List)1 SqlLoop (org.sagacity.sqltoy.plugins.id.macro.impl.SqlLoop)1