use of com.jfinal.plugin.activerecord.ActiveRecordException 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);
}
}
use of com.jfinal.plugin.activerecord.ActiveRecordException 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("赋予角色失败");
}
}
use of com.jfinal.plugin.activerecord.ActiveRecordException 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);
}
}
use of com.jfinal.plugin.activerecord.ActiveRecordException in project my_curd by qinyou.
the class SysMenuController method deleteAction.
@Before(Tx.class)
public void deleteAction() {
Integer id = getParaToInt("id");
try {
Record record = Db.findFirst("select getChildLst(?,'sys_menu') as childrenIds ", id);
// 子、孙 id
String childrenIds = record.getStr("childrenIds");
// 删除相应 角色菜单
String deleteSql = "delete from sys_menu where id in (" + childrenIds + ")";
Db.update(deleteSql);
// 删除角色菜单关联数据
deleteSql = "delete from sys_role_menu where menu_id in (" + childrenIds + ") ";
Db.update(deleteSql);
renderText(Constant.DELETE_SUCCESS);
} catch (ActiveRecordException e) {
e.printStackTrace();
renderText(Constant.DELETE_FAIL);
}
}
use of com.jfinal.plugin.activerecord.ActiveRecordException in project my_curd by qinyou.
the class SysRoleController method givePermission.
/**
* 用户赋权限
*/
@Before(Tx.class)
public void givePermission() {
Integer roleId = getParaToInt("roleId");
String permissIds = getPara("permissIds");
try {
String deleteSql = "delete from sys_role_menu where role_id = ?";
Db.update(deleteSql, roleId);
if (StrKit.notBlank(permissIds)) {
String[] menuIds = permissIds.split(";");
for (int i = 0; i < menuIds.length; i++) {
SysRoleMenu sysRoleMenu = new SysRoleMenu();
sysRoleMenu.setRoleId(roleId);
sysRoleMenu.setMenuId(Integer.parseInt(menuIds[i]));
sysRoleMenu.save();
}
}
renderText("赋权成功");
} catch (ActiveRecordException e) {
e.printStackTrace();
renderText("赋权失败");
}
}
Aggregations