use of com.akaxin.site.storage.bean.UicBean in project openzaly by akaxincom.
the class HttpUICService method info.
/**
* 获取UIC信息
*
* @param command
* @return
*/
public CommandResponse info(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUicInfoProto.HaiUicInfoRequest request = HaiUicInfoProto.HaiUicInfoRequest.parseFrom(command.getParams());
int id = request.getId();
String uic = request.getUic();
LogUtils.requestDebugLog(logger, command, request.toString());
if (id > 0 && StringUtils.isNotBlank(uic)) {
UicBean bean = SiteUicDao.getInstance().getUicInfo(uic);
if (bean != null) {
HaiUicInfoProto.HaiUicInfoResponse response = HaiUicInfoProto.HaiUicInfoResponse.newBuilder().setUicInfo(getUicInfo(bean)).build();
commandResponse.setParams(response.toByteArray());
errorCode = ErrorCode2.SUCCESS;
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.site.storage.bean.UicBean in project openzaly by akaxincom.
the class SQLiteUICDao method queryUIC.
/**
* 查询UIC使用情况
*
* @param uic
* @return
* @throws SQLException
*/
public UicBean queryUIC(String uic) throws SQLException {
long startTime = System.currentTimeMillis();
String sql = "SELECT uic,site_user_id,status,create_time,use_time FROM " + UIC_TABLE + " WHERE uic=?;";
UicBean bean = null;
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setString(1, uic);
ResultSet rs = preStatement.executeQuery();
if (rs.next()) {
bean = new UicBean();
bean.setUic(rs.getString(1));
bean.setSiteUserId(rs.getString(2));
bean.setStatus(rs.getInt(3));
bean.setCreateTime(rs.getLong(4));
bean.setUseTime(rs.getLong(5));
}
LogUtils.dbDebugLog(logger, startTime, bean, sql, uic);
return bean;
}
use of com.akaxin.site.storage.bean.UicBean in project openzaly by akaxincom.
the class SQLiteUICDao method queryUicList.
public List<UicBean> queryUicList(int pageNum, int pageSize, int status) throws SQLException {
long startTime = System.currentTimeMillis();
List<UicBean> uicList = new ArrayList<UicBean>();
String sql = "SELECT a.id,a.uic,a.site_user_id,b.user_name,a.create_time,a.use_time FROM " + UIC_TABLE + " AS a LEFT JOIN " + USER_PROFILE_TABLE + " AS b ON a.site_user_id=b.site_user_id where a.status=? LIMIT ?,?;";
int startNum = (pageNum - 1) * pageSize;
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setInt(1, status);
preStatement.setInt(2, startNum);
preStatement.setInt(3, pageSize);
ResultSet rs = preStatement.executeQuery();
while (rs.next()) {
UicBean bean = new UicBean();
bean.setId(rs.getInt(1));
bean.setUic(rs.getString(2));
bean.setSiteUserId(rs.getString(3));
bean.setUserName(rs.getString(4));
bean.setCreateTime(rs.getLong(5));
bean.setUseTime(rs.getLong(6));
uicList.add(bean);
}
LogUtils.dbDebugLog(logger, startTime, uicList, sql);
return uicList;
}
use of com.akaxin.site.storage.bean.UicBean in project openzaly by akaxincom.
the class SQLiteUICDao method queryAllUicList.
/**
* 查询所有UIC列表
*
* @param pageNum
* @param pageSize
* @return
* @throws SQLException
*/
public List<UicBean> queryAllUicList(int pageNum, int pageSize) throws SQLException {
long startTime = System.currentTimeMillis();
List<UicBean> uicList = new ArrayList<UicBean>();
String sql = "SELECT a.id,a.uic,a.site_user_id,b.user_name,a.create_time,a.use_time FROM " + UIC_TABLE + " AS a LEFT JOIN " + USER_PROFILE_TABLE + " AS b ON a.site_user_id=b.site_user_id LIMIT ?,?;";
int startNum = (pageNum - 1) * pageSize;
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setInt(1, startNum);
preStatement.setInt(2, pageSize);
ResultSet rs = preStatement.executeQuery();
while (rs.next()) {
UicBean bean = new UicBean();
bean.setId(rs.getInt(1));
bean.setUic(rs.getString(2));
bean.setSiteUserId(rs.getString(3));
bean.setUserName(rs.getString(4));
bean.setCreateTime(rs.getLong(5));
bean.setUseTime(rs.getLong(6));
uicList.add(bean);
}
LogUtils.dbDebugLog(logger, startTime, uicList, sql, startNum, pageSize);
return uicList;
}
use of com.akaxin.site.storage.bean.UicBean in project openzaly by akaxincom.
the class HttpUICService method create.
/**
* 生成UIC(用户邀请码)
*
* @param command
* @return
*/
public CommandResponse create(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUicCreateProto.HaiUicCreateRequest request = HaiUicCreateProto.HaiUicCreateRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
int num = request.getUicNumber();
int successCount = 0;
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && num > 0) {
UicBean bean = new UicBean();
bean.setStatus(UicStatus.UNUSED_VALUE);
bean.setCreateTime(System.currentTimeMillis());
if (SiteUicDao.getInstance().batchAddUic(bean, num)) {
errorCode = ErrorCode2.SUCCESS;
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
Aggregations