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);
}
}
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("赋予角色失败");
}
}
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);
}
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);
}
}
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);
}
Aggregations