writer接口url调整,Vo参数去掉platform
This commit is contained in:
parent
ba1167c806
commit
7e9d88b2c4
|
|
@ -0,0 +1,11 @@
|
|||
package cn.org.gitlink.notification.common.constant;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: wanjia
|
||||
* @time: 2021/9/9
|
||||
*/
|
||||
public class NotificationSystemConstant {
|
||||
//平台编码
|
||||
public static final String PLATFORM_CODE_GITLINK = "gitlink"; //gitlink平台
|
||||
}
|
||||
|
|
@ -10,10 +10,6 @@ import javax.validation.constraints.Size;
|
|||
|
||||
public class NewSysNotificationVo {
|
||||
|
||||
@ApiModelProperty(value = "平台编码", required = true)
|
||||
@NotBlank(message = "平台编码不能为空")
|
||||
private String platform;
|
||||
|
||||
@ApiModelProperty(value = "消息发送者", required = true)
|
||||
@NotNull(message = "消息发送者不能为空")
|
||||
@Range(min = Integer.MIN_VALUE, max = Integer.MAX_VALUE)
|
||||
|
|
@ -59,14 +55,6 @@ public class NewSysNotificationVo {
|
|||
this.extra = extra;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public Integer getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@ import javax.validation.constraints.NotNull;
|
|||
import javax.validation.constraints.Pattern;
|
||||
|
||||
public class UpdateNotificationStatusVo {
|
||||
@ApiModelProperty(value = "平台编号", required = true)
|
||||
@NotBlank
|
||||
private String platform;
|
||||
|
||||
@ApiModelProperty(value = "消息ids", required = true)
|
||||
@NotBlank
|
||||
@Pattern(regexp = "^\\d+(,\\d+)*$", message = "消息id串非法")
|
||||
|
|
@ -32,14 +28,6 @@ public class UpdateNotificationStatusVo {
|
|||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getNotificationIds() {
|
||||
return notificationIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.org.gitlink.notification.model.service.notification.impl;
|
||||
|
||||
import cn.org.gitlink.notification.common.constant.NotificationSystemConstant;
|
||||
import cn.org.gitlink.notification.common.utils.RedisUtil;
|
||||
import cn.org.gitlink.notification.model.dao.entity.SysNotification;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.NewSysNotificationVo;
|
||||
|
|
@ -36,7 +37,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
List<String> list = Arrays.asList(newSysNotificationVo.getReceivers().split(","));
|
||||
for (String receiver : list) {
|
||||
sysNotification.setReceiver(Integer.parseInt(receiver));
|
||||
baseMapper.insertSelective(newSysNotificationVo.getPlatform(), sysNotification);
|
||||
baseMapper.insertSelective(NotificationSystemConstant.PLATFORM_CODE_GITLINK, sysNotification);
|
||||
this.delUserCache(Integer.parseInt(receiver));
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ public class CachedServiceTest {
|
|||
notificationVo.setContent("wowowowowo");
|
||||
notificationVo.setReceivers("1111,2222,3333,4444,5555");
|
||||
notificationVo.setExtra("extra_info");
|
||||
notificationVo.setPlatform("gitlink");
|
||||
notificationVo.setSource("delete_issue");
|
||||
notificationVo.setType(1);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.org.gitlink.notification.reader.controller;
|
||||
|
||||
import cn.org.gitlink.notification.common.constant.NotificationSystemConstant;
|
||||
import cn.org.gitlink.notification.common.response.DataPacketUtil;
|
||||
import cn.org.gitlink.notification.common.response.ResponseData;
|
||||
import cn.org.gitlink.notification.common.utils.RedisUtil;
|
||||
|
|
@ -18,10 +19,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
@RestController
|
||||
@RequestMapping(value = "/gns/notification")
|
||||
public class NotificationController {
|
||||
|
||||
//平台编号
|
||||
private static final String PLATFORM_CODE_GITLINK = "gitlink";
|
||||
|
||||
//未读消息类型
|
||||
private static final Integer NOTIFICATION_TYPE_ALL = -1; //全部未读消息
|
||||
private static final Integer NOTIFICATION_TYPE_SYS = 1; //系统消息
|
||||
|
|
@ -184,7 +181,7 @@ public class NotificationController {
|
|||
private ResponseData validatePlatformCodeAndReceiver(String platform, Integer receiver) {
|
||||
|
||||
//验证 {platform} 参数合法性,以判断请求来源
|
||||
if (!platform.trim().toLowerCase().equals(PLATFORM_CODE_GITLINK)) {
|
||||
if (!platform.trim().toLowerCase().equals(NotificationSystemConstant.PLATFORM_CODE_GITLINK)) {
|
||||
logger.debug("\t 输入参数 {platform} 的值 {" + platform + "} 无效");
|
||||
return DataPacketUtil.jsonFailResult("{platform} 参数非法");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.org.gitlink.notification.writer.controller;
|
||||
|
||||
import cn.org.gitlink.notification.common.constant.NotificationSystemConstant;
|
||||
import cn.org.gitlink.notification.common.response.DataPacketUtil;
|
||||
import cn.org.gitlink.notification.common.response.ResponseData;
|
||||
import cn.org.gitlink.notification.common.utils.KafkaUtil;
|
||||
|
|
@ -9,6 +10,7 @@ import cn.org.gitlink.notification.model.service.notification.SysNotificationSer
|
|||
import cn.org.gitlink.notification.model.dao.entity.vo.UpdateNotificationStatusVo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -21,10 +23,6 @@ import java.util.Map;
|
|||
@RestController
|
||||
@RequestMapping(value = "/gns/notification")
|
||||
public class NotificationController {
|
||||
|
||||
//平台编号
|
||||
private static final String PLATFORM_CODE_GITLINK = "gitlink";
|
||||
|
||||
@Autowired
|
||||
private KafkaUtil kafkaUtil;
|
||||
|
||||
|
|
@ -34,15 +32,21 @@ public class NotificationController {
|
|||
private Logger logger = LogManager.getLogger(NotificationController.class);
|
||||
|
||||
@ApiOperation("添加系统消息")
|
||||
@RequestMapping(path = "/", method = RequestMethod.POST)
|
||||
@RequestMapping(path = "/{platform}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseData sendNotification(@Validated @RequestBody NewSysNotificationVo newSysNotificationVo, BindingResult bindingResult) {
|
||||
public ResponseData sendNotification(@ApiParam(value = "平台编码", required = true)
|
||||
@PathVariable(name = "platform") String platform,
|
||||
|
||||
@Validated @RequestBody NewSysNotificationVo newSysNotificationVo,
|
||||
|
||||
BindingResult bindingResult) {
|
||||
|
||||
//参数合法性验证
|
||||
Map<String, String> errors = ValidatorUtils.buildValidationErrorMessageMap(bindingResult);
|
||||
if (!errors.isEmpty()) {
|
||||
return DataPacketUtil.jsonFailResult(errors);
|
||||
}
|
||||
ResponseData jsonFailResult = validatePlatformCode(newSysNotificationVo.getPlatform());
|
||||
ResponseData jsonFailResult = validatePlatformCode(platform);
|
||||
if (jsonFailResult != null) return jsonFailResult;
|
||||
|
||||
try {
|
||||
|
|
@ -56,19 +60,25 @@ public class NotificationController {
|
|||
}
|
||||
|
||||
@ApiOperation("改变系统消息状态")
|
||||
@RequestMapping(path = "/", method = RequestMethod.PUT)
|
||||
@RequestMapping(path = "/{platform}", method = RequestMethod.PUT)
|
||||
@ResponseBody
|
||||
public ResponseData changeNotificationStatus(@Validated @RequestBody UpdateNotificationStatusVo updateNotificationStatusVo, BindingResult bindingResult) {
|
||||
public ResponseData changeNotificationStatus(@ApiParam(value = "平台编码", required = true)
|
||||
@PathVariable(name = "platform") String platform,
|
||||
|
||||
@Validated @RequestBody UpdateNotificationStatusVo updateNotificationStatusVo,
|
||||
|
||||
BindingResult bindingResult) {
|
||||
|
||||
//参数合法性验证
|
||||
Map<String, String> errors = ValidatorUtils.buildValidationErrorMessageMap(bindingResult);
|
||||
if (!errors.isEmpty()) {
|
||||
return DataPacketUtil.jsonFailResult(errors);
|
||||
}
|
||||
ResponseData jsonFailResult = validatePlatformCode(updateNotificationStatusVo.getPlatform());
|
||||
ResponseData jsonFailResult = validatePlatformCode(platform);
|
||||
if (jsonFailResult != null) return jsonFailResult;
|
||||
|
||||
try {
|
||||
sysNotificationService.markNotificationAs(updateNotificationStatusVo.getPlatform(), updateNotificationStatusVo.getReceiver(), updateNotificationStatusVo.getNotificationIds(), updateNotificationStatusVo.getStatus());
|
||||
sysNotificationService.markNotificationAs(platform, updateNotificationStatusVo.getReceiver(), updateNotificationStatusVo.getNotificationIds(), updateNotificationStatusVo.getStatus());
|
||||
return DataPacketUtil.jsonSuccessResult();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
|
|
@ -86,7 +96,7 @@ public class NotificationController {
|
|||
private ResponseData validatePlatformCode(String platform) {
|
||||
|
||||
//验证 {platform} 参数合法性,以判断请求来源
|
||||
if (!platform.trim().toLowerCase().equals(PLATFORM_CODE_GITLINK)) {
|
||||
if (!platform.trim().toLowerCase().equals(NotificationSystemConstant.PLATFORM_CODE_GITLINK)) {
|
||||
logger.debug("\t 输入参数 {platform} 的值 {" + platform + "} 无效");
|
||||
return DataPacketUtil.jsonFailResult("{platform} 参数非法");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue