diff --git a/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/AppInfoSetFeignClient.java b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/AppInfoSetFeignClient.java new file mode 100644 index 0000000..b04f51e --- /dev/null +++ b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/AppInfoSetFeignClient.java @@ -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 queryByUserId(); + +} diff --git a/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/fallback/AppInfoSetFeignClientFallbackFactory.java b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/fallback/AppInfoSetFeignClientFallbackFactory.java new file mode 100644 index 0000000..535b35c --- /dev/null +++ b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/api/fallback/AppInfoSetFeignClientFallbackFactory.java @@ -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 { + @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 queryByUserId() { + log.error("{}异常,降级处理,异常为:{}","查看用户消息推送配置",cause.toString()); + throw new BusinessException(finalExceptionEnum); + } + + }; + } +} diff --git a/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/pojo/param/AppInfoSetParam.java b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/pojo/param/AppInfoSetParam.java new file mode 100644 index 0000000..3662d9d --- /dev/null +++ b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/pojo/param/AppInfoSetParam.java @@ -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; + } + +} diff --git a/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/pojo/po/AppInfoSet.java b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/pojo/po/AppInfoSet.java new file mode 100644 index 0000000..ea1e972 --- /dev/null +++ b/cs-system/cs-system-api/src/main/java/com/njcn/cssystem/pojo/po/AppInfoSet.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/cs-system/cs-system-boot/pom.xml b/cs-system/cs-system-boot/pom.xml index e05c31e..919a4a0 100644 --- a/cs-system/cs-system-boot/pom.xml +++ b/cs-system/cs-system-boot/pom.xml @@ -90,7 +90,7 @@ com.spotify docker-maven-plugin - 1.0.0 + 1.2.2 diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/messageConfig/AppInfoSetController.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/messageConfig/AppInfoSetController.java new file mode 100644 index 0000000..46c0893 --- /dev/null +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/controller/messageConfig/AppInfoSetController.java @@ -0,0 +1,58 @@ +package com.njcn.cssystem.controller.messageConfig; + + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.cssystem.pojo.param.AppInfoSetParam; +import com.njcn.cssystem.pojo.po.AppInfoSet; +import com.njcn.cssystem.service.IAppInfoSetService; +import com.njcn.web.controller.BaseController; +import com.njcn.web.utils.RequestUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + *

+ * 前端控制器 + *

+ * 用户推送消息配置 + * @author xuyang + * @since 2023-08-21 + */ +@RestController +@RequestMapping("/appInfoSet") +@Api(tags = "用户推送消息配置") +@AllArgsConstructor +@Validated +public class AppInfoSetController extends BaseController { + + private final IAppInfoSetService appInfoSetService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/queryByUserId") + @ApiOperation("查看用户消息推送配置") + public HttpResult queryByUserId(){ + String methodDescribe = getMethodDescribe("queryByUserId"); + AppInfoSet appInfoSet = appInfoSetService.lambdaQuery().eq(AppInfoSet::getUserId,RequestUtil.getUserIndex()).one(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, appInfoSet, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/update") + @ApiOperation("更新消息推送配置") + @ApiImplicitParam(name = "param", value = "参数实体", required = true) + public HttpResult update(@RequestBody AppInfoSetParam.AppInfoSetUpdateParam param){ + String methodDescribe = getMethodDescribe("update"); + appInfoSetService.updateAppInfo(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + +} + diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/mapper/AppInfoSetMapper.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/mapper/AppInfoSetMapper.java new file mode 100644 index 0000000..5d41cf0 --- /dev/null +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/mapper/AppInfoSetMapper.java @@ -0,0 +1,16 @@ +package com.njcn.cssystem.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.cssystem.pojo.po.AppInfoSet; + +/** + *

+ * Mapper 接口 + *

+ * + * @author xuyang + * @since 2023-08-21 + */ +public interface AppInfoSetMapper extends BaseMapper { + +} diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/IAppInfoSetService.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/IAppInfoSetService.java new file mode 100644 index 0000000..bd105e3 --- /dev/null +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/IAppInfoSetService.java @@ -0,0 +1,21 @@ +package com.njcn.cssystem.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.cssystem.pojo.param.AppInfoSetParam; +import com.njcn.cssystem.pojo.po.AppInfoSet; + +/** + *

+ * 服务类 + *

+ * + * @author xuyang + * @since 2023-08-21 + */ +public interface IAppInfoSetService extends IService { + /** + * 更新用户消息配置 + */ + void updateAppInfo(AppInfoSetParam param); + +} diff --git a/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/AppInfoSetServiceImpl.java b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/AppInfoSetServiceImpl.java new file mode 100644 index 0000000..542ee61 --- /dev/null +++ b/cs-system/cs-system-boot/src/main/java/com/njcn/cssystem/service/impl/AppInfoSetServiceImpl.java @@ -0,0 +1,30 @@ +package com.njcn.cssystem.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.cssystem.mapper.AppInfoSetMapper; +import com.njcn.cssystem.pojo.param.AppInfoSetParam; +import com.njcn.cssystem.pojo.po.AppInfoSet; +import com.njcn.cssystem.service.IAppInfoSetService; +import com.njcn.web.utils.RequestUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author xuyang + * @since 2023-08-21 + */ +@Service +public class AppInfoSetServiceImpl extends ServiceImpl implements IAppInfoSetService { + + @Override + public void updateAppInfo(AppInfoSetParam param) { + AppInfoSet appInfoSet = new AppInfoSet(); + BeanUtils.copyProperties(param,appInfoSet); + appInfoSet.setUserId(RequestUtil.getUserIndex()); + this.updateById(appInfoSet); + } +} diff --git a/cs-warn/cs-warn-boot/pom.xml b/cs-warn/cs-warn-boot/pom.xml index 127d737..d5c2ac6 100644 --- a/cs-warn/cs-warn-boot/pom.xml +++ b/cs-warn/cs-warn-boot/pom.xml @@ -93,7 +93,7 @@ com.spotify docker-maven-plugin - 1.0.0 + 1.2.2