Browse Source

算法平台

LingxinMeng 2 years ago
parent
commit
ffb59b5415

+ 1 - 0
api-common/src/main/java/api/common/util/HttpUtil.java

@@ -163,6 +163,7 @@ public class HttpUtil {
      * @return 请求结果
      * @return 请求结果
      */
      */
     public static String get(CloseableHttpClient closeableHttpClient, RequestConfig requestConfig, String url) {
     public static String get(CloseableHttpClient closeableHttpClient, RequestConfig requestConfig, String url) {
+        log.info("发送HTTP请求:" + url);
         String result = null;
         String result = null;
         try {
         try {
             //1 创建 post 请求
             //1 创建 post 请求

+ 4 - 0
simulation-resource-common/src/main/java/com/css/simulation/resource/common/acl/algorithm/AlgorithmExpandAcl.java

@@ -76,6 +76,10 @@ public class AlgorithmExpandAcl {
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, "请求成功!", algorithmName);
         return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, "请求成功!", algorithmName);
     }
     }
 
 
+    /**
+     * 从缓存中获取token,没有才发送请求
+     * @return
+     */
     private String getToken() {
     private String getToken() {
         RedisParameter redisParameter = new RedisParameter();
         RedisParameter redisParameter = new RedisParameter();
         redisParameter.setKey(TOKEN_KEY);
         redisParameter.setKey(TOKEN_KEY);

+ 24 - 10
simulation-resource-server/src/main/java/com/css/simulation/resource/server/application/impl/AlgorithmServiceImpl.java

@@ -16,6 +16,7 @@ import com.css.simulation.resource.server.acl.feign.SchedulerService;
 import com.css.simulation.resource.server.application.service.AlgorithmService;
 import com.css.simulation.resource.server.application.service.AlgorithmService;
 import com.css.simulation.resource.server.application.service.DictService;
 import com.css.simulation.resource.server.application.service.DictService;
 import com.css.simulation.resource.server.application.service.SimulationProjectService;
 import com.css.simulation.resource.server.application.service.SimulationProjectService;
+import com.css.simulation.resource.server.domain.service.UserDomainService;
 import com.css.simulation.resource.server.infrastructure.common.configuration.git.GitConfiguration;
 import com.css.simulation.resource.server.infrastructure.common.configuration.git.GitConfiguration;
 import com.css.simulation.resource.server.infrastructure.common.utils.AuthUtil;
 import com.css.simulation.resource.server.infrastructure.common.utils.AuthUtil;
 import com.css.simulation.resource.server.infrastructure.common.utils.PageUtil;
 import com.css.simulation.resource.server.infrastructure.common.utils.PageUtil;
@@ -44,6 +45,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     private final DictService dictService;
     private final DictService dictService;
     private final GitConfiguration gitConfiguration;
     private final GitConfiguration gitConfiguration;
     private final AlgorithmExpandMapper algorithmExpandMapper;
     private final AlgorithmExpandMapper algorithmExpandMapper;
+    private final UserDomainService userDomainService;
 
 
     @Resource
     @Resource
     private SimulationProjectService simulationProjectService;
     private SimulationProjectService simulationProjectService;
@@ -148,6 +150,10 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
 
     @Override
     @Override
     public ResponseBodyVO<Object> selectAlgoPlatformList(AlgorithmParameter param) {
     public ResponseBodyVO<Object> selectAlgoPlatformList(AlgorithmParameter param) {
+
+        // 判断用户是否是管理员
+        final boolean admin = userDomainService.isAdmin(AuthUtil.getCurrentUserId(), AuthUtil.getCurrentUserRoleCode());
+
         //1 同步算法平台数据到仿真云
         //1 同步算法平台数据到仿真云
 //        final String algorithmId = param.getAlgorithmCode();
 //        final String algorithmId = param.getAlgorithmCode();
         final String algorithmName = param.getAlgorithmName();
         final String algorithmName = param.getAlgorithmName();
@@ -169,20 +175,28 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         if (StringUtil.isNotEmpty(description)) {
         if (StringUtil.isNotEmpty(description)) {
             urlParam = urlParam + "&description=" + description;
             urlParam = urlParam + "&description=" + description;
         }
         }
-        if (StringUtil.isNotEmpty(page)) {
-            urlParam = urlParam + "&page=" + page;
-        }
-        if (StringUtil.isNotEmpty(size)) {
-            urlParam = urlParam + "&size=" + size;
-        }
+//        if (StringUtil.isNotEmpty(page)) {
+//            urlParam = urlParam + "&page=" + page;
+//        }
+//        if (StringUtil.isNotEmpty(size)) {
+//            urlParam = urlParam + "&size=" + size;
+//        }
         urlParam = urlParam + "&sort=" + sort;
         urlParam = urlParam + "&sort=" + sort;
         // 此接口在此处只作为同步更新数据到仿真云数据库,分页查询通过仿真云数据库来查
         // 此接口在此处只作为同步更新数据到仿真云数据库,分页查询通过仿真云数据库来查
         algoPlatformService.getAlgorithmList(urlParam);
         algoPlatformService.getAlgorithmList(urlParam);
         //2 查询仿真数据库里的数据
         //2 查询仿真数据库里的数据
-        PageHelper.startPage(page, size);
-        final List<AlgorithmVO> algorithmVOS = algorithmExpandMapper.select(param);
-        PageInfo<AlgorithmVO> objectPageInfo = new PageInfo<>(algorithmVOS);
-        return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, objectPageInfo);
+        if (admin) {
+            PageHelper.startPage(page, size);
+            final List<AlgorithmVO> algorithmVOS = algorithmExpandMapper.select(param);
+            PageInfo<AlgorithmVO> objectPageInfo = new PageInfo<>(algorithmVOS);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, objectPageInfo);
+        } else {
+            PageHelper.startPage(page, size);
+            final List<AlgorithmVO> algorithmVOS = algorithmExpandMapper.selectWithNoTeam(param);
+            PageInfo<AlgorithmVO> objectPageInfo = new PageInfo<>(algorithmVOS);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, objectPageInfo);
+        }
+
 //        //解析数据
 //        //解析数据
 //        final String json = algorithmList.getInfo();
 //        final String json = algorithmList.getInfo();
 //        Map jsonMap = JsonUtil.jsonToMap(json);
 //        Map jsonMap = JsonUtil.jsonToMap(json);

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/server/infrastructure/mysql/mapper/AlgorithmExpandMapper.java

@@ -10,4 +10,6 @@ import java.util.List;
 public interface AlgorithmExpandMapper {
 public interface AlgorithmExpandMapper {
 
 
     List<AlgorithmVO> select(AlgorithmParameter param);
     List<AlgorithmVO> select(AlgorithmParameter param);
+    List<AlgorithmVO> selectWithNoTeam(AlgorithmParameter param);
+
 }
 }

+ 28 - 0
simulation-resource-server/src/main/resources/mysql/mapper/AlgorithmExpandMapper.xml

@@ -34,4 +34,32 @@
             and status = #{status}
             and status = #{status}
         </if>
         </if>
     </select>
     </select>
+    <select id="selectWithNoTeam" resultType="api.common.pojo.vo.algorithm.AlgorithmVO">
+        select id,
+        algorithm_id algorithm_code,
+        algorithm_name,
+        description,
+        algorithm_type,
+        algorithm_version,
+        team,
+        topic,
+        status
+        from algorithm_expand
+        where team is null or team = ''
+        <if test="algorithmName != null and algorithmName != ''">
+            and algorithm_name like concat('%',#{algorithmName},'%')
+        </if>
+        <if test="description != null and description != ''">
+            and description like concat('%',#{description},'%')
+        </if>
+        <if test="algorithmVersion != null and algorithmVersion != ''">
+            and algorithm_version like concat('%',#{algorithmVersion},'%')
+        </if>
+        <if test="topic != null and topic != ''">
+            and topic like concat('%',#{topic},'%')
+        </if>
+        <if test="status != null and status != ''">
+            and status = #{status}
+        </if>
+    </select>
 </mapper>
 </mapper>