writer中sendNotification和changeNotificationStatus接口
This commit is contained in:
parent
7891be574d
commit
c1bb616b3e
11
pom.xml
11
pom.xml
|
|
@ -61,6 +61,17 @@
|
|||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>20.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -26,6 +26,18 @@
|
|||
<artifactId>gns-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.org.gitlink.notification</groupId>
|
||||
<artifactId>gns-model</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.org.gitlink.notification</groupId>
|
||||
<artifactId>gns-model</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package cn.org.gitlink.notification.writer.controller.sysNotification;
|
||||
|
||||
import cn.org.gitlink.notification.common.response.DataPacketUtil;
|
||||
import cn.org.gitlink.notification.common.response.ResponseData;
|
||||
import cn.org.gitlink.notification.common.utils.KafkaUtil;
|
||||
import cn.org.gitlink.notification.model.service.notification.SysNotificationService;
|
||||
import cn.org.gitlink.notification.writer.controller.sysNotification.vo.NewSysNotificationVo;
|
||||
import cn.org.gitlink.notification.writer.controller.sysNotification.vo.UpdateNotificationStatusVo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/gns/notification")
|
||||
public class SysNotificationController {
|
||||
|
||||
@Autowired
|
||||
private KafkaUtil kafkaUtil;
|
||||
|
||||
@Autowired
|
||||
private SysNotificationService sysNotificationService;
|
||||
|
||||
@ApiOperation("添加系统消息")
|
||||
@RequestMapping(path = "/", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseData sendNotification(@Validated @RequestBody NewSysNotificationVo newSysNotificationVo) {
|
||||
kafkaUtil.sendMessage("gitlink_notification", JSONObject.toJSONString(newSysNotificationVo));
|
||||
return DataPacketUtil.jsonSuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation("改变系统消息状态")
|
||||
@RequestMapping(path = "/", method = RequestMethod.PUT)
|
||||
@ResponseBody
|
||||
public ResponseData changeNotificationStatus(@RequestBody UpdateNotificationStatusVo updateNotificationStatusVo) {
|
||||
int i = sysNotificationService.markNotificationAs(updateNotificationStatusVo.getPlatform(), updateNotificationStatusVo.getNotificationIds(), updateNotificationStatusVo.getStatus());
|
||||
return i > 0 ? DataPacketUtil.jsonSuccessResult() : DataPacketUtil.jsonFailResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package cn.org.gitlink.notification.writer.controller.sysNotification.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
public class NewSysNotificationVo {
|
||||
|
||||
@ApiModelProperty(value = "平台编码", required = true)
|
||||
@NotBlank
|
||||
private String platform;
|
||||
|
||||
@ApiModelProperty(value = "消息发送者", required = true)
|
||||
@NotNull
|
||||
private long sender;
|
||||
|
||||
@ApiModelProperty(value = "消息接受者", required = true)
|
||||
@NotBlank
|
||||
private String receivers;
|
||||
|
||||
@ApiModelProperty(value = "消息内容", required = true)
|
||||
@NotBlank
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "消息跳转链接", required = true)
|
||||
@NotBlank
|
||||
private String notification_url;
|
||||
|
||||
@ApiModelProperty(value = "消息类型 1-系统消息 2-@我", required = true)
|
||||
@NotNull
|
||||
private Integer type;
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public long getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSender(long sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public String getReceivers() {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void setReceivers(String receivers) {
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getNotification_url() {
|
||||
return notification_url;
|
||||
}
|
||||
|
||||
public void setNotification_url(String notification_url) {
|
||||
this.notification_url = notification_url;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package cn.org.gitlink.notification.writer.controller.sysNotification.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class UpdateNotificationStatusVo {
|
||||
@ApiModelProperty(value = "平台编号", required = true)
|
||||
@NotBlank
|
||||
private String platform;
|
||||
|
||||
@ApiModelProperty(value = "消息ids", required = true)
|
||||
@NotBlank
|
||||
private String notificationIds;
|
||||
|
||||
@ApiModelProperty(value = "已读状态: 1未读,2已读", required = true)
|
||||
@NotNull
|
||||
private Integer status;
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getNotificationIds() {
|
||||
return notificationIds;
|
||||
}
|
||||
|
||||
public void setNotificationIds(String notificationIds) {
|
||||
this.notificationIds = notificationIds;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue