diff --git a/src/main/java/com/lovenav/controller/CommentController.java b/src/main/java/com/lovenav/controller/CommentController.java index b41e663..1be6752 100644 --- a/src/main/java/com/lovenav/controller/CommentController.java +++ b/src/main/java/com/lovenav/controller/CommentController.java @@ -14,34 +14,34 @@ import java.util.List; @RestController -@RequestMapping("/comment") + public class CommentController { @Autowired private CommentService commentService; // 评论功能 -@RequestMapping(method = RequestMethod.POST, value = "/comment") - public String Reply1(@RequestBody Comment comment){ +@RequestMapping("/comment/comment") + public String Reply1(Comment comment){ return commentService.Reply1(comment); } // 回复功能 -@RequestMapping(method = RequestMethod.POST, value = "/reply_comment") +@RequestMapping(method = RequestMethod.POST, value = "/comment/reply_comment") public String Reply2(@RequestBody Comment comment,int id){ return commentService.Reply2(comment,id); } // 删除功能 -@RequestMapping(method = RequestMethod.GET, value = "/delete_comment") +@RequestMapping(method = RequestMethod.GET, value = "/comment/delete_comment") public String Delete(int id){ return commentService.Delete(id); } -@RequestMapping(method = RequestMethod.GET, value = "/addLikeCount") +@RequestMapping(method = RequestMethod.GET, value = "/comment/addLikeCount") public String addLikeCount(int id){ return commentService.AddLikeCount(id); } // 显示回复 -@RequestMapping(method = RequestMethod.GET, value = "/view_reply") +@RequestMapping(method = RequestMethod.GET, value = "/comment/view_reply") public String View_reply(int id){ return commentService.View_Reply(id); } @@ -52,7 +52,7 @@ public class CommentController { * @param UrlId 博客id * @return 博客的评论信息 */ -@RequestMapping(method = RequestMethod.GET, value = "/UrlId") +@RequestMapping(method = RequestMethod.GET, value = "/comment/UrlId") public ResponseEntity> queryCommentByUrlId (Integer UrlId) { return ResponseEntity.ok(commentService.queryCommentByUrlId(UrlId)); } @@ -62,7 +62,7 @@ public class CommentController { * @param Id 评论id * @return 评论信息,携带用户信息 */ -@RequestMapping(method = RequestMethod.GET, value = "/Id") +@RequestMapping(method = RequestMethod.GET, value = "/comment/Id") public ResponseEntity queryObserveUserById (Integer Id) { return ResponseEntity.ok(commentService.queryCommentUserById(Id)); } diff --git a/src/main/java/com/lovenav/controller/NoticeController.java b/src/main/java/com/lovenav/controller/NoticeController.java new file mode 100644 index 0000000..bd13007 --- /dev/null +++ b/src/main/java/com/lovenav/controller/NoticeController.java @@ -0,0 +1,40 @@ +package com.lovenav.controller; + +import com.lovenav.entity.Notice; +import com.lovenav.service.CommentService; +import com.lovenav.service.NoticeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@RestController +public class NoticeController { + @Autowired + private NoticeService noticeService; + +// 增 + @RequestMapping("/notice/add") + public String add(Notice notice){ + return noticeService.add(notice); + } +// 删 + @RequestMapping(method = RequestMethod.GET,value = "/notice/delete") + public String delete(int id){ + return noticeService.delete(id); + } +// 查 + @RequestMapping(method = RequestMethod.GET,value = "/notice/select") + public String select(int id){ + return noticeService.select(id); + } +// 改 + @RequestMapping(method = RequestMethod.GET,value = "/notice/update") + public String update(@RequestBody Notice notice){ + return noticeService.update(notice); + } +} diff --git a/src/main/java/com/lovenav/controller/UrlListController.java b/src/main/java/com/lovenav/controller/UrlListController.java index 1ce6231..47fa04b 100644 --- a/src/main/java/com/lovenav/controller/UrlListController.java +++ b/src/main/java/com/lovenav/controller/UrlListController.java @@ -6,6 +6,7 @@ import com.lovenav.entity.UrlList; import com.lovenav.service.UrlCateListService; import com.lovenav.service.UrlListService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -133,7 +134,7 @@ public class UrlListController { } @RequestMapping("/admin/weblist/update") - public HashMap Update(UrlList urlList){ + public HashMap Update(@RequestBody UrlList urlList){ int x = urlListService.update(urlList); HashMap result = new HashMap<>(); if(x == 1){ diff --git a/src/main/java/com/lovenav/dao/NoticeDao.java b/src/main/java/com/lovenav/dao/NoticeDao.java index 6a02856..26c0bdb 100644 --- a/src/main/java/com/lovenav/dao/NoticeDao.java +++ b/src/main/java/com/lovenav/dao/NoticeDao.java @@ -1,9 +1,11 @@ package com.lovenav.dao; import com.lovenav.entity.Notice; +import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @Repository +@Mapper public interface NoticeDao { int deleteByPrimaryKey(Integer id); diff --git a/src/main/java/com/lovenav/entity/Notice.java b/src/main/java/com/lovenav/entity/Notice.java index 9662ec8..e28a8d9 100644 --- a/src/main/java/com/lovenav/entity/Notice.java +++ b/src/main/java/com/lovenav/entity/Notice.java @@ -9,6 +9,10 @@ import lombok.Data; */ @Data public class Notice implements Serializable { + Notice(){ + this.noticeStatus = 0; + } + /** * id */ @@ -39,5 +43,53 @@ public class Notice implements Serializable { */ private Date createtime; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Byte getNoticeStatus() { + return noticeStatus; + } + + public void setNoticeStatus(Byte noticeStatus) { + this.noticeStatus = noticeStatus; + } + + public Date getCreatetime() { + return createtime; + } + + public void setCreatetime(Date createtime) { + this.createtime = createtime; + } + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/src/main/java/com/lovenav/service/NoticeService.java b/src/main/java/com/lovenav/service/NoticeService.java new file mode 100644 index 0000000..168d199 --- /dev/null +++ b/src/main/java/com/lovenav/service/NoticeService.java @@ -0,0 +1,11 @@ +package com.lovenav.service; + +import com.lovenav.entity.Notice; + +public interface NoticeService { + String add(Notice notice); + String delete(int id); + String update(Notice notice); + String select(int id); + +} diff --git a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java index ec52ab0..d7d997d 100644 --- a/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java +++ b/src/main/java/com/lovenav/service/serviceImpl/CommentServiceImpl.java @@ -27,9 +27,12 @@ public class CommentServiceImpl implements CommentService { int result = commentDao.insert(comment); HashMap hashMap = new HashMap<>(); if(result > 0){ - return JSON.toJSONString(comment); + hashMap.put("code", 200); + hashMap.put("msg", "评论成功"); + return JSON.toJSONString(hashMap); } else{ + hashMap.put("code", 500); hashMap.put("msg", "评论失败"); return JSON.toJSONString(hashMap); } diff --git a/src/main/java/com/lovenav/service/serviceImpl/NoticeServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/NoticeServiceImpl.java new file mode 100644 index 0000000..e748e96 --- /dev/null +++ b/src/main/java/com/lovenav/service/serviceImpl/NoticeServiceImpl.java @@ -0,0 +1,67 @@ +package com.lovenav.service.serviceImpl; + +import com.alibaba.fastjson.JSON; +import com.lovenav.dao.NoticeDao; +import com.lovenav.entity.Notice; +import com.lovenav.service.NoticeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; + +@Service +public class NoticeServiceImpl implements NoticeService { + @Autowired + private NoticeDao noticeDao; + public String add(Notice notice){ + HashMap hashMap = new HashMap<>(); + int result = noticeDao.insert(notice); + if(result>0){ + hashMap.put("code",200); + hashMap.put("msg","添加成功"); + return JSON.toJSONString(hashMap); + }else{ + hashMap.put("code",500); + hashMap.put("msg","添加成功"); + return JSON.toJSONString(hashMap); + } + } + public String delete(int id){ + HashMap hashMap = new HashMap<>(); + int result = noticeDao.deleteByPrimaryKey(id); + if(result>0){ + hashMap.put("code",200); + hashMap.put("msg","删除成功"); + return JSON.toJSONString(hashMap); + }else{ + hashMap.put("code",500); + hashMap.put("msg","删除失败"); + return JSON.toJSONString(hashMap); + } + } + public String select(int id){ + HashMap hashMap = new HashMap<>(); + Notice result = noticeDao.selectByPrimaryKey(id); + if(result != null){ + return JSON.toJSONString(result); + }else{ + hashMap.put("code",500); + hashMap.put("msg","查找失败"); + return JSON.toJSONString(hashMap); + } + } + public String update(Notice notice){ + HashMap hashMap = new HashMap<>(); + int result = noticeDao.updateByPrimaryKeySelective(notice); + if(result > 0){ + hashMap.put("code",200); + hashMap.put("msg","修改成功"); + return JSON.toJSONString(hashMap); + }else{ + hashMap.put("code",500); + hashMap.put("msg","修改失败"); + return JSON.toJSONString(hashMap); + } + } + +} diff --git a/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java b/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java index be0da06..b689954 100644 --- a/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java +++ b/src/main/java/com/lovenav/service/serviceImpl/UrlLiserServiceImpl.java @@ -109,6 +109,6 @@ public class UrlLiserServiceImpl implements UrlListService { public List latestEight(){return urlListDao.latestEight(); } - public int update(UrlList urlList){return urlListDao.updateByPrimaryKeySelective(urlList);} + public int update(UrlList urlList){return urlListDao.updateByPrimaryKey(urlList);} }