Search in sources :

Example 21 with Before

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

the class SysUserController method updateAction.

/**
 * update action
 */
@Before(Tx.class)
public void updateAction() {
    SysUser sysUser = getBean(SysUser.class, "");
    // 防止恶意修改用户名
    String sql = "select count(1) as c from sys_user where username = ?";
    if (SysUser.dao.findFirst(sql, sysUser.getUsername()).getLong("c") != 1) {
        renderFail(UPDATE_FAIL);
        return;
    }
    sysUser.setUpdater(WebUtils.getSessionUsername(this)).setUpdateTime(new Date());
    sysUser.update();
    // 更新用户组织机构
    sql = "delete from sys_user_org where sysUserId = ?";
    Db.delete(sql, sysUser.getId());
    String[] orgIds = getParaValues("orgIds");
    for (String orgId : orgIds) {
        if (StringUtils.isEmpty(orgId)) {
            continue;
        }
        new SysUserOrg().setSysUserId(sysUser.getId()).setSysOrgId(orgId).save();
    }
    renderSuccess(UPDATE_SUCCESS);
}
Also used : SysUser(com.github.qinyou.system.model.SysUser) Date(java.util.Date) SysUserOrg(com.github.qinyou.system.model.SysUserOrg) Before(com.jfinal.aop.Before)

Example 22 with Before

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

the class SysUserController method addAction.

/**
 * add action
 */
@Before(Tx.class)
public void addAction() {
    SysUser sysUser = getBean(SysUser.class, "");
    String sql = "select count(1) as c from sys_user where username = ?";
    if (sysUser.dao().findFirst(sql).getLong("c") > 0L) {
        renderFail(ADD_FAIL + ", 该用户名已存在");
    }
    sysUser.setId(IdUtils.id()).setCreater(WebUtils.getSessionUsername(this)).setCreateTime(new Date()).setUserState("0");
    sysUser.setPassword(HashKit.sha1(DEFAULT_PWD));
    sysUser.save();
    String[] orgIds = getParaValues("orgIds");
    for (String orgId : orgIds) {
        if (StringUtils.isEmpty(orgId)) {
            continue;
        }
        new SysUserOrg().setSysUserId(sysUser.getId()).setSysOrgId(orgId).save();
    }
    renderSuccess(ADD_SUCCESS);
}
Also used : SysUser(com.github.qinyou.system.model.SysUser) Date(java.util.Date) SysUserOrg(com.github.qinyou.system.model.SysUserOrg) Before(com.jfinal.aop.Before)

Example 23 with Before

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

the class SysVisitLogController method exportExcel.

/**
 * 导出excel
 */
@RequirePermission("sysVisitLog:export")
@Before(SearchSql.class)
public void exportExcel() {
    String where = getAttr(Constant.SEARCH_SQL);
    if (SysVisitLog.dao.findCountByWhere(where) > 50000) {
        setAttr("msg", "一次导出数据不可大于 5W 条,请修改查询条件。");
        render("common/card.ftl");
        return;
    }
    // 测试大数据量导出
    List<SysVisitLog> list = SysVisitLog.dao.findByWhere(where);
    Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("访问日志", "访问日志"), SysVisitLog.class, list);
    render(ExcelRender.me(workbook).fileName("访问日志.xls"));
}
Also used : ExportParams(cn.afterturn.easypoi.excel.entity.ExportParams) SysVisitLog(com.github.qinyou.system.model.SysVisitLog) Workbook(org.apache.poi.ss.usermodel.Workbook) Before(com.jfinal.aop.Before) RequirePermission(com.github.qinyou.common.annotation.RequirePermission)

Example 24 with Before

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

the class SysRoleController method updateMenus.

// 更新角色 相关菜单
@Before(Tx.class)
public void updateMenus() {
    String roleId = get("roleId");
    String menuIds = get("menuIds");
    if (StringUtils.isEmpty(roleId)) {
        renderFail("roleId 参数不可为空.");
        return;
    }
    // 删除 角色原有菜单
    String sql = "delete from  sys_role_menu where sysRoleId = ?";
    Db.update(sql, roleId);
    // 防止保存 非叶子菜单(没有具体的controller)
    menuIds = menuIds.replace(",", "','");
    sql = "select GROUP_CONCAT(id) as menuIds from sys_menu where url !='/' and id in ('" + menuIds + "')";
    Record record = Db.findFirst(sql);
    if (record == null || StringUtils.isEmpty(record.getStr("menuIds"))) {
        renderFail("授权失败");
        return;
    }
    menuIds = record.getStr("menuIds");
    // 添加 角色新菜单
    if (StringUtils.notEmpty(menuIds)) {
        String[] menuIdAry = menuIds.split(",");
        for (String menuId : menuIdAry) {
            SysRoleMenu sysRoleMenu = new SysRoleMenu();
            sysRoleMenu.setSysRoleId(roleId).setSysMenuId(menuId).setCreater(WebUtils.getSessionUsername(this)).setCreateTime(new Date()).save();
        }
    }
    renderSuccess("授权成功");
}
Also used : Record(com.jfinal.plugin.activerecord.Record) Before(com.jfinal.aop.Before)

Example 25 with Before

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

the class ExStaffController method addAction.

/**
 * 新增 action
 */
@Before(Tx.class)
public void addAction() {
    // 新增主表
    ExStaff exStaff = getBean(ExStaff.class, "exStaff");
    exStaff.setId(IdUtils.id()).setCreater(WebUtils.getSessionUsername(this)).setCreateTime(new Date()).save();
    // 新增 子表
    List<ExStaffEducation> exStaffEducations = getBeans(ExStaffEducation.class, "exStaffEducation");
    exStaffEducations.forEach(item -> item.setId(IdUtils.id()).setExStaffId(exStaff.getId()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)));
    Db.batchSave(exStaffEducations, exStaffEducations.size());
    List<ExStaffExperience> exStaffExperiences = getBeans(ExStaffExperience.class, "exStaffExperience");
    exStaffExperiences.forEach(item -> item.setId(IdUtils.id()).setExStaffId(exStaff.getId()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)));
    Db.batchSave(exStaffExperiences, exStaffExperiences.size());
    List<ExStaffFamily> exStaffFamilys = getBeans(ExStaffFamily.class, "exStaffFamily");
    exStaffFamilys.forEach(item -> item.setId(IdUtils.id()).setExStaffId(exStaff.getId()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)));
    Db.batchSave(exStaffFamilys, exStaffFamilys.size());
    renderSuccess(ADD_SUCCESS);
}
Also used : ExStaffFamily(com.github.qinyou.example.model.ExStaffFamily) ExStaff(com.github.qinyou.example.model.ExStaff) ExStaffExperience(com.github.qinyou.example.model.ExStaffExperience) ExStaffEducation(com.github.qinyou.example.model.ExStaffEducation) Date(java.util.Date) 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