优化日志的记录

This commit is contained in:
季圣华
2019-11-19 20:35:26 +08:00
parent 47c90a0e26
commit b186ae1636
53 changed files with 415 additions and 386 deletions

View File

@@ -49,18 +49,18 @@ public class RoleComponent implements ICommonQuery {
}
@Override
public int update(String beanJson, Long id)throws Exception {
return roleService.updateRole(beanJson, id);
public int update(String beanJson, Long id, HttpServletRequest request)throws Exception {
return roleService.updateRole(beanJson, id, request);
}
@Override
public int delete(Long id)throws Exception {
return roleService.deleteRole(id);
public int delete(Long id, HttpServletRequest request)throws Exception {
return roleService.deleteRole(id, request);
}
@Override
public int batchDelete(String ids)throws Exception {
return roleService.batchDeleteRole(ids);
public int batchDelete(String ids, HttpServletRequest request)throws Exception {
return roleService.batchDeleteRole(ids, request);
}
@Override

View File

@@ -86,6 +86,7 @@ public class RoleService {
int result=0;
try{
result=roleMapper.insertSelective(role);
logService.insertLog("角色", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -93,12 +94,14 @@ public class RoleService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateRole(String beanJson, Long id) throws Exception{
public int updateRole(String beanJson, Long id, HttpServletRequest request) throws Exception{
Role role = JSONObject.parseObject(beanJson, Role.class);
role.setId(id);
int result=0;
try{
result=roleMapper.updateByPrimaryKeySelective(role);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -106,10 +109,12 @@ public class RoleService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteRole(Long id)throws Exception {
public int deleteRole(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result=roleMapper.deleteByPrimaryKey(id);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -117,13 +122,14 @@ public class RoleService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRole(String ids) throws Exception{
public int batchDeleteRole(String ids, HttpServletRequest request) throws Exception{
List<Long> idList = StringUtil.strToLongList(ids);
RoleExample example = new RoleExample();
example.createCriteria().andIdIn(idList);
int result=0;
try{
result=roleMapper.deleteByExample(example);
logService.insertLog("角色", "批量删除,id集:" + ids, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -153,7 +159,7 @@ public class RoleService {
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRoleByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER,
logService.insertLog("序列号",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();