Search in sources :

Example 1 with Ret

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);
    }
}
Also used : Ret(com.jfinal.kit.Ret) Table(com.hxkj.common.util.code_generator.Table) JSONObject(com.alibaba.fastjson.JSONObject) CodeGeneratorService(com.hxkj.system.service.CodeGeneratorService) JSONArray(com.alibaba.fastjson.JSONArray) ArrayList(java.util.ArrayList) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with 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);
}
Also used : Ret(com.jfinal.kit.Ret) Record(com.jfinal.plugin.activerecord.Record)

Example 3 with 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);
}
Also used : Ret(com.jfinal.kit.Ret)

Example 4 with 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());
}
Also used : Ret(com.jfinal.kit.Ret) JsonRender(com.jfinal.render.JsonRender)

Example 5 with Ret

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());
}
Also used : Ret(com.jfinal.kit.Ret) JsonRender(com.jfinal.render.JsonRender)

Aggregations

Ret (com.jfinal.kit.Ret)17 JsonRender (com.jfinal.render.JsonRender)10 RequirePermission (com.github.qinyou.common.annotation.RequirePermission)2 Controller (com.jfinal.core.Controller)2 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 UserClaim (com.github.qinyou.common.utils.jwt.UserClaim)1 SysNoticeService (com.github.qinyou.system.service.SysNoticeService)1 Table (com.hxkj.common.util.code_generator.Table)1 CodeGeneratorService (com.hxkj.system.service.CodeGeneratorService)1 Record (com.jfinal.plugin.activerecord.Record)1 UploadFile (com.jfinal.upload.UploadFile)1 ExpiredJwtException (io.jsonwebtoken.ExpiredJwtException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1