use of cn.cerc.jdb.mysql.SqlQuery in project summer-bean by cn-cerc.
the class SvrUserOption method execute.
@Override
public IStatus execute(DataSet dataIn, DataSet dataOut) throws ServiceException {
Record head = dataIn.getHead();
SqlQuery ds = new SqlQuery(this);
ds.add(String.format("select Value_ from %s", SystemTable.get(SystemTable.getUserOptions)));
ds.add(String.format("where UserCode_=N'%s' and Code_=N'%s'", this.getUserCode(), head.getString("Code_")));
ds.open();
dataOut.appendDataSet(ds);
return success();
}
use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SvrCustomMenus method append.
public boolean append() {
DataSet dataIn = getDataIn();
String corpNo = dataIn.getHead().getString("CorpNo_");
BuildQuery f1 = new BuildQuery(this);
BuildQuery f2 = new BuildQuery(this);
f1.byField("Custom_", true);
f1.add("select * from %s ", SystemTable.get(SystemTable.getAppMenus));
SqlQuery ds1 = f1.open();
f2.byField("CorpNo_", corpNo);
f2.add("select * from %s ", SystemTable.get(SystemTable.getCustomMenus));
SqlQuery ds2 = f2.open();
while (!ds2.eof()) {
if (!dataIn.locate("id", ds2.getString("ID_")))
ds2.delete();
else
ds2.next();
}
while (dataIn.fetch()) {
if (!ds1.locate("ID_", dataIn.getString("id")))
throw new RuntimeException("菜单错误,请核查!");
if (!ds2.locate("ID_", dataIn.getString("id"))) {
ds1.locate("ID_", dataIn.getString("id"));
ds2.append();
ds2.setField("CorpNo_", corpNo);
ds2.setField("Code_", ds1.getString("Code_"));
ds2.setField("Name_", ds1.getString("Name_"));
ds2.setField("AppUser_", getUserCode());
ds2.setField("AppDate_", TDateTime.Now().getDate());
ds2.setField("Remark_", "");
ds2.post();
}
}
return true;
}
use of cn.cerc.jdb.mysql.SqlQuery 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;
}
}
use of cn.cerc.jdb.mysql.SqlQuery 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();
}
use of cn.cerc.jdb.mysql.SqlQuery in project summer-mis by cn-cerc.
the class SvrUserLogin method getMachInfo.
// 获取用户的移动设备信息
public boolean getMachInfo() throws DataValidateException {
Record headIn = getDataIn().getHead();
String userCode = headIn.getString("UserCode_");
DataValidateException.stopRun("用户帐号不允许为空", "".equals(userCode));
String corpNo = headIn.getString("CorpNo_");
DataValidateException.stopRun("用户帐套不允许为空", "".equals(corpNo));
SqlQuery cdsTmp = new SqlQuery(this);
cdsTmp.add("select * from %s", SystemTable.get(SystemTable.getDeviceVerify));
cdsTmp.add("where CorpNo_='%s'and UserCode_='%s'", corpNo, userCode);
/*
* FIXME MachineType_代表设备类型,6-iOS、7-Android,用于极光推送 JPushRecord
*
* 黄荣君 2017-06-19
*/
cdsTmp.add("and Used_=1 and MachineType_ in (6,7)");
cdsTmp.add("and ifnull(MachineCode_,'')<>''");
cdsTmp.open();
getDataOut().appendDataSet(cdsTmp);
return true;
}
Aggregations