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("添加用户角色成功.");
}
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);
}
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();
});
}
Aggregations