优化日志的记录

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

@@ -56,18 +56,18 @@ public class MaterialComponent implements ICommonQuery {
}
@Override
public int update(String beanJson, Long id)throws Exception {
return materialService.updateMaterial(beanJson, id);
public int update(String beanJson, Long id, HttpServletRequest request)throws Exception {
return materialService.updateMaterial(beanJson, id, request);
}
@Override
public int delete(Long id)throws Exception {
return materialService.deleteMaterial(id);
public int delete(Long id, HttpServletRequest request)throws Exception {
return materialService.deleteMaterial(id, request);
}
@Override
public int batchDelete(String ids)throws Exception {
return materialService.batchDeleteMaterial(ids);
public int batchDelete(String ids, HttpServletRequest request)throws Exception {
return materialService.batchDeleteMaterial(ids, request);
}
@Override

View File

@@ -125,6 +125,7 @@ public class MaterialService {
int result =0;
try{
result= materialMapper.insertSelective(material);
logService.insertLog("商品", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -132,7 +133,7 @@ public class MaterialService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateMaterial(String beanJson, Long id) throws Exception{
public int updateMaterial(String beanJson, Long id, HttpServletRequest request) throws Exception{
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setId(id);
int res =0;
@@ -144,6 +145,8 @@ public class MaterialService {
} else {
materialMapperEx.updateUnitIdNullByPrimaryKey(id); //将多单位置空
}
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -152,10 +155,12 @@ public class MaterialService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterial(Long id)throws Exception {
public int deleteMaterial(Long id, HttpServletRequest request)throws Exception {
int result =0;
try{
result= materialMapper.deleteByPrimaryKey(id);
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -163,13 +168,14 @@ public class MaterialService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterial(String ids)throws Exception {
public int batchDeleteMaterial(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(idList);
int result =0;
try{
result= materialMapper.deleteByExample(example);
logService.insertLog("商品", "批量删除,id集:" + ids, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -215,7 +221,7 @@ public class MaterialService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetEnable(Boolean enabled, String materialIDs)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL,
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialIDs).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
List<Long> ids = StringUtil.strToLongList(materialIDs);
@@ -292,7 +298,7 @@ public class MaterialService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BaseResponseInfo importExcel(List<Material> mList) throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL,
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
BaseResponseInfo info = new BaseResponseInfo();
@@ -324,7 +330,7 @@ public class MaterialService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_MATERIAL,
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();