Search in sources :

Example 1 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class SysOrgController method deleteAction.

/**
 * 1: 删除当前结构和子组织机构
 * 2: 当前机构和子组织机构的 人员 orgId 设置为null
 */
@Before(Tx.class)
public void deleteAction() {
    Integer id = getParaToInt("id");
    try {
        Record record = Db.findFirst("select getChildLst(?,'sys_org') as childrenIds ", id);
        // 子、孙 id
        String childrenIds = record.getStr("childrenIds");
        String deleteSql = "delete from sys_org where  id  in (" + childrenIds + ")";
        Db.update(deleteSql);
        String updateSql = "update sys_user set org_id = null where  org_id in (" + childrenIds + ")";
        Db.update(updateSql);
        renderText(Constant.DELETE_SUCCESS);
    } catch (ActiveRecordException e) {
        renderText(Constant.DELETE_FAIL);
    }
}
Also used : Record(com.jfinal.plugin.activerecord.Record) ActiveRecordException(com.jfinal.plugin.activerecord.ActiveRecordException) Before(com.jfinal.aop.Before)

Example 2 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class SysUserController method giveRole.

/**
 * 用户赋予角色
 */
@Before(Tx.class)
public void giveRole() {
    String userId = getPara("userId");
    String roleIdstr = getPara("roleIds");
    try {
        String deleteSql = "delete from  sys_user_role where user_id = ?";
        Db.update(deleteSql, userId);
        String[] roleIds = roleIdstr.split(";");
        for (int i = 0; i < roleIds.length; i++) {
            SysUserRole sysUserRole = new SysUserRole();
            sysUserRole.setUserId(userId);
            sysUserRole.setRoleId(Integer.parseInt(roleIds[i]));
            sysUserRole.save();
        }
        renderText("赋予角色成功");
    } catch (ActiveRecordException e) {
        e.printStackTrace();
        renderText("赋予角色失败");
    }
}
Also used : ActiveRecordException(com.jfinal.plugin.activerecord.ActiveRecordException) SysUserRole(com.hxkj.system.model.SysUserRole) Before(com.jfinal.aop.Before)

Example 3 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class sysOplogController method query.

@Before(SearchSql.class)
public void query() {
    int pageNumber = getAttr("pageNumber");
    int pageSize = getAttr("pageSize");
    String where = getAttr(Constant.SEARCH_SQL);
    Page<SysOplog> sysOplogPage = SysOplog.dao.page(pageNumber, pageSize, where);
    renderDatagrid(sysOplogPage);
}
Also used : SysOplog(com.hxkj.system.model.SysOplog) ToolString(com.hxkj.common.util.ToolString) Before(com.jfinal.aop.Before)

Example 4 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class sysOplogController method deleteAction.

@Before(Tx.class)
public void deleteAction() {
    String ids = getPara("ids");
    ids = "'" + ids.replace(",", "','") + "'";
    try {
        String deleteSql = "delete from sys_oplog where id  in ( " + ids + " ) ";
        Db.update(deleteSql);
        renderText(Constant.DELETE_SUCCESS);
    } catch (ActiveRecordException e) {
        renderText(Constant.DELETE_FAIL);
    }
}
Also used : ToolString(com.hxkj.common.util.ToolString) ActiveRecordException(com.jfinal.plugin.activerecord.ActiveRecordException) Before(com.jfinal.aop.Before)

Example 5 with Before

use of com.jfinal.aop.Before in project my_curd by qinyou.

the class sysOplogController method exportToCvs.

@Before(SearchSql.class)
public void exportToCvs() {
    String where = getAttr(Constant.SEARCH_SQL);
    List<SysOplog> sysOplogs = SysOplog.dao.findWhere(where);
    List<String> headers = Arrays.asList("操作人员", "日志内容", "IP地址", "操作时间");
    List<String> columns = Arrays.asList("user_name", "op_content", "ip", "create_time");
    CsvRender csvRender = new CsvRender(headers, sysOplogs);
    csvRender.fileName("oplog.csv");
    csvRender.clomuns(columns);
    render(csvRender);
}
Also used : CsvRender(com.hxkj.common.util.csv.CsvRender) SysOplog(com.hxkj.system.model.SysOplog) ToolString(com.hxkj.common.util.ToolString) Before(com.jfinal.aop.Before)

Aggregations

Before (com.jfinal.aop.Before)53 Date (java.util.Date)11 ActiveRecordException (com.jfinal.plugin.activerecord.ActiveRecordException)5 Record (com.jfinal.plugin.activerecord.Record)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ToolString (com.hxkj.common.util.ToolString)4 ExportParams (cn.afterturn.easypoi.excel.entity.ExportParams)3 ExcelRdException (com.fruit.manage.util.excelRd.ExcelRdException)3 ActFormTpl (com.github.qinyou.process.model.ActFormTpl)3 SysOplog (com.hxkj.system.model.SysOplog)3 SysUser (com.hxkj.system.model.SysUser)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 RepositoryService (org.activiti.engine.RepositoryService)3 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)3 Model (org.activiti.engine.repository.Model)3 DateTime (org.joda.time.DateTime)3