Search in sources :

Example 11 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.

the class SvrUserLogin method enrollMachineInfo.

private void enrollMachineInfo(String corpNo, String userCode, String deviceId, String deviceName) {
    SqlQuery ds = new SqlQuery(this);
    ds.add("select * from %s", SystemTable.get(SystemTable.getDeviceVerify));
    ds.add("where UserCode_='%s' and MachineCode_='%s'", userCode, deviceId);
    ds.open();
    if (!ds.eof()) {
        return;
    }
    ds.append();
    ds.setField("CorpNo_", corpNo);
    ds.setField("UserCode_", userCode);
    ds.setField("VerifyCode_", intToStr(random(900000) + 100000));
    ds.setField("DeadLine_", TDateTime.Now().incDay(1));
    ds.setField("MachineCode_", deviceId);
    if (deviceId.startsWith("i_")) {
        // iOS
        ds.setField("MachineType_", 6);
        ds.setField("MachineName_", ClientType.IOS.toString());
    } else if (deviceId.startsWith("n_")) {
        // Android
        ds.setField("MachineType_", 7);
        ds.setField("MachineName_", ClientType.Android.toString());
    } else {
        // 系统默认
        ds.setField("MachineType_", 0);
        ds.setField("MachineName_", deviceName);
    }
    ds.setField("Remark_", "");
    ds.setField("Used_", 0);
    ds.setField("UpdateUser_", userCode);
    ds.setField("UpdateDate_", TDateTime.Now());
    ds.setField("AppUser_", userCode);
    ds.setField("AppDate_", TDateTime.Now());
    ds.setField("UpdateKey_", newGuid());
    ds.post();
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery)

Example 12 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.

the class SvrUserMessages method getWaitList.

/**
 * @return 取出所有的等待处理的消息列表
 */
public boolean getWaitList() {
    SqlQuery ds = new SqlQuery(this);
    ds.setMaximum(5);
    ds.add("select ms.UID_ from %s ms", SystemTable.get(SystemTable.getUserMessages));
    ds.add("where ms.Level_=%s", MessageLevel.Service.ordinal());
    ds.add("and ms.Process_=%s", MessageProcess.wait.ordinal());
    ds.open();
    this.getDataOut().appendDataSet(ds);
    return true;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery)

Example 13 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.

the class SvrUserMessages method readAsyncService.

/**
 * @return 读取指定的消息记录
 */
public boolean readAsyncService() {
    String msgId = getDataIn().getHead().getString("msgId");
    SqlQuery ds = new SqlQuery(this);
    ds.add("select * from %s", SystemTable.get(SystemTable.getUserMessages));
    ds.add("where Level_=%s", MessageLevel.Service.ordinal());
    ds.add("and Process_=%s", MessageProcess.wait.ordinal());
    ds.add("and UID_='%s'", msgId);
    ds.open();
    if (// 此任务可能被其它主机抢占
    ds.eof())
        return false;
    Record headOut = getDataOut().getHead();
    headOut.setField("corpNo", ds.getString("CorpNo_"));
    headOut.setField("userCode", ds.getString("UserCode_"));
    headOut.setField("subject", ds.getString("Subject_"));
    headOut.setField("content", ds.getString("Content_"));
    return true;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery) Record(cn.cerc.jdb.core.Record) MessageRecord(cn.cerc.jmis.message.MessageRecord) JPushRecord(cn.cerc.jmis.message.JPushRecord)

Example 14 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.

the class SecurityEnvironment method getUserSecuirtyMobile.

public static String getUserSecuirtyMobile(IForm form) {
    SqlQuery ds1 = new SqlQuery(form.getHandle());
    ds1.add("SELECT mobile_,securityMobile_,countryCode_ FROM %s", SystemTable.getUserInfo);
    ds1.add("WHERE id_='%s'", form.getHandle().getUserCode());
    ds1.open();
    if (ds1.eof()) {
        log.error(String.format("userCode %s 找不到", form.getHandle().getUserCode()));
        return "";
    }
    String mobile = ds1.getString("mobile_");
    if (!"".equals(ds1.getString("securityMobile_"))) {
        mobile = ds1.getString("securityMobile_");
    } else {
        mobile = ds1.getString("countryCode_") + mobile;
    }
    return mobile;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery)

Example 15 with SqlQuery

use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.

the class SecurityEnvironment method isSecurity.

private static boolean isSecurity(AbstractForm form) {
    String remoteIP = RemoteIP.get(form);
    String clientId = form.getClient().getId();
    String userId = form.getHandle().getUserCode();
    log.debug(String.format("ip: %s, clientId:%s, userId: %s", remoteIP, clientId, userId));
    String mobile = getUserSecuirtyMobile(form);
    if ("".equals(mobile)) {
        return false;
    }
    SqlQuery ds2 = new SqlQuery(form.getHandle());
    ds2.add("select * from %s", SystemTable.getSecurityMobile);
    ds2.add("where mobile_='%s'", mobile);
    ds2.open();
    if (ds2.eof()) {
        return false;
    }
    if (!clientId.equals(ds2.getString("clientId_"))) {
        return false;
    }
    if (!remoteIP.equals(ds2.getString("remoteIP_"))) {
        return false;
    }
    // }
    return true;
}
Also used : SqlQuery(cn.cerc.jdb.mysql.SqlQuery)

Aggregations

SqlQuery (cn.cerc.jdb.mysql.SqlQuery)38 Record (cn.cerc.jdb.core.Record)15 Webfunc (cn.cerc.jbean.core.Webfunc)4 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)3 BuildQuery (cn.cerc.jdb.mysql.BuildQuery)3 CustomHandle (cn.cerc.jbean.core.CustomHandle)2 IMemcache (cn.cerc.jdb.cache.IMemcache)2 JPushRecord (cn.cerc.jmis.message.JPushRecord)2 MessageRecord (cn.cerc.jmis.message.MessageRecord)2 HashMap (java.util.HashMap)2 LocalService (cn.cerc.jbean.client.LocalService)1 DataValidateException (cn.cerc.jbean.core.DataValidateException)1 ServerConfig (cn.cerc.jbean.core.ServerConfig)1 ServiceException (cn.cerc.jbean.core.ServiceException)1 UserNotFindException (cn.cerc.jbean.other.UserNotFindException)1 StubHandle (cn.cerc.jbean.rds.StubHandle)1 DataSet (cn.cerc.jdb.core.DataSet)1 SqlSession (cn.cerc.jdb.mysql.SqlSession)1 Transaction (cn.cerc.jdb.mysql.Transaction)1 Gson (com.google.gson.Gson)1