package cn.com.chinautrust.idm.repo.mybatis.provider; import org.springframework.util.StringUtils; import cn.com.chinautrust.idm.bo.user.AdminVO; public class AdminVOProvider { public static String findListBySql(final String sql, final String contextSql){ return new IbatisSQL(){{ SELECT("id, adminName, adminLoginName, adminRole, deptName, pwd, lastTime, deptCodeLimit, deptCodeSkip"); FROM("ADMIN_INFO"); if(StringUtils.hasText(sql)){ WHERE(sql); } }}.toString(contextSql); } public static String update(final AdminVO bean){ return new IbatisSQL(){{ UPDATE("ADMIN_INFO"); if(StringUtils.hasText(bean.getAdminName())){ SET("adminName = #{adminName}"); } if(StringUtils.hasText(bean.getAdminLoginName())){ SET("adminLoginName = #{adminLoginName}"); } if(StringUtils.hasText(bean.getAdminRole())){ SET("adminRole = #{adminRole}"); } if(StringUtils.hasText(bean.getDeptName())){ SET("deptName = #{deptName}"); } if(StringUtils.hasText(bean.getPwd())){ SET("pwd = #{pwd}"); } if(StringUtils.hasText(bean.getLastTime())){ SET("lastTime = #{lastTime}"); } if(bean.getDeptCodeLimit() != null){ SET("deptCodeLimit = #{deptCodeLimit}"); } if(bean.getDeptCodeSkip() != null){ SET("deptCodeSkip = #{deptCodeSkip}"); } WHERE("ID = #{id}"); }}.toString(); } public static String findListByBean(final AdminVO bean){ return new IbatisSQL(){{ SELECT("id, adminName, adminLoginName, adminRole, deptName, pwd, lastTime, deptCodeLimit, deptCodeSkip"); FROM("ADMIN_INFO"); if(bean.getId() > 0){ WHERE("id = #{id}"); } if(StringUtils.hasText(bean.getAdminName())){ WHERE("adminName = #{adminName}"); } if(StringUtils.hasText(bean.getAdminLoginName())){ WHERE("adminLoginName = #{adminLoginName}"); } if(StringUtils.hasText(bean.getAdminRole())){ WHERE("adminRole = #{adminRole}"); } if(StringUtils.hasText(bean.getDeptName())){ WHERE("deptName = #{deptName}"); } if(StringUtils.hasText(bean.getPwd())){ WHERE("pwd = #{pwd}"); } if(StringUtils.hasText(bean.getLastTime())){ WHERE("lastTime = #{lastTime}"); } if(bean.getDeptCodeLimit() != null){ WHERE("deptCodeLimit = #{deptCodeLimit}"); } if(bean.getDeptCodeSkip() != null){ WHERE("deptCodeSkip = #{deptCodeSkip}"); } }}.toString(); } }