App用户消息配置迁移

This commit is contained in:
2023-08-28 12:32:58 +08:00
parent 1e7b0c7f74
commit 18ea80ab50
8 changed files with 0 additions and 300 deletions

View File

@@ -1,24 +0,0 @@
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 org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT, path = "/appInfoSet", fallbackFactory = AppInfoSetFeignClientFallbackFactory.class,contextId = "appInfoSet")
public interface AppInfoSetFeignClient {
@PostMapping("/add")
HttpResult<String> add(@RequestBody AppInfoSet appInfoSet);
@PostMapping("/queryByUserId")
HttpResult<AppInfoSet> queryByUserId();
}

View File

@@ -1,48 +0,0 @@
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<String> add(AppInfoSet appInfoSet) {
log.error("{}异常,降级处理,异常为:{}","新增用户消息推送配置",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<AppInfoSet> queryByUserId() {
log.error("{}异常,降级处理,异常为:{}","查看用户消息推送配置",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,37 +0,0 @@
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

@@ -1,54 +0,0 @@
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;
}

View File

@@ -1,70 +0,0 @@
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.*;
import springfox.documentation.annotations.ApiIgnore;
/**
* <p>
* 前端控制器
* </p>
* 用户推送消息配置
* @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("/add")
@ApiOperation("新增用户消息推送配置")
@ApiImplicitParam(name = "appInfoSet", value = "参数实体", required = true)
@ApiIgnore
public HttpResult<String> add(@RequestBody AppInfoSet appInfoSet){
String methodDescribe = getMethodDescribe("add");
appInfoSetService.save(appInfoSet);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryByUserId")
@ApiOperation("查看用户消息推送配置")
public HttpResult<AppInfoSet> 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<String> update(@RequestBody AppInfoSetParam.AppInfoSetUpdateParam param){
String methodDescribe = getMethodDescribe("update");
appInfoSetService.updateAppInfo(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -1,16 +0,0 @@
package com.njcn.cssystem.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.cssystem.pojo.po.AppInfoSet;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xuyang
* @since 2023-08-21
*/
public interface AppInfoSetMapper extends BaseMapper<AppInfoSet> {
}

View File

@@ -1,21 +0,0 @@
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;
/**
* <p>
* 服务类
* </p>
*
* @author xuyang
* @since 2023-08-21
*/
public interface IAppInfoSetService extends IService<AppInfoSet> {
/**
* 更新用户消息配置
*/
void updateAppInfo(AppInfoSetParam param);
}

View File

@@ -1,30 +0,0 @@
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;
/**
* <p>
* 服务实现类
* </p>
*
* @author xuyang
* @since 2023-08-21
*/
@Service
public class AppInfoSetServiceImpl extends ServiceImpl<AppInfoSetMapper, AppInfoSet> implements IAppInfoSetService {
@Override
public void updateAppInfo(AppInfoSetParam param) {
AppInfoSet appInfoSet = new AppInfoSet();
BeanUtils.copyProperties(param,appInfoSet);
appInfoSet.setUserId(RequestUtil.getUserIndex());
this.updateById(appInfoSet);
}
}