Commit ca660632 by fsn

重构日志记录

parent daca4423
......@@ -22,4 +22,9 @@ public @interface BussinessLog {
* 被修改的实体的唯一标识,例如:菜单实体的唯一标识为"id"
*/
String key() default "id";
/**
* 字典(用于查找key的中文名称和字段的中文名称)
*/
String dict() default "SystemDict";
}
package com.stylefeng.guns.common.constant.dictmap;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
/**
* 部门的映射
*
* @author fengshuonan
* @date 2017-05-06 15:01
*/
public class DeptDict extends AbstractDictMap {
@Override
public void init() {
put("deptId","部门id");
put("num","部门排序");
put("pid","部门父级");
put("simplename","部门简称");
put("fullname","部门全称");
put("tips","备注");
}
}
package com.stylefeng.guns.common.constant.dictmap;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
/**
* 字典map
*
* @author fengshuonan
* @date 2017-05-06 15:43
*/
public class DictMap extends AbstractDictMap {
@Override
public void init() {
put("dictId","字典id");
put("dictName","字典名称");
}
}
package com.stylefeng.guns.common.constant.dictmap;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
/**
* 日志的字典
*
* @author fengshuonan
* @date 2017-05-06 15:01
*/
public class LogDict extends AbstractDictMap {
@Override
public void init() {
put("tips","备注");
}
}
package com.stylefeng.guns.common.constant.dictmap;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
/**
* 菜单的字典
*
* @author fengshuonan
* @date 2017-05-06 15:01
*/
public class MenuDict extends AbstractDictMap {
@Override
public void init() {
put("menuId","菜单id");
put("id","菜单id");
put("code","菜单编号");
put("pcode","菜单父编号");
put("name","菜单名称");
put("icon","菜单图标");
put("url","url地址");
put("num","菜单排序号");
put("levels","菜单层级");
put("tips","备注");
put("status","菜单状态");
put("isopen","是否打开");
put("","");
}
}
package com.stylefeng.guns.common.constant.dictmap;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
/**
* 角色的字典
*
* @author fengshuonan
* @date 2017-05-06 15:01
*/
public class RoleDict extends AbstractDictMap {
@Override
public void init() {
put("roleId","角色id");
put("id","角色id");
put("num","角色排序");
put("pid","角色的父级");
put("name","角色名称");
put("deptid","部门id");
put("tips","备注");
}
}
package com.stylefeng.guns.common.constant.dictmap;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
/**
* 用户的字典
*
* @author fengshuonan
* @date 2017-05-06 15:01
*/
public class UserDict extends AbstractDictMap {
@Override
public void init() {
put("userId","用户id");
put("id","用户id");
put("account","账号");
put("name","名字");
put("birthday","生日");
put("sex","性别");
put("email","电子邮件");
put("phone","电话");
put("roleid","角色id");
put("deptid","部门id");
}
}
package com.stylefeng.guns.common.constant.dictmap.base;
import java.util.HashMap;
/**
* 字典映射抽象类
*
* @author fengshuonan
* @date 2017-05-06 14:58
*/
public abstract class AbstractDictMap {
protected HashMap<String, String> dictory = new HashMap<>();
public AbstractDictMap(){
put("id","主键id");
init();
}
public String get(String key) {
return this.dictory.get(key);
}
public void put(String key, String value) {
this.dictory.put(key, value);
}
public abstract void init();
}
package com.stylefeng.guns.common.constant.dictmap.base;
/**
* 系统相关的字典
*
* @author fengshuonan
* @date 2017-05-06 15:48
*/
public class SystemDict extends AbstractDictMap {
@Override
public void init() {
}
}
package com.stylefeng.guns.common.constant.dictmap.factory;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
import com.stylefeng.guns.common.constant.dictmap.base.SystemDict;
import com.stylefeng.guns.common.exception.BizExceptionEnum;
import com.stylefeng.guns.common.exception.BussinessException;
/**
* 字典的创建工厂
*
* @author fengshuonan
* @date 2017-05-06 15:12
*/
public class DictMapFactory {
private static final String basePath = "com.stylefeng.guns.common.constant.dictmap.";
/**
* 通过类名创建具体的字典类
*/
public static AbstractDictMap createDictMap(String className) {
if("SystemDict".equals(className)){
return new SystemDict();
}else{
try {
Class<AbstractDictMap> clazz = (Class<AbstractDictMap>) Class.forName(basePath + className);
return clazz.newInstance();
} catch (Exception e) {
throw new BussinessException(BizExceptionEnum.ERROR_CREATE_DICT);
}
}
}
}
......@@ -11,6 +11,7 @@ public enum BizExceptionEnum {
* 字典
*/
DICT_EXISTED(400,"字典已经存在"),
ERROR_CREATE_DICT(500,"创建字典失败"),
/**
......
package com.stylefeng.guns.core.aop;
import com.stylefeng.guns.common.annotion.log.BussinessLog;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
import com.stylefeng.guns.common.constant.dictmap.factory.DictMapFactory;
import com.stylefeng.guns.core.log.LogManager;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.log.factory.LogTaskFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.core.support.HttpKit;
import com.stylefeng.guns.core.support.StrKit;
import com.stylefeng.guns.core.util.Contrast;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
......@@ -67,6 +67,7 @@ public class LogAop {
BussinessLog annotation = currentMethod.getAnnotation(BussinessLog.class);
String bussinessName = annotation.value();
String key = annotation.key();
String dictClass = annotation.dict();
StringBuilder sb = new StringBuilder();
for (Object param : params) {
......@@ -75,14 +76,20 @@ public class LogAop {
}
//如果涉及到修改,比对变化
String msg = null;
String msg;
if (bussinessName.indexOf("修改") != -1 || bussinessName.indexOf("编辑") != -1) {
Object obj1 = LogObjectHolder.me().get();
Map<String, String> obj2 = HttpKit.getRequestParameters();
msg = Contrast.contrastObj(key, obj1, obj2);
msg = Contrast.contrastObj(dictClass, key, obj1, obj2);
} else {
msg = ToolUtil.format("[时间]:{} [类名]:{} [方法]:{} [参数]:{}", DateUtil.getTime(), className, methodName, sb.toString());
msg = StrKit.removeSuffix(msg, "& ");
Map<String, String> parameters = HttpKit.getRequestParameters();
String value = parameters.get(key);
if(ToolUtil.isNotEmpty(value)){
AbstractDictMap dictMap = DictMapFactory.createDictMap(dictClass);
msg = dictMap.get(key) + ":" + value;
}else{
msg = "无";
}
}
LogManager.me().executeLog(LogTaskFactory.bussinessLog(user.getId(), bussinessName, className, methodName, msg));
......
package com.stylefeng.guns.core.util;
import com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap;
import com.stylefeng.guns.common.constant.dictmap.factory.DictMapFactory;
import com.stylefeng.guns.core.support.StrKit;
import java.beans.PropertyDescriptor;
......@@ -49,9 +51,10 @@ public class Contrast {
return str;
}
public static String contrastObj(String key, Object pojo1, Map<String, String> pojo2) {
public static String contrastObj(String dictClass, String key, Object pojo1, Map<String, String> pojo2) {
AbstractDictMap dictMap = DictMapFactory.createDictMap(dictClass);
String value = pojo2.get(key);
String str = key + "=" + value + separator;
String str = dictMap.get(key) + "=" + value + separator;
try {
Class clazz = pojo1.getClass();
Field[] fields = pojo1.getClass().getDeclaredFields();
......@@ -71,7 +74,8 @@ public class Contrast {
if (i != 1) {
str += separator;
}
str += "字段名称" + field.getName() + ",旧值:" + o1 + ",新值:" + o2;
String fieldName = dictMap.get(field.getName());
str += "字段名称:" + fieldName + ",旧值:" + o1 + ",新值:" + o2;
i++;
}
}
......
......@@ -18,6 +18,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
......@@ -84,7 +85,7 @@ public class DeptController extends BaseController {
/**
* 新增部门
*/
@BussinessLog("添加部门")
@BussinessLog(value = "添加部门", key = "simplename", dict = "DeptDict")
@RequestMapping(value = "/add")
@ResponseBody
@Permission(Const.ADMIN_NAME)
......@@ -117,7 +118,7 @@ public class DeptController extends BaseController {
/**
* 修改部门
*/
@BussinessLog("修改部门")
@BussinessLog(value = "修改部门", key = "simplename", dict = "DeptDict")
@RequestMapping(value = "/update")
@ResponseBody
@Permission(Const.ADMIN_NAME)
......@@ -132,11 +133,11 @@ public class DeptController extends BaseController {
/**
* 删除部门
*/
@BussinessLog(value = "删除部门", key = "deptId")
@RequestMapping(value = "/delete/{deptId}")
@BussinessLog(value = "删除部门", key = "deptId", dict = "DeptDict")
@RequestMapping(value = "/delete")
@ResponseBody
@Permission(Const.ADMIN_NAME)
public Object delete(@PathVariable("deptId") Integer deptId) {
public Object delete(@RequestParam Integer deptId) {
deptMapper.deleteById(deptId);
return SUCCESS_TIP;
}
......
......@@ -18,6 +18,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
......@@ -67,9 +68,9 @@ public class DictController extends BaseController {
@RequestMapping("/dict_edit/{dictId}")
public String deptUpdate(@PathVariable Integer dictId, Model model) {
Dict dict = dictMapper.selectById(dictId);
model.addAttribute("dict",dict);
model.addAttribute("dict", dict);
List<Dict> subDicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("pid", dictId));
model.addAttribute("subDicts",subDicts);
model.addAttribute("subDicts", subDicts);
LogObjectHolder.me().set(dict);
return PREFIX + "dict_edit.html";
}
......@@ -79,7 +80,7 @@ public class DictController extends BaseController {
*
* @param dictValues 格式例如 "1:启用;2:禁用;3:冻结"
*/
@BussinessLog(value = "添加字典记录", key = "dictName")
@BussinessLog(value = "添加字典记录", key = "dictName", dict = "DictMap")
@RequestMapping(value = "/add")
@Permission(Const.ADMIN_NAME)
@ResponseBody
......@@ -113,26 +114,26 @@ public class DictController extends BaseController {
/**
* 修改字典
*/
@BussinessLog("修改字典")
@BussinessLog(value = "修改字典", key = "dictName", dict = "DictMap")
@RequestMapping(value = "/update")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object update(Integer dictId, String dictName, String dictValues) {
if (ToolUtil.isOneEmpty(dictId,dictName,dictValues)) {
if (ToolUtil.isOneEmpty(dictId, dictName, dictValues)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
dictService.editDict(dictId,dictName,dictValues);
dictService.editDict(dictId, dictName, dictValues);
return super.SUCCESS_TIP;
}
/**
* 删除字典记录
*/
@BussinessLog(value = "删除字典记录", key = "dictId")
@RequestMapping(value = "/delete/{dictId}")
@BussinessLog(value = "删除字典记录", key = "dictId", dict = "DictMap")
@RequestMapping(value = "/delete")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object delete(@PathVariable("dictId") Integer dictId) {
public Object delete(@RequestParam Integer dictId) {
this.dictService.delteDict(dictId);
return SUCCESS_TIP;
}
......
......@@ -3,6 +3,7 @@ package com.stylefeng.guns.modular.system.controller;
import com.baomidou.mybatisplus.mapper.SqlRunner;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.common.annotion.Permission;
import com.stylefeng.guns.common.annotion.log.BussinessLog;
import com.stylefeng.guns.common.constant.Const;
import com.stylefeng.guns.common.constant.factory.PageFactory;
import com.stylefeng.guns.common.constant.state.BizLogType;
......@@ -74,6 +75,7 @@ public class LogController extends BaseController {
/**
* 清空日志
*/
@BussinessLog(value = "清空业务日志")
@RequestMapping("/delLog")
@Permission(Const.ADMIN_NAME)
@ResponseBody
......
......@@ -2,6 +2,7 @@ package com.stylefeng.guns.modular.system.controller;
import com.baomidou.mybatisplus.mapper.SqlRunner;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.common.annotion.log.BussinessLog;
import com.stylefeng.guns.common.constant.factory.PageFactory;
import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.modular.system.dao.LogDao;
......@@ -54,6 +55,7 @@ public class LoginLogController extends BaseController {
/**
* 清空日志
*/
@BussinessLog("清空登录日志")
@RequestMapping("/delLoginLog")
@ResponseBody
public Object delLog() {
......
......@@ -86,7 +86,7 @@ public class MenuController extends BaseController {
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/edit")
@ResponseBody
@BussinessLog("修改菜单")
@BussinessLog(value = "修改菜单", dict = "MenuDict")
public Tip edit(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
......@@ -100,8 +100,8 @@ public class MenuController extends BaseController {
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(@RequestParam(required = false) String menuName,@RequestParam(required = false) String level) {
List<Map<String, Object>> menus = this.menuDao.selectMenus(menuName,level);
public Object list(@RequestParam(required = false) String menuName, @RequestParam(required = false) String level) {
List<Map<String, Object>> menus = this.menuDao.selectMenus(menuName, level);
return super.warpObject(new MenuWarpper(menus));
}
......@@ -110,7 +110,7 @@ public class MenuController extends BaseController {
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/add")
@BussinessLog("菜单新增")
@BussinessLog(value = "菜单新增", key = "name", dict = "MenuDict")
@ResponseBody
public Tip add(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
......@@ -125,10 +125,10 @@ public class MenuController extends BaseController {
* 删除菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/remove/{menuId}")
@BussinessLog(value = "删除菜单",key = "menuId")
@RequestMapping(value = "/remove")
@BussinessLog(value = "删除菜单", key = "menuId", dict = "MenuDict")
@ResponseBody
public Tip remove(@PathVariable Integer menuId) {
public Tip remove(@RequestParam Integer menuId) {
if (ToolUtil.isEmpty(menuId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
......
......@@ -117,7 +117,7 @@ public class RoleController extends BaseController {
* 角色新增
*/
@RequestMapping(value = "/add")
@BussinessLog("添加角色")
@BussinessLog(value = "添加角色", key = "name", dict = "RoleDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip add(@Valid Role role, BindingResult result) {
......@@ -133,7 +133,7 @@ public class RoleController extends BaseController {
* 角色修改
*/
@RequestMapping(value = "/edit")
@BussinessLog("修改角色")
@BussinessLog(value = "修改角色", key = "name", dict = "RoleDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip edit(@Valid Role role, BindingResult result) {
......@@ -150,11 +150,11 @@ public class RoleController extends BaseController {
/**
* 删除角色
*/
@RequestMapping(value = "/remove/{roleId}")
@BussinessLog(value = "删除角色",key = "roleId")
@RequestMapping(value = "/remove")
@BussinessLog(value = "删除角色", key = "roleId", dict = "RoleDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip remove(@PathVariable Integer roleId) {
public Tip remove(@RequestParam Integer roleId) {
if (ToolUtil.isEmpty(roleId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
......@@ -182,7 +182,7 @@ public class RoleController extends BaseController {
* 配置权限
*/
@RequestMapping("/setAuthority")
@BussinessLog(value = "配置权限",key = "roleId")
@BussinessLog(value = "配置权限", key = "roleId", dict = "RoleDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip setAuthority(@RequestParam("roleId") Integer roleId, @RequestParam("ids") String ids) {
......
......@@ -119,7 +119,7 @@ public class UserMgrController extends BaseController {
* 跳转到修改密码界面
*/
@RequestMapping("/user_chpwd")
public String chPwd(){
public String chPwd() {
return PREFIX + "user_chpwd.html";
}
......@@ -128,19 +128,19 @@ public class UserMgrController extends BaseController {
*/
@RequestMapping("/changePwd")
@ResponseBody
public Object changePwd(@RequestParam String oldPwd,@RequestParam String newPwd,@RequestParam String rePwd){
if(!newPwd.equals(rePwd)){
public Object changePwd(@RequestParam String oldPwd, @RequestParam String newPwd, @RequestParam String rePwd) {
if (!newPwd.equals(rePwd)) {
throw new BussinessException(BizExceptionEnum.TWO_PWD_NOT_MATCH);
}
Integer userId = ShiroKit.getUser().getId();
User user = userMapper.selectById(userId);
String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt());
if(user.getPassword().equals(oldMd5)){
String newMd5 = ShiroKit.md5(newPwd,user.getSalt());
if (user.getPassword().equals(oldMd5)) {
String newMd5 = ShiroKit.md5(newPwd, user.getSalt());
user.setPassword(newMd5);
user.updateById();
return SUCCESS_TIP;
}else{
} else {
throw new BussinessException(BizExceptionEnum.OLD_PWD_NOT_RIGHT);
}
}
......@@ -151,7 +151,7 @@ public class UserMgrController extends BaseController {
@RequestMapping("/list")
@ResponseBody
public Object list(@RequestParam(required = false) String name, @RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime) {
List<Map<String, Object>> users = managerDao.selectUsers(name,beginTime,endTime);
List<Map<String, Object>> users = managerDao.selectUsers(name, beginTime, endTime);
return new UserWarpper(users).warp();
}
......@@ -159,7 +159,7 @@ public class UserMgrController extends BaseController {
* 添加管理员
*/
@RequestMapping("/add")
@BussinessLog("添加管理员")
@BussinessLog(value = "添加管理员", key = "name", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip add(@Valid UserDto user, BindingResult result) {
......@@ -189,7 +189,7 @@ public class UserMgrController extends BaseController {
* @throws NoPermissionException
*/
@RequestMapping("/edit")
@BussinessLog("修改管理员")
@BussinessLog(value = "修改管理员", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip edit(@Valid UserDto user, BindingResult result) throws NoPermissionException {
......@@ -213,11 +213,11 @@ public class UserMgrController extends BaseController {
/**
* 删除管理员(逻辑删除)
*/
@RequestMapping("/delete/{userId}")
@BussinessLog(value = "删除管理员", key = "userId")
@RequestMapping("/delete")
@BussinessLog(value = "删除管理员", key = "userId", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip delete(@PathVariable Integer userId) {
public Tip delete(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
......@@ -240,11 +240,11 @@ public class UserMgrController extends BaseController {
/**
* 重置管理员的密码
*/
@RequestMapping("/reset/{userId}")
@BussinessLog(value = "重置管理员密码", key = "userId")
@RequestMapping("/reset")
@BussinessLog(value = "重置管理员密码", key = "userId", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip reset(@PathVariable Integer userId) {
public Tip reset(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
......@@ -258,11 +258,11 @@ public class UserMgrController extends BaseController {
/**
* 冻结用户
*/
@RequestMapping("/freeze/{userId}")
@BussinessLog(value = "冻结用户", key = "userId")
@RequestMapping("/freeze")
@BussinessLog(value = "冻结用户", key = "userId", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip freeze(@PathVariable Integer userId) {
public Tip freeze(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
......@@ -273,11 +273,11 @@ public class UserMgrController extends BaseController {
/**
* 解除冻结用户
*/
@RequestMapping("/unfreeze/{userId}")
@BussinessLog(value = "解除冻结用户", key = "userId")
@RequestMapping("/unfreeze")
@BussinessLog(value = "解除冻结用户", key = "userId", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip unfreeze(@PathVariable Integer userId) {
public Tip unfreeze(@RequestParam Integer userId) {
if (ToolUtil.isEmpty(userId)) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
......@@ -289,7 +289,7 @@ public class UserMgrController extends BaseController {
* 分配角色
*/
@RequestMapping("/setRole")
@BussinessLog(value = "分配角色", key = "userId")
@BussinessLog(value = "分配角色", key = "userId", dict = "UserDict")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip setRole(@RequestParam("userId") Integer userId, @RequestParam("roleIds") String roleIds) {
......
package com.stylefeng.guns.modular.system.service.impl;
import com.stylefeng.guns.common.annotion.log.BussinessLog;
import com.stylefeng.guns.core.util.Convert;
import com.stylefeng.guns.modular.system.dao.RoleDao;
import com.stylefeng.guns.modular.system.service.IRoleService;
......@@ -25,7 +24,6 @@ public class RoleServiceImpl implements IRoleService {
RelationMapper relationMapper;
@Override
@BussinessLog("分配角色权限")
@Transactional(readOnly = false)
public void setAuthority(Integer roleId, String ids) {
......
......@@ -73,12 +73,13 @@ Dept.openDeptDetail = function () {
*/
Dept.delete = function () {
if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/dept/delete/" + this.seItem.id, function (data) {
var ajax = new $ax(Feng.ctxPath + "/dept/delete", function (data) {
Feng.success("删除成功!");
Dept.table.refresh();
}, function (data) {
Feng.error("删除失败!");
});
ajax.set("deptId",this.seItem.id);
ajax.start();
}
};
......
......@@ -25,10 +25,10 @@ Dict.initColumn = function () {
*/
Dict.check = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length == 0){
if (selected.length == 0) {
Feng.info("请先选中表格中的某一记录!");
return false;
}else{
} else {
Dict.seItem = selected[0];
return true;
}
......@@ -71,12 +71,13 @@ Dict.openDictDetail = function () {
*/
Dict.delete = function () {
if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/dict/delete/" + this.seItem.id, function (data) {
var ajax = new $ax(Feng.ctxPath + "/dict/delete", function (data) {
Feng.success("删除成功!");
Dict.table.refresh();
}, function (data) {
Feng.error("删除失败!");
});
ajax.set("dictId", this.seItem.id);
ajax.start();
}
};
......
......@@ -77,12 +77,13 @@ Menu.openChangeMenu = function () {
*/
Menu.delMenu = function () {
if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/menu/remove/" + this.seItem.id, function (data) {
var ajax = new $ax(Feng.ctxPath + "/menu/remove", function (data) {
Feng.success("删除成功!");
Menu.table.refresh();
}, function (data) {
Feng.error("删除失败!");
});
ajax.set("menuId", this.seItem.id);
ajax.start();
}
};
......
......@@ -74,12 +74,13 @@ Role.openChangeRole = function () {
*/
Role.delRole = function () {
if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/role/remove/" + this.seItem.id, function (data) {
var ajax = new $ax(Feng.ctxPath + "/role/remove", function (data) {
Feng.success("删除成功!");
Role.table.refresh();
}, function (data) {
Feng.error("删除失败!");
});
ajax.set("roleId", this.seItem.id);
ajax.start();
}
};
......
......@@ -98,12 +98,13 @@ MgrUser.roleAssign = function () {
MgrUser.delMgrUser = function () {
if (this.check()) {
var userId = this.seItem.id;
var ajax = new $ax(Feng.ctxPath + "/mgr/delete/" + userId, function (data) {
var ajax = new $ax(Feng.ctxPath + "/mgr/delete", function (data) {
Feng.success("删除成功!");
MgrUser.table.refresh();
}, function (data) {
Feng.error("删除失败!");
});
ajax.set("userId", userId);
ajax.start();
}
};
......@@ -115,12 +116,13 @@ MgrUser.delMgrUser = function () {
MgrUser.freezeAccount = function () {
if (this.check()) {
var userId = this.seItem.id;
var ajax = new $ax(Feng.ctxPath + "/mgr/freeze/" + userId, function (data) {
var ajax = new $ax(Feng.ctxPath + "/mgr/freeze", function (data) {
Feng.success("冻结成功!");
MgrUser.table.refresh();
}, function (data) {
Feng.error("冻结失败!");
});
ajax.set("userId", userId);
ajax.start();
}
};
......@@ -132,12 +134,13 @@ MgrUser.freezeAccount = function () {
MgrUser.unfreeze = function () {
if (this.check()) {
var userId = this.seItem.id;
var ajax = new $ax(Feng.ctxPath + "/mgr/unfreeze/" + userId, function (data) {
var ajax = new $ax(Feng.ctxPath + "/mgr/unfreeze", function (data) {
Feng.success("解除冻结成功!");
MgrUser.table.refresh();
}, function (data) {
Feng.error("解除冻结失败!");
});
ajax.set("userId", userId);
ajax.start();
}
}
......@@ -152,11 +155,12 @@ MgrUser.resetPwd = function () {
btn: ['确定', '取消'],
shade: false //不显示遮罩
}, function () {
var ajax = new $ax(Feng.ctxPath + "/mgr/reset/" + userId, function (data) {
var ajax = new $ax(Feng.ctxPath + "/mgr/reset", function (data) {
Feng.success("重置密码成功!");
}, function (data) {
Feng.error("重置密码失败!");
});
ajax.set("userId", userId);
ajax.start();
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment