use of com.ikoori.vip.common.annotion.log.BussinessLog in project vip by guangdada.
the class UserMgrController method add.
/**
* 添加管理员
*/
@RequestMapping("/add")
@BussinessLog(value = "添加管理员", key = "account", dict = Dict.UserDict)
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Tip add(@Valid UserDto user, BindingResult result) {
if (result.hasErrors()) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
// 判断账号是否重复
User theUser = managerDao.getByAccount(user.getAccount());
if (theUser != null) {
throw new BussinessException(BizExceptionEnum.USER_ALREADY_REG);
}
// 完善账号信息
user.setSalt(ShiroKit.getRandomSalt(5));
user.setPassword(ShiroKit.md5(user.getPassword(), user.getSalt()));
user.setStatus(ManagerStatus.OK.getCode());
user.setCreatetime(new Date());
this.userMapper.insert(UserFactory.createUser(user));
return SUCCESS_TIP;
}
use of com.ikoori.vip.common.annotion.log.BussinessLog in project vip by guangdada.
the class NoticeController method update.
/**
* 修改通知
*/
@RequestMapping(value = "/update")
@ResponseBody
@BussinessLog(value = "修改通知", key = "title", dict = Dict.NoticeMap)
public Object update(Notice notice) {
if (ToolUtil.isOneEmpty(notice, notice.getId(), notice.getTitle(), notice.getContent())) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
Notice old = this.noticeMapper.selectById(notice.getId());
old.setTitle(notice.getTitle());
old.setContent(notice.getContent());
old.updateById();
return super.SUCCESS_TIP;
}
use of com.ikoori.vip.common.annotion.log.BussinessLog in project vip by guangdada.
the class NoticeController method add.
/**
* 新增通知
*/
@RequestMapping(value = "/add")
@ResponseBody
@BussinessLog(value = "新增通知", key = "title", dict = Dict.NoticeMap)
public Object add(Notice notice) {
if (ToolUtil.isOneEmpty(notice, notice.getTitle(), notice.getContent())) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
notice.setCreater(ShiroKit.getUser().getId());
notice.setCreatetime(new Date());
notice.insert();
return super.SUCCESS_TIP;
}
use of com.ikoori.vip.common.annotion.log.BussinessLog in project vip by guangdada.
the class LogAop method handle.
private void handle(ProceedingJoinPoint point) throws Exception {
// 获取拦截的方法名
Signature sig = point.getSignature();
MethodSignature msig = null;
if (!(sig instanceof MethodSignature)) {
throw new IllegalArgumentException("该注解只能用于方法");
}
msig = (MethodSignature) sig;
Object target = point.getTarget();
Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
String methodName = currentMethod.getName();
// 如果当前用户未登录,不做日志
ShiroUser user = ShiroKit.getUser();
if (null == user) {
return;
}
// 获取拦截方法的参数
String className = point.getTarget().getClass().getName();
Object[] params = point.getArgs();
// 获取操作名称
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) {
sb.append(param);
sb.append(" & ");
}
// 如果涉及到修改,比对变化
String msg;
if (bussinessName.indexOf("修改") != -1 || bussinessName.indexOf("编辑") != -1) {
Object obj1 = LogObjectHolder.me().get();
Map<String, String> obj2 = HttpKit.getRequestParameters();
msg = Contrast.contrastObj(dictClass, key, obj1, obj2);
} else {
Map<String, String> parameters = HttpKit.getRequestParameters();
AbstractDictMap dictMap = DictMapFactory.createDictMap(dictClass);
msg = Contrast.parseMutiKey(dictMap, key, parameters);
}
LogManager.me().executeLog(LogTaskFactory.bussinessLog(user.getId(), bussinessName, className, methodName, msg));
}
use of com.ikoori.vip.common.annotion.log.BussinessLog in project vip by guangdada.
the class MenuController method edit.
/**
* 修该菜单
*/
@Permission(Const.ADMIN_NAME)
@RequestMapping(value = "/edit")
@BussinessLog(value = "修改菜单", key = "name", dict = Dict.MenuDict)
@ResponseBody
public Tip edit(@Valid Menu menu, BindingResult result) {
if (result.hasErrors()) {
throw new BussinessException(BizExceptionEnum.REQUEST_NULL);
}
// 设置父级菜单编号
menuSetPcode(menu);
this.menuMapper.updateById(menu);
if (!menu.getCode().equals("0") && menu.getIsmenu().intValue() == 1) {
Wrapper<Menu> wrapper = new EntityWrapper<>();
wrapper.eq("pcode", menu.getCode());
List<Menu> submenus = menuMapper.selectList(wrapper);
Map<String, Boolean> map = new HashMap<String, Boolean>();
map.put(menu.getUrl() + "/add", false);
map.put(menu.getUrl() + "/update", false);
map.put(menu.getUrl() + "/delete", false);
map.put(menu.getUrl() + "/detail", false);
map.put(menu.getUrl() + "/list", false);
map.put(menu.getUrl() + "/" + menu.getCode() + "_add", false);
map.put(menu.getUrl() + "/" + menu.getCode() + "_update", false);
for (Menu m : submenus) {
if (map.get(m.getUrl()) != null) {
map.put(m.getUrl(), true);
}
}
for (String key : map.keySet()) {
if (!map.get(key)) {
Menu subMenu = new Menu();
if (key.equals(menu.getUrl() + "/add")) {
subMenu.setName(menu.getName() + "添加");
subMenu.setCode(menu.getCode() + "_add");
} else if (key.equals(menu.getUrl() + "/update")) {
subMenu.setName(menu.getName() + "修改");
subMenu.setCode(menu.getCode() + "_update");
} else if (key.equals(menu.getUrl() + "/delete")) {
subMenu.setName(menu.getName() + "删除");
subMenu.setCode(menu.getCode() + "_delete");
} else if (key.equals(menu.getUrl() + "/detail")) {
subMenu.setName(menu.getName() + "详情");
subMenu.setCode(menu.getCode() + "_detail");
} else if (key.equals(menu.getUrl() + "/list")) {
subMenu.setName(menu.getName() + "查询");
subMenu.setCode(menu.getCode() + "_list");
} else if (key.equals(menu.getUrl() + "/" + menu.getCode() + "_add")) {
subMenu.setName(menu.getName() + "跳转添加");
subMenu.setCode("to_" + menu.getCode() + "_add");
} else if (key.equals(menu.getUrl() + "/" + menu.getCode() + "_update")) {
subMenu.setName(menu.getName() + "跳转修改");
subMenu.setCode("to_" + menu.getCode() + "_update");
}
subMenu.setIsmenu(0);
subMenu.setPcode(menu.getId().toString());
subMenu.setNum(1);
subMenu.setUrl(key);
subMenu.setStatus(1);
// 判断是否存在该编号
String existedMenuName = ConstantFactory.me().getMenuNameByCode(subMenu.getCode());
if (ToolUtil.isNotEmpty(existedMenuName)) {
throw new BussinessException(BizExceptionEnum.EXISTED_THE_MENU);
}
// 设置父级菜单编号
menuSetPcode(subMenu);
subMenu.setStatus(MenuStatus.ENABLE.getCode());
this.menuMapper.insert(subMenu);
}
}
}
return SUCCESS_TIP;
}
Aggregations