use of com.jfinal.kit.Ret in project my_curd by qinyou.
the class SysGeneratorController method generate.
/**
* 生成代码 文件
*/
public void generate() {
Ret ret = Ret.create();
String jsonStr = getPara("jsonStr");
if (StrKit.isBlank(jsonStr)) {
ret.setFail();
ret.set("msg", "jsonStr参数不能为空");
renderJson(ret);
return;
}
try {
JSONObject jsonObject = JSON.parseObject(jsonStr, JSONObject.class);
String moduleName = jsonObject.getString("moduleName");
if (moduleName.contains(":)")) {
ret.setFail();
ret.set("msg", "jsonStr 中 moduleName 不合法");
renderJson(ret);
return;
}
JSONArray jsonArray = jsonObject.getJSONArray("tables");
Iterator<Object> it = jsonArray.iterator();
List<Table> tables = new ArrayList<Table>();
while (it.hasNext()) {
JSONObject jsonObjectTemp = (JSONObject) it.next();
Table table = jsonObjectTemp.toJavaObject(Table.class);
tables.add(table);
}
CodeGeneratorService codeGeneratorService = new CodeGeneratorService();
List<String> outputPaths = codeGeneratorService.generate(moduleName, tables);
ret.setOk();
ret.put("outputPaths", outputPaths);
renderJson(ret);
} catch (Exception e) {
LogKit.error(e.getMessage());
ret.setFail();
ret.set("msg", "系统发生异常。");
renderJson(ret);
}
}
use of com.jfinal.kit.Ret in project my_curd by qinyou.
the class MainController method noticeUnreadCount.
/**
* 获得 未读消息数量
*/
public void noticeUnreadCount() {
SysUser sysUser = WebUtils.getSysUser(this);
String sql = " select count(1) as unreadCount from sys_notice_detail where receiver = ? and hasRead !='Y' ";
Record record = Db.findFirst(sql, sysUser.getId());
Ret ret = Ret.create().setOk().set("unreadCount", record == null ? 0 : record.get("unreadCount"));
renderJson(ret);
}
use of com.jfinal.kit.Ret in project my_curd by qinyou.
the class IdRequired method handleError.
@Override
protected void handleError(Controller c) {
Ret ret = Ret.create().setFail().set("msg", "id 参数为空");
c.renderJson(ret);
}
use of com.jfinal.kit.Ret in project my_curd by qinyou.
the class BaseController method renderFail.
/**
* 失败操作
*/
protected void renderFail() {
Ret ret = Ret.create().setFail();
render(new JsonRender(ret).forIE());
}
use of com.jfinal.kit.Ret in project my_curd by qinyou.
the class BaseController method renderSuccess.
/**
* 成功操作
*
* @param data
*/
protected void renderSuccess(List<?> data) {
Ret ret = Ret.create().setOk().setIfNotNull("data", data);
render(new JsonRender(ret).forIE());
}
Aggregations