/** * 查询用户数据 * * @param user * @param page * @return */ public List<User> listUsers(User user, PageInfo page) { StringBuilder sql = new StringBuilder(); sql.append("SELECT T1.id,nickname,phone,industry, ") .append("T2.name as schoolName,major,grade,T3.name AS gradeName ") .append("FROM USER_INFO T1 ") .append("LEFT JOIN SYS_SCHOOL T2 ON T2.ID=T1.schoolId ") .append("LEFT JOIN SYS_DICT T3 ON T3.CODE=T1.grade AND T3.groupName=? ") .append("WHERE 1=1 "); ParamInfo paramInfo = new ParamInfo(); paramInfo.setTypeAndData(Types.VARCHAR, GloabConstant.GROUP_GRADE); if (!Utils.isEmpty(user.getNickname())) { sql.append(" AND T1.nickname like ? "); paramInfo.setTypeAndData(Types.VARCHAR, "%" + user.getNickname() + "%"); } if (!Utils.isEmpty(user.getType())) { sql.append(" AND T1.type = ? "); paramInfo.setTypeAndData(Types.CHAR, user.getType()); } // if(!Utils.isEmpty(user.getStatus())) // { // sql.append(" AND status = ? "); // paramInfo.setTypeAndData(Types.CHAR, user.getStatus()); // } return userDao.getRecords(sql.toString(), paramInfo, page, User.class); }
/** * 更新用户 * * @param user * @return */ public void updateUser(User user) { StringBuilder sql = new StringBuilder(); sql.append("update USER_INFO set "); ParamInfo paramInfo = new ParamInfo(); if (!Utils.isEmpty(user.getName())) { sql.append("name=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getName()); } if (!Utils.isEmpty(user.getPhone())) { sql.append("phone=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getPhone()); } if (!Utils.isEmpty(user.getNickname())) { sql.append("nickname=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getNickname()); } if (!Utils.isEmpty(user.getSchoolId())) { sql.append("schoolId=?,"); paramInfo.setTypeAndData(Types.BIGINT, user.getSchoolId()); } if (!Utils.isEmpty(user.getMajor())) { sql.append("major=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getMajor()); } if (!Utils.isEmpty(user.getGrade())) { sql.append("grade=?,"); paramInfo.setTypeAndData(Types.CHAR, user.getGrade()); } if (!Utils.isEmpty(user.getUrl())) { sql.append("url=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getUrl()); } if (!Utils.isEmpty(user.getBackground_url())) { sql.append("background_url=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getBackground_url()); } if (!Utils.isEmpty(user.getIndustry())) { sql.append("industry=?,"); paramInfo.setTypeAndData(Types.VARCHAR, user.getIndustry()); } if (sql.toString().endsWith(",")) { sql.replace(sql.length() - 1, sql.length(), ""); sql.append(" where id=?"); paramInfo.setTypeAndData(Types.BIGINT, user.getId()); userDao.updateRecord(sql.toString(), paramInfo); } }
/** * 获取大拿数量 * * @param user * @return */ public long getGreaterCount(User user) { StringBuilder sql = new StringBuilder(); sql.append("SELECT count(1) ") .append("FROM USER_GREATER T1 ") .append("INNER JOIN USER_INFO T2 ON T2.ID=T1.ID ") .append("WHERE 1=1 "); ParamInfo paramInfo = new ParamInfo(); if (user != null) { if (!Utils.isEmpty(user.getNickname())) { sql.append(" AND T2.nickname like ? "); paramInfo.setTypeAndData(Types.VARCHAR, "%" + user.getNickname() + "%"); } } return greaterDao.getCount(sql.toString(), paramInfo); }
/** * 查询大拿列表 * * @param page * @return */ public List<Greater> listGreaters(User user, PageInfo page) { StringBuilder sql = new StringBuilder(); sql.append( "SELECT T1.id,T2.phone,T1.tags,T2.nickname,T1.company,T1.post,T2.url,T1.answerTimes ") .append("FROM USER_GREATER T1 ") .append("INNER JOIN USER_INFO T2 ON T2.ID=T1.ID ") .append("WHERE 1=1 "); ParamInfo paramInfo = new ParamInfo(); if (user != null) { if (!Utils.isEmpty(user.getNickname())) { sql.append(" AND T2.nickname like ? "); paramInfo.setTypeAndData(Types.VARCHAR, "%" + user.getNickname() + "%"); } } else { sql.append("AND isshow=? "); paramInfo.setTypeAndData(Types.CHAR, GloabConstant.YESNO_YES); } sql.append("ORDER BY orderNo ASC "); return greaterDao.getRecords(sql.toString(), paramInfo, page, Greater.class); }