更新notice

This commit is contained in:
sjm 2023-12-28 00:27:15 +08:00
parent 79c3d2bff8
commit 6d6f311886
9 changed files with 188 additions and 12 deletions

View File

@ -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<List<CommentNode>> 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<CommentUser> queryObserveUserById (Integer Id) {
return ResponseEntity.ok(commentService.queryCommentUserById(Id));
}

View File

@ -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);
}
}

View File

@ -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<String, Object> Update(UrlList urlList){
public HashMap<String, Object> Update(@RequestBody UrlList urlList){
int x = urlListService.update(urlList);
HashMap<String, Object> result = new HashMap<>();
if(x == 1){

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}

View File

@ -27,9 +27,12 @@ public class CommentServiceImpl implements CommentService {
int result = commentDao.insert(comment);
HashMap<String, Object> 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);
}

View File

@ -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<String,Object> 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<String,Object> 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<String,Object> 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<String,Object> 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);
}
}
}

View File

@ -109,6 +109,6 @@ public class UrlLiserServiceImpl implements UrlListService {
public List<UrlList> latestEight(){return urlListDao.latestEight(); }
public int update(UrlList urlList){return urlListDao.updateByPrimaryKeySelective(urlList);}
public int update(UrlList urlList){return urlListDao.updateByPrimaryKey(urlList);}
}