Search in sources :

Example 11 with Record

use of cn.cerc.jdb.core.Record in project summer-mis by cn-cerc.

the class MemoryBookInfo method get.

public static BookInfoRecord get(IHandle handle, String corpNo) {
    IMemcache buff = Application.getMemcache();
    String tmp = (String) buff.get(getBuffKey(corpNo));
    if (tmp == null || "".equals(tmp)) {
        LocalService svr = new LocalService(handle, "SvrBookInfo.getRecord");
        if (!svr.exec("corpNo", corpNo))
            return null;
        BookInfoRecord result = new BookInfoRecord();
        Record ds = svr.getDataOut().getHead();
        result.setCode(ds.getString("corpNo"));
        result.setShortName(ds.getString("shortName"));
        result.setName(ds.getString("name"));
        result.setAddress(ds.getString("address"));
        result.setTel(ds.getString("tel"));
        result.setManagerPhone(ds.getString("managerPhone"));
        result.setStartHost(ds.getString("host"));
        result.setContact(ds.getString("contact"));
        result.setAuthentication(ds.getBoolean("authentication"));
        result.setStatus(ds.getInt("status"));
        result.setCorpType(ds.getInt("type"));
        Gson gson = new Gson();
        buff.set(getBuffKey(corpNo), gson.toJson(result));
        return result;
    } else {
        Gson gson = new Gson();
        return gson.fromJson(tmp, BookInfoRecord.class);
    }
}
Also used : IMemcache(cn.cerc.jdb.cache.IMemcache) Gson(com.google.gson.Gson) Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Example 12 with Record

use of cn.cerc.jdb.core.Record in project summer-mis by cn-cerc.

the class AppLoginPage method getAccountFromTel.

/**
 * @param handle
 *            环境变量
 * @param 电话号码
 * @return 根据电话号码返回用户帐号,用于普及版登入
 * @throws ServletException
 *             异常
 * @throws IOException
 *             异常
 */
private String getAccountFromTel(IHandle handle, String tel) throws ServletException, IOException {
    LocalService app = new LocalService(handle);
    app.setService("SvrUserLogin.getUserCodeByMobile");
    app.getDataIn().getHead().setField("UserCode_", tel);
    if (!app.exec()) {
        Record headOut = app.getDataOut().getHead();
        throw new RuntimeException(headOut.getString("Msg_"));
    } else
        return app.getDataOut().getHead().getString("UserCode_");
}
Also used : Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService)

Example 13 with Record

use of cn.cerc.jdb.core.Record in project summer-mis by cn-cerc.

the class SvrCustomMenus method search.

public boolean search() {
    if (!SystemTable.ManageBook.equals(handle.getCorpNo()))
        throw new RuntimeException("您不是运营商账号不允许操作!");
    Record headIn = getDataIn().getHead();
    BuildQuery f = new BuildQuery(this);
    f.byField("s.Custom_", true);
    if (headIn.exists("SearchText_"))
        f.byLink(new String[] { "s.Name_", "c.CorpNo_", "oi.ShortName_" }, headIn.getString("SearchText_"));
    if (headIn.exists("MaxRecord_"))
        f.setMaximum(headIn.getInt("MaxRecord_"));
    if (headIn.exists("Custom"))
        f.byParam("c.CorpNo_ !='' and c.CorpNo_ is Not null");
    f.add("select s.Code_,s.Name_,c.Code_ as CostomCode_,oi.ShortName_,c.Remark_,c.CorpNo_,c.AppUser_,c.AppDate_ ");
    f.add("from %s s ", SystemTable.get(SystemTable.getAppMenus));
    f.add("left join %s c on s.Code_ = c.Code_", SystemTable.get(SystemTable.getCustomMenus));
    f.add("left join %s oi on oi.CorpNo_ = c.CorpNo_", SystemTable.get(SystemTable.getBookInfo));
    getDataOut().appendDataSet(f.open());
    return true;
}
Also used : BuildQuery(cn.cerc.jdb.mysql.BuildQuery) Record(cn.cerc.jdb.core.Record)

Example 14 with Record

use of cn.cerc.jdb.core.Record in project summer-mis by cn-cerc.

the class SvrUserLogin method sendVerifyCode.

@Webfunc
public boolean sendVerifyCode() throws DataValidateException {
    try (MemoryBuffer buff = new MemoryBuffer(BufferType.getObject, getUserCode(), SvrUserLogin.class.getName(), "sendVerifyCode")) {
        if (!buff.isNull()) {
            log.info(String.format("verifyCode %s", buff.getString("VerifyCode_")));
            throw new RuntimeException(String.format("请勿在 %d 分钟内重复点击获取认证码!", TimeOut));
        }
        Record headIn = getDataIn().getHead();
        DataValidateException.stopRun("用户帐号不允许为空", "".equals(getUserCode()));
        String deviceId = headIn.getString("deviceId");
        if ("".equals(deviceId)) {
            throw new RuntimeException("认证码不允许为空");
        }
        SqlQuery cdsUser = new SqlQuery(this);
        cdsUser.add("select Mobile_ from %s ", SystemTable.get(SystemTable.getUserInfo));
        cdsUser.add("where Code_='%s' ", getUserCode());
        cdsUser.open();
        DataValidateException.stopRun("系统检测到该帐号还未登记过手机号,无法发送认证码到该手机上,请您联系管理员,让其开一个认证码给您登录系统!", cdsUser.eof());
        String mobile = cdsUser.getString("Mobile_");
        SqlQuery cdsVer = new SqlQuery(this);
        cdsVer.add("select * from %s", SystemTable.get(SystemTable.getDeviceVerify));
        cdsVer.add("where UserCode_='%s' and MachineCode_='%s'", getUserCode(), deviceId);
        cdsVer.open();
        DataValidateException.stopRun("系统出错,请您重新进入系统!", cdsVer.size() != 1);
        String verifyCode = "888888";
        if (ServerConfig.getAppLevel() != ServerConfig.appTest) {
            verifyCode = intToStr(random(900000) + 100000);
        }
        cdsVer.edit();
        cdsVer.setField("VerifyCode_", verifyCode);
        cdsVer.setField("DeadLine_", TDateTime.Now().incDay(1));
        cdsVer.post();
        // 发送认证码到手机上
        Record record = getDataOut().getHead();
        LocalService svr = new LocalService(this, "SvrNotifyMachineVerify");
        if (svr.exec("verifyCode", verifyCode, "mobile", mobile)) {
            record.setField("Msg_", String.format("系统已将认证码发送到您尾号为 %s 的手机上,并且该认证码 %d 分钟内有效,请注意查收!", mobile.substring(mobile.length() - 4, mobile.length()), TimeOut));
            buff.setExpires(TimeOut * 60);
            buff.setField("VerifyCode", verifyCode);
        } else {
            record.setField("Msg_", String.format("验证码发送失败,失败原因:%s", svr.getMessage()));
        }
        record.setField("VerifyCode_", verifyCode);
        return true;
    }
}
Also used : MemoryBuffer(cn.cerc.jbean.other.MemoryBuffer) SqlQuery(cn.cerc.jdb.mysql.SqlQuery) Record(cn.cerc.jdb.core.Record) LocalService(cn.cerc.jbean.client.LocalService) Webfunc(cn.cerc.jbean.core.Webfunc)

Example 15 with Record

use of cn.cerc.jdb.core.Record in project summer-mis by cn-cerc.

the class SvrUserLogin method autoLogin.

@Webfunc
public boolean autoLogin() throws SecurityCheckException {
    Record headIn = getDataIn().getHead();
    String token1 = headIn.getString("token");
    // 加入ABCD是为了仅允许内部调用
    ServerConfig config = ServerConfig.getInstance();
    String token2 = config.getProperty(OssSession.oss_accessKeySecret, "") + "ABCD";
    // 如果不是内部调用,则返回false
    if (!token2.equals(token1)) {
        return false;
    }
    String clientId = headIn.getString("openid");
    SqlQuery ds = new SqlQuery(this);
    ds.add("SELECT A.Code_,A.Password_ FROM %s A", SystemTable.get(SystemTable.getDeviceVerify));
    ds.add("inner JOIN %s B", SystemTable.get(SystemTable.getUserInfo));
    ds.add("ON A.UserCode_=B.Code_");
    ds.add("WHERE A.MachineCode_='%s' AND A.AutoLogin_=1", clientId);
    ds.open();
    if (ds.eof()) {
        return false;
    }
    headIn.setField("Account_", ds.getString("Code_"));
    headIn.setField("Password_", ds.getString("Password_"));
    headIn.setField("MachineID_", clientId);
    headIn.setField("ClientName_", "Web浏览器");
    headIn.setField("ClientIP_", "127.0.0.1");
    headIn.setField("wx", true);
    return this.Check();
}
Also used : ServerConfig(cn.cerc.jbean.core.ServerConfig) SqlQuery(cn.cerc.jdb.mysql.SqlQuery) Record(cn.cerc.jdb.core.Record) Webfunc(cn.cerc.jbean.core.Webfunc)

Aggregations

Record (cn.cerc.jdb.core.Record)53 SqlQuery (cn.cerc.jdb.mysql.SqlQuery)15 LocalService (cn.cerc.jbean.client.LocalService)9 Webfunc (cn.cerc.jbean.core.Webfunc)4 DataSet (cn.cerc.jdb.core.DataSet)4 Ignore (org.junit.Ignore)4 Test (org.junit.Test)4 MemoryBuffer (cn.cerc.jbean.other.MemoryBuffer)3 StubHandle (cn.cerc.jbean.rds.StubHandle)3 IMemcache (cn.cerc.jdb.cache.IMemcache)3 MessageRecord (cn.cerc.jmis.message.MessageRecord)3 UrlRecord (cn.cerc.jpage.core.UrlRecord)3 Label (jxl.write.Label)3 CustomHandle (cn.cerc.jbean.core.CustomHandle)2 IService (cn.cerc.jbean.core.IService)2 IStatus (cn.cerc.jbean.core.IStatus)2 UserNotFindException (cn.cerc.jbean.other.UserNotFindException)2 QueueQuery (cn.cerc.jdb.queue.QueueQuery)2 Column (cn.cerc.jexport.excel.Column)2 JPushRecord (cn.cerc.jmis.message.JPushRecord)2