app用户消息配置接口

This commit is contained in:
2023-08-21 11:35:40 +08:00
parent 62058c41ca
commit 91217219a4
10 changed files with 282 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
package com.njcn.cssystem.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.cssystem.api.fallback.AppInfoSetFeignClientFallbackFactory;
import com.njcn.cssystem.pojo.po.AppInfoSet;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT, path = "/appInfoSet", fallbackFactory = AppInfoSetFeignClientFallbackFactory.class,contextId = "appInfoSet")
public interface AppInfoSetFeignClient {
@PostMapping("/queryByUserId")
@ApiOperation("查看用户消息推送配置")
HttpResult<AppInfoSet> queryByUserId();
}

View File

@@ -0,0 +1,42 @@
package com.njcn.cssystem.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.cssystem.api.AppInfoSetFeignClient;
import com.njcn.cssystem.pojo.po.AppInfoSet;
import com.njcn.cssystem.utils.CsSystemEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/4/10 20:09
*/
@Slf4j
@Component
public class AppInfoSetFeignClientFallbackFactory implements FallbackFactory<AppInfoSetFeignClient> {
@Override
public AppInfoSetFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = CsSystemEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new AppInfoSetFeignClient() {
@Override
public HttpResult<AppInfoSet> queryByUserId() {
log.error("{}异常,降级处理,异常为:{}","查看用户消息推送配置",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,37 @@
package com.njcn.cssystem.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/8/21 10:17
*/
@Data
public class AppInfoSetParam {
@ApiModelProperty(value = "事件消息模块")
private Integer eventInfo;
@ApiModelProperty(value = "数据消息模块")
private Integer dataInfo;
@ApiModelProperty(value = "终端消息模块")
private Integer deviceInfo;
@ApiModelProperty(value = "系统消息模块")
private Integer systemInfo;
@Data
@EqualsAndHashCode(callSuper = true)
public static class AppInfoSetUpdateParam extends AppInfoSetParam {
@ApiModelProperty("用户id")
private String userId;
}
}

View File

@@ -0,0 +1,54 @@
package com.njcn.cssystem.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
*
* </p>
*
* @author xuyang
* @since 2023-08-21
*/
@Data
@TableName("app_info_set")
public class AppInfoSet {
private static final long serialVersionUID = 1L;
/**
* 用户索引
*/
@TableId("user_id")
@ApiModelProperty("用户索引")
private String userId;
/**
* 0关闭 1开启 事件消息模块
*/
@ApiModelProperty("事件消息模块")
private Integer eventInfo;
/**
* 0关闭 1开启 数据消息模块
*/
@ApiModelProperty("数据消息模块")
private Integer dataInfo;
/**
* 0关闭 1开启 终端消息模块
*/
@ApiModelProperty("终端消息模块")
private Integer deviceInfo;
/**
* 0关闭 1开启 系统消息模块
*/
@ApiModelProperty("系统消息模块")
private Integer systemInfo;
}