Browse Source

新建馆时,借阅配置信息修改

shenhao 5 years ago
parent
commit
b103424542

+ 5 - 0
src/main/java/com/ssj/dao/weixin/sales/dao/LibBorrowedServiceDao.java

@@ -9,6 +9,8 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 
 /** 
  * @author  ZhangCaibao 
@@ -30,4 +32,7 @@ public interface LibBorrowedServiceDao extends JpaRepository<LibBorrowedService,
 	 
 	 @Query(nativeQuery = true, value = " select * from   tb_lib_borrowed_service  where lib_id = ?1  and   species =?2  and type =?3  LIMIT 1 ")
 	 public LibBorrowedService findByLibIdAndSpeciesAndType(String libId,String species,String type);
+
+	@Query(nativeQuery = true, value = " select * from   tb_lib_borrowed_service  where lib_id = ?1")
+    List<LibBorrowedService> findListByAddType(String addType);
 }

+ 14 - 7
src/main/java/com/ssj/service/weixin/sales/service/impl/LibBorrowedServiceServiceImpl.java

@@ -7,6 +7,7 @@ import com.ssj.framework.core.persistence.DynamicSpecifications;
 import com.ssj.framework.core.persistence.SearchFilter;
 import com.ssj.framework.idworker.IdWorker;
 import com.ssj.service.weixin.sales.service.LibBorrowedServiceService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -15,7 +16,9 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 
 /** 
@@ -45,13 +48,17 @@ public class LibBorrowedServiceServiceImpl extends BaseServiceImpl<LibBorrowedSe
 	public void insertBorrowedService(String libId,Integer libType) {
 		Integer count=libBorrowedServiceDao.getLibCount(libId);
 		if(count==0){
-            String id = IdWorker.generateId();
-		    if(libType == 1){
-		    	libBorrowedServiceDao.insertBorrowedService(libId,"SSJ",id);
-		    }else{
-		    	libBorrowedServiceDao.insertBorrowedService(libId,"SSJGx",id);//共享
-		    }
-			
+			String addType = libType==1?"SSJ":"SSJGx";
+			List<LibBorrowedService> list = libBorrowedServiceDao.findListByAddType(addType);
+			if(Objects.nonNull(list) && list.size()>0){
+				for (LibBorrowedService libBorrowedService:list){
+					LibBorrowedService vo = new LibBorrowedService();
+					BeanUtils.copyProperties(libBorrowedService,vo);
+					vo.setId(IdWorker.generateId());
+					vo.setLibId(libId);
+					this.save(vo);
+				}
+			}
 		}
 	}
 

BIN
src/main/resources/META-INF/resources/favicon.ico