Browse Source

消息通知 type= "error"

master
sige 1 year ago
parent
commit
e01f312cfd
  1. BIN
      app.db
  2. 26
      src/main/java/com/iflytop/digester/underframework/controller/UfApiNotification.java
  3. 13
      src/main/java/com/iflytop/digester/underframework/dao/record/UfActiveRecord.java
  4. 2
      web

BIN
app.db

26
src/main/java/com/iflytop/digester/underframework/controller/UfApiNotification.java

@ -0,0 +1,26 @@
package com.iflytop.digester.underframework.controller;
import com.iflytop.digester.underframework.dao.model.UfMdbNotification;
import com.iflytop.digester.underframework.dao.record.UfActiveRecord;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
@Controller
public class UfApiNotification extends UfApiControllerBase {
@ResponseBody
@PostMapping("/api/notification/fetch-one")
public UfApiResponse notificationFetchOne() {
var notification = UfActiveRecord.findOne(UfMdbNotification.class, Map.of("status", "new"));
return this.success(notification);
}
@ResponseBody
@PostMapping("/api/notification/mark-read")
public UfApiResponse notificationMarkRead(@RequestBody UfMdbNotification notification) {
notification.reload();
notification.status = "read";
notification.save();
return this.success();
}
}

13
src/main/java/com/iflytop/digester/underframework/dao/record/UfActiveRecord.java

@ -202,4 +202,17 @@ public class UfActiveRecord {
}
return data;
}
// reload model
public void reload() {
if ( null == this.id ) {
throw new RuntimeException("Model id is null");
}
var model = UfActiveRecord.findOne(this.getClass(), this.id);
if ( null == model ) {
throw new RuntimeException("Model not found: " + this.id);
}
this.setAttributes(model.toMap());
this.isNewRecord = false;
}
}

2
web

@ -1 +1 @@
Subproject commit 5a0d77238339189b0fc83e950c0f12d02fff9d2d
Subproject commit 1281f43be8a5de2f98d83c2a32506bb878eb5495
Loading…
Cancel
Save