提交 bdda6d3f authored 作者: xc's avatar xc

消失提醒

上级 03a65f95
package com.zjty.efs.bus.Dao;
import com.zjty.efs.bus.entity.Attention;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface AttentionDao extends JpaRepository<Attention, Integer> {
}
package com.zjty.efs.bus.Dao; package com.zjty.efs.bus.Dao;
import com.zjty.efs.bus.entity.Notice; import com.zjty.efs.bus.entity.Notice;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface NoticeDao extends JpaRepository<Notice , Integer> { public interface NoticeDao extends JpaRepository<Notice , Integer> {
Notice findById(int id);
Page<Notice> findOutBySenderAndType(int sender, int type, Pageable pageable);
} }
package com.zjty.efs.bus.controller;
import com.zjty.efs.bus.entity.Attention;
import com.zjty.efs.misc.config.AutoDocument;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
@AutoDocument
@Api(tags = "提醒接口")
@RestController
@RequestMapping("/attention")
public class AttentionController {
@ApiOperation(value = "获取提醒列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "当前登录用户", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "条数", dataType = "int", paramType = "query", required = true)
})
@PostMapping("/getAttention")
public ResponseEntity<Page<Attention>> test(@RequestParam int userId, int pageNum, int pageSize){
return ResponseEntity.ok(new PageImpl<>(new ArrayList<>()));
}
}
...@@ -29,14 +29,6 @@ public class NoticeController { ...@@ -29,14 +29,6 @@ public class NoticeController {
private NoticeService noticeService; private NoticeService noticeService;
@ApiOperation(value = "测试接口")
@ApiImplicitParam(name = "test", value = "", dataType = "String", paramType = "query", required = true)
@PostMapping("/testNotice")
public ResponseEntity test(@RequestParam String notice){
System.out.println(notice);
return ResponseEntity.ok(true);
}
/** /**
* 新增通知 * 新增通知
* @param notice * @param notice
...@@ -46,8 +38,7 @@ public class NoticeController { ...@@ -46,8 +38,7 @@ public class NoticeController {
@ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true) @ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true)
@PostMapping("/addNotice") @PostMapping("/addNotice")
public ResponseEntity addNotice(@RequestBody @Valid Notice notice){ public ResponseEntity addNotice(@RequestBody @Valid Notice notice){
System.out.println(notice); return ResponseEntity.ok(noticeService.addNotice(notice));
return ResponseEntity.ok(true);
} }
/** /**
...@@ -59,8 +50,8 @@ public class NoticeController { ...@@ -59,8 +50,8 @@ public class NoticeController {
@ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true) @ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true)
@PutMapping("/updateNotice") @PutMapping("/updateNotice")
public ResponseEntity updateNotice(@RequestBody @Valid Notice notice){ public ResponseEntity updateNotice(@RequestBody @Valid Notice notice){
System.out.println(notice);
return ResponseEntity.ok(true); return ResponseEntity.ok(noticeService.updateNotice(notice));
} }
@ApiOperation(value = "查看通知接口") @ApiOperation(value = "查看通知接口")
...@@ -68,29 +59,26 @@ public class NoticeController { ...@@ -68,29 +59,26 @@ public class NoticeController {
required = true, example = "1", dataType = "int") required = true, example = "1", dataType = "int")
@GetMapping("/getNotice") @GetMapping("/getNotice")
public ResponseEntity<Notice> getNotice(@RequestParam int id){ public ResponseEntity<Notice> getNotice(@RequestParam int id){
System.out.println(id); return ResponseEntity.ok(noticeService.getNotice(id));
return ResponseEntity.ok(new Notice());
} }
@GetMapping("/getNoticeList") @GetMapping("/getNoticeList")
@ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2,消息提醒 0") @ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2,消息提醒 0")
@ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "username", dataType = "String"), @ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "username", dataType = "int"),
@ApiImplicitParam(name = "type", value = "通知类型", paramType = "query", required = true, example = "0", dataType = "int"), @ApiImplicitParam(name = "type", value = "通知类型", paramType = "query", required = true, example = "0", dataType = "int"),
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", required = true, dataType = "int"), @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "条数", paramType = "query", required = true, dataType = "int")}) @ApiImplicitParam(name = "pageSize", value = "条数", paramType = "query", required = true, dataType = "int")})
public ResponseEntity<List<Notice>> getNoticeList(@RequestParam String user, int type, int pageNum, int pageSize){ public ResponseEntity<Page<Notice>> getNoticeList(@RequestParam int user, int type, int pageNum, int pageSize){
Page<Notice> data = noticeService.getReceiveList(user, type, pageNum, pageSize);
return ResponseEntity.ok(new ArrayList<>()); return ResponseEntity.ok(data);
} }
@PutMapping("/updateStatus") @PutMapping("/updateStatus")
@ApiOperation(value = "修改通知为已读") @ApiOperation(value = "修改通知为已读")
@ApiImplicitParams({@ApiImplicitParam(name = "ids", value = "通知id列表", paramType = "query", required = true, @ApiImplicitParams({@ApiImplicitParam(name = "notices", value = "通知列表", paramType = "body", required = true,
allowMultiple = true, dataType = "int")}) allowMultiple = true, dataType = "Notice")})
public ResponseEntity updateStatus(@RequestParam List<Integer> ids){ public ResponseEntity updateStatus(@RequestBody List<Notice> notices){
System.out.println(ids); return ResponseEntity.ok(noticeService.updateStatus(notices));
return ResponseEntity.ok(true);
} }
} }
package com.zjty.efs.bus.entity;
import com.zjty.efs.misc.config.AutoDocument;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.lang.annotation.Documented;
@AutoDocument
@ApiModel(value = "提醒", description = "提醒实体类")
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "attention")
public class Attention {
/**
* id
*/
@ApiModelProperty(value = "id", example = "1")
@Id
@GeneratedValue
@Column(name = "id")
private int id;
/**
* 标题
*/
@ApiModelProperty(value = "data", example = "您收到来自XX单位的文件,请及时查收。", dataType = "String", name = "提醒内容")
@Column(name = "data")
private String data;
/**
* 通知编号
*/
@ApiModelProperty(value = "noticeId", example = "1", dataType = "int", name = "通知编号")
@Column(name = "notice_id")
private int noticeId;
/**
* 当前用户
*/
@ApiModelProperty(value = "userId", example = "1", dataType = "int", name = "当前用户编号")
@Column(name = "user_id")
private int userId;
}
...@@ -4,6 +4,9 @@ import lombok.AllArgsConstructor; ...@@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.persistence.Table;
import java.lang.annotation.Documented;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Data @Data
......
...@@ -43,16 +43,16 @@ public class Notice { ...@@ -43,16 +43,16 @@ public class Notice {
/** /**
* 收件人 * 收件人
*/ */
@ApiModelProperty(value = "addressee", example = "谢潮", dataType = "String", name = "收件人") @ApiModelProperty(value = "addressee", example = "1", dataType = "int", name = "收件人")
@Column(name = "addressee") @Column(name = "addressee")
private String addressee; private int addressee;
/** /**
* 发件人 * 发件人
*/ */
@ApiModelProperty(value = "sender", example = "谢借口", dataType = "String", name = "发件人") @ApiModelProperty(value = "sender", example = "2", dataType = "String", name = "发件人")
@Column(name = "sender") @Column(name = "sender")
private String sender; private int sender;
/** /**
* 留言 * 留言
......
package com.zjty.efs.bus.service;
import com.zjty.efs.bus.entity.Attention;
import org.springframework.data.domain.Page;
public interface AttentionService {
Page<Attention> getAttentionList(int userId, int pageNum, int pageSize);
}
...@@ -2,29 +2,32 @@ package com.zjty.efs.bus.service; ...@@ -2,29 +2,32 @@ package com.zjty.efs.bus.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zjty.efs.bus.entity.Notice; import com.zjty.efs.bus.entity.Notice;
import org.springframework.data.domain.Page;
import java.util.List;
public interface NoticeService { public interface NoticeService {
/** /**
* 新增通知 * 新增通知
* @param jsonObject 通知json对象 * @param jsonObject 通知对象
* @return * @return
*/ */
String addNotice(Notice jsonObject); boolean addNotice(Notice jsonObject);
/** /**
* 修改通知 * 修改通知
* @param jsonObject 通知json对象 * @param jsonObject 通知对象
* @return * @return
*/ */
String updateNotice(Notice jsonObject); boolean updateNotice(Notice jsonObject);
/** /**
* 查看通知 * 查看通知
* @param id * @param id 通知id
* @return * @return
*/ */
String getNotice(int id); Notice getNotice(int id);
/** /**
* 获取通知列表 * 获取通知列表
...@@ -34,7 +37,13 @@ public interface NoticeService { ...@@ -34,7 +37,13 @@ public interface NoticeService {
* *
* @return 通知json对象 * @return 通知json对象
*/ */
String getReceiveList(String user, int type); Page<Notice> getReceiveList(int user, int type, int pageNum, int pageSize);
/**
* 修改通知为已读
* @param notices 需要修改的通知实体列表
*/
boolean updateStatus(List<Notice> notices);
} }
package com.zjty.efs.bus.service.impl;
import com.zjty.efs.bus.entity.Attention;
import com.zjty.efs.bus.service.AttentionService;
import org.springframework.data.domain.Page;
public class AttentionServiceImpl implements AttentionService {
@Override
public Page<Attention> getAttentionList(int userId, int pageNum, int pageSize) {
return null;
}
}
...@@ -5,8 +5,16 @@ import com.zjty.efs.bus.Dao.NoticeDao; ...@@ -5,8 +5,16 @@ import com.zjty.efs.bus.Dao.NoticeDao;
import com.zjty.efs.bus.entity.Notice; import com.zjty.efs.bus.entity.Notice;
import com.zjty.efs.bus.service.NoticeService; import com.zjty.efs.bus.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service @Service
public class NoticeServiceImpl implements NoticeService { public class NoticeServiceImpl implements NoticeService {
@Autowired @Autowired
...@@ -14,22 +22,61 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -14,22 +22,61 @@ public class NoticeServiceImpl implements NoticeService {
@Override @Override
public String addNotice(Notice jsonObject) { public boolean addNotice(Notice notice) {
return "成功"; try{
noticeDao.save(notice);
notice.setType(0);
noticeDao.save(notice);
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
}
@Override
public boolean updateNotice(Notice notice) {
try{
noticeDao.save(notice);
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
} }
@Override @Override
public String updateNotice(Notice jsonObject) { public Notice getNotice(int id) {
return null; try {
return noticeDao.findById(id);
}catch (Exception e){
e.printStackTrace();
return null;
}
} }
@Override @Override
public String getNotice(int id) { public Page<Notice> getReceiveList(int user, int type, int pageNum, int pageSize) {
return null;
Pageable pageable = PageRequest.of(pageNum - 1, pageSize, Sort.Direction.DESC,"updateTime");
Page<Notice> p = noticeDao.findOutBySenderAndType(user, type, pageable);
return p;
} }
@Override @Override
public String getReceiveList(String user, int type) { public boolean updateStatus(List<Notice> notices) {
return null; try {
for (Notice notice:notices){
noticeDao.save(notice);
}
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论