优化删除日志功能

This commit is contained in:
季圣华
2020-06-10 00:34:26 +08:00
parent 5168a11b1e
commit 753c865deb
18 changed files with 295 additions and 70 deletions

View File

@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -51,6 +52,19 @@ public class UnitService {
return result;
}
public List<Unit> getUnitListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Unit> list = new ArrayList<>();
try{
UnitExample example = new UnitExample();
example.createCriteria().andIdIn(idList);
list = unitMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Unit> getUnit()throws Exception {
UnitExample example = new UnitExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
@@ -153,8 +167,13 @@ public class UnitService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnitByIds(String ids)throws Exception {
logService.insertLog("计量单位",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<Unit> list = getUnitListByIds(ids);
for(Unit unit: list){
sb.append("[").append(unit.getUname()).append("]");
}
logService.insertLog("计量单位", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");