Przeglądaj źródła

Merge branch 'feature-V2.0' of http://git.mooctest.com/crowd-2019/crowd-test-service-backend into feature-V2.0

 Conflicts:
	site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java
xuxuan 5 lat temu
rodzic
commit
23b619ac2a

+ 2 - 0
core/src/main/java/com/mooctest/crowd/domain/dao/ResourceDao.java

@@ -25,4 +25,6 @@ public interface ResourceDao extends CrudRepository<ResourcePO, Long>, JpaSpecif
     List<ResourcePO> findAll();
 
     Page<ResourcePO> findAll(Specification<ResourcePO> spec , Pageable pageable);
+
+    List<ResourcePO> findByNameLike(String name);
 }

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/domainobject/Resource.java

@@ -21,7 +21,7 @@ public class Resource {
     private String unitWork;
     private String standard;
     private String unit;
-    private String state;
+    private int state;
     private Timestamp startTime;
     private String personnel;
     private String remarks;

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/model/ResourcePO.java

@@ -48,7 +48,7 @@ public class ResourcePO {
     private String unit;
 
     @Column(name = "R_STATE")
-    private String state;
+    private int state;
 
     @Column(name = "R_DATE")
     private Timestamp startTime;

+ 1 - 1
core/src/main/java/com/mooctest/crowd/domain/repository/CommonRepo.java

@@ -208,7 +208,7 @@ public class CommonRepo {
                 Predicate predicate = cb.conjunction();
                 if(code != null) {
                     predicate.getExpressions().add(
-                            cb.equal(a.get("platform"), code)
+                            cb.equal(a.get("applicationType"), code)
                     );
                 }
                 return predicate;

Plik diff jest za duży
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java


+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/data/vo/ResourceVO.java

@@ -26,7 +26,7 @@ public class ResourceVO implements Serializable {
     private String unitWork;
     private String standard;
     private String unit;
-    private String state;
+    private int state;
     private Timestamp startTime;
     private String personnel;
     private String remarks;

+ 6 - 0
site/src/main/java/com/mooctest/crowd/site/mediator/ViewMediator.java

@@ -99,4 +99,10 @@ public interface ViewMediator {
     BankCardDTO deleteBankCard(long id,long userId);
 
     TechnicalArticlesDTO  updateRanking(long id);
+
+    List<ResourceVO>  getResource();
+
+    ResourceVO getResourceDetailed(String code);
+
+    List<ResourceVO>  getSearchResource(String name);
 }

+ 80 - 0
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -105,6 +105,12 @@ public class WebMediatorImpl implements ViewMediator {
     private ApplicationTypeDao applicationTypeDao;
 
     @Autowired
+    private  ResourceDao resourceDao;
+
+    @Autowired
+    private ResourceTypeDao resourceTypeDao;
+
+    @Autowired
     private FieldDao fieldDao;
 
     @Value("${agency}")
@@ -996,6 +1002,80 @@ public class WebMediatorImpl implements ViewMediator {
         return technicalArticlesDTO;
     }
 
+    @Override
+    public List<ResourceVO> getResource() {
+        List<ResourceVO> resourceVOList = new ArrayList<>();
+        resourceDao.findAll().forEach(resourcePO -> {
+            ResourceVO resourceVO = new ResourceVO();
+            resourceVO.setCode(resourcePO.getCode());
+            resourceVO.setName(resourcePO.getName());
+            Optional<ResourceTypePO> type = resourceTypeDao.findByCode(resourcePO.getType());
+            resourceVO.setType(type.get().getName());
+            resourceVO.setQuantity(resourcePO.getQuantity());
+            resourceVO.setPhotoUrl(resourcePO.getPhotoUrl());
+            resourceVO.setDescription(resourcePO.getDescription());
+            resourceVO.setScene(resourcePO.getScene());
+            resourceVO.setUnitWork(resourcePO.getUnitWork());
+            resourceVO.setStandard(resourcePO.getStandard());
+            resourceVO.setUnit(resourcePO.getUnit());
+            resourceVO.setState(resourcePO.getState());
+            resourceVO.setStartTime(resourcePO.getStartTime());
+            resourceVO.setPersonnel(resourcePO.getPersonnel());
+            resourceVO.setRemarks(resourcePO.getRemarks());
+            resourceVOList.add(resourceVO);
+        });
+        List<ResourceVO> results=resourceVOList.stream().sorted(Comparator.comparing(ResourceVO::getStartTime).reversed()).collect(Collectors.toList());
+        return results;
+    }
+
+    @Override
+    public ResourceVO getResourceDetailed(String code) {
+        Optional<ResourcePO> resourcePO=resourceDao.findByCode(code);
+        ResourceVO resourceVO = new ResourceVO();
+        resourceVO.setCode(resourcePO.get().getCode());
+        resourceVO.setName(resourcePO.get().getName());
+        Optional<ResourceTypePO> type = resourceTypeDao.findByCode(resourcePO.get().getType());
+        resourceVO.setType(type.get().getName());
+        resourceVO.setQuantity(resourcePO.get().getQuantity());
+        resourceVO.setPhotoUrl(resourcePO.get().getPhotoUrl());
+        resourceVO.setDescription(resourcePO.get().getDescription());
+        resourceVO.setScene(resourcePO.get().getScene());
+        resourceVO.setUnitWork(resourcePO.get().getUnitWork());
+        resourceVO.setStandard(resourcePO.get().getStandard());
+        resourceVO.setUnit(resourcePO.get().getUnit());
+        resourceVO.setState(resourcePO.get().getState());
+        resourceVO.setStartTime(resourcePO.get().getStartTime());
+        resourceVO.setPersonnel(resourcePO.get().getPersonnel());
+        resourceVO.setRemarks(resourcePO.get().getRemarks());
+        return resourceVO;
+    }
+
+    @Override
+    public List<ResourceVO> getSearchResource(String name) {
+        List<ResourceVO> resourceVOList = new ArrayList<>();
+        resourceDao.findByNameLike("%" + name + "%").forEach(resourcePO -> {
+            ResourceVO resourceVO = new ResourceVO();
+            resourceVO.setCode(resourcePO.getCode());
+            resourceVO.setName(resourcePO.getName());
+            Optional<ResourceTypePO> type = resourceTypeDao.findByCode(resourcePO.getType());
+            resourceVO.setType(type.get().getName());
+            resourceVO.setQuantity(resourcePO.getQuantity());
+            resourceVO.setPhotoUrl(resourcePO.getPhotoUrl());
+            resourceVO.setDescription(resourcePO.getDescription());
+            resourceVO.setScene(resourcePO.getScene());
+            resourceVO.setUnitWork(resourcePO.getUnitWork());
+            resourceVO.setStandard(resourcePO.getStandard());
+            resourceVO.setUnit(resourcePO.getUnit());
+            resourceVO.setState(resourcePO.getState());
+            resourceVO.setStartTime(resourcePO.getStartTime());
+            resourceVO.setPersonnel(resourcePO.getPersonnel());
+            resourceVO.setRemarks(resourcePO.getRemarks());
+            resourceVOList.add(resourceVO);
+        });
+        List<ResourceVO> results=resourceVOList.stream().sorted(Comparator.comparing(ResourceVO::getStartTime).reversed()).collect(Collectors.toList());
+        return results;
+    }
+
     private ProjectOperationControl initProjectPermission(CrowdTestProject project, User user) {
         ProjectOperationControl operationControl = new ProjectOperationControl();
         if (user == null)

+ 8 - 2
site/src/main/java/com/mooctest/crowd/site/service/CommonService.java

@@ -4,6 +4,7 @@ import com.mooctest.crowd.site.data.dto.IndexDTO;
 import com.mooctest.crowd.site.data.dto.IndexInfoDTO;
 import com.mooctest.crowd.site.data.dto.IndexPageDTO;
 import com.mooctest.crowd.site.data.dto.MyCrowdDTO;
+import com.mooctest.crowd.site.data.response.ResponseVO;
 import com.mooctest.crowd.site.data.vo.*;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -34,7 +35,12 @@ public interface CommonService {
 
     Page<CompetitionVO> getCompetition(Pageable pageable,String keyword);
 
-    Page<ResourceVO> getResource(Pageable pageable,String keyword);
-
     Page<CrowdProjectVO> getProjectList(Pageable pageable,String code);
+
+    List<ResourceVO>  getResource();
+
+    ResourceVO getResourceDetailed(String code);
+
+    ResponseVO findByNameLike(SearchConditionVO searchConditionVO);
+
 }

+ 43 - 4
site/src/main/java/com/mooctest/crowd/site/service/impl/CommonServiceImpl.java

@@ -1,19 +1,30 @@
 package com.mooctest.crowd.site.service.impl;
 
 import com.mooctest.crowd.domain.repository.*;
+import com.mooctest.crowd.site.constants.CommonConstant;
+import com.mooctest.crowd.site.data.ColumnFilter;
 import com.mooctest.crowd.site.data.dto.IndexDTO;
 import com.mooctest.crowd.site.data.dto.IndexInfoDTO;
 import com.mooctest.crowd.site.data.dto.IndexPageDTO;
 import com.mooctest.crowd.site.data.dto.MyCrowdDTO;
+import com.mooctest.crowd.site.data.enums.ColumnFilterType;
+import com.mooctest.crowd.site.data.response.ResponseVO;
+import com.mooctest.crowd.site.data.response.ServerCode;
 import com.mooctest.crowd.site.data.vo.*;
 import com.mooctest.crowd.site.mediator.ViewMediator;
 import com.mooctest.crowd.site.service.CommonService;
+import com.mooctest.crowd.site.util.DataUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -103,12 +114,40 @@ public class CommonServiceImpl implements CommonService {
     }
 
     @Override
-    public Page<ResourceVO> getResource(Pageable pageable, String keyword) {
-        return commonRepo.findAllResourceByPage(pageable, keyword).map(resource -> new ResourceVO(resource));
+    public Page<CrowdProjectVO> getProjectList(Pageable pageable, String code) {
+        return commonRepo.getProjectList(pageable,code).map(project->new CrowdProjectVO(project));
     }
 
     @Override
-    public Page<CrowdProjectVO> getProjectList(Pageable pageable, String code) {
-        return commonRepo.getProjectList(pageable,code).map(project->new CrowdProjectVO(project));
+    public List<ResourceVO> getResource() {
+        return viewMediator.getResource();
+    }
+
+    @Override
+    public ResourceVO getResourceDetailed(String code) {
+        return viewMediator.getResourceDetailed(code);
+    }
+
+    @Override
+    public ResponseVO findByNameLike(SearchConditionVO searchConditionVO) {
+        Pageable pageable = this.getPageable(searchConditionVO);
+        String keyword = searchConditionVO.getKeyword();
+        List<ResourceVO> resourceList=viewMediator.getSearchResource(keyword);
+        Page<ResourceVO> resourcePage = DataUtils.listToPage(resourceList, pageable);
+        return new ResponseVO<>(ServerCode.SUCCESS, resourcePage);
+    }
+
+    Pageable getPageable(SearchConditionVO searchConditionVO) {
+        int activePage = searchConditionVO.getActivePage() == 0 ? 1 : searchConditionVO.getActivePage();
+        Sort sort = new Sort(Sort.Direction.DESC, "id");
+        if (searchConditionVO.getColumnFilters() != null) {
+            for (ColumnFilter columnFilter : searchConditionVO.getColumnFilters()) {
+                if (ColumnFilterType.SORT.getName().equals(columnFilter.getType()) && columnFilter.getValue() != null) {
+                    sort = new Sort(Sort.Direction.fromString(columnFilter.getValue()), columnFilter.getField());
+                    break;
+                }
+            }
+        }
+        return new PageRequest(activePage - 1, CommonConstant.SQUARE_ROWS_ON_PAGE, sort);
     }
 }

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików