Commit 354631d5 authored by 廖旭伟's avatar 廖旭伟

应用信息改为从基础平台获取

parent a4c0c563
package com.mortals.xhx.feign.app;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.app.AppPdu;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.feign.device.IDeviceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 自助终端应用
*/
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = AppFeignFallbackFactory.class)
public interface IAppFeign extends IFeign {
/**
* 查看自助终端应用列表
*
* @param appPdu
* @return
*/
@PostMapping(value = "/app/list")
Rest<RespData<List<AppPdu>>> list(@RequestBody AppPdu appPdu);
/**
* 查看自助终端应用
*
* @param id
* @return
*/
@GetMapping(value = "/app/info")
Rest<AppPdu> info(@RequestParam(value = "id") Long id);
}
@Slf4j
@Component
class AppFeignFallbackFactory implements FallbackFactory<IAppFeign> {
@Override
public IAppFeign create(Throwable throwable) {
return new IAppFeign(){
@Override
public Rest<RespData<List<AppPdu>>> list(AppPdu appPdu) {
return Rest.fail("暂时无法获取自助终端应用列表,请稍后再试!");
}
@Override
public Rest<AppPdu> info(Long id) {
return Rest.fail("暂时无法获取自助终端应用,请稍后再试!");
}
};
}
}
\ No newline at end of file
package com.mortals.xhx.module.apps.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.apps.model.AppsInfoEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -9,6 +11,7 @@ import java.util.List;
* @author zxfei
* @date 2022-12-26
*/
@Data
public class AppsInfoVo extends BaseEntityLong {
private Long siteId;
}
\ No newline at end of file
package com.mortals.xhx.module.apps.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.app.AppPdu;
import com.mortals.xhx.feign.app.IAppFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,6 +12,12 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.apps.dao.AppsInfoDao;
import com.mortals.xhx.module.apps.model.AppsInfoEntity;
import com.mortals.xhx.module.apps.service.AppsInfoService;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* AppsInfoService
* 应用信息 service实现
......@@ -15,5 +27,73 @@ import com.mortals.xhx.module.apps.service.AppsInfoService;
*/
@Service("appsInfoService")
public class AppsInfoServiceImpl extends AbstractCRUDServiceImpl<AppsInfoDao, AppsInfoEntity, Long> implements AppsInfoService {
@Autowired
private IAppFeign appFeign;
@Override
public AppsInfoEntity save(AppsInfoEntity entity, Context context) throws AppException {
return null;
}
@Override
public int save(List<AppsInfoEntity> list, Context context) throws AppException {
return 0;
}
@Override
public AppsInfoEntity update(AppsInfoEntity entity, Context context) throws AppException {
return null;
}
@Override
public int update(List<AppsInfoEntity> list, Context context) throws AppException {
return 0;
}
@Override
public AppsInfoEntity get(Long key, Context context) throws AppException {
return null;
}
@Override
public List<AppsInfoEntity> find(AppsInfoEntity entity) throws AppException {
AppPdu appPdu = new AppPdu();
appPdu.setSiteId(entity.getSiteId());
appPdu.setSize(999);
Rest<RespData<List<AppPdu>>> rest = appFeign.list(appPdu);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
List<AppsInfoEntity> appsInfoEntities = new ArrayList<>();
for(AppPdu pdu:rest.getData().getData()){
appsInfoEntities.add(conversion(pdu));
}
return appsInfoEntities;
}else {
return Collections.emptyList();
}
}
@Override
public AppsInfoEntity get(Long id) throws AppException {
Rest<AppPdu> rest = appFeign.info(id);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
return conversion(rest.getData());
}else {
return null;
}
}
private AppsInfoEntity conversion(AppPdu pdu){
if(pdu==null){
return null;
}
AppsInfoEntity appsInfoEntity = new AppsInfoEntity();
appsInfoEntity.setId(pdu.getId());
appsInfoEntity.setName(pdu.getAppName());
appsInfoEntity.setDescribe(pdu.getSummary());
appsInfoEntity.setIcon(pdu.getAppIconPath());
appsInfoEntity.setUrl(pdu.getUrl());
return appsInfoEntity;
}
}
\ No newline at end of file
......@@ -35,7 +35,9 @@ public class SstAppsServiceImpl extends AbstractCRUDServiceImpl<SstAppsDao, SstA
if(siteId == null){
throw new AppException("站点id不能为空");
}
List<AppsInfoEntity> allApps = appsInfoService.find(new AppsInfoEntity());
AppsInfoEntity appsInfoQuery = new AppsInfoEntity();
appsInfoQuery.setSiteId(siteId);
List<AppsInfoEntity> allApps = appsInfoService.find(appsInfoQuery);
SstAppsEntity query = new SstAppsEntity();
query.setSiteId(siteId);
List<SstAppsEntity> appsEntities = this.find(query);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment