You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.0 KiB
90 lines
3.0 KiB
package com.community.pocket.api.web;
|
|
|
|
import com.community.pocket.entity.vo.*;
|
|
import com.community.pocket.entity.vo.android.ForumDto;
|
|
import com.community.pocket.entity.vo.web.ForumCheck;
|
|
import com.community.pocket.entity.vo.web.ForumCheckResponse;
|
|
import com.community.pocket.repository.android.ForumDao;
|
|
import com.community.pocket.repository.android.NoticeDao;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* web和android端共用论坛接口
|
|
*/
|
|
@CrossOrigin("http://localhost:4200")
|
|
@RestController
|
|
public class WebForumController {
|
|
|
|
|
|
@Autowired
|
|
private NoticeDao noticeDao;
|
|
|
|
@Autowired
|
|
private ForumDao forumDao;
|
|
|
|
//加载最新帖子
|
|
@GetMapping({"/api/forum/posts", "/forum/new"})
|
|
public ForumNewResponse loadForumNew(ForumQuery forumQuery) {
|
|
Page<ForumDto> forumList = forumDao.loadForum(forumQuery);
|
|
if (forumList != null) {
|
|
ForumNewResponse response = new ForumNewResponse(Result.OK, ForumNewResponse.Msg.ok);
|
|
response.setForumList(forumList);
|
|
return response;
|
|
} else {
|
|
return new ForumNewResponse(Result.FAIL, ForumNewResponse.Msg.fail);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除公告
|
|
*/
|
|
@PostMapping("/api/forum/notice/delete")
|
|
public ForumNoticeResponse deleteNotices(@RequestBody NoticeVo noticeVo) {
|
|
if (noticeDao.deleteNotice(noticeVo)) {
|
|
return new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.delete_ok);
|
|
} else {
|
|
return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.delete_fail);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 添加公告
|
|
*/
|
|
@PostMapping("/api/forum/notice/add")
|
|
public ForumNoticeResponse addNotices(@RequestBody NoticeVo noticeForm) {
|
|
if (noticeDao.save(noticeForm) != null) {
|
|
return new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.add_ok);
|
|
} else {
|
|
return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.add_fail);
|
|
}
|
|
}
|
|
|
|
//帖子审核接口
|
|
@PostMapping("/api/forum/posts/check")
|
|
public ForumCheckResponse check(@RequestBody ForumCheck forumCheck) {
|
|
if (forumDao.check(forumCheck)) {
|
|
return new ForumCheckResponse(Result.OK, ForumCheckResponse.Msg.check_ok);
|
|
} else {
|
|
return new ForumCheckResponse(Result.FAIL, ForumCheckResponse.Msg.check_fail);
|
|
}
|
|
}
|
|
|
|
//加载公告接口
|
|
@GetMapping({"/api/forum/notices", "/forum/notice"})
|
|
public ForumNoticeResponse loadNotices() {
|
|
List<NoticeVo> noticeList = noticeDao.loadNotices();
|
|
if (noticeList != null) {
|
|
ForumNoticeResponse response = new ForumNoticeResponse(Result.OK, ForumNoticeResponse.Msg.ok);
|
|
response.setNoticeList(noticeList);
|
|
return response;
|
|
} else {
|
|
return new ForumNoticeResponse(Result.FAIL, ForumNoticeResponse.Msg.fail);
|
|
}
|
|
}
|
|
|
|
}
|
|
|