全局修改物理删除为逻辑删除,同时修改查询语句过滤删除标识

This commit is contained in:
qiankunpingtai
2019-04-01 17:07:13 +08:00
parent 7dc1cdaafc
commit 1f2cf8c313
85 changed files with 1632 additions and 224 deletions

View File

@@ -1,18 +1,25 @@
package com.jsh.erp.service.inOutItem;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.InOutItem;
import com.jsh.erp.datasource.entities.InOutItemExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.InOutItemMapper;
import com.jsh.erp.datasource.mappers.InOutItemMapperEx;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
@Service
@@ -24,6 +31,10 @@ public class InOutItemService {
@Resource
private InOutItemMapperEx inOutItemMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
public InOutItem getInOutItem(long id) {
return inOutItemMapper.selectByPrimaryKey(id);
@@ -70,7 +81,7 @@ public class InOutItemService {
public int checkIsNameExist(Long id, String name) {
InOutItemExample example = new InOutItemExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<InOutItem> list = inOutItemMapper.selectByExample(example);
return list.size();
}
@@ -85,4 +96,13 @@ public class InOutItemService {
example.setOrderByClause("id desc");
return inOutItemMapper.selectByExample(example);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItemByIds(String ids) {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_IN_OUT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
return inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}
}