采购类型软删除
parent
1c4f946df8
commit
9db9c5078a
|
@ -15,6 +15,9 @@ public class ProcurementType {
|
|||
public static final int ENABLED = 1;
|
||||
public static final int DISABLED = 0;
|
||||
|
||||
public static final int DELETED = 1;
|
||||
public static final int NOTDELETE = 0;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
|
@ -32,6 +35,9 @@ public class ProcurementType {
|
|||
@Column(name = "created_by")
|
||||
private String createdBy;
|
||||
|
||||
@Column(name = "is_deleted")
|
||||
private int isDeleted;
|
||||
|
||||
@Transient
|
||||
private String typeName;
|
||||
|
||||
|
@ -97,4 +103,12 @@ public class ProcurementType {
|
|||
public void setCreatedTime(Date createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public int getIsDeleted() {
|
||||
return isDeleted;
|
||||
}
|
||||
|
||||
public void setIsDeleted(int isDeleted) {
|
||||
this.isDeleted = isDeleted;
|
||||
}
|
||||
}
|
|
@ -5,5 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
import java.util.List;
|
||||
|
||||
public interface ProcurementTypeRepository extends JpaRepository<ProcurementType,Integer> {
|
||||
List<ProcurementType> findAllByEnabledEquals(int enable);
|
||||
List<ProcurementType> findAllByEnabledEqualsAndIsDeletedEquals(int enable,int deleted);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class ProcurementTypeService {
|
|||
|
||||
public Page<ProcurementType> list(Map<String, String> searchInfo, int pageNumber, int pageSize){
|
||||
QueryHelper queryHelper = new QueryHelper("SELECT *","procurement_type");
|
||||
queryHelper.addCondition("is_deleted=0");
|
||||
queryHelper.addCondition(searchInfo.containsKey("name"), "name like ?", "%" +
|
||||
searchInfo.get("name") + "%");
|
||||
queryHelper.addCondition(searchInfo.containsKey("type") && !"-1".equals(searchInfo.get("type")),
|
||||
|
@ -85,7 +86,11 @@ public class ProcurementTypeService {
|
|||
boolean deleted = true;
|
||||
try {
|
||||
for (String id : deleteIds) {
|
||||
procurementTypeRepository.delete(Integer.parseInt(id));
|
||||
ProcurementType procurementType = procurementTypeRepository.findOne(Integer.parseInt(id));
|
||||
if(null != procurementType){
|
||||
procurementType.setIsDeleted(1);
|
||||
procurementTypeRepository.saveAndFlush(procurementType);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
@ -104,6 +109,6 @@ public class ProcurementTypeService {
|
|||
}
|
||||
|
||||
public List<ProcurementType> allProcurementTypeList(){
|
||||
return procurementTypeRepository.findAllByEnabledEquals(ProcurementType.ENABLED);
|
||||
return procurementTypeRepository.findAllByEnabledEqualsAndIsDeletedEquals(ProcurementType.ENABLED,ProcurementType.NOTDELETE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue