articles) {
44 | this.articles = articles;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2 |
3 |
4 | IT头条信息管理系统
5 |
20 |
21 |
22 |
23 |
24 |
25 | 欢迎来到IT头条信息管理系统
26 |
27 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/target/headline/index.jsp:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2 |
3 |
4 | IT头条信息管理系统
5 |
20 |
21 |
22 |
23 |
24 |
25 | 欢迎来到IT头条信息管理系统
26 |
27 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/utils/DateConvert.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.utils;
2 |
3 | import java.text.ParseException;
4 | import java.text.ParsePosition;
5 | import java.text.SimpleDateFormat;
6 | import java.util.Date;
7 |
8 | /**
9 | * @author Calvin
10 | * @Description:
11 | */
12 | public class DateConvert {
13 | public static Date convert2Date(String bir) throws ParseException {
14 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
15 | ParsePosition pos = new ParsePosition(0);
16 | Date date = sdf.parse(bir);
17 | return date;
18 | }
19 |
20 | public static String convert2d(Date date){
21 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
22 | return sdf.format(date);
23 | }
24 |
25 | public static String convert2s(Date date){
26 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
27 | return sdf.format(date);
28 | }
29 |
30 | public static String convert2json(Long l){
31 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
32 | Date date = new Date(l);
33 | return sdf.format(date);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/Relation.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | /**
4 | * @author Calvin
5 | * @Description:
6 | */
7 | public class Relation {
8 | /**
9 | * 相关id
10 | */
11 | private Integer relationId;
12 | /**
13 | * 用户id
14 | */
15 | private Integer userId;
16 | /**
17 | *关注的用户的id
18 | */
19 | private Integer followId;
20 | /**
21 | *
22 | */
23 | private Integer state;
24 |
25 | public Integer getRelationId() {
26 | return relationId;
27 | }
28 |
29 | public void setRelationId(Integer relationId) {
30 | this.relationId = relationId;
31 | }
32 |
33 | public Integer getUserId() {
34 | return userId;
35 | }
36 |
37 | public void setUserId(Integer userId) {
38 | this.userId = userId;
39 | }
40 |
41 | public Integer getFollowId() {
42 | return followId;
43 | }
44 |
45 | public void setFollowId(Integer followId) {
46 | this.followId = followId;
47 | }
48 |
49 | public Integer getState() {
50 | return state;
51 | }
52 |
53 | public void setState(Integer state) {
54 | this.state = state;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/web/BannerController.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.web;
2 |
3 | import com.nuc.calvin.ssm.entity.BannerCustom;
4 | import com.nuc.calvin.ssm.service.BannerService;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.ResponseBody;
9 |
10 | import javax.servlet.http.HttpSession;
11 | import java.util.List;
12 |
13 | /**
14 | * @author Calvin
15 | * @Description:
16 | */
17 | @Controller("bannerController")
18 | @RequestMapping("/banner")
19 | public class BannerController {
20 |
21 | @Autowired
22 | private BannerService bannerService;
23 |
24 | @ResponseBody
25 | @RequestMapping("/queryAllBanner")
26 | public List queryAllBanner() {
27 | List list = bannerService.queryAllBanner();
28 | return list;
29 | }
30 |
31 | @RequestMapping("/bannerManage")
32 | public String getAllBanner(HttpSession session) {
33 | List banners = bannerService.queryAllBanner();
34 | session.setAttribute("banner", banners);
35 | return "banner";
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/Likes.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author Calvin
7 | * @Description:
8 | */
9 | public class Likes {
10 | /**
11 | * 点赞id
12 | */
13 | private Integer likesId;
14 | /**
15 | * 点赞用户的id
16 | */
17 | private Integer userId;
18 | /**
19 | * 被点赞的文章
20 | */
21 | private Integer articleId;
22 | /**
23 | * 点赞的时间
24 | */
25 | private Date likesTime;
26 |
27 |
28 |
29 | public Integer getLikesId() {
30 | return likesId;
31 | }
32 |
33 | public void setLikesId(Integer likesId) {
34 | this.likesId = likesId;
35 | }
36 |
37 | public Integer getUserId() {
38 | return userId;
39 | }
40 |
41 | public void setUserId(Integer userId) {
42 | this.userId = userId;
43 | }
44 |
45 | public Integer getArticleId() {
46 | return articleId;
47 | }
48 |
49 | public void setArticleId(Integer articleId) {
50 | this.articleId = articleId;
51 | }
52 |
53 | public Date getLikesTime() {
54 | return likesTime;
55 | }
56 |
57 | public void setLikeTime(Date likeTime) {
58 | this.likesTime = likeTime;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/CollectCustom.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | /**
4 | * @author Calvin
5 | * @Description:
6 | */
7 | public class CollectCustom extends Collect{
8 | private String date;
9 | private String username;
10 | private String userImg;
11 |
12 | private UserCustom user;
13 | private ArticleCustom article;
14 |
15 | public String getDate() {
16 | return date;
17 | }
18 |
19 | public void setDate(String date) {
20 | this.date = date;
21 | }
22 |
23 | public String getUsername() {
24 | return username;
25 | }
26 |
27 | public void setUsername(String username) {
28 | this.username = username;
29 | }
30 |
31 | public String getUserImg() {
32 | return userImg;
33 | }
34 |
35 | public void setUserImg(String userImg) {
36 | this.userImg = userImg;
37 | }
38 |
39 | public UserCustom getUser() {
40 | return user;
41 | }
42 |
43 | public void setUser(UserCustom user) {
44 | this.user = user;
45 | }
46 |
47 | public ArticleCustom getArticle() {
48 | return article;
49 | }
50 |
51 | public void setArticle(ArticleCustom article) {
52 | this.article = article;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/Collect.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author Calvin
7 | * @Description:
8 | */
9 | public class Collect {
10 | /**
11 | * 收藏id
12 | */
13 | private Integer collectId;
14 | /**
15 | * 文章id
16 | */
17 | private Integer ArticleId;
18 | /**
19 | * 用户id
20 | */
21 | private Integer userId;
22 | /**
23 | * 收藏时间
24 | */
25 | private Date collectTime;
26 |
27 | public Integer getCollectId() {
28 | return collectId;
29 | }
30 |
31 | public void setCollectId(Integer collectId) {
32 | this.collectId = collectId;
33 | }
34 |
35 | public Integer getArticleId() {
36 | return ArticleId;
37 | }
38 |
39 | public void setArticleId(Integer articleId) {
40 | ArticleId = articleId;
41 | }
42 |
43 | public Integer getUserId() {
44 | return userId;
45 | }
46 |
47 | public void setUserId(Integer userId) {
48 | this.userId = userId;
49 | }
50 |
51 | public Date getCollectTime() {
52 | return collectTime;
53 | }
54 |
55 | public void setCollectTime(Date collectTime) {
56 | this.collectTime = collectTime;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/UserCustom.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | /**
4 | * @author Calvin
5 | * @Description:
6 | */
7 | public class UserCustom extends User {
8 | /**
9 | * 用户关系 0——未关注 1——已关注 2——相互关注
10 | */
11 | private Relation relation;
12 |
13 | /**
14 | * 文章数
15 | */
16 | private int articleCount;
17 | /**
18 | * 关注数
19 | */
20 | private int followCount;
21 | /**
22 | * 粉丝数
23 | */
24 | private int fansCount;
25 |
26 | public Relation getRelation() {
27 | return relation;
28 | }
29 |
30 | public void setRelation(Relation relation) {
31 | this.relation = relation;
32 | }
33 |
34 | public int getArticleCount() {
35 | return articleCount;
36 | }
37 |
38 | public void setArticleCount(int articleCount) {
39 | this.articleCount = articleCount;
40 | }
41 |
42 | public int getFollowCount() {
43 | return followCount;
44 | }
45 |
46 | public void setFollowCount(int followCount) {
47 | this.followCount = followCount;
48 | }
49 |
50 | public int getFansCount() {
51 | return fansCount;
52 | }
53 |
54 | public void setFansCount(int fansCount) {
55 | this.fansCount = fansCount;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/LikesCustom.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | /**
4 | * @author Calvin
5 | * @Description:
6 | */
7 | public class LikesCustom extends Likes {
8 | /**
9 | * 扩展自定义的date String类型
10 | */
11 | private String date;
12 |
13 | private String username;
14 | private String userImg;
15 | private ArticleCustom article;
16 | private UserCustom user;
17 |
18 | public String getDate() {
19 | return date;
20 | }
21 |
22 | public void setDate(String date) {
23 | this.date = date;
24 | }
25 |
26 | public String getUsername() {
27 | return username;
28 | }
29 |
30 | public void setUsername(String username) {
31 | this.username = username;
32 | }
33 |
34 | public String getUserImg() {
35 | return userImg;
36 | }
37 |
38 | public void setUserImg(String userImg) {
39 | this.userImg = userImg;
40 | }
41 |
42 | public ArticleCustom getArticle() {
43 | return article;
44 | }
45 |
46 | public void setArticle(ArticleCustom article) {
47 | this.article = article;
48 | }
49 |
50 | public UserCustom getUser() {
51 | return user;
52 | }
53 |
54 | public void setUser(UserCustom user) {
55 | this.user = user;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/target/classes/spring/spring-service.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/resources/spring/spring-service.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/spring/spring-service.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/Article.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonFormat;
4 |
5 | import java.util.Date;
6 |
7 | /**
8 | * @author Calvin
9 | * @Description:
10 | */
11 | public class Article {
12 | /**
13 | * 文章id
14 | */
15 | private Integer articleId;
16 | /**
17 | * 作者id
18 | */
19 | private Integer userId;
20 | /**
21 | * 文章标题
22 | */
23 | private String articleTitle;
24 | /**
25 | * 文章url
26 | */
27 | private String articleUrl;
28 |
29 |
30 | public Integer getArticleId() {
31 | return articleId;
32 | }
33 |
34 | public void setArticleId(Integer articleId) {
35 | this.articleId = articleId;
36 | }
37 |
38 | public Integer getUserId() {
39 | return userId;
40 | }
41 |
42 | public void setUserId(Integer userId) {
43 | this.userId = userId;
44 | }
45 |
46 | public String getArticleTitle() {
47 | return articleTitle;
48 | }
49 |
50 | public void setArticleTitle(String articleTitle) {
51 | this.articleTitle = articleTitle;
52 | }
53 |
54 | public String getArticleUrl() {
55 | return articleUrl;
56 | }
57 |
58 | public void setArticleUrl(String articleUrl) {
59 | this.articleUrl = articleUrl;
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/web/LikesController.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.web;
2 |
3 | import com.nuc.calvin.ssm.service.LikesService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 | import org.springframework.web.bind.annotation.ResponseBody;
9 |
10 | import javax.servlet.http.HttpServletRequest;
11 |
12 | /**
13 | * @author Calvin
14 | * @Description:
15 | */
16 | @Controller("likesController")
17 | @RequestMapping("/likes")
18 | public class LikesController {
19 |
20 | @Autowired
21 | private LikesService likesService;
22 |
23 | @ResponseBody
24 | @RequestMapping( "/like")
25 | public void like(HttpServletRequest request) {
26 | Integer articleId = Integer.valueOf(request.getParameter("articleId"));
27 | Integer userId = Integer.valueOf(request.getParameter("userId"));
28 | System.out.println("userId" + userId + "articleId" + articleId);
29 | likesService.like(articleId, userId);
30 | }
31 |
32 | @ResponseBody
33 | @RequestMapping("/unlike")
34 | public void unLike(int articleId, HttpServletRequest request) {
35 | Integer userId = Integer.parseInt(request.getParameter("userId"));
36 | likesService.unLike(articleId, userId);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/service/impl/ReplyServiceImp.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.service.impl;
2 |
3 | import com.nuc.calvin.ssm.dao.ReplyCustomDao;
4 | import com.nuc.calvin.ssm.entity.ReplyCustom;
5 | import com.nuc.calvin.ssm.service.ReplyService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @author Calvin
14 | * @Description:
15 | */
16 | @Transactional(rollbackFor = Exception.class)
17 | @Service("replyService")
18 | public class ReplyServiceImp implements ReplyService {
19 |
20 | @Autowired
21 | private ReplyCustomDao replyCustomDao;
22 |
23 | /**
24 | * 添加回复
25 | * @param replyCustom
26 | */
27 | @Override
28 | public void addReply(ReplyCustom replyCustom) {
29 | replyCustomDao.addReply(replyCustom);
30 | }
31 |
32 | /**
33 | * 遍历评论id为commentId的回复
34 | * @param commentId
35 | * @return
36 | */
37 | @Override
38 | public List queryReply(int commentId) {
39 | return replyCustomDao.queryReply(commentId);
40 | }
41 |
42 | /**
43 | * 根据userId查询回复列表
44 | * @param userId
45 | * @return
46 | */
47 | @Override
48 | public List queryReplyByUserId(Integer userId) {
49 | return replyCustomDao.queryReplyByUserId(userId);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/target/classes/mapper/BannerDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 | insert into banner(bannerTitle,bannerImage) values (#{bannerImage,jdbcType=VARCHAR} )
19 |
20 |
21 |
22 | update banner
23 |
24 | articleId=#{articleId}
25 | bannerImage=#{bannerImage,jdbcType=VARCHAR}
26 |
27 |
28 |
29 |
30 | delete from banner where bannerId =#{bannerId}
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/BannerDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 | insert into banner(bannerTitle,bannerImage) values (#{bannerImage,jdbcType=VARCHAR} )
19 |
20 |
21 |
22 | update banner
23 |
24 | articleId=#{articleId}
25 | bannerImage=#{bannerImage,jdbcType=VARCHAR}
26 |
27 |
28 |
29 |
30 | delete from banner where bannerId =#{bannerId}
31 |
32 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/BannerDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 | insert into banner(bannerTitle,bannerImage) values (#{bannerImage,jdbcType=VARCHAR} )
19 |
20 |
21 |
22 | update banner
23 |
24 | articleId=#{articleId}
25 | bannerImage=#{bannerImage,jdbcType=VARCHAR}
26 |
27 |
28 |
29 |
30 | delete from banner where bannerId =#{bannerId}
31 |
32 |
--------------------------------------------------------------------------------
/target/classes/mapper/LikesDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | insert into likes (userId,articleId,likesTime)
15 | values (#{userId,jdbcType=INTEGER} ,#{articleId,jdbcType=INTEGER} ,#{likesTime,jdbcType=TIMESTAMP} );
16 |
17 |
18 |
22 |
23 |
24 | delete from likes
25 | where likesId=#{likesId,jdbcType=INTEGER}
26 |
27 |
28 |
29 | update likes set
30 | userId=#{userId,jdbcType=INTEGER}
31 | articleId=#{articleId,jdbcType=INTEGER}
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/LikesDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | insert into likes (userId,articleId,likesTime)
15 | values (#{userId,jdbcType=INTEGER} ,#{articleId,jdbcType=INTEGER} ,#{likesTime,jdbcType=TIMESTAMP} );
16 |
17 |
18 |
22 |
23 |
24 | delete from likes
25 | where likesId=#{likesId,jdbcType=INTEGER}
26 |
27 |
28 |
29 | update likes set
30 | userId=#{userId,jdbcType=INTEGER}
31 | articleId=#{articleId,jdbcType=INTEGER}
32 |
33 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/LikesDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | insert into likes (userId,articleId,likesTime)
15 | values (#{userId,jdbcType=INTEGER} ,#{articleId,jdbcType=INTEGER} ,#{likesTime,jdbcType=TIMESTAMP} );
16 |
17 |
18 |
22 |
23 |
24 | delete from likes
25 | where likesId=#{likesId,jdbcType=INTEGER}
26 |
27 |
28 |
29 | update likes set
30 | userId=#{userId,jdbcType=INTEGER}
31 | articleId=#{articleId,jdbcType=INTEGER}
32 |
33 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/Comment.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author Calvin
7 | * @Description:
8 | */
9 | public class Comment {
10 | /**
11 | * 评论id
12 | */
13 | private Integer commentId;
14 | /**
15 | * 用户id
16 | */
17 | private Integer userId;
18 | /**
19 | * 文章id
20 | */
21 | private Integer articleId;
22 | /**
23 | * 评论内容
24 | */
25 | private String commentContent;
26 | private Date commentTime;
27 |
28 |
29 | public Date getCommentTime() {
30 | return commentTime;
31 | }
32 |
33 | public void setCommentTime(Date commentTime) {
34 | this.commentTime = commentTime;
35 | }
36 |
37 | public Integer getCommentId() {
38 | return commentId;
39 | }
40 |
41 | public void setCommentId(Integer commentId) {
42 | this.commentId = commentId;
43 | }
44 |
45 | public Integer getUserId() {
46 | return userId;
47 | }
48 |
49 | public void setUserId(Integer userId) {
50 | this.userId = userId;
51 | }
52 |
53 | public Integer getArticleId() {
54 | return articleId;
55 | }
56 |
57 | public void setArticleId(Integer articleId) {
58 | this.articleId = articleId;
59 | }
60 |
61 | public String getCommentContent() {
62 | return commentContent;
63 | }
64 |
65 | public void setCommentContent(String commentContent) {
66 | this.commentContent = commentContent;
67 | }
68 | }
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/service/impl/CommentServiceImp.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.service.impl;
2 |
3 | import com.nuc.calvin.ssm.dao.CommentCustomDao;
4 | import com.nuc.calvin.ssm.entity.CommentCustom;
5 | import com.nuc.calvin.ssm.service.CommentService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @author Calvin
14 | * @Description:
15 | */
16 | @Transactional(rollbackFor = Exception.class)
17 | @Service("commentService")
18 | public class CommentServiceImp implements CommentService {
19 |
20 | @Autowired
21 | private CommentCustomDao commentCustomDao;
22 |
23 | @Override
24 | public void addComment(CommentCustom commentCustom) {
25 | commentCustomDao.addComment(commentCustom);
26 | }
27 |
28 | @Override
29 | public List queryComment(Integer articleId) {
30 | return commentCustomDao.queryComment(articleId);
31 | }
32 |
33 | @Override
34 | public int queryCountReply(Integer commentId) {
35 | return commentCustomDao.queryCountReply(commentId);
36 | }
37 |
38 | @Override
39 | public void deleteCommentById(Integer commentId) {
40 | commentCustomDao.deleteCommentById(commentId);
41 | }
42 |
43 |
44 | @Override
45 | public List queryCommentByUserId(Integer userId) {
46 | List commentList = commentCustomDao.queryCommentByUserId(userId);
47 | return commentList;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/target/classes/spring/spring-web.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/main/resources/spring/spring-web.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/spring/spring-web.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/ReplyCustom.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | /**
4 | * @author Calvin
5 | * @Description:
6 | */
7 | public class ReplyCustom extends Reply {
8 | /**
9 | * from 昵称
10 | */
11 | private String fromName;
12 | /**
13 | * to 昵称
14 | */
15 | private String toName;
16 | /**
17 | * 头像
18 | */
19 | private String fromImg;
20 | private String toImg;
21 | /**
22 | * 源文章
23 | */
24 | private Article article;
25 |
26 | /**
27 | * 回复时间 sql扩展
28 | */
29 | private String rtime;
30 |
31 | public String getFromName() {
32 | return fromName;
33 | }
34 |
35 | public void setFromName(String fromName) {
36 | this.fromName = fromName;
37 | }
38 |
39 | public String getToName() {
40 | return toName;
41 | }
42 |
43 | public void setToName(String toName) {
44 | this.toName = toName;
45 | }
46 |
47 | public String getFromImg() {
48 | return fromImg;
49 | }
50 |
51 | public void setFromImg(String fromImg) {
52 | this.fromImg = fromImg;
53 | }
54 |
55 | public String getToImg() {
56 | return toImg;
57 | }
58 |
59 | public void setToImg(String toImg) {
60 | this.toImg = toImg;
61 | }
62 |
63 | public Article getArticle() {
64 | return article;
65 | }
66 |
67 | public void setArticle(Article article) {
68 | this.article = article;
69 | }
70 |
71 | public String getRtime() {
72 | return rtime;
73 | }
74 |
75 | public void setRtime(String rtime) {
76 | this.rtime = rtime;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/CommentCustom.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author Calvin
7 | * @Description:
8 | */
9 | public class CommentCustom extends Comment {
10 | private User user;
11 | private Article article;
12 | /**
13 | * 被评论文章作者昵称
14 | */
15 | private String username;
16 |
17 | /**
18 | * json评论时间
19 | */
20 | private String time;
21 | /**
22 | * 评论回复数
23 | */
24 | private int countReply;
25 |
26 | /**
27 | * 回复列表
28 | */
29 | private List replyList;
30 |
31 | public Article getArticle() {
32 | return article;
33 | }
34 |
35 | public void setArticle(Article article) {
36 | this.article = article;
37 | }
38 |
39 | public User getUser() {
40 | return user;
41 | }
42 |
43 | public void setUser(User user) {
44 | this.user = user;
45 | }
46 |
47 | public String getUsername() {
48 | return username;
49 | }
50 |
51 | public void setUsername(String username) {
52 | this.username = username;
53 | }
54 |
55 | public String getTime() {
56 | return time;
57 | }
58 |
59 | public void setTime(String time) {
60 | this.time = time;
61 | }
62 |
63 | public int getCountReply() {
64 | return countReply;
65 | }
66 |
67 | public void setCountReply(int countReply) {
68 | this.countReply = countReply;
69 | }
70 |
71 | public List getReplyList() {
72 | return replyList;
73 | }
74 |
75 | public void setReplyList(List replyList) {
76 | this.replyList = replyList;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/target/classes/mapper/CollectDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | insert into collect (collectId,articleId,userId,collectTime)
15 | values (#{collectId,jdbcType=INTEGER} ,#{articleId,jdbcType=INTEGER}
16 | ,#{userId,jdbcType=INTEGER} ,#{collectTime,jdbcType=TIMESTAMP} );
17 |
18 |
19 |
24 |
25 |
26 | delete from collect
27 | where collectId=#{collectId,jdbcType=INTEGER}
28 |
29 |
30 |
31 | update collcet set
32 | articleId=#{articleId,jdbcType=INTEGER} ,
33 | userId=#{userId,jdbcType=INTEGER} ,
34 | collectTime=#{collectTime,jdbcType=TIMESTAMP}
35 |
36 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/CollectDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | insert into collect (collectId,articleId,userId,collectTime)
15 | values (#{collectId,jdbcType=INTEGER} ,#{articleId,jdbcType=INTEGER}
16 | ,#{userId,jdbcType=INTEGER} ,#{collectTime,jdbcType=TIMESTAMP} );
17 |
18 |
19 |
24 |
25 |
26 | delete from collect
27 | where collectId=#{collectId,jdbcType=INTEGER}
28 |
29 |
30 |
31 | update collcet set
32 | articleId=#{articleId,jdbcType=INTEGER} ,
33 | userId=#{userId,jdbcType=INTEGER} ,
34 | collectTime=#{collectTime,jdbcType=TIMESTAMP}
35 |
36 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/CollectDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | insert into collect (collectId,articleId,userId,collectTime)
15 | values (#{collectId,jdbcType=INTEGER} ,#{articleId,jdbcType=INTEGER}
16 | ,#{userId,jdbcType=INTEGER} ,#{collectTime,jdbcType=TIMESTAMP} );
17 |
18 |
19 |
24 |
25 |
26 | delete from collect
27 | where collectId=#{collectId,jdbcType=INTEGER}
28 |
29 |
30 |
31 | update collcet set
32 | articleId=#{articleId,jdbcType=INTEGER} ,
33 | userId=#{userId,jdbcType=INTEGER} ,
34 | collectTime=#{collectTime,jdbcType=TIMESTAMP}
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/Reply.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author Calvin
7 | * @Description:
8 | */
9 | public class Reply {
10 | /**
11 | * 回复id
12 | */
13 | private Integer replyId;
14 | /**
15 | * 评论id
16 | */
17 | private Integer commentId;
18 | /**
19 | * from 哪个user
20 | */
21 | private Integer fromId;
22 | /**
23 | * to哪个user
24 | */
25 | private Integer toId;
26 | /**
27 | * 评论内容
28 | */
29 | private String replyContent;
30 |
31 | /**
32 | * 回复时间
33 | */
34 | private Date replyTime;
35 |
36 | public Integer getReplyId() {
37 | return replyId;
38 | }
39 |
40 | public void setReplyId(Integer replyId) {
41 | this.replyId = replyId;
42 | }
43 |
44 | public Integer getCommentId() {
45 | return commentId;
46 | }
47 |
48 | public void setCommentId(Integer commentId) {
49 | this.commentId = commentId;
50 | }
51 |
52 | public Integer getFromId() {
53 | return fromId;
54 | }
55 |
56 | public void setFromId(Integer fromId) {
57 | this.fromId = fromId;
58 | }
59 |
60 | public Integer getToId() {
61 | return toId;
62 | }
63 |
64 | public void setToId(Integer toId) {
65 | this.toId = toId;
66 | }
67 |
68 | public String getReplyContent() {
69 | return replyContent;
70 | }
71 |
72 | public void setReplyContent(String replyContent) {
73 | this.replyContent = replyContent;
74 | }
75 |
76 | public Date getReplyTime() {
77 | return replyTime;
78 | }
79 |
80 | public void setReplyTime(Date replyTime) {
81 | this.replyTime = replyTime;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/RelationDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 | insert into relation (userId,followId,state)
16 | values (#{userId,jdbcType=INTEGER} ,#{followId,jdbcType=INTEGER} ,#{state,jdbcType=INTEGER} );
17 |
18 |
19 |
20 | delete from relation
21 | where relationId=#{relationId,jdbcType=INTEGER}
22 |
23 |
24 |
25 | update relation set
26 | userId=#{userId,jdbcType=INTEGER} ,
27 | followId=#{followId,jdbcType=INTEGER} ,
28 | state=#{state,jdbcType=INTEGER}
29 | where relationId=#{relationId,jdbcType=INTEGER}
30 |
31 |
32 |
36 |
--------------------------------------------------------------------------------
/target/classes/mapper/RelationDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 | insert into relation (userId,followId,state)
16 | values (#{userId,jdbcType=INTEGER} ,#{followId,jdbcType=INTEGER} ,#{state,jdbcType=INTEGER} );
17 |
18 |
19 |
20 | delete from relation
21 | where relationId=#{relationId,jdbcType=INTEGER}
22 |
23 |
24 |
25 | update relation set
26 | userId=#{userId,jdbcType=INTEGER} ,
27 | followId=#{followId,jdbcType=INTEGER} ,
28 | state=#{state,jdbcType=INTEGER}
29 | where relationId=#{relationId,jdbcType=INTEGER}
30 |
31 |
32 |
36 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/RelationDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
15 | insert into relation (userId,followId,state)
16 | values (#{userId,jdbcType=INTEGER} ,#{followId,jdbcType=INTEGER} ,#{state,jdbcType=INTEGER} );
17 |
18 |
19 |
20 | delete from relation
21 | where relationId=#{relationId,jdbcType=INTEGER}
22 |
23 |
24 |
25 | update relation set
26 | userId=#{userId,jdbcType=INTEGER} ,
27 | followId=#{followId,jdbcType=INTEGER} ,
28 | state=#{state,jdbcType=INTEGER}
29 | where relationId=#{relationId,jdbcType=INTEGER}
30 |
31 |
32 |
36 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/service/ArticleService.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.service;
2 |
3 | import com.nuc.calvin.ssm.entity.Article;
4 | import com.nuc.calvin.ssm.entity.ArticleCustom;
5 | import com.nuc.calvin.ssm.entity.ArticleVo;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @author Calvin
11 | * @Description:
12 | */
13 | public interface ArticleService {
14 |
15 | /**
16 | * 根据用户id查询文章列表
17 | *
18 | * @param userId
19 | * @return
20 | */
21 | List queryByUserId(Integer userId);
22 |
23 | /**
24 | * 发微博
25 | * @param articleCustom
26 | */
27 | void post(ArticleCustom articleCustom);
28 |
29 | /**
30 | * 根据文章id删除文章
31 | *
32 | * @param articleId
33 | */
34 | void deleteByArticle(Integer articleId);
35 |
36 | /**
37 | * 根据文章id查询文章信息
38 | *
39 | * @param articleId
40 | * @return
41 | */
42 | List queryArticleByArticleId(Integer articleId);
43 |
44 | /**
45 | * 查询点赞次数
46 | *
47 | * @param articleId
48 | * @return
49 | */
50 | int queryLikeCount(Integer articleId);
51 |
52 | /**
53 | * 查询评论次数
54 | *
55 | * @param articleId
56 | * @return
57 | */
58 | int queryCommentCount(Integer articleId);
59 |
60 | /**
61 | * 查询文章被收藏数
62 | * @param articleId
63 | * @return
64 | */
65 | int queryCollectCount(Integer articleId);
66 |
67 |
68 | /**
69 | * 根据关键字查询相关文章
70 | *
71 | * @param keyWord
72 | * @return
73 | */
74 | List queryArticleByWord(String keyWord);
75 |
76 | /**
77 | * 查询所有文章
78 | * @return
79 | */
80 | List queryAllArticle();
81 |
82 | /**
83 | * 查询热门文章
84 | * @return
85 | */
86 | List queryHotArticle();
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/service/impl/CollectServiceImp.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.service.impl;
2 |
3 | import com.nuc.calvin.ssm.dao.CollectionCustomDao;
4 | import com.nuc.calvin.ssm.entity.CollectCustom;
5 | import com.nuc.calvin.ssm.service.CollectService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * @author Calvin
14 | * @Description:
15 | */
16 | @Transactional(rollbackFor = Exception.class)
17 | @Service("collectService")
18 | public class CollectServiceImp implements CollectService {
19 |
20 | @Autowired
21 | private CollectionCustomDao collectionCustomDao;
22 |
23 | /**
24 | * 收藏
25 | *
26 | * @param collectCustom
27 | */
28 | @Override
29 | public void collect(CollectCustom collectCustom) {
30 | collectionCustomDao.collect(collectCustom);
31 | }
32 |
33 | @Override
34 | public void unCollect(CollectCustom collectCustom) {
35 | collectionCustomDao.uncollect(collectCustom);
36 | }
37 |
38 | /**
39 | * 是否收藏 1——是 0——否
40 | *
41 | * @param userId
42 | * @param articleId
43 | * @return
44 | */
45 | @Override
46 | public int isCollect(Integer userId, Integer articleId) {
47 | CollectCustom collect = new CollectCustom();
48 | collect.setUserId(userId);
49 | collect.setArticleId(articleId);
50 | List collectList = collectionCustomDao.isCollect(collect);
51 | if (collectList.size() != 0) {
52 | return 1;
53 | } else {
54 | return 0;
55 | }
56 | }
57 |
58 | @Override
59 | public List queryMyCollection(Integer userId) {
60 | List list = collectionCustomDao.queryAllCollection(userId);
61 | return list;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/target/classes/mapper/BannerCustomDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
35 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/BannerCustomDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
35 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/BannerCustomDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
35 |
--------------------------------------------------------------------------------
/target/classes/mapper/ArticleDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 | insert into article(articleId,userId,articleTitle,articleUrl,postTime)
17 | values (#{articleId,jdbcType=INTEGER} ,#{userId,jdbcType=INTEGER} ,#{articleTitle,jdbcType=VARCHAR}
18 | ,#{articleUrl,jdbcType=VARCHAR} ,#{postTime,jdbcType=TIMESTAMP} )
19 |
20 |
21 |
22 |
23 | delete from article where articleId=#{articleId,jdbcType=INTEGER}
24 |
25 |
26 |
27 |
28 | update article set
29 | userId=#{userId,jdbcType=INTEGER} ,
30 | articleTitle=#{articleTitle,jdbcType=VARCHAR} ,
31 | articleUrl=#{articleUrl,jdbcType=VARCHAR}
32 | where articleId=#{articleId,jdbcType=INTEGER}
33 |
34 |
35 |
36 |
39 |
40 |
41 |
44 |
45 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/ArticleDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 | insert into article(articleId,userId,articleTitle,articleUrl,postTime)
17 | values (#{articleId,jdbcType=INTEGER} ,#{userId,jdbcType=INTEGER} ,#{articleTitle,jdbcType=VARCHAR}
18 | ,#{articleUrl,jdbcType=VARCHAR} ,#{postTime,jdbcType=TIMESTAMP} )
19 |
20 |
21 |
22 |
23 | delete from article where articleId=#{articleId,jdbcType=INTEGER}
24 |
25 |
26 |
27 |
28 | update article set
29 | userId=#{userId,jdbcType=INTEGER} ,
30 | articleTitle=#{articleTitle,jdbcType=VARCHAR} ,
31 | articleUrl=#{articleUrl,jdbcType=VARCHAR}
32 | where articleId=#{articleId,jdbcType=INTEGER}
33 |
34 |
35 |
36 |
39 |
40 |
41 |
44 |
45 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/ArticleDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
16 | insert into article(articleId,userId,articleTitle,articleUrl,postTime)
17 | values (#{articleId,jdbcType=INTEGER} ,#{userId,jdbcType=INTEGER} ,#{articleTitle,jdbcType=VARCHAR}
18 | ,#{articleUrl,jdbcType=VARCHAR} ,#{postTime,jdbcType=TIMESTAMP} )
19 |
20 |
21 |
22 |
23 | delete from article where articleId=#{articleId,jdbcType=INTEGER}
24 |
25 |
26 |
27 |
28 | update article set
29 | userId=#{userId,jdbcType=INTEGER} ,
30 | articleTitle=#{articleTitle,jdbcType=VARCHAR} ,
31 | articleUrl=#{articleUrl,jdbcType=VARCHAR}
32 | where articleId=#{articleId,jdbcType=INTEGER}
33 |
34 |
35 |
36 |
39 |
40 |
41 |
44 |
45 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonFormat;
4 |
5 | import java.util.Date;
6 |
7 | /**
8 | * @author Calvin
9 | * @Description:
10 | */
11 | public class User {
12 | /**
13 | * 用户id
14 | */
15 | private Integer userId;
16 | /**
17 | * 用户昵称
18 | */
19 | private String username;
20 | /**
21 | * 注册邮箱
22 | */
23 | private String email;
24 | /**
25 | * 用户密码
26 | */
27 | private String password;
28 | /**
29 | * 用户头像
30 | */
31 | private String headImg;
32 | /**
33 | * 用户个性签名
34 | */
35 | private String signature;
36 | /**
37 | * 用户性别 0--男 1--女
38 | */
39 | private Integer sex;
40 |
41 |
42 | public Integer getUserId() {
43 | return userId;
44 | }
45 |
46 | public void setUserId(Integer userId) {
47 | this.userId = userId;
48 | }
49 |
50 | public String getUsername() {
51 | return username;
52 | }
53 |
54 | public void setUsername(String username) {
55 | this.username = username;
56 | }
57 |
58 | public String getEmail() {
59 | return email;
60 | }
61 |
62 | public void setEmail(String email) {
63 | this.email = email;
64 | }
65 |
66 | public String getPassword() {
67 | return password;
68 | }
69 |
70 | public void setPassword(String password) {
71 | this.password = password;
72 | }
73 |
74 | public String getHeadImg() {
75 | return headImg;
76 | }
77 |
78 | public void setHeadImg(String headImg) {
79 | this.headImg = headImg;
80 | }
81 |
82 | public String getSignature() {
83 | return signature;
84 | }
85 |
86 | public void setSignature(String signature) {
87 | this.signature = signature;
88 | }
89 |
90 | public Integer getSex() {
91 | return sex;
92 | }
93 |
94 | public void setSex(Integer sex) {
95 | this.sex = sex;
96 | }
97 |
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/dao/UserCustomDao.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.dao;
2 |
3 | import com.nuc.calvin.ssm.entity.User;
4 | import com.nuc.calvin.ssm.entity.UserCustom;
5 | import com.nuc.calvin.ssm.entity.UserVo;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @author Calvin
11 | * @Description:
12 | */
13 | public interface UserCustomDao {
14 |
15 | /**
16 | * 用户登录
17 | */
18 | public List loginVerify(UserVo userVo);
19 |
20 | /**
21 | * 根据用户id查询用户信息
22 | *
23 | * @param id
24 | * @return
25 | */
26 | UserCustom queryInfoByUserId(Integer id);
27 |
28 | /**
29 | * 修改用户id为userId的用户信息
30 | */
31 | public void updateByUserId(UserVo userVo);
32 |
33 | /**
34 | * 查询用户分享文章数
35 | */
36 | public int queryArticleCount(int id);
37 |
38 | /**
39 | * 查询用户关注数
40 | */
41 | public int queryFollowCount(Integer userId);
42 |
43 | /**
44 | * 查询用户粉丝数
45 | */
46 | public int queryFansCount(Integer userId);
47 |
48 | /**
49 | * 添加用户
50 | */
51 | public int insertUser(User user);
52 |
53 | /**
54 | * 根据userId查询关注列表
55 | *
56 | * @param userId
57 | * @return
58 | */
59 | public List queryFollowList(Integer userId);
60 |
61 | /**
62 | * 根据userId查询粉丝列表
63 | *
64 | * @param userId
65 | * @return
66 | */
67 | public List queryFansList(Integer userId);
68 |
69 | /**
70 | * 修改密码
71 | *
72 | * @param user
73 | */
74 | public void updatePassword(User user);
75 |
76 | /**
77 | * 模糊查询用户
78 | */
79 | public List queryUserByWord(String keyWord);
80 |
81 | /**
82 | * 获得登录邮箱
83 | *
84 | * @param email
85 | * @return
86 | */
87 | UserCustom getEmail(String email);
88 |
89 | /**
90 | * 查询所有用户
91 | *
92 | * @return
93 | */
94 | List queryAllUser();
95 |
96 | /**
97 | * 查询除userId外的热门用户
98 | * @param userId
99 | * @return
100 | */
101 | List queryUserExSelf(Integer userId);
102 |
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/RelationCustomDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
19 |
20 |
21 |
26 |
27 |
28 |
30 | insert into relation (userId,followId,state)
31 | values (#{userId,jdbcType=INTEGER} ,#{followId,jdbcType=INTEGER} ,#{state,jdbcType=INTEGER} );
32 |
33 |
34 |
35 |
36 | update relation set
37 | state=#{state,jdbcType=INTEGER}
38 | where userId=#{userId,jdbcType=INTEGER} and followId=#{followId,jdbcType=INTEGER}
39 |
40 |
41 |
42 | delete from relation where userId=#{userId,jdbcType=INTEGER} and
43 | followId=#{followId,jdbcType=INTEGER}
44 |
45 |
--------------------------------------------------------------------------------
/target/classes/mapper/RelationCustomDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
19 |
20 |
21 |
26 |
27 |
28 |
30 | insert into relation (userId,followId,state)
31 | values (#{userId,jdbcType=INTEGER} ,#{followId,jdbcType=INTEGER} ,#{state,jdbcType=INTEGER} );
32 |
33 |
34 |
35 |
36 | update relation set
37 | state=#{state,jdbcType=INTEGER}
38 | where userId=#{userId,jdbcType=INTEGER} and followId=#{followId,jdbcType=INTEGER}
39 |
40 |
41 |
42 | delete from relation where userId=#{userId,jdbcType=INTEGER} and
43 | followId=#{followId,jdbcType=INTEGER}
44 |
45 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/RelationCustomDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
19 |
20 |
21 |
26 |
27 |
28 |
30 | insert into relation (userId,followId,state)
31 | values (#{userId,jdbcType=INTEGER} ,#{followId,jdbcType=INTEGER} ,#{state,jdbcType=INTEGER} );
32 |
33 |
34 |
35 |
36 | update relation set
37 | state=#{state,jdbcType=INTEGER}
38 | where userId=#{userId,jdbcType=INTEGER} and followId=#{followId,jdbcType=INTEGER}
39 |
40 |
41 |
42 | delete from relation where userId=#{userId,jdbcType=INTEGER} and
43 | followId=#{followId,jdbcType=INTEGER}
44 |
45 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/dao/ArticleCustomDao.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.dao;
2 |
3 | import com.nuc.calvin.ssm.entity.Article;
4 | import com.nuc.calvin.ssm.entity.ArticleCustom;
5 | import com.nuc.calvin.ssm.entity.ArticleVo;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @author Calvin
11 | * @Description:
12 | */
13 | public interface ArticleCustomDao {
14 | /**
15 | * 通过用户id查询文章
16 | *
17 | * @param userId
18 | * @return
19 | */
20 | List queryArticleByUserId(Integer userId);
21 |
22 | /**
23 | * 根据文章id查询文章
24 | *
25 | * @param articleId
26 | * @return
27 | */
28 | List queryArticleByArticleId(Integer articleId);
29 |
30 | /**
31 | * 分享文章
32 | * @param articleCustom
33 | */
34 | void postArticle(ArticleCustom articleCustom);
35 |
36 | /**
37 | * 根据文章id删除文章
38 | *
39 | * @param articleId
40 | */
41 | void deleteByArticleId(Integer articleId);
42 |
43 | /**
44 | * 查询赞的次数
45 | *
46 | * @param articleId
47 | * @return
48 | */
49 | int queryLikeCount(Integer articleId);
50 |
51 | /**
52 | * 查询评论次数
53 | *
54 | * @param articleId
55 | * @return
56 | */
57 | int queryCommentCount(Integer articleId);
58 |
59 | /**
60 | * 查询被收藏次数
61 | * @param articleId
62 | * @return
63 | */
64 | int queryCollectCount(Integer articleId);
65 |
66 |
67 |
68 | /**
69 | * 根据用户id查询被订阅的文章
70 | *
71 | * @param userId
72 | * @return
73 | */
74 | List queryCollectArticle(Integer userId);
75 |
76 | /**
77 | * 根据关键字搜索文章
78 | *
79 | * @param keyWord
80 | * @return
81 | */
82 | List queryArticleByWord(String keyWord);
83 |
84 | /**
85 | * 查询回复次数
86 | *
87 | * @param articleId
88 | * @return
89 | */
90 | int queryReplyCount(Integer articleId);
91 |
92 | /**
93 | * 查询所有文章
94 | * @return
95 | */
96 | List queryAllArticle();
97 |
98 | /**
99 | * 查询热门文章
100 | * @return
101 | */
102 | List queryHotArticle();
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.service;
2 |
3 | import com.nuc.calvin.ssm.entity.User;
4 | import com.nuc.calvin.ssm.entity.UserCustom;
5 | import com.nuc.calvin.ssm.entity.UserVo;
6 | import org.springframework.transaction.annotation.Transactional;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * @author Calvin
12 | * @Description:
13 | */
14 | public interface UserService {
15 | /**
16 | * 用户登录
17 | *
18 | * @param userVo
19 | * @return
20 | */
21 | List doUserLogin(UserVo userVo);
22 |
23 | /**
24 | * 根据用户id查询用户所有信息
25 | *
26 | * @param id
27 | * @return
28 | */
29 | UserCustom queryInfoByUserId(Integer id);
30 |
31 | /**
32 | * 修改用户信息
33 | *
34 | * @param userVo
35 | */
36 | void updateUserInfo(UserVo userVo);
37 |
38 | /**
39 | * 根据用户id查询用户所有的文章数量
40 | *
41 | * @param userId
42 | * @return
43 | */
44 | int queryArticleCount(Integer userId);
45 |
46 | /**
47 | * 根据用户id查询用户的关注数
48 | *
49 | * @param userId
50 | * @return
51 | */
52 | int queryFollowCount(Integer userId);
53 |
54 | /**
55 | * 根据用户id查询用户的粉丝数
56 | *
57 | * @param userId
58 | * @return
59 | */
60 | int queryFansCount(Integer userId);
61 |
62 |
63 | /**
64 | * 注册用户
65 | *
66 | * @param user
67 | */
68 | void singUpUser(User user);
69 |
70 | /**
71 | * 根据用户id查询关注列表
72 | *
73 | * @param userId
74 | * @return
75 | */
76 | List queryFollowList(Integer userId);
77 |
78 | /**
79 | * 根据用户id查询粉丝列表
80 | *
81 | * @param userId
82 | * @return
83 | */
84 | List queryFansList(Integer userId);
85 |
86 | /**
87 | * 修改密码
88 | *
89 | * @param user
90 | */
91 | void updatePassword(User user);
92 |
93 | /**
94 | * 模糊查询用户
95 | *
96 | * @param keyWord
97 | * @return
98 | */
99 | List queryUserByWord(String keyWord);
100 |
101 | UserCustom getEmail(String email);
102 |
103 | List queryAllUser();
104 |
105 | List queryUserExSelf(Integer userId);
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/entity/ArticleCustom.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.entity;
2 |
3 | /**
4 | * @author Calvin
5 | * @Description:
6 | */
7 | public class ArticleCustom extends Article {
8 | /**
9 | * 扩展user
10 | */
11 | private User user;
12 | /**
13 | * 广告文章
14 | */
15 | private ArticleCustom bannerArticle;
16 | /**
17 | * 是否广告 1-是 0-否
18 | */
19 | private int isAdvertorial;
20 |
21 | /**
22 | * 赞 0-否 1-是
23 | */
24 | private int likes;
25 | /**
26 | * 收藏 0-否 1-是
27 | */
28 | private int collect;
29 | /**
30 | * 被评论次数
31 | */
32 | private int commentCount;
33 | /**
34 | * 被点赞数
35 | */
36 | private int likeCount;
37 |
38 | private int collectCount;
39 |
40 |
41 | public int getCollectCount() {
42 | return collectCount;
43 | }
44 |
45 | public void setCollectCount(int collectCount) {
46 | this.collectCount = collectCount;
47 | }
48 |
49 | public User getUser() {
50 | return user;
51 | }
52 |
53 | public void setUser(User user) {
54 | this.user = user;
55 | }
56 |
57 | public ArticleCustom getBannerArticle() {
58 | return bannerArticle;
59 | }
60 |
61 | public void setBannerArticle(ArticleCustom bannerArticle) {
62 | this.bannerArticle = bannerArticle;
63 | }
64 |
65 | public int getIsAdvertorial() {
66 | return isAdvertorial;
67 | }
68 |
69 | public void setIsAdvertorial(int isAdvertorial) {
70 | this.isAdvertorial = isAdvertorial;
71 | }
72 |
73 | public int getLikes() {
74 | return likes;
75 | }
76 |
77 | public void setLikes(int likes) {
78 | this.likes = likes;
79 | }
80 |
81 | public int getCollect() {
82 | return collect;
83 | }
84 |
85 | public void setCollect(int collect) {
86 | this.collect = collect;
87 | }
88 |
89 | public int getCommentCount() {
90 | return commentCount;
91 | }
92 |
93 | public void setCommentCount(int commentCount) {
94 | this.commentCount = commentCount;
95 | }
96 |
97 | public int getLikeCount() {
98 | return likeCount;
99 | }
100 |
101 | public void setLikeCount(int likeCount) {
102 | this.likeCount = likeCount;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/web/RelationController.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.web;
2 |
3 | import com.nuc.calvin.ssm.entity.Relation;
4 | import com.nuc.calvin.ssm.entity.UserCustom;
5 | import com.nuc.calvin.ssm.service.RelationService;
6 | import com.nuc.calvin.ssm.service.UserService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Controller;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.ResponseBody;
11 |
12 | import javax.servlet.http.HttpServletRequest;
13 | import java.util.List;
14 |
15 | /**
16 | * @author Calvin
17 | * @Description:
18 | */
19 | @Controller("relationController")
20 | @RequestMapping("/relation")
21 | public class RelationController {
22 |
23 | @Autowired
24 | private RelationService relationService;
25 |
26 | @Autowired
27 | private UserService userService;
28 |
29 | /**
30 | * 关注 flag=1 为陌生 flag=2为对方已关注自己
31 | *
32 | * @param request
33 | */
34 | @ResponseBody
35 | @RequestMapping("/follow")
36 | public void follow(HttpServletRequest request) {
37 | Integer userId = Integer.valueOf(request.getParameter("userId"));
38 | Integer myId = Integer.valueOf(request.getParameter("myId"));
39 | int flag = Integer.parseInt(request.getParameter("flag"));
40 | Relation relation = new Relation();
41 | relation.setUserId(myId);
42 | relation.setFollowId(userId);
43 | relationService.follow(relation, flag);
44 | }
45 |
46 | @ResponseBody
47 | @RequestMapping("/unFollow")
48 | public void unFollow(HttpServletRequest request) {
49 | int flagId = Integer.parseInt(request.getParameter("flag"));
50 | Integer user_id = Integer.valueOf(request.getParameter("userId"));
51 | Integer my_id = Integer.valueOf(request.getParameter("myId"));
52 | Relation relation = new Relation();
53 | relation.setUserId(my_id);
54 | relation.setFollowId(user_id);
55 | relationService.unFollow(relation, flagId);
56 | }
57 |
58 |
59 | @ResponseBody
60 | @RequestMapping("/listFollow")
61 | public List listFollow(HttpServletRequest request) {
62 | Integer userId = Integer.valueOf(request.getParameter("userId"));
63 | List followlist = userService.queryFollowList(userId);
64 | return followlist;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/target/classes/spring/spring-dao.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/main/resources/spring/spring-dao.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/spring/spring-dao.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/target/classes/mapper/UserDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
25 |
26 |
27 |
28 | delete from user where userId =#{userId,jdbcType=INTEGER}
29 |
30 |
31 |
32 |
33 | update user
34 |
35 | username=#{username,jdbcType=VARCHAR}
36 | email=#{email,jdbcType=VARCHAR}
37 | email=#{password,jdbcType=VARCHAR}
38 | signature=#{signature,jdbcType=VARCHAR}
39 | headImg=#{headImg,jdbcType=VARCHAR}
40 | sex=#{sex,jdbcType=INTEGER}
41 |
42 | where userId=#{userId,jdbcType=INTEGER}
43 |
44 |
45 |
46 |
48 | insert into user(username,email,password)
49 | values (#{username,jdbcType=VARCHAR} ,#{email,jdbcType=VARCHAR} ,#{password,jdbcType=VARCHAR})
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/main/resources/mapper/UserDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
25 |
26 |
27 |
28 | delete from user where userId =#{userId,jdbcType=INTEGER}
29 |
30 |
31 |
32 |
33 | update user
34 |
35 | username=#{username,jdbcType=VARCHAR}
36 | email=#{email,jdbcType=VARCHAR}
37 | email=#{password,jdbcType=VARCHAR}
38 | signature=#{signature,jdbcType=VARCHAR}
39 | headImg=#{headImg,jdbcType=VARCHAR}
40 | sex=#{sex,jdbcType=INTEGER}
41 |
42 | where userId=#{userId,jdbcType=INTEGER}
43 |
44 |
45 |
46 |
48 | insert into user(username,email,password)
49 | values (#{username,jdbcType=VARCHAR} ,#{email,jdbcType=VARCHAR} ,#{password,jdbcType=VARCHAR})
50 |
51 |
52 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/classes/mapper/UserDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
25 |
26 |
27 |
28 | delete from user where userId =#{userId,jdbcType=INTEGER}
29 |
30 |
31 |
32 |
33 | update user
34 |
35 | username=#{username,jdbcType=VARCHAR}
36 | email=#{email,jdbcType=VARCHAR}
37 | email=#{password,jdbcType=VARCHAR}
38 | signature=#{signature,jdbcType=VARCHAR}
39 | headImg=#{headImg,jdbcType=VARCHAR}
40 | sex=#{sex,jdbcType=INTEGER}
41 |
42 | where userId=#{userId,jdbcType=INTEGER}
43 |
44 |
45 |
46 |
48 | insert into user(username,email,password)
49 | values (#{username,jdbcType=VARCHAR} ,#{email,jdbcType=VARCHAR} ,#{password,jdbcType=VARCHAR})
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/main/webapp/WEB-INF/jsp/article.jsp:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2 |
3 |
4 |
5 | 首页
6 |
7 |
8 |
9 |
10 |
11 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
12 | <%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
13 |
14 |
15 |
16 | 欢迎使用IT头条信息管理系统
17 |
18 |
19 |
20 |
21 |
25 |
26 |
27 |
28 |
29 | 文章信息管理
30 |
31 |
32 | | 文章id |
33 | 作者id |
34 | 文章标题 |
35 | 文章url |
36 | 被评论次数 |
37 | 被点赞次数 |
38 | 操作 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 |
53 | 删除
54 | 更改
55 | |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/jsp/article.jsp:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2 |
3 |
4 |
5 | 首页
6 |
7 |
8 |
9 |
10 |
11 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
12 | <%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
13 |
14 |
15 |
16 | 欢迎使用IT头条信息管理系统
17 |
18 |
19 |
20 |
21 |
25 |
26 |
27 |
28 |
29 | 文章信息管理
30 |
31 |
32 | | 文章id |
33 | 作者id |
34 | 文章标题 |
35 | 文章url |
36 | 被评论次数 |
37 | 被点赞次数 |
38 | 操作 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 |
53 | 删除
54 | 更改
55 | |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/web/CollectController.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.web;
2 |
3 | import com.nuc.calvin.ssm.entity.ArticleCustom;
4 | import com.nuc.calvin.ssm.entity.CollectCustom;
5 | import com.nuc.calvin.ssm.service.ArticleService;
6 | import com.nuc.calvin.ssm.service.CollectService;
7 | import com.nuc.calvin.ssm.utils.DateConvert;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Controller;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.ResponseBody;
12 |
13 | import javax.servlet.http.HttpServletRequest;
14 | import java.util.ArrayList;
15 | import java.util.Date;
16 | import java.util.List;
17 |
18 | /**
19 | * @author Calvin
20 | * @Description:
21 | */
22 | @Controller("collectController")
23 | @RequestMapping("/collection")
24 | public class CollectController {
25 |
26 | @Autowired
27 | private CollectService collectService;
28 |
29 | @Autowired
30 | private ArticleService articleService;
31 |
32 | @ResponseBody
33 | @RequestMapping("/collect")
34 | public void collect(HttpServletRequest request) {
35 | Integer articleId = Integer.valueOf(request.getParameter("articleId"));
36 | Integer userId = Integer.valueOf(request.getParameter("userId"));
37 | CollectCustom collection = new CollectCustom();
38 | collection.setUserId(userId);
39 | collection.setArticleId(articleId);
40 |
41 | Date time = new java.sql.Date(new java.util.Date().getTime());
42 | collection.setCollectTime(time);
43 | collectService.collect(collection);
44 | }
45 |
46 | @ResponseBody
47 | @RequestMapping("/unCollect")
48 | public void unCollect(HttpServletRequest request) {
49 | Integer articleId = Integer.valueOf(request.getParameter("articleId"));
50 | Integer userId = Integer.parseInt(request.getParameter("userId"));
51 | CollectCustom collectCustom = new CollectCustom();
52 | collectCustom.setUserId(userId);
53 | collectCustom.setArticleId(articleId);
54 | collectService.unCollect(collectCustom);
55 | }
56 |
57 | @ResponseBody
58 | @RequestMapping("/queryAllCollection")
59 | public List queryAllCollection(HttpServletRequest request) {
60 | Integer userId = Integer.valueOf(request.getParameter("userId"));
61 | List list = collectService.queryMyCollection(userId);
62 | for (CollectCustom collectCustom : list) {
63 | collectCustom.setDate(DateConvert.convert2json(collectCustom.getCollectTime().getTime()));
64 | }
65 | return list;
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/com/nuc/calvin/ssm/service/impl/LikesServiveImp.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.ssm.service.impl;
2 |
3 | import ch.qos.logback.classic.pattern.DateConverter;
4 | import com.nuc.calvin.ssm.dao.LikesCustomDao;
5 | import com.nuc.calvin.ssm.entity.LikesCustom;
6 | import com.nuc.calvin.ssm.service.LikesService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 | import org.springframework.transaction.annotation.Transactional;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Date;
13 | import java.util.List;
14 |
15 | /**
16 | * @author Calvin
17 | * @Description:
18 | */
19 | @Transactional(rollbackFor = Exception.class)
20 | @Service("likesService")
21 | public class LikesServiveImp implements LikesService {
22 |
23 | @Autowired
24 | private LikesCustomDao likesCustomDao;
25 | /**
26 | * date格式化工具
27 | */
28 | private DateConverter dateConverter;
29 |
30 | /**
31 | * 赞
32 | *
33 | * @param articleId
34 | * @param userId
35 | */
36 | @Override
37 | public void like(Integer articleId, Integer userId) {
38 | LikesCustom likes = new LikesCustom();
39 | likes.setUserId(userId);
40 | likes.setArticleId(articleId);
41 | Date likeTime = new Date();
42 | likes.setLikeTime(likeTime);
43 | likesCustomDao.like(likes);
44 | }
45 |
46 | /**
47 | * 取消赞
48 | *
49 | * @param articleId
50 | * @param userId
51 | */
52 | @Override
53 | public void unLike(Integer articleId, Integer userId) {
54 | LikesCustom likes = new LikesCustom();
55 | likes.setUserId(userId);
56 | likes.setArticleId(articleId);
57 | likesCustomDao.unLike(likes);
58 | }
59 |
60 | /**
61 | * 是否赞
62 | *
63 | * @param userId
64 | * @param articleId
65 | * @return
66 | */
67 | @Override
68 | public int isLike(Integer userId, Integer articleId) {
69 | LikesCustom likes = new LikesCustom();
70 | likes.setUserId(userId);
71 | likes.setArticleId(articleId);
72 | List likesList = likesCustomDao.queryIsLike(likes);
73 | if (likesList.size() != 0) {
74 | /**
75 | * 存在记录,点赞
76 | */
77 | return 1;
78 | } else {
79 | /**
80 | * 无记录
81 | */
82 | return 0;
83 | }
84 | }
85 |
86 | /**
87 | * 查询用户被赞过信息
88 | *
89 | * @param userId
90 | * @return
91 | */
92 | @Override
93 | public List queryLikesByUserId(Integer userId) {
94 | List likesCustomList = likesCustomDao.queryLikesByUserId(userId);
95 | return likesCustomList;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/main/webapp/WEB-INF/jsp/main.jsp:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2 |
3 |
4 |
5 | 首页
6 |
7 |
8 |
9 |
10 |
11 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
12 | <%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
13 |
14 |
15 |
16 | 欢迎使用IT头条信息管理系统
17 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
30 | 用户信息管理
31 |
32 |
33 | | 用户id |
34 | 用户名 |
35 | 邮箱 |
36 | 密码 |
37 | 个性签名 |
38 | 性别 |
39 | 文章数 |
40 | 关注数 |
41 | 粉丝数 |
42 | 操作 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 |
60 | 删除
61 | 更改
62 | |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/target/headline/WEB-INF/jsp/main.jsp:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
2 |
3 |
4 |
5 | 首页
6 |
7 |
8 |
9 |
10 |
11 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
12 | <%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
13 |
14 |
15 |
16 | 欢迎使用IT头条信息管理系统
17 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
30 | 用户信息管理
31 |
32 |
33 | | 用户id |
34 | 用户名 |
35 | 邮箱 |
36 | 密码 |
37 | 个性签名 |
38 | 性别 |
39 | 文章数 |
40 | 关注数 |
41 | 粉丝数 |
42 | 操作 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 |
60 | 删除
61 | 更改
62 | |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------