Search in sources :

Example 51 with Before

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

the class SysUserController method addUserRoleAction.

/**
 * 用户改角色保存
 */
@Before(Tx.class)
public void addUserRoleAction() {
    String userId = get("userId");
    String roleIds = get("roleIds");
    if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(roleIds)) {
        renderFail("userId roleIds 参数不可为空.");
        return;
    }
    String[] roleIdAry = roleIds.split(",");
    for (String roleId : roleIdAry) {
        SysUserRole sysUserRoleOld = SysUserRole.dao.findByIds(userId, roleId);
        if (sysUserRoleOld == null) {
            SysUserRole sysUserRole = new SysUserRole();
            sysUserRole.setSysUserId(userId).setSysRoleId(roleId).setCreater(WebUtils.getSessionUsername(this)).setCreateTime(new Date()).save();
        }
    }
    renderSuccess("添加用户角色成功.");
}
Also used : Date(java.util.Date) SysUserRole(com.github.qinyou.system.model.SysUserRole) Before(com.jfinal.aop.Before)

Example 52 with Before

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

the class SysVisitLogController method deleteAction.

/**
 * 批量删除
 */
@RequirePermission("sysVisitLog:delete")
@Before(IdsRequired.class)
public void deleteAction() {
    String ids = getPara("ids").replaceAll(",", "','");
    String sql = "delete from sys_visit_log where  id in ('" + ids + "')";
    int number = Db.update(sql);
    // 发送系统通知
    String noticeTypeCode = "delVisitLog";
    Map<String, Object> params = new HashMap<>();
    params.put("username", WebUtils.getSessionUsername(this));
    params.put("datetime", new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
    params.put("number", number);
    SysNoticeService service = Duang.duang(SysNoticeService.class);
    service.sendNotice(noticeTypeCode, params);
    renderSuccess(DELETE_SUCCESS);
}
Also used : HashMap(java.util.HashMap) DateTime(org.joda.time.DateTime) SysNoticeService(com.github.qinyou.system.service.SysNoticeService) Before(com.jfinal.aop.Before) RequirePermission(com.github.qinyou.common.annotation.RequirePermission)

Example 53 with Before

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

the class SysNoticeService method saveData.

/**
 * 通知数据 存库
 * @param sysNoticeType 通知类型对象
 * @param msgTitle      通知标题
 * @param msgConent     通知内容
 * @param receivers     接收人集合,不可为null,不可为空集
 */
@Before(Tx.class)
private void saveData(SysNoticeType sysNoticeType, String msgTitle, String msgConent, Set<String> receivers) {
    SysNotice sysNotice = new SysNotice();
    sysNotice.setTypeCode(sysNoticeType.getTypeCode()).setTitle(msgTitle).setContent(msgConent).setCreateTime(new Date()).setExpiryTime(new DateTime().plusDays(sysNoticeType.getUntilExpiryDay()).toDate()).setDeadTime(new DateTime().plusDays(sysNoticeType.getUntilDeadDay()).toDate()).setId(IdUtils.id()).save();
    receivers.forEach(receiverId -> {
        new SysNoticeDetail().setId(IdUtils.id()).setSysNoticeId(sysNotice.getId()).setReceiver(receiverId).setHasRead("N").save();
    });
}
Also used : DateTime(org.joda.time.DateTime) 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