├── .gitignore ├── src └── main │ ├── webapp │ ├── static │ │ ├── layui │ │ │ ├── css │ │ │ │ ├── st-style.css │ │ │ │ └── modules │ │ │ │ │ ├── layer │ │ │ │ │ └── default │ │ │ │ │ │ ├── icon.png │ │ │ │ │ │ ├── icon-ext.png │ │ │ │ │ │ ├── loading-0.gif │ │ │ │ │ │ ├── loading-1.gif │ │ │ │ │ │ └── loading-2.gif │ │ │ │ │ └── code.css │ │ │ ├── font │ │ │ │ ├── iconfont.eot │ │ │ │ ├── iconfont.ttf │ │ │ │ ├── iconfont.woff │ │ │ │ └── iconfont.woff2 │ │ │ ├── images │ │ │ │ └── face │ │ │ │ │ ├── 0.gif │ │ │ │ │ ├── 1.gif │ │ │ │ │ ├── 10.gif │ │ │ │ │ ├── 11.gif │ │ │ │ │ ├── 12.gif │ │ │ │ │ ├── 13.gif │ │ │ │ │ ├── 14.gif │ │ │ │ │ ├── 15.gif │ │ │ │ │ ├── 16.gif │ │ │ │ │ ├── 17.gif │ │ │ │ │ ├── 18.gif │ │ │ │ │ ├── 19.gif │ │ │ │ │ ├── 2.gif │ │ │ │ │ ├── 20.gif │ │ │ │ │ ├── 21.gif │ │ │ │ │ ├── 22.gif │ │ │ │ │ ├── 23.gif │ │ │ │ │ ├── 24.gif │ │ │ │ │ ├── 25.gif │ │ │ │ │ ├── 26.gif │ │ │ │ │ ├── 27.gif │ │ │ │ │ ├── 28.gif │ │ │ │ │ ├── 29.gif │ │ │ │ │ ├── 3.gif │ │ │ │ │ ├── 30.gif │ │ │ │ │ ├── 31.gif │ │ │ │ │ ├── 32.gif │ │ │ │ │ ├── 33.gif │ │ │ │ │ ├── 34.gif │ │ │ │ │ ├── 35.gif │ │ │ │ │ ├── 36.gif │ │ │ │ │ ├── 37.gif │ │ │ │ │ ├── 38.gif │ │ │ │ │ ├── 39.gif │ │ │ │ │ ├── 4.gif │ │ │ │ │ ├── 40.gif │ │ │ │ │ ├── 41.gif │ │ │ │ │ ├── 42.gif │ │ │ │ │ ├── 43.gif │ │ │ │ │ ├── 44.gif │ │ │ │ │ ├── 45.gif │ │ │ │ │ ├── 46.gif │ │ │ │ │ ├── 47.gif │ │ │ │ │ ├── 48.gif │ │ │ │ │ ├── 49.gif │ │ │ │ │ ├── 5.gif │ │ │ │ │ ├── 50.gif │ │ │ │ │ ├── 51.gif │ │ │ │ │ ├── 52.gif │ │ │ │ │ ├── 53.gif │ │ │ │ │ ├── 54.gif │ │ │ │ │ ├── 55.gif │ │ │ │ │ ├── 56.gif │ │ │ │ │ ├── 57.gif │ │ │ │ │ ├── 58.gif │ │ │ │ │ ├── 59.gif │ │ │ │ │ ├── 6.gif │ │ │ │ │ ├── 60.gif │ │ │ │ │ ├── 61.gif │ │ │ │ │ ├── 62.gif │ │ │ │ │ ├── 63.gif │ │ │ │ │ ├── 64.gif │ │ │ │ │ ├── 65.gif │ │ │ │ │ ├── 66.gif │ │ │ │ │ ├── 67.gif │ │ │ │ │ ├── 68.gif │ │ │ │ │ ├── 69.gif │ │ │ │ │ ├── 7.gif │ │ │ │ │ ├── 70.gif │ │ │ │ │ ├── 71.gif │ │ │ │ │ ├── 8.gif │ │ │ │ │ └── 9.gif │ │ │ ├── lay │ │ │ │ └── modules │ │ │ │ │ ├── code.js │ │ │ │ │ ├── laytpl.js │ │ │ │ │ ├── flow.js │ │ │ │ │ ├── rate.js │ │ │ │ │ ├── util.js │ │ │ │ │ ├── carousel.js │ │ │ │ │ ├── laypage.js │ │ │ │ │ ├── transfer.js │ │ │ │ │ └── slider.js │ │ │ └── layui.js │ │ └── image │ │ │ ├── album-banner.png │ │ │ └── photo_default.jpg │ └── WEB-INF │ │ ├── applicationContext.xml │ │ ├── view │ │ ├── permission_denied.jsp │ │ ├── admin_operations.jsp │ │ ├── my_left_bar.jsp │ │ ├── my_statistics.jsp │ │ ├── header.jsp │ │ ├── send_message.jsp │ │ ├── my_messages.jsp │ │ ├── my_follow.jsp │ │ ├── photo_upload.jsp │ │ ├── album_create.jsp │ │ ├── album_edit.jsp │ │ ├── album_list.jsp │ │ ├── my_albums.jsp │ │ ├── admin_manage_users.jsp │ │ └── my_info.jsp │ │ ├── classes │ │ └── c3p0-config.xml │ │ ├── dispatcher-servlet.xml │ │ └── web.xml │ └── java │ ├── util │ ├── Test.java │ ├── ImageHelper.java │ ├── DateHelper.java │ └── ShortUUID.java │ ├── dao │ ├── MessageDAO.java │ ├── OperationDAO.java │ ├── PhotoDAO.java │ ├── FollowDAO.java │ ├── C3P0Utils.java │ ├── CommentDAO.java │ ├── JDBCDAO.java │ ├── UserDAO.java │ └── AlbumDAO.java │ ├── server │ ├── PhotoServer.java │ ├── MessageServer.java │ ├── OperationServer.java │ ├── FollowServer.java │ ├── CommentServer.java │ └── UserServer.java │ ├── entity │ └── DataResult.java │ ├── controller │ ├── MessageController.java │ ├── FollowController.java │ ├── UserHomeController.java │ ├── ImageController.java │ ├── IndexController.java │ ├── AdminController.java │ ├── MeController.java │ └── AlbumController.java │ ├── model │ ├── Comment.java │ ├── Photo.java │ ├── Statistics.java │ ├── Message.java │ ├── Operation.java │ ├── User.java │ └── Album.java │ └── constant │ └── Constant.java ├── screenshoots ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── 9.png ├── 10.png ├── 11.png ├── 12.png ├── 13.png └── 14.png └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | target 3 | *.iml -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/st-style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /screenshoots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/1.png -------------------------------------------------------------------------------- /screenshoots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/2.png -------------------------------------------------------------------------------- /screenshoots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/3.png -------------------------------------------------------------------------------- /screenshoots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/4.png -------------------------------------------------------------------------------- /screenshoots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/5.png -------------------------------------------------------------------------------- /screenshoots/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/6.png -------------------------------------------------------------------------------- /screenshoots/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/7.png -------------------------------------------------------------------------------- /screenshoots/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/8.png -------------------------------------------------------------------------------- /screenshoots/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/9.png -------------------------------------------------------------------------------- /screenshoots/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/10.png -------------------------------------------------------------------------------- /screenshoots/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/11.png -------------------------------------------------------------------------------- /screenshoots/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/12.png -------------------------------------------------------------------------------- /screenshoots/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/13.png -------------------------------------------------------------------------------- /screenshoots/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/screenshoots/14.png -------------------------------------------------------------------------------- /src/main/webapp/static/image/album-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/image/album-banner.png -------------------------------------------------------------------------------- /src/main/webapp/static/image/photo_default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/image/photo_default.jpg -------------------------------------------------------------------------------- /src/main/webapp/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /src/main/webapp/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /src/main/webapp/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /src/main/webapp/static/layui/font/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/font/iconfont.woff2 -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /src/main/java/util/Test.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | public class Test { 4 | public static void dosome(){ 5 | System.out.println("xx"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxc19990331/SpringWebAlbum/HEAD/src/main/webapp/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/util/ImageHelper.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import constant.Constant; 4 | 5 | public class ImageHelper { 6 | public static String getFilePath(String url){ 7 | return Constant.IMAGE_PATH + "\\" + url; 8 | } 9 | 10 | public static String getAvatarPath(String id){ 11 | return Constant.IMAGE_PATH + "\\avatar\\" + id + ".jpg"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/permission_denied.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2020/1/12 5 | Time: 13:39 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 权限不足 12 | 13 | 14 |
15 | 权限不足! 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main/java/util/DateHelper.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | public class DateHelper { 7 | public static String getCurrentDate(){ 8 | SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 9 | return dateFormat.format(new Date()); 10 | } 11 | 12 | public static String getCurrentDateStr(){ 13 | SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); 14 | return dateFormat.format(new Date()); 15 | } 16 | 17 | public static String dateToString(){ 18 | return null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/classes/c3p0-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.microsoft.sqlserver.jdbc.SQLServerDriver 5 | jdbc:sqlserver://localhost:1433;DatabaseName=web_album 6 | sa 7 | 123456 8 | 10 9 | 30 10 | 100 11 | 10 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/java/dao/MessageDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | /** 4 | * Created by hi on 2019/12/30. 5 | */ 6 | import constant.Constant; 7 | import util.DateHelper; 8 | import util.ShortUUID; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class MessageDAO { 13 | public static List> getMessageBytoId(String toId){ 14 | return JDBCDAO.select(String.format("SELECT * FROM message WHERE to_id = '%s'",toId)); 15 | } 16 | public static List> getMessageByfromId(String fromId){ 17 | return JDBCDAO.select(String.format("SELECT * FROM message WHERE from_id = '%s'",fromId)); 18 | } 19 | public static void addNewMessage(String fromId,String toId,String context){ 20 | String messageId = ShortUUID.generateShortUuid(); 21 | JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO message VALUES('%s','%s','%s','%s','%s','%s')", 22 | messageId,fromId,toId,context,DateHelper.getCurrentDate()," ")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/util/ShortUUID.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.util.UUID; 4 | 5 | public class ShortUUID { 6 | 7 | public static String[] chars = new String[]{"a", "b", "c", "d", "e", "f", 8 | "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", 9 | "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", 10 | "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", 11 | "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", 12 | "W", "X", "Y", "Z"}; 13 | 14 | 15 | public static String generateShortUuid() { 16 | StringBuffer shortBuffer = new StringBuffer(); 17 | String uuid = UUID.randomUUID().toString().replace("-", ""); 18 | for (int i = 0; i < 8; i++) { 19 | String str = uuid.substring(i * 4, i * 4 + 4); 20 | int x = Integer.parseInt(str, 16); 21 | shortBuffer.append(chars[x % 0x3E]); 22 | } 23 | return shortBuffer.toString(); 24 | } 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/dao/OperationDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import constant.Constant; 4 | import util.DateHelper; 5 | import util.ShortUUID; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class OperationDAO { 11 | 12 | public static boolean addOp(String from_id,String to_id,String op,String note){ 13 | String id = ShortUUID.generateShortUuid(); 14 | String date = DateHelper.getCurrentDate(); 15 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO operation VALUES('%s','%s','%s','%s','%s','%s')", 16 | id,from_id,to_id,op,note,date)); 17 | } 18 | 19 | public static List> getOperationList(int page,int limit){ 20 | int pre = (page-1)*limit; 21 | return JDBCDAO.select(String.format("SELECT TOP %d * FROM operation WHERE id NOT IN (SELECT TOP %d id FROM operation)",limit,pre)); 22 | } 23 | 24 | public static boolean addBanUserOp(String from_id,String to_id,String note){ 25 | return addOp(from_id,to_id, Constant.BAN_USR,note); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/server/PhotoServer.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | import dao.PhotoDAO; 4 | import entity.DataResult; 5 | 6 | public class PhotoServer { 7 | public static DataResult delPhotoStore(String albumId,String photoId){ 8 | boolean res = PhotoDAO.delPhotoFromAlbum(albumId,photoId); 9 | if(res){ 10 | return DataResult.success("del photo store success",null); 11 | }else{ 12 | return DataResult.fail("del photo store fail"); 13 | } 14 | } 15 | 16 | public static DataResult delPhoto(String photoId){ 17 | boolean res = PhotoDAO.delPhoto(photoId); 18 | if(res){ 19 | return DataResult.success("del photo success",null); 20 | }else{ 21 | return DataResult.fail("del photo fail"); 22 | } 23 | } 24 | 25 | public static DataResult changePhotoName(String name,String photoId){ 26 | boolean res = PhotoDAO.changePhotoName(name,photoId); 27 | return res?DataResult.success("change name success",null):DataResult.fail("change name fail"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /src/main/java/entity/DataResult.java: -------------------------------------------------------------------------------- 1 | package entity; 2 | 3 | public class DataResult { 4 | private int status; 5 | private String msg = ""; 6 | private Object data; 7 | 8 | public int getStatus() { 9 | return status; 10 | } 11 | 12 | public void setStatus(int status) { 13 | this.status = status; 14 | } 15 | 16 | public String getMsg() { 17 | return msg; 18 | } 19 | 20 | public void setMsg(String msg) { 21 | this.msg = msg; 22 | } 23 | 24 | public Object getData() { 25 | return data; 26 | } 27 | 28 | public void setData(Object data) { 29 | this.data = data; 30 | } 31 | 32 | public static DataResult fail(String msg){ 33 | DataResult dataResult = new DataResult(); 34 | dataResult.setMsg(msg); 35 | dataResult.setStatus(-1); 36 | return dataResult; 37 | } 38 | 39 | public static DataResult success(String msg,Object data){ 40 | DataResult dataResult = new DataResult(); 41 | dataResult.setMsg(msg); 42 | dataResult.setData(data); 43 | dataResult.setStatus(0); 44 | return dataResult; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpringWebAlbum 2 | ## 技术框架 3 | SpringMVC+jsp,前端使用layui框架,数据库使用SQLServer,如果真的有人想要运行(大概是未来同样要做软工作业的学弟学妹吧……),可以私信524918010@qq.com,我可以把用的数据库发你。 4 | 5 | ## 部分页面展示 6 | ![登入页面](screenshoots/1.png) 7 | 登入页面,~~从清新的观感出发,采用了扁平设计和绿色的主色调……~~ 为了跟layui的默认风格保持一致,采用了绿色和纯色为主色调。 8 | ![主页](screenshoots/2.png) 9 | 主页界面,~~抄袭~~ 借鉴了站酷网的主页设计(包括不知道放啥的广告牌banner)。每一个卡片都代表了一个相册,相册中存储多张照片。 10 | ![导航栏](screenshoots/3.png) 11 | 导航栏,layui中的组件。 12 | ![在这里插入图片描述](screenshoots/4.png) 13 | ![在这里插入图片描述](screenshoots/5.png) 14 | 相册内容和评论功能,继续~~抄袭~~ 借鉴了站酷网以及各类新闻网站的设计,或者说基本都差不多吧,总不能文艺复兴做成QQ相册那种样子……自己可以删除自己的评论。 15 | ![个人主页](screenshoots/6.png) 16 | 个人主页,可以在这个界面上划过鼠标删除编辑相册,也可以到后台操作。 17 | ![上传图片](screenshoots/7.png) 18 | 上传图片,用的layui中一个组件,不过因为懒(毕竟要在考试周答辩)没有做撤销上传,选错图片就要刷新重新上传…… 19 | ![管理员后台](screenshoots/8.png) 20 | 管理员后台界面,比普通用户多了下面几栏功能,其他的管理自己的相册照片等都一样,可以删除、编辑、设置封面之类的。 21 | ![图片预览](screenshoots/9.png) 22 | 点击可以预览图片。 23 | ![图片预览](screenshoots/10.png) 24 | 私信界面,是很简单的数据库读表,没有websocket之类的。 25 | ![个人资料](screenshoots/11.png) 26 | ![个人资料](screenshoots/12.png) 27 | 个人信息,可以设置一些个人资料和头像。 28 | ![管理员后台](screenshoots/13.png) 29 | ![管理员后台](screenshoots/14.png) 30 | 管理员后台界面,在我们的设计方案里,管理员可以封禁解禁用户和相册,但需要附封禁理由,会记录入库。 31 | -------------------------------------------------------------------------------- /src/main/java/dao/PhotoDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import util.DateHelper; 4 | import util.ShortUUID; 5 | 6 | public class PhotoDAO { 7 | public static String uploadPhoto(String name,String url){ 8 | String id = ShortUUID.generateShortUuid(); 9 | boolean res = JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO photo VALUES('%s','%s','%s','%s',%s)", 10 | id,name, DateHelper.getCurrentDate(),url,'0')); 11 | if(res){ 12 | return id; 13 | }else{ 14 | return null; 15 | } 16 | } 17 | 18 | //仅删除store 19 | public static boolean delPhotoFromAlbum(String albumId,String photoId){ 20 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("DELETE store WHERE photo_id = '%s'AND album_id = '%s'",photoId,albumId)); 21 | } 22 | 23 | //删除photo和store 24 | public static boolean delPhoto(String photoId){ 25 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("DELETE photo WHERE id = '%s'",photoId)); 26 | } 27 | 28 | //更改照片名称 29 | public static boolean changePhotoName(String name,String photoId){ 30 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE photo SET name = '%s' WHERE id = '%s'",name,photoId)); 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/controller/MessageController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import dao.MessageDAO; 4 | import entity.DataResult; 5 | import model.User; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | import server.MessageServer; 13 | 14 | import javax.servlet.http.HttpSession; 15 | 16 | /** 17 | * Created by hi on 2019/12/30. 18 | */ 19 | @Controller 20 | public class MessageController { 21 | @RequestMapping("/sendMessage") 22 | public String goToSendMessage(@RequestParam("id")String toId, Model model){ 23 | model.addAttribute("toId",toId); 24 | return "send_message"; 25 | } 26 | @RequestMapping(value="/sendmessageS",method = RequestMethod.POST) 27 | @ResponseBody 28 | public DataResult sendmessageS(@RequestParam("context")String context, @RequestParam("toId")String toId, HttpSession session){ 29 | System.out.print("发送内容:"+context); 30 | String fromId=((User)session.getAttribute("myInfo")).getId(); 31 | return MessageServer.sendMessage(fromId,toId,context); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/controller/FollowController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import entity.DataResult; 4 | import model.User; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import server.FollowServer; 10 | 11 | import javax.servlet.http.HttpSession; 12 | 13 | @Controller 14 | public class FollowController { 15 | @RequestMapping("/delfow") 16 | @ResponseBody 17 | public DataResult delMyFollows(@RequestParam("TID")String tId,HttpSession session){ 18 | System.out.println("DelFollow"); 19 | User user= (User) session.getAttribute("myInfo"); 20 | DataResult dataResult = FollowServer.deleteFollow(user.getId(),tId); 21 | System.out.println(dataResult.getStatus()); 22 | return dataResult; 23 | } 24 | 25 | @RequestMapping("/addfow") 26 | @ResponseBody 27 | public DataResult addMyFollows(@RequestParam("TID")String tId, HttpSession session){ 28 | User user= (User) session.getAttribute("myInfo"); 29 | System.out.println("AddFollow" + user.getId() + " " + tId); 30 | DataResult dataResult = FollowServer.addFollow(user.getId(),tId); 31 | System.out.println(dataResult.getMsg()); 32 | return dataResult; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/dao/FollowDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import constant.Constant; 4 | import util.DateHelper; 5 | import util.ShortUUID; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class FollowDAO { 11 | 12 | public static List> getFollowInfoListById(String fromId){ 13 | return JDBCDAO.select(String.format("SELECT * FROM users WHERE id IN (SELECT to_id FROM follow WHERE from_id = '%s')",fromId)); 14 | } 15 | 16 | public static boolean delFollow(String fromId,String toId){ 17 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("DELETE follow where from_id = '%s' and to_id = '%s'",fromId,toId)); 18 | } 19 | 20 | public static boolean addFollow(String fromId,String toId){ 21 | String curDate = DateHelper.getCurrentDate(); 22 | System.out.println("DAO: " + curDate); 23 | 24 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO follow VALUES('%s','%s','%s')", 25 | fromId,toId,curDate)); 26 | 27 | } 28 | 29 | public static boolean isFollow(String fromId,String toId){ 30 | 31 | List> obj =JDBCDAO.select(String.format("SELECT * FROM dbo.follow WHERE from_id = '%s' and to_id = '%s'",fromId,toId)); 32 | if(obj.isEmpty()){ 33 | return false; 34 | }else { 35 | return true; 36 | } 37 | 38 | } 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/model/Comment.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.Map; 4 | import constant.Constant; 5 | public class Comment { 6 | private String id = ""; 7 | private String context = ""; 8 | private String createTime = ""; 9 | private String userId = ""; 10 | private String fromId = ""; 11 | 12 | public Comment(){ 13 | 14 | } 15 | 16 | public Comment(Map map){ 17 | setId((String) map.get(Constant.COM_ID)); 18 | setContext((String) map.get(Constant.COM_CONTEXT)); 19 | setCreateTime((String) map.get(Constant.CREATE_TIME)); 20 | setUserId((String) map.get(Constant.COM_USERID)); 21 | setFromId((String) map.get(Constant.COM_FROMID)); 22 | } 23 | 24 | public void setId(String id){ 25 | this.id = id; 26 | } 27 | public String getId(){ 28 | return id; 29 | } 30 | 31 | public void setContext(String context){ 32 | this.context = context; 33 | } 34 | public String getContext(){ 35 | return context; 36 | } 37 | 38 | public void setCreateTime(String createTime){ 39 | this.createTime = createTime; 40 | } 41 | public String getCreateTime(){ 42 | return createTime; 43 | } 44 | 45 | public void setUserId(String userId){ 46 | this.userId = userId; 47 | } 48 | public String getUserId(){ 49 | return userId; 50 | } 51 | 52 | public void setFromId(String fromId){ 53 | this.fromId = fromId; 54 | } 55 | public String getFromId(){ 56 | return fromId; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/model/Photo.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import constant.Constant; 4 | 5 | import java.util.Map; 6 | 7 | public class Photo { 8 | private String id = ""; 9 | private String name = ""; 10 | private String createTime = ""; 11 | private String url = ""; 12 | private int praiseCount = 0; 13 | 14 | public Photo(Map map){ 15 | setId((String) map.get(Constant.PHOTO_ID)); 16 | setName((String)map.get(Constant.PHOTO_NAME)); 17 | setCreateTime((String)map.get(Constant.CREATE_TIME)); 18 | setUrl((String)map.get(Constant.URL)); 19 | setPraiseCount((int)map.get(Constant.PRAISE_COUNT)); 20 | } 21 | 22 | public Photo(){ 23 | 24 | } 25 | 26 | public String getId() { 27 | return id; 28 | } 29 | 30 | public void setId(String id) { 31 | this.id = id; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public String getCreateTime() { 43 | return createTime; 44 | } 45 | 46 | public void setCreateTime(String createTime) { 47 | this.createTime = createTime; 48 | } 49 | 50 | public String getUrl() { 51 | return url; 52 | } 53 | 54 | public void setUrl(String url) { 55 | this.url = url; 56 | } 57 | 58 | public int getPraiseCount() { 59 | return praiseCount; 60 | } 61 | 62 | public void setPraiseCount(int praiseCount) { 63 | this.praiseCount = praiseCount; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/server/MessageServer.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | /** 4 | * Created by hi on 2019/12/30. 5 | */ 6 | import dao.MessageDAO; 7 | import entity.DataResult; 8 | import model.Message; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | public class MessageServer { 15 | public static DataResult getMessageBytoId(String toId){ 16 | DataResult dataResult=new DataResult(); 17 | List> maps=MessageDAO.getMessageBytoId(toId); 18 | List MessageList=new ArrayList<>(); 19 | for(Map map :maps){ 20 | MessageList.add(new Message(map)); 21 | } 22 | dataResult.setStatus(0); 23 | dataResult.setMsg("get Message "); 24 | dataResult.setData(MessageList); 25 | return dataResult; 26 | } 27 | public static DataResult getMessageByfromId(String fromId){ 28 | DataResult dataResult=new DataResult(); 29 | List> maps=MessageDAO.getMessageByfromId(fromId); 30 | List MessageList=new ArrayList<>(); 31 | for(Map map :maps){ 32 | MessageList.add(new Message(map)); 33 | } 34 | dataResult.setStatus(0); 35 | dataResult.setMsg("get Message "); 36 | dataResult.setData(MessageList); 37 | return dataResult; 38 | } 39 | public static DataResult sendMessage(String fromId,String toId,String messageContext){ 40 | MessageDAO.addNewMessage(fromId,toId,messageContext); 41 | return DataResult.success("send message success",null); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/model/Statistics.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import constant.Constant; 4 | 5 | import java.util.Map; 6 | 7 | public class Statistics { 8 | private int AlbumCount = -1; 9 | private int CommentCount = -1; 10 | private int FollowCount = -1; 11 | private int FollowedCount = -1; 12 | private int PhotoCount = -1; 13 | 14 | public Statistics(){ 15 | 16 | } 17 | 18 | public Statistics(Map map){ 19 | AlbumCount = map.get(Constant.STATISTICS_ALBUM); 20 | CommentCount = map.get(Constant.STATISTICS_COMMENT); 21 | FollowCount = map.get(Constant.STATISTICS_FOLLOW); 22 | FollowedCount = map.get(Constant.STATISTICS_FOLLOWED); 23 | PhotoCount = map.get(Constant.STATISTICS_PHOTO); 24 | } 25 | 26 | public void setAlbumCount(int albumCount) { 27 | this.AlbumCount = albumCount; 28 | } 29 | public int getAlbumCount() { 30 | return AlbumCount; 31 | } 32 | 33 | public void setCommentCount(int commentCount) { 34 | this.CommentCount = commentCount; 35 | } 36 | public int getCommentCount() { 37 | return CommentCount; 38 | } 39 | 40 | public void setFollowCount(int followCount) { 41 | this.FollowCount = followCount; 42 | } 43 | public int getFollowCount() { 44 | return FollowCount; 45 | } 46 | 47 | public void setFollowedCount(int followedCount) { 48 | this.FollowedCount = followedCount; 49 | } 50 | public int getFollowedCount() { 51 | return FollowedCount; 52 | } 53 | 54 | public void setPhotoCount(int photoCount) { 55 | this.PhotoCount = photoCount; 56 | } 57 | public int getPhotoCount() { 58 | return PhotoCount; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /src/main/java/dao/C3P0Utils.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import com.mchange.v2.c3p0.ComboPooledDataSource; 4 | 5 | import javax.sql.DataSource; 6 | import java.sql.Connection; 7 | import java.sql.PreparedStatement; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | 11 | 12 | public class C3P0Utils { 13 | private C3P0Utils() { 14 | } 15 | 16 | private static ComboPooledDataSource ds = null; 17 | private static ThreadLocal tLocal = new ThreadLocal<>(); 18 | 19 | static { 20 | ds = new ComboPooledDataSource();//读取默认配置文件 21 | 22 | } 23 | 24 | public static DataSource getDataSource() { 25 | return ds; 26 | } 27 | 28 | public static Connection getConnection() { 29 | Connection con = tLocal.get(); 30 | if (con == null) { 31 | try { 32 | con = ds.getConnection(); 33 | tLocal.set(con); 34 | } catch (SQLException e) { 35 | e.printStackTrace(); 36 | } 37 | } 38 | return con; 39 | } 40 | 41 | public static void close(ResultSet resultSet, PreparedStatement pst, Connection connection) { 42 | if (resultSet != null) { 43 | try { 44 | resultSet.close(); 45 | } catch (SQLException e) { 46 | e.printStackTrace(); 47 | } 48 | } 49 | if (pst != null) { 50 | try { 51 | pst.close(); 52 | } catch (SQLException e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | // if (connection != null) { 57 | // try { 58 | // //connection.close(); 59 | // } catch (SQLException e) { 60 | // e.printStackTrace(); 61 | // } 62 | // } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/model/Message.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import java.util.Map; 4 | import constant.Constant; 5 | /** 6 | * Created by hi on 2019/12/30. 7 | */ 8 | public class Message { 9 | private String id=""; 10 | private String fromId=""; 11 | private String toId=""; 12 | private String context=""; 13 | private String createTime=""; 14 | private String extra=""; 15 | public String getId() { 16 | return id; 17 | } 18 | 19 | public void setId(String id) { 20 | this.id = id; 21 | } 22 | 23 | public String getFromId() { 24 | return fromId; 25 | } 26 | 27 | public void setFromId(String fromId) { 28 | this.fromId = fromId; 29 | } 30 | 31 | public String getToId() { 32 | return toId; 33 | } 34 | 35 | public void setToId(String toId) { 36 | this.toId = toId; 37 | } 38 | 39 | public String getContext() { 40 | return context; 41 | } 42 | 43 | public void setContext(String context) { 44 | this.context = context; 45 | } 46 | 47 | public String getCreateTime() { 48 | return createTime; 49 | } 50 | 51 | public void setCreateTime(String createTime) { 52 | this.createTime = createTime; 53 | } 54 | 55 | public String getExtra() { 56 | return extra; 57 | } 58 | 59 | public void setExtra(String extra) { 60 | this.extra = extra; 61 | } 62 | 63 | public Message(Map map){ 64 | setId((String)map.get(Constant.MESSAGE_ID)); 65 | setToId((String)map.get(Constant.MESSAGE_TOID)); 66 | setFromId((String)map.get(Constant.MESSAGE_FROMID)); 67 | setContext((String)map.get(Constant.MESSAGE_CONTEXT)); 68 | setCreateTime((String)map.get(Constant.MESSAGE_CREATE_TIME)); 69 | setExtra((String)map.get(Constant.MESSAGE_EXTRA)); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/controller/UserHomeController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import model.Album; 4 | import model.User; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import server.AlbumServer; 10 | import server.FollowServer; 11 | import server.UserServer; 12 | 13 | import javax.servlet.http.HttpSession; 14 | import java.util.List; 15 | 16 | @Controller 17 | public class UserHomeController { 18 | 19 | @RequestMapping("/user") 20 | public String goToUserHome(@RequestParam("id")String id,Model model,HttpSession session){ 21 | User user = (User)UserServer.getUserInfoById(id).getData(); 22 | List albumList = (List)AlbumServer.getAlbumInfoListByUserId(id).getData(); 23 | 24 | User Myuser= (User) session.getAttribute("myInfo"); 25 | int res = 0; 26 | if(Myuser!= null){ 27 | if(FollowServer.checkFollow(Myuser.getId(),user.getId()).getStatus() == 0){ 28 | res = 1; 29 | } 30 | } 31 | model.addAttribute("isFollow",res); 32 | model.addAttribute("userInfo",user); 33 | model.addAttribute("albumList",albumList); 34 | return "user_home"; 35 | } 36 | 37 | @RequestMapping("/createAlbum") 38 | public String goToCreateAlbum(){ 39 | return "album_create"; 40 | } 41 | 42 | @RequestMapping("/uploadPhoto") 43 | public String goToUpload(Model model, HttpSession session){ 44 | User user = (User)session.getAttribute("myInfo"); 45 | String userId = user.getId(); 46 | List albumList = (List)AlbumServer.getAlbumInfoListByUserId(userId).getData(); 47 | model.addAttribute("albumList",albumList); 48 | model.addAttribute("userId",userId); 49 | return "photo_upload"; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /src/main/java/dao/CommentDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import util.DateHelper; 4 | import util.ShortUUID; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class CommentDAO { 10 | 11 | public static List> getCommentInfoListAll(){ 12 | return JDBCDAO.select(String.format("SELECT * FROM comment")); 13 | } 14 | 15 | public static List> getCommentInfoListByUserId(String userId){ 16 | return JDBCDAO.select(String.format("SELECT * FROM comment WHERE user_id = '%s'",userId)); 17 | } 18 | 19 | public static List> getCommentInfoListByAlbumId(String albumId){ 20 | return JDBCDAO.select(String.format("SELECT * FROM comment WHERE from_id = '%s'",albumId)); 21 | } 22 | 23 | public static Map getCommentInfoById(String Id){ 24 | return JDBCDAO.select(String.format("SELECT * FROM comment WHERE id = '%s'",Id)).get(0); 25 | } 26 | 27 | public static String createNewComment(String userId,String albumId,String context){ 28 | String commentId = ShortUUID.generateShortUuid(); 29 | String curDate = DateHelper.getCurrentDate(); 30 | boolean res = JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO comment VALUES('%s','%s','%s','%s','%s')", 31 | commentId,context,curDate,userId,albumId)); 32 | if(res){ 33 | return commentId; 34 | }else { 35 | return null; 36 | } 37 | } 38 | 39 | public static boolean delComment(String commentId){ 40 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("DELETE comment WHERE id = '%s'",commentId)); 41 | } 42 | 43 | 44 | public static boolean isCommentExist(String commentId){ 45 | List> res = JDBCDAO.select(String.format("SELECT * FROM album WHERE id = '%s'",commentId)); 46 | return !(res.size()==0); 47 | } 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/model/Operation.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import constant.Constant; 4 | 5 | import java.util.Map; 6 | 7 | public class Operation { 8 | private String id; 9 | private String fromId; 10 | private String toId; 11 | private String operate; 12 | private String operateName; 13 | private String note; 14 | private String createTime; 15 | 16 | public Operation(){ 17 | 18 | } 19 | 20 | public Operation(Map map){ 21 | setId((String)map.get(Constant.ID)); 22 | setFromId((String)map.get(Constant.FROM_ID)); 23 | setToId((String)map.get(Constant.TO_ID)); 24 | setOperate((String)map.get(Constant.OPERATE)); 25 | setNote((String)map.get(Constant.NOTE)); 26 | setCreateTime((String)map.get(Constant.CREATE_TIME)); 27 | //对应的中文 *那么为什么不直接用中文做值呢?? 28 | setOperateName(Constant.OP_NAME_MAP.get(getOperate())); 29 | } 30 | 31 | public String getId() { 32 | return id; 33 | } 34 | 35 | public void setId(String id) { 36 | this.id = id; 37 | } 38 | 39 | public String getFromId() { 40 | return fromId; 41 | } 42 | 43 | public void setFromId(String fromId) { 44 | this.fromId = fromId; 45 | } 46 | 47 | public String getToId() { 48 | return toId; 49 | } 50 | 51 | public void setToId(String toId) { 52 | this.toId = toId; 53 | } 54 | 55 | public String getOperate() { 56 | return operate; 57 | } 58 | 59 | public void setOperate(String operate) { 60 | this.operate = operate; 61 | } 62 | 63 | public String getNote() { 64 | return note; 65 | } 66 | 67 | public String getOperateName() { 68 | return operateName; 69 | } 70 | 71 | public void setOperateName(String operateName) { 72 | this.operateName = operateName; 73 | } 74 | 75 | public void setNote(String note) { 76 | this.note = note; 77 | } 78 | 79 | public String getCreateTime() { 80 | return createTime; 81 | } 82 | 83 | public void setCreateTime(String createTime) { 84 | this.createTime = createTime; 85 | } 86 | 87 | 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/model/User.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import constant.Constant; 4 | 5 | import java.util.Map; 6 | 7 | public class User { 8 | private String id; 9 | private String password; 10 | private String name; 11 | private String userState; 12 | private String type; 13 | private String descp; 14 | private String createTime; 15 | 16 | 17 | public User(Map info){ 18 | setId((String)info.get(Constant.USER_ID)); 19 | setPassword((String)info.get(Constant.PASSWORD)); 20 | setName((String)info.get(Constant.USER_NAME)); 21 | setUserState((String)info.get(Constant.USER_STATE)); 22 | setType((String)info.get(Constant.TYPE)); 23 | setDescp((String)info.get(Constant.DESCP)); 24 | setCreateTime((String)info.get(Constant.CREATE_TIME)); 25 | } 26 | 27 | public String getDescp() { 28 | return descp; 29 | } 30 | 31 | public void setDescp(String descp) { 32 | this.descp = descp; 33 | } 34 | 35 | public String getCreateTime() { 36 | return createTime; 37 | } 38 | 39 | public void setCreateTime(String createTime) { 40 | this.createTime = createTime; 41 | } 42 | public User(){ 43 | 44 | } 45 | 46 | public String getType() { 47 | return type; 48 | } 49 | 50 | public void setType(String type) { 51 | this.type = type; 52 | } 53 | public String getId() { 54 | return id; 55 | } 56 | 57 | public void setId(String id) { 58 | this.id = id; 59 | } 60 | 61 | public String getPassword() { 62 | return password; 63 | } 64 | 65 | public void setPassword(String password) { 66 | this.password = password; 67 | } 68 | 69 | public String getName() { 70 | return name; 71 | } 72 | 73 | public void setName(String name) { 74 | this.name = name; 75 | } 76 | 77 | public String getUserState() { 78 | return userState; 79 | } 80 | 81 | public void setUserState(String userState) { 82 | this.userState = userState; 83 | } 84 | 85 | public boolean isAdmin(){ 86 | return this.type.equals(Constant.ADMIN); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/admin_operations.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/29 5 | Time: 23:52 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | ${myInfo.name} -管理后台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 |
25 |
26 |
27 | 28 | 29 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/server/OperationServer.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | import constant.Constant; 4 | import dao.OperationDAO; 5 | import entity.DataResult; 6 | import model.Operation; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class OperationServer { 13 | 14 | public static DataResult getOperationList(int page,int limit){ 15 | List> maps = OperationDAO.getOperationList(page,limit); 16 | if(maps == null){ 17 | return DataResult.fail("get op lists fail"); 18 | } 19 | List ops = new ArrayList<>(); 20 | for(Map map:maps){ 21 | ops.add(new Operation(map)); 22 | } 23 | return DataResult.success("get op list success",ops); 24 | } 25 | 26 | public static DataResult addChangeUserState(String opId,String userId,String note,String state, String op){ 27 | int res = UserServer.setState(userId, state).getStatus(); 28 | if(res == 0){ 29 | boolean r = OperationDAO.addOp(opId,userId,op,note); 30 | if(r){ 31 | return DataResult.success("change ban user success",null); 32 | } 33 | } 34 | return DataResult.fail("change ban user fail"); 35 | } 36 | 37 | public static DataResult addChangeAlbumState(String opId,String albumId,String note,String state,String op){ 38 | int res = AlbumServer.setState(albumId,state).getStatus(); 39 | if(res == 0){ 40 | boolean r = OperationDAO.addOp(opId,albumId,op,note); 41 | if(r){ 42 | return DataResult.success("change ban album success",null); 43 | } 44 | } 45 | return DataResult.fail("change ban album fail"); 46 | } 47 | 48 | public static DataResult banUser(String opId,String userId,String note){ 49 | return addChangeUserState(opId,userId,note,Constant.BANNED,Constant.BAN_USR); 50 | } 51 | 52 | public static DataResult debanUser(String opId,String userId,String note){ 53 | return addChangeUserState(opId,userId,note,Constant.NORMAL,Constant.DEBAN_USR); 54 | } 55 | 56 | public static DataResult banAlbum(String opId,String albumId,String note){ 57 | return addChangeAlbumState(opId,albumId,note,Constant.BANNED,Constant.BAN_ALBUM); 58 | } 59 | 60 | public static DataResult debanAlbum(String opId,String albumId,String note){ 61 | return addChangeAlbumState(opId,albumId,note,Constant.NORMAL,Constant.DEBAN_ALBUM); 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/server/FollowServer.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | 4 | import dao.AlbumDAO; 5 | import dao.CommentDAO; 6 | import dao.FollowDAO; 7 | import entity.DataResult; 8 | import model.User; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | public class FollowServer { 15 | public static DataResult getFollowInfoById(String fromId){ 16 | DataResult dataResult = new DataResult(); 17 | dataResult.setStatus(0); 18 | dataResult.setMsg("get follow info"); 19 | List followList = new ArrayList<>(); 20 | List> maps = FollowDAO.getFollowInfoListById(fromId); 21 | for(Mapmap:maps){ 22 | followList.add(new User(map)); 23 | } 24 | 25 | dataResult.setMsg("get comment success"); 26 | dataResult.setData(followList); 27 | 28 | return dataResult; 29 | } 30 | 31 | public static DataResult addFollow(String fromId,String toId){ 32 | DataResult dataResult = new DataResult(); 33 | boolean res = FollowDAO.addFollow(fromId,toId); 34 | if(res == true){ 35 | dataResult.setStatus(0); 36 | dataResult.setMsg("add new follow success"); 37 | // Follow follow = new Follow(FollowDAO.getFollowInfoListById(fromId,toId)); 38 | // dataResult.setData(follow); 39 | }else{ 40 | dataResult.setStatus(-1); 41 | dataResult.setMsg("add new follow error"); 42 | } 43 | return dataResult; 44 | } 45 | 46 | public static DataResult deleteFollow(String fromId,String toId){ 47 | DataResult dataResult = new DataResult(); 48 | boolean res = FollowDAO.delFollow(fromId,toId); 49 | if(res!=false){ 50 | dataResult.setStatus(0); 51 | dataResult.setMsg("delete follow success"); 52 | }else{ 53 | dataResult.setStatus(-1); 54 | dataResult.setMsg("delete follow error"); 55 | } 56 | return dataResult; 57 | } 58 | 59 | public static DataResult checkFollow(String fromId,String toId){ 60 | DataResult dataResult = new DataResult(); 61 | boolean res = FollowDAO.isFollow(fromId,toId); 62 | if(res == true){ 63 | System.out.println("CHECKSERVER IS"); 64 | dataResult.setStatus(0); 65 | dataResult.setMsg("is followed"); 66 | }else { 67 | System.out.println("CHECKSERVER NOT"); 68 | dataResult.setStatus(-1); 69 | dataResult.setMsg("is not followed"); 70 | } 71 | return dataResult; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/rate.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,i={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var i=this;return i.config=a.extend({},i.config,e),i},on:function(e,a){return layui.onevent.call(this,n,e,a)}},l=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",s="layui-icon-rate-solid",u="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var l=this;l.index=++i.index,l.config=a.extend({},l.config,i.config,e),l.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,i=e.config,l=i.theme?'style="color: '+i.theme+';"':"";i.elem=a(i.elem),parseInt(i.value)!==i.value&&(i.half||(i.value=Math.ceil(i.value)-i.value<.5?Math.ceil(i.value):Math.floor(i.value)));for(var n='
    ",u=1;u<=i.length;u++){var r='
  • ";i.half&&parseInt(i.value)!==i.value&&u==Math.ceil(i.value)?n=n+'
  • ":n+=r}n+="
"+(i.text?''+i.value+"星":"")+"";var c=i.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),i.span=e.elemTemp.next("span"),i.setText&&i.setText(i.value),c.html(e.elemTemp),c.addClass("layui-inline"),i.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,i=a.config;i.value=e,a.render()},v.prototype.action=function(){var e=this,i=e.config,l=e.elemTemp,n=l.find("i").width();l.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(i.value=t,i.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(i.value=i.value-.5)}i.text&&l.next("span").text(i.value+"星"),i.choose&&i.choose(i.value),i.setText&&i.setText(i.value)}),v.on("mousemove",function(e){if(l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+t+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(u).removeClass(s)}}),v.on("mouseleave",function(){l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+Math.floor(i.value)+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half&&parseInt(i.value)!==i.value&&l.children("li:eq("+Math.floor(i.value)+")").children("i").addClass(u).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},i.render=function(e){var a=new v(e);return l.call(a)},e(n,i)}); -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/my_left_bar.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 52491 5 | Date: 2019/12/29 6 | Time: 15:30 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 |
13 |
14 |
15 | 16 |
17 |
${sessionScope.myInfo.name}
18 |
ID:${sessionScope.myInfo.id}
19 |
权限:${sessionScope.myInfo.type}
20 | 21 | <%--封禁状态什么都不能干--%> 22 | 23 | 24 |
该用户已被封禁!
25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 | 47 | 48 | <%--管理员才有的后台菜单--%> 49 | 50 |
51 | 57 |
58 |
59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/my_statistics.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 加法还没学 4 | Date: 2020/1/1 5 | Time: 21:11 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | ${myInfo.name} -我的统计 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 |
23 |
24 |
    25 |
  • 我的统计
  • 26 |
27 |
28 |
29 |
30 |
31 |
${mystatis.albumCount}
32 |
发布的相册数量
33 |
34 | 35 |
36 |
${mystatis.commentCount}
37 |
发布的评论数量
38 |
39 | 40 |
41 |
${mystatis.followCount}
42 |
我关注的数量
43 |
44 | 45 |
46 |
${mystatis.followedCount}
47 |
我被关注的数量
48 |
49 | 50 |
51 |
${mystatis.photoCount}
52 |
我的照片的数量
53 |
54 |
55 |
56 | 57 |
58 |
59 |
60 | 61 | 64 | 65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /src/main/java/model/Album.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import constant.Constant; 4 | 5 | import java.util.Map; 6 | 7 | public class Album { 8 | private String id = ""; 9 | private String name = ""; 10 | private String userId = ""; 11 | private String createTime = ""; 12 | private String coverId = ""; 13 | private String descp = ""; 14 | private String albumState = ""; 15 | private int praiseCount = 0; 16 | private String category = ""; 17 | 18 | public Album(){ 19 | 20 | } 21 | 22 | public Album(Map map){ 23 | setId((String)map.get(Constant.ALB_ID)); 24 | setName((String)map.get(Constant.ALB_NAME)); 25 | setUserId((String)map.get(Constant.ALB_UER_ID)); 26 | setCreateTime((String)map.get(Constant.CREATE_TIME)); 27 | setCoverId((String)map.get(Constant.COVER_ID)); 28 | setDescp((String)map.get(Constant.DESCP)); 29 | setAlbumState((String)map.get(Constant.ALBUM_STATE)); 30 | setPraiseCount((int)map.get(Constant.PRAISE_COUNT)); 31 | setCategory((String)map.get(Constant.CATEGORY)); 32 | } 33 | 34 | public String getCategory() { 35 | return category; 36 | } 37 | 38 | public void setCategory(String category) { 39 | this.category = category; 40 | } 41 | public String getId() { 42 | return id; 43 | } 44 | 45 | public void setId(String id) { 46 | this.id = id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getUserId() { 58 | return userId; 59 | } 60 | 61 | public void setUserId(String userId) { 62 | this.userId = userId; 63 | } 64 | 65 | public String getCreateTime() { 66 | return createTime; 67 | } 68 | 69 | public void setCreateTime(String createTime) { 70 | this.createTime = createTime; 71 | } 72 | 73 | public String getCoverId() { 74 | return coverId; 75 | } 76 | 77 | public void setCoverId(String coverId) { 78 | this.coverId = coverId; 79 | } 80 | 81 | public String getDescp() { 82 | return descp; 83 | } 84 | 85 | public void setDescp(String descp) { 86 | this.descp = descp; 87 | } 88 | 89 | public String getAlbumState() { 90 | return albumState; 91 | } 92 | 93 | public void setAlbumState(String albumState) { 94 | this.albumState = albumState; 95 | } 96 | 97 | public int getPraiseCount() { 98 | return praiseCount; 99 | } 100 | 101 | public void setPraiseCount(int praiseCount) { 102 | this.praiseCount = praiseCount; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/controller/ImageController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | import org.springframework.web.bind.annotation.ResponseBody; 7 | import sun.security.x509.AVA; 8 | import util.ImageHelper; 9 | 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.File; 12 | import java.io.FileInputStream; 13 | import java.io.IOException; 14 | import java.io.OutputStream; 15 | 16 | @Controller 17 | public class ImageController { 18 | 19 | public static final String DEFAULT_PATH = ImageHelper.getFilePath("default.jpg"); 20 | public static final String DEAFULT_AVATAR = ImageHelper.getFilePath("avatar\\default.jpg"); 21 | public static final int AVATAR = 0; 22 | public static final int IMG = 1; 23 | 24 | public void handleRp(HttpServletResponse rp,String filePath,int type) { 25 | File imageFile = new File(filePath); 26 | if(!imageFile.exists()) { 27 | imageFile = new File(type == IMG ?DEFAULT_PATH:DEAFULT_AVATAR); 28 | } 29 | if (imageFile.exists()) { 30 | FileInputStream fis = null; 31 | OutputStream os = null; 32 | try { 33 | fis = new FileInputStream(imageFile); 34 | os = rp.getOutputStream(); 35 | int count = 0; 36 | byte[] buffer = new byte[1024 * 8]; 37 | while ((count = fis.read(buffer)) != -1) { 38 | os.write(buffer, 0, count); 39 | os.flush(); 40 | } 41 | 42 | } catch (Exception e) { 43 | e.printStackTrace(); 44 | } finally { 45 | try { 46 | fis.close(); 47 | os.close(); 48 | } catch (IOException e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | } 53 | } 54 | @RequestMapping(value = "/getDefaultImage") 55 | @ResponseBody 56 | public void getDefaultImage(HttpServletResponse rp) { 57 | String filePath = DEFAULT_PATH; 58 | handleRp(rp,filePath,IMG); 59 | } 60 | 61 | @RequestMapping(value = "/getImage") 62 | @ResponseBody 63 | public void getImage(@RequestParam("url")String url,HttpServletResponse rp){ 64 | String filePath = ImageHelper.getFilePath(url); 65 | handleRp(rp,filePath, IMG); 66 | System.out.println(filePath); 67 | } 68 | 69 | @RequestMapping(value = "/getAvatar") 70 | @ResponseBody 71 | public void getAvatar(@RequestParam("id")String id,HttpServletResponse rp){ 72 | String filePath = ImageHelper.getAvatarPath(id); 73 | handleRp(rp,filePath,AVATAR); 74 | System.out.println("avatar path:" + filePath); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/dao/JDBCDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import java.sql.*; 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class JDBCDAO { 10 | /** 11 | *  * 增加,删除,修改   12 | */ 13 | public static boolean insertOrDeleteOrUpdate(String sql) { 14 | try { 15 | Connection connection = C3P0Utils.getConnection(); 16 | PreparedStatement pst = connection.prepareStatement(sql); 17 | int execute = pst.executeUpdate(); 18 | System.out.println("执行语句:" + sql + "," + execute + "行数据受影响"); 19 | C3P0Utils.close(null, pst, connection); 20 | return true; 21 | } catch (SQLException e) { 22 | System.out.println("异常提醒:" + e); 23 | return false; 24 | } 25 | } 26 | 27 | /** 28 | *  * 查询,返回结果集   29 | */ 30 | public static List> select(String sql) { 31 | List> returnResultToList = null; 32 | try { 33 | Connection connection = C3P0Utils.getConnection(); 34 | PreparedStatement pst = connection.prepareStatement(sql); 35 | ResultSet resultSet = pst.executeQuery(); 36 | returnResultToList = returnResultToList(resultSet); 37 | C3P0Utils.close(resultSet, pst, connection); 38 | } catch (SQLException e) { 39 | 40 | System.out.println("异常提醒:" + e); 41 | } 42 | return returnResultToList; 43 | } 44 | 45 | /** 46 | *  * 数据返回集合  * @param resultSet  * @return  * @throws SQLException   47 | */ 48 | public static List> returnResultToList(ResultSet resultSet) { 49 | List> values = null; 50 | try { 51 | // 键: 存放列的别名, 值: 存放列的值. 52 | values = new ArrayList<>(); 53 | // 存放字段名 54 | List columnName = new ArrayList<>(); 55 | ResultSetMetaData rsmd = resultSet.getMetaData(); 56 | for (int i = 0; i < rsmd.getColumnCount(); i++) { 57 | // 字段名 58 | columnName.add(rsmd.getColumnLabel(i + 1)); 59 | } 60 | Map map = null; 61 | // 处理 ResultSet, 使用 while 循环 62 | while (resultSet.next()) { 63 | map = new HashMap<>(); 64 | for (String column : columnName) { 65 | Object value = resultSet.getObject(column); 66 | map.put(column, value); 67 | System.out.print(value + "\t"); 68 | } 69 | // 把一条记录的 Map 对象放入准备的 List 中 70 | values.add(map); 71 | System.out.println(); 72 | } 73 | } catch (SQLException e) { 74 | System.out.println("异常提醒:" + e); 75 | } 76 | return values; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/dao/UserDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import util.DateHelper; 4 | 5 | import java.util.HashMap; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class UserDAO { 10 | public static boolean isUserIdExist(String id){ 11 | List> res = JDBCDAO.select(String.format("SELECT * FROM users WHERE id = '%s'",id)); 12 | System.out.println("UserDAO id" + id); 13 | if (res == null) 14 | return false; 15 | System.out.println(res.size()); 16 | return !(res.size() == 0) ; 17 | } 18 | 19 | public static Map getUserInfoById(String id){ 20 | return JDBCDAO.select(String.format("SELECT * FROM users WHERE id = '%s'",id)).get(0); 21 | } 22 | 23 | public static void addNewUser(String id,String password,String name){ 24 | // 默认个人简介为空 25 | JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO users VALUES('%s','%s','%s','%s','%s','%s','%s')", 26 | id,name,password,"normal","user","", DateHelper.getCurrentDate())); 27 | } 28 | 29 | public static boolean editBaseInfo(String userId,String name,String desc){ 30 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE users SET name = '%s',descp = '%s' WHERE id = '%s'",name,desc,userId)); 31 | } 32 | 33 | public static List> getUserList(int page,int limit){ 34 | int pre = (page - 1)*limit; 35 | //沙雕sqlserver 36 | return JDBCDAO.select(String.format("SELECT TOP %d * FROM users WHERE id NOT IN (SELECT TOP %d id FROM users ORDER BY create_time DESC) ORDER BY create_time DESC",limit,pre)); 37 | } 38 | 39 | public static boolean setUserState(String userId,String state){ 40 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE users SET user_state = '%s' WHERE id = '%s'",state,userId)); 41 | } 42 | 43 | public static Map getStatisticsAll(String userId){ 44 | Map statistics = new HashMap<>(); 45 | 46 | int AlbumCount = JDBCDAO.select(String.format("SELECT * FROM album where user_id = '%s'",userId)).size(); 47 | statistics.put("albumCount",AlbumCount);//发布的相册数量 48 | 49 | int CommentCount = JDBCDAO.select(String.format("SELECT * FROM comment where user_id = '%s'",userId)).size(); 50 | statistics.put("commentCount",CommentCount);//发布的评论数量 51 | 52 | int FollowCount = JDBCDAO.select(String.format("SELECT * FROM follow where from_id = '%s'",userId)).size(); 53 | statistics.put("followCount",FollowCount);//我关注的数量 54 | 55 | int FollowedCount = JDBCDAO.select(String.format("SELECT * FROM follow where to_id = '%s'",userId)).size(); 56 | statistics.put("followedCount",FollowedCount);//我被关注的数量 57 | 58 | int PhotoCount = JDBCDAO.select(String.format("SELECT * from store where album_id in (select id from album where user_id = '%s')",userId)).size(); 59 | statistics.put("photoCount",PhotoCount);//我的照片的数量 60 | 61 | return statistics; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | 4 | import dao.UserDAO; 5 | import entity.DataResult; 6 | import model.User; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.*; 10 | import org.springframework.web.servlet.ModelAndView; 11 | import server.AlbumServer; 12 | import server.UserServer; 13 | 14 | import javax.jws.soap.SOAPBinding; 15 | import javax.servlet.http.HttpSession; 16 | 17 | @Controller 18 | @SessionAttributes(value = {"isLogin","myInfo"}) 19 | public class IndexController { 20 | 21 | @RequestMapping("/") 22 | public String main(){ 23 | return "redirect:index"; 24 | } 25 | 26 | @RequestMapping("/index") 27 | public ModelAndView index() throws Exception{ 28 | return new ModelAndView("index"); 29 | } 30 | 31 | @RequestMapping("/home") 32 | public ModelAndView goToHome(Model model){ 33 | model.addAttribute("albumList", AlbumServer.getAllAlbum().getData()); 34 | return new ModelAndView("album_list"); 35 | } 36 | 37 | @RequestMapping(value="/register",method = RequestMethod.POST) 38 | public String register(@RequestParam("loginid")String loginname, 39 | @RequestParam("password")String password, 40 | @RequestParam("username")String username,Model model) { 41 | if(UserDAO.isUserIdExist(loginname)){ 42 | 43 | model.addAttribute("msg","该用户名已存在!"); 44 | System.out.println("已存在该用户名"); 45 | }else{ 46 | model.addAttribute("msg","该用户名可用!"); 47 | System.out.println("该用户名可用!"); 48 | } 49 | return "forward:index"; 50 | } 51 | 52 | @RequestMapping(value="/registerJ",method = RequestMethod.POST) 53 | @ResponseBody 54 | public DataResult registerJ(@RequestParam("id")String id, 55 | @RequestParam("password")String password, 56 | @RequestParam("name")String name){ 57 | return UserServer.register(id,password,name); 58 | } 59 | 60 | 61 | //登录 62 | @RequestMapping("/login") 63 | @ResponseBody 64 | public DataResult login(@RequestParam("id")String loginname, 65 | @RequestParam("password")String password, Model model, HttpSession httpSession){ 66 | DataResult dataResult = UserServer.login(loginname,password); 67 | //登录成功了 68 | if(dataResult.getStatus() == 0){ 69 | model.addAttribute("isLogin",true); 70 | model.addAttribute("myInfo",dataResult.getData()); 71 | } 72 | return dataResult; 73 | } 74 | 75 | //获得用户信息 76 | @RequestMapping("/getUserInfoById") 77 | @ResponseBody 78 | public DataResult getUserInfoById(@RequestParam(name="id",required=true) String id){ 79 | return UserServer.getUserInfoById(id); 80 | } 81 | 82 | @RequestMapping("/logout") 83 | @ResponseBody 84 | public void logout(Model model,HttpSession httpSession){ 85 | 86 | httpSession.invalidate(); 87 | model.addAttribute("isLogin",false); 88 | model.addAttribute("myInfo",null); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/server/CommentServer.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | import dao.AlbumDAO; 4 | import dao.CommentDAO; 5 | import entity.DataResult; 6 | import model.Comment; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class CommentServer { 13 | 14 | public static DataResult getCommentInfoByAlbumId(String albumId){ 15 | DataResult dataResult = new DataResult(); 16 | if(!checkAlbumExist(albumId)){ 17 | dataResult.setStatus(-1); 18 | dataResult.setMsg("no such comment"); 19 | }else{ 20 | dataResult.setStatus(0); 21 | dataResult.setMsg("get comment info"); 22 | List commentList = new ArrayList<>(); 23 | List> maps = CommentDAO.getCommentInfoListByAlbumId(albumId); 24 | for(Mapmap:maps){ 25 | commentList.add(new Comment(map)); 26 | } 27 | dataResult.setMsg("get comment success"); 28 | dataResult.setData(commentList); 29 | } 30 | return dataResult; 31 | } 32 | 33 | 34 | public static DataResult getCommentInfoListByUserId(String userId){ 35 | DataResult dataResult = new DataResult(); 36 | if(!UserServer.checkUserExist(userId)){ 37 | dataResult.setStatus(-1); 38 | dataResult.setMsg("no such user"); 39 | }else { 40 | List commentList = new ArrayList<>(); 41 | List> maps = CommentDAO.getCommentInfoListByUserId(userId); 42 | for (Map map : maps) { 43 | commentList.add(new Comment(map)); 44 | } 45 | dataResult.setStatus(0); 46 | dataResult.setMsg("get commentlist success"); 47 | dataResult.setData(commentList); 48 | } 49 | return dataResult; 50 | } 51 | 52 | public static DataResult addNewComment(String userId,String albumName,String context){ 53 | DataResult dataResult = new DataResult(); 54 | // return album id 55 | String res = CommentDAO.createNewComment(userId,albumName,context); 56 | if(res!=null){ 57 | dataResult.setStatus(0); 58 | dataResult.setMsg("add new comment success"); 59 | Comment comment = new Comment(CommentDAO.getCommentInfoById(res)); 60 | dataResult.setData(comment); 61 | }else{ 62 | dataResult.setStatus(-1); 63 | dataResult.setMsg("add new comment error"); 64 | } 65 | return dataResult; 66 | } 67 | 68 | public static DataResult delComment(String commentId){ 69 | DataResult dataResult = new DataResult(); 70 | boolean res = CommentDAO.delComment(commentId); 71 | if(res!=false){ 72 | dataResult.setStatus(0); 73 | dataResult.setMsg("delete comment success"); 74 | }else{ 75 | dataResult.setStatus(-1); 76 | dataResult.setMsg("add new album error"); 77 | } 78 | return dataResult; 79 | } 80 | 81 | 82 | public static boolean checkAlbumExist(String albumId){ 83 | return AlbumDAO.isAlbumExist(albumId); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/header.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 52491 5 | Date: 2019/12/11 6 | Time: 18:31 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | 47 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/send_message.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: hi 4 | Date: 2019/12/30 5 | Time: 22:17 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 私信 13 | 14 | 15 | 16 | 17 | 57 | 58 | 59 |
60 | 61 |
62 | 63 |
64 | 65 |
66 | 67 |
68 |
69 | 70 |
71 | 72 |
73 |
74 |
75 | 76 | 79 | 80 |
81 |
82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/util.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(t){"use strict";var e=layui.$,i={fixbar:function(t){var i,n,a="layui-fixbar",o="layui-fixbar-top",r=e(document),l=e("body");t=e.extend({showHeight:200},t),t.bar1=t.bar1===!0?"":t.bar1,t.bar2=t.bar2===!0?"":t.bar2,t.bgcolor=t.bgcolor?"background-color:"+t.bgcolor:"";var c=[t.bar1,t.bar2,""],g=e(['
    ',t.bar1?'
  • '+c[0]+"
  • ":"",t.bar2?'
  • '+c[1]+"
  • ":"",'
  • '+c[2]+"
  • ","
"].join("")),s=g.find("."+o),u=function(){var e=r.scrollTop();e>=t.showHeight?i||(s.show(),i=1):i&&(s.hide(),i=0)};e("."+a)[0]||("object"==typeof t.css&&g.css(t.css),l.append(g),u(),g.find("li").on("click",function(){var i=e(this),n=i.attr("lay-type");"top"===n&&e("html,body").animate({scrollTop:0},200),t.click&&t.click.call(this,n)}),r.on("scroll",function(){clearTimeout(n),n=setTimeout(function(){u()},100)}))},countdown:function(t,e,i){var n=this,a="function"==typeof e,o=new Date(t).getTime(),r=new Date(!e||a?(new Date).getTime():e).getTime(),l=o-r,c=[Math.floor(l/864e5),Math.floor(l/36e5)%24,Math.floor(l/6e4)%60,Math.floor(l/1e3)%60];a&&(i=e);var g=setTimeout(function(){n.countdown(t,r+1e3,i)},1e3);return i&&i(l>0?c:[0,0,0,0],e,g),l<=0&&clearTimeout(g),g},timeAgo:function(t,e){var i=this,n=[[],[]],a=(new Date).getTime()-new Date(t).getTime();return a>6912e5?(a=new Date(t),n[0][0]=i.digit(a.getFullYear(),4),n[0][1]=i.digit(a.getMonth()+1),n[0][2]=i.digit(a.getDate()),e||(n[1][0]=i.digit(a.getHours()),n[1][1]=i.digit(a.getMinutes()),n[1][2]=i.digit(a.getSeconds())),n[0].join("-")+" "+n[1].join(":")):a>=864e5?(a/1e3/60/60/24|0)+"天前":a>=36e5?(a/1e3/60/60|0)+"小时前":a>=12e4?(a/1e3/60|0)+"分钟前":a<0?"未来":"刚刚"},digit:function(t,e){var i="";t=String(t),e=e||2;for(var n=t.length;n/g,">").replace(/'/g,"'").replace(/"/g,""")},event:function(t,n,a){n=i.event[t]=e.extend(!0,i.event[t],n)||{},e("body").on(a||"click","*["+t+"]",function(){var i=e(this),a=i.attr(t);n[a]&&n[a].call(this,i)})}};!function(t,e,i){"$:nomunge";function n(){a=e[l](function(){o.each(function(){var e=t(this),i=e.width(),n=e.height(),a=t.data(this,g);(i!==a.w||n!==a.h)&&e.trigger(c,[a.w=i,a.h=n])}),n()},r[s])}var a,o=t([]),r=t.resize=t.extend(t.resize,{}),l="setTimeout",c="resize",g=c+"-special-event",s="delay",u="throttleWindow";r[s]=250,r[u]=!0,t.event.special[c]={setup:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.add(e),t.data(this,g,{w:e.width(),h:e.height()}),1===o.length&&n()},teardown:function(){if(!r[u]&&this[l])return!1;var e=t(this);o=o.not(e),e.removeData(g),o.length||clearTimeout(a)},add:function(e){function n(e,n,o){var r=t(this),l=t.data(this,g)||{};l.w=n!==i?n:r.width(),l.h=o!==i?o:r.height(),a.apply(this,arguments)}if(!r[u]&&this[l])return!1;var a;return t.isFunction(e)?(a=e,n):(a=e.handler,void(e.handler=n))}}}(e,window),t("util",i)}); -------------------------------------------------------------------------------- /src/main/java/constant/Constant.java: -------------------------------------------------------------------------------- 1 | package constant; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Constant { 7 | public static final String IMAGE_PATH = "E:\\study-软件工程\\web_album_rep"; 8 | public static final String USER_ID = "id"; 9 | public static final String USER_NAME = "name"; 10 | public static final String PASSWORD = "password"; 11 | public static final String USER_STATE = "user_state"; 12 | public static final String TYPE = "type"; 13 | 14 | public static final String ADMIN = "admin"; 15 | public static final String USER = "user"; 16 | 17 | public static final String ALB_NAME = "album_name"; 18 | public static final String ALB_ID = "id"; 19 | public static final String ALB_UER_ID = "user_id"; 20 | public static final String CREATE_TIME = "create_time"; 21 | public static final String COVER_ID = "cover_id"; 22 | public static final String DESCP = "descp"; 23 | public static final String ALBUM_STATE = "album_state"; 24 | public static final String PRAISE_COUNT = "praise_count"; 25 | public static final String CATEGORY = "category"; 26 | 27 | public static final String PHOTO_ID = "id"; 28 | public static final String PHOTO_NAME = "name"; 29 | public static final String URL = "url"; 30 | 31 | public static final String MESSAGE_ID ="id"; 32 | public static final String MESSAGE_TOID ="to_id"; 33 | public static final String MESSAGE_FROMID ="from_id"; 34 | public static final String MESSAGE_CONTEXT ="context"; 35 | public static final String MESSAGE_CREATE_TIME ="create_time"; 36 | public static final String MESSAGE_EXTRA ="extra"; 37 | 38 | public static final String ORDER_DEFAULT = "order_default"; 39 | public static final String ORDER_DATE = "order_date"; 40 | public static final String ORDER_DATE_DESC = "order_default_desc"; 41 | public static final String ORDER_DATE_ASC = "order_default_asc"; 42 | 43 | public static final String BANNED = "banned"; 44 | public static final String NORMAL = "normal"; 45 | 46 | public static final String BAN_USR = "ban_user"; 47 | public static final String DEBAN_USR = "deban_user"; 48 | public static final String BAN_ALBUM = "ban_album"; 49 | public static final String DEBAN_ALBUM = "deban_album"; 50 | 51 | public static final String ID = "id"; 52 | public static final String FROM_ID = "from_id"; 53 | public static final String TO_ID = "to_id"; 54 | public static final String OPERATE = "operate"; 55 | public static final String NOTE = "note"; 56 | 57 | public static final Map OP_NAME_MAP = new HashMap(){{ 58 | put(BAN_USR,"封禁用户"); 59 | put(BAN_ALBUM,"封禁相册"); 60 | put(DEBAN_USR,"解禁用户"); 61 | put(DEBAN_ALBUM,"解禁相册"); 62 | }}; 63 | 64 | public static final String COM_ID = "id"; 65 | public static final String COM_CONTEXT = "context"; 66 | public static final String COM_USERID = "user_id"; 67 | public static final String COM_FROMID = "from_id"; 68 | 69 | public static final String FOLLOW_FROMID = "from_id"; 70 | public static final String FOLLOW_TOID = "to_id"; 71 | 72 | 73 | public static final String STATISTICS_ALBUM = "albumCount"; 74 | public static final String STATISTICS_COMMENT = "commentCount"; 75 | public static final String STATISTICS_FOLLOW = "followCount"; 76 | public static final String STATISTICS_FOLLOWED = "followedCount"; 77 | public static final String STATISTICS_PHOTO = "photoCount"; 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | error_fileupload 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | text/plain;charset=UTF-8 53 | text/html;charset=UTF-8 54 | 55 | 56 | 57 | 59 | 60 | 61 | application/json; charset=UTF-8 62 | application/x-www-form-urlencoded; charset=UTF-8 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/main/java/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import constant.Constant; 4 | import entity.DataResult; 5 | import model.Operation; 6 | import model.User; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | import server.AlbumServer; 13 | import server.OperationServer; 14 | import server.UserServer; 15 | 16 | import javax.servlet.http.HttpSession; 17 | 18 | @Controller 19 | @RequestMapping("/admin") 20 | public class AdminController { 21 | 22 | @RequestMapping("/users") 23 | public String enterUsers(Model model, HttpSession session){ 24 | User user = (User)session.getAttribute("myInfo"); 25 | model.addAttribute("myInfo",user); 26 | return user.isAdmin()?"admin_manage_users":"permission_denied"; 27 | } 28 | 29 | @RequestMapping("/getUserList") 30 | @ResponseBody 31 | public DataResult getUserList(@RequestParam("limit")int limit, 32 | @RequestParam("page")int page){ 33 | return UserServer.getUserList(page,limit); 34 | } 35 | 36 | @RequestMapping("/operations") 37 | public String enterOperations(Model model, HttpSession session){ 38 | User user = (User)session.getAttribute("myInfo"); 39 | model.addAttribute("myInfo",user); 40 | return user.isAdmin()?"admin_operations":"permission_denied"; 41 | } 42 | 43 | @RequestMapping("/getOperationList") 44 | @ResponseBody 45 | public DataResult getOperationList(@RequestParam("limit")int limit, 46 | @RequestParam("page")int page){ 47 | return OperationServer.getOperationList(page,limit); 48 | } 49 | 50 | @RequestMapping("/albums") 51 | public String enterAlbums(Model model, HttpSession session){ 52 | User user = (User)session.getAttribute("myInfo"); 53 | model.addAttribute("myInfo",user); 54 | return user.isAdmin()?"admin_manage_albums":"permission_denied"; 55 | } 56 | 57 | @RequestMapping("/getAlbumList") 58 | @ResponseBody 59 | public DataResult getAlbumList(@RequestParam("limit")int limit, 60 | @RequestParam("page")int page){ 61 | return AlbumServer.getAllAlbum(page,limit); 62 | } 63 | 64 | @RequestMapping("/banUser") 65 | @ResponseBody 66 | public DataResult banUser(@RequestParam("userId")String userId,@RequestParam("note")String note,HttpSession session){ 67 | User user = (User)session.getAttribute("myInfo"); 68 | return OperationServer.banUser(user.getId(),userId,note); 69 | } 70 | 71 | @RequestMapping("/debanUser") 72 | @ResponseBody 73 | public DataResult debanUser(@RequestParam("userId")String userId,HttpSession session){ 74 | User user = (User)session.getAttribute("myInfo"); 75 | return OperationServer.debanUser(user.getId(),userId,""); 76 | } 77 | 78 | @RequestMapping("/banAlbum") 79 | @ResponseBody 80 | public DataResult banAlbum(@RequestParam("albumId")String albumId,@RequestParam("note")String note,HttpSession session){ 81 | User user = (User)session.getAttribute("myInfo"); 82 | return OperationServer.banAlbum(user.getId(),albumId,note); 83 | } 84 | 85 | @RequestMapping("/debanAlbum") 86 | @ResponseBody 87 | public DataResult debanAlbum(@RequestParam("albumId")String albumId,HttpSession session){ 88 | User user = (User)session.getAttribute("myInfo"); 89 | return OperationServer.debanAlbum(user.getId(),albumId,""); 90 | } 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/my_messages.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 52491 5 | Date: 2019/12/30 6 | Time: 18:16 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | Title 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 |
${message.fromId}
42 |
${message.context}
43 |
44 |
${message.createTime}
45 |
回复
46 |
47 |
48 |
49 |
50 |
51 |
52 | 53 |
54 |
55 | 56 | 57 | 58 |
59 |
60 |
发送给:${message.toId}
61 |
${message.context}
62 |
${message.createTime}
63 |
64 |
65 |
66 |
67 | 68 |
69 |
70 |
71 | 72 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/carousel.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var i=layui.$,n=(layui.hint(),layui.device(),{config:{},set:function(e){var n=this;return n.config=i.extend({},n.config,e),n},on:function(e,i){return layui.onevent.call(this,t,e,i)}}),t="carousel",a="layui-this",l=">*[carousel-item]>*",o="layui-carousel-left",r="layui-carousel-right",d="layui-carousel-prev",s="layui-carousel-next",u="layui-carousel-arrow",c="layui-carousel-ind",m=function(e){var t=this;t.config=i.extend({},t.config,n.config,e),t.render()};m.prototype.config={width:"600px",height:"280px",full:!1,arrow:"hover",indicator:"inside",autoplay:!0,interval:3e3,anim:"",trigger:"click",index:0},m.prototype.render=function(){var e=this,n=e.config;n.elem=i(n.elem),n.elem[0]&&(e.elemItem=n.elem.find(l),n.index<0&&(n.index=0),n.index>=e.elemItem.length&&(n.index=e.elemItem.length-1),n.interval<800&&(n.interval=800),n.full?n.elem.css({position:"fixed",width:"100%",height:"100%",zIndex:9999}):n.elem.css({width:n.width,height:n.height}),n.elem.attr("lay-anim",n.anim),e.elemItem.eq(n.index).addClass(a),e.elemItem.length<=1||(e.indicator(),e.arrow(),e.autoplay(),e.events()))},m.prototype.reload=function(e){var n=this;clearInterval(n.timer),n.config=i.extend({},n.config,e),n.render()},m.prototype.prevIndex=function(){var e=this,i=e.config,n=i.index-1;return n<0&&(n=e.elemItem.length-1),n},m.prototype.nextIndex=function(){var e=this,i=e.config,n=i.index+1;return n>=e.elemItem.length&&(n=0),n},m.prototype.addIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index+e,n.index>=i.elemItem.length&&(n.index=0)},m.prototype.subIndex=function(e){var i=this,n=i.config;e=e||1,n.index=n.index-e,n.index<0&&(n.index=i.elemItem.length-1)},m.prototype.autoplay=function(){var e=this,i=e.config;i.autoplay&&(clearInterval(e.timer),e.timer=setInterval(function(){e.slide()},i.interval))},m.prototype.arrow=function(){var e=this,n=e.config,t=i(['",'"].join(""));n.elem.attr("lay-arrow",n.arrow),n.elem.find("."+u)[0]&&n.elem.find("."+u).remove(),n.elem.append(t),t.on("click",function(){var n=i(this),t=n.attr("lay-type");e.slide(t)})},m.prototype.indicator=function(){var e=this,n=e.config,t=e.elemInd=i(['
    ',function(){var i=[];return layui.each(e.elemItem,function(e){i.push("")}),i.join("")}(),"
"].join(""));n.elem.attr("lay-indicator",n.indicator),n.elem.find("."+c)[0]&&n.elem.find("."+c).remove(),n.elem.append(t),"updown"===n.anim&&t.css("margin-top",-(t.height()/2)),t.find("li").on("hover"===n.trigger?"mouseover":n.trigger,function(){var t=i(this),a=t.index();a>n.index?e.slide("add",a-n.index):a 2 | 6 | 7 | contextConfigLocation 8 | /WEB-INF/applicationContext.xml 9 | 10 | 11 | org.springframework.web.context.ContextLoaderListener 12 | 13 | 14 | 15 | dispatcher 16 | org.springframework.web.servlet.DispatcherServlet 17 | 18 | 1 19 | 20 | 21 | 22 | default 23 | *.eot 24 | 25 | 26 | 27 | default 28 | *.woff 29 | 30 | 31 | 32 | default 33 | *.woff2 34 | 35 | 36 | 37 | default 38 | *.svg 39 | 40 | 41 | 42 | 43 | 44 | default 45 | *.ttf 46 | 47 | 48 | 49 | default 50 | *.css 51 | 52 | 53 | 54 | default 55 | *.gif 56 | 57 | 58 | 59 | 60 | default 61 | *.jpg 62 | 63 | 64 | 65 | default 66 | *.js 67 | 68 | 69 | 70 | default 71 | *.png 72 | 73 | 74 | 75 | 76 | dispatcher 77 | 78 | / 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | /WEB-INF/view/index 89 | 90 | 91 | 92 | 93 | 94 | characterEncodingFilter 95 | org.springframework.web.filter.CharacterEncodingFilter 96 | 97 | encoding 98 | UTF-8 99 | 100 | 101 | forceEncoding 102 | true 103 | 104 | 105 | 106 | characterEncodingFilter 107 | /* 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/laypage.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var a=document,t="getElementById",n="getElementsByTagName",i="laypage",r="layui-disabled",u=function(e){var a=this;a.config=e||{},a.config.index=++s.index,a.render(!0)};u.prototype.type=function(){var e=this.config;if("object"==typeof e.elem)return void 0===e.elem.length?2:3},u.prototype.view=function(){var e=this,a=e.config,t=a.groups="groups"in a?0|a.groups:5;a.layout="object"==typeof a.layout?a.layout:["prev","page","next"],a.count=0|a.count,a.curr=0|a.curr||1,a.limits="object"==typeof a.limits?a.limits:[10,20,30,40,50],a.limit=0|a.limit||10,a.pages=Math.ceil(a.count/a.limit)||1,a.curr>a.pages&&(a.curr=a.pages),t<0?t=1:t>a.pages&&(t=a.pages),a.prev="prev"in a?a.prev:"上一页",a.next="next"in a?a.next:"下一页";var n=a.pages>t?Math.ceil((a.curr+(t>1?1:0))/(t>0?t:1)):1,i={prev:function(){return a.prev?''+a.prev+"":""}(),page:function(){var e=[];if(a.count<1)return"";n>1&&a.first!==!1&&0!==t&&e.push(''+(a.first||1)+"");var i=Math.floor((t-1)/2),r=n>1?a.curr-i:1,u=n>1?function(){var e=a.curr+(t-i-1);return e>a.pages?a.pages:e}():t;for(u-r2&&e.push('');r<=u;r++)r===a.curr?e.push('"+r+""):e.push(''+r+"");return a.pages>t&&a.pages>u&&a.last!==!1&&(u+1…'),0!==t&&e.push(''+(a.last||a.pages)+"")),e.join("")}(),next:function(){return a.next?''+a.next+"":""}(),count:'共 '+a.count+" 条",limit:function(){var e=['"}(),refresh:['','',""].join(""),skip:function(){return['到第','','页',""].join("")}()};return['
',function(){var e=[];return layui.each(a.layout,function(a,t){i[t]&&e.push(i[t])}),e.join("")}(),"
"].join("")},u.prototype.jump=function(e,a){if(e){var t=this,i=t.config,r=e.children,u=e[n]("button")[0],l=e[n]("input")[0],p=e[n]("select")[0],c=function(){var e=0|l.value.replace(/\s|\D/g,"");e&&(i.curr=e,t.render())};if(a)return c();for(var o=0,y=r.length;oi.pages||(i.curr=e,t.render())});p&&s.on(p,"change",function(){var e=this.value;i.curr*e>i.count&&(i.curr=Math.ceil(i.count/e)),i.limit=e,t.render()}),u&&s.on(u,"click",function(){c()})}},u.prototype.skip=function(e){if(e){var a=this,t=e[n]("input")[0];t&&s.on(t,"keyup",function(t){var n=this.value,i=t.keyCode;/^(37|38|39|40)$/.test(i)||(/\D/.test(n)&&(this.value=n.replace(/\D/,"")),13===i&&a.jump(e,!0))})}},u.prototype.render=function(e){var n=this,i=n.config,r=n.type(),u=n.view();2===r?i.elem&&(i.elem.innerHTML=u):3===r?i.elem.html(u):a[t](i.elem)&&(a[t](i.elem).innerHTML=u),i.jump&&i.jump(i,e);var s=a[t]("layui-laypage-"+i.index);n.jump(s),i.hash&&!e&&(location.hash="!"+i.hash+"="+i.curr),n.skip(s)};var s={render:function(e){var a=new u(e);return a.index},index:layui.laypage?layui.laypage.index+1e4:0,on:function(e,a,t){return e.attachEvent?e.attachEvent("on"+a,function(a){a.target=a.srcElement,t.call(e,a)}):e.addEventListener(a,t,!1),this}};e(i,s)}); -------------------------------------------------------------------------------- /src/main/java/server/UserServer.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | import constant.Constant; 4 | import dao.UserDAO; 5 | import entity.DataResult; 6 | import model.Statistics; 7 | import model.User; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | import java.io.File; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | public class UserServer { 16 | 17 | public static DataResult uploadAvatar(MultipartFile file,String userId) throws Exception{ 18 | String name = userId + ".jpg"; 19 | String path = Constant.IMAGE_PATH + "\\avatar"; 20 | file.transferTo(new File(path + File.separator + name)); 21 | return DataResult.success("upload avatar success",null); 22 | } 23 | 24 | public static DataResult getUserList(int page,int limit){ 25 | List> maps = UserDAO.getUserList(page,limit); 26 | List users = new ArrayList<>(); 27 | for(Map map : maps){ 28 | users.add(new User(map)); 29 | } 30 | return DataResult.success("get userlist success",users); 31 | } 32 | 33 | public static DataResult getUserInfoById(String id){ 34 | DataResult dataResult = new DataResult(); 35 | if(!checkUserExist(id)){ 36 | dataResult.setStatus(-1); 37 | dataResult.setMsg("find user fail"); 38 | }else{ 39 | dataResult.setStatus(0); 40 | dataResult.setMsg("find user success"); 41 | dataResult.setData(new User(UserDAO.getUserInfoById(id))); 42 | } 43 | return dataResult; 44 | } 45 | 46 | 47 | public static boolean checkUserExist(String id){ 48 | return UserDAO.isUserIdExist(id); 49 | } 50 | 51 | public static DataResult login(String id,String password){ 52 | DataResult dataResult = new DataResult(); 53 | if(!checkUserExist(id)){ 54 | dataResult.setStatus(-1); 55 | dataResult.setMsg("user not exist"); 56 | }else { 57 | User user = new User(UserDAO.getUserInfoById(id)); 58 | if (user.getPassword().equals(password)) { 59 | dataResult.setStatus(0); 60 | dataResult.setMsg("login success"); 61 | dataResult.setData(user); 62 | } else { 63 | dataResult.setStatus(-1); 64 | dataResult.setMsg("login fail"); 65 | } 66 | } 67 | return dataResult; 68 | } 69 | 70 | public static DataResult register(String id,String password,String name){ 71 | DataResult dataResult = new DataResult(); 72 | if(checkUserExist(id)){ 73 | dataResult.setStatus(-1); 74 | dataResult.setMsg("user exist"); 75 | }else{ 76 | UserDAO.addNewUser(id,password,name); 77 | dataResult.setMsg("register success"); 78 | dataResult.setStatus(0); 79 | User user = new User(); 80 | user.setName(id); 81 | user.setPassword(password); 82 | user.setName(name); 83 | dataResult.setData(user); 84 | } 85 | return dataResult; 86 | } 87 | 88 | public static DataResult editBaseInfo(String userId,String name,String desc){ 89 | boolean res = UserDAO.editBaseInfo(userId,name,desc); 90 | if(res){ 91 | return DataResult.success("edit base info success",(User)UserServer.getUserInfoById(userId).getData()); 92 | }else{ 93 | return DataResult.fail("edit base info fail"); 94 | } 95 | } 96 | 97 | public static DataResult setState(String userId,String state){ 98 | boolean res = UserDAO.setUserState(userId,state); 99 | if(res){ 100 | return DataResult.success("set user state success",null); 101 | }else{ 102 | return DataResult.fail("set user state fail"); 103 | } 104 | } 105 | 106 | public static DataResult getStatistics(String userId){ 107 | DataResult dataResult = new DataResult(); 108 | 109 | Statistics statistics = new Statistics(UserDAO.getStatisticsAll(userId)); 110 | 111 | dataResult.setStatus(0); 112 | dataResult.setData(statistics); 113 | 114 | return dataResult; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/my_follow.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 加法还没学 5 | Date: 2019/12/31 6 | Time: 21:37 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | 12 | ${myInfo.name} -我的关注 13 | 14 | 15 | 16 | 17 | 18 | 19 | 49 | 50 | 51 | 52 |
53 | 54 |
55 |
56 |
    57 |
  • 我的关注
  • 58 |
59 |
60 |
61 |
62 | 63 |
64 | 69 | 78 | 82 |
83 |
84 |
85 |
86 | 87 |
88 | 89 |
90 |
91 |
92 | 93 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/photo_upload.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: 52491 5 | Date: 2019/12/11 6 | Time: 19:12 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 24 |
25 |
26 |
27 | 28 |
29 |
30 | 31 |
32 |
${sessionScope.myInfo.name}
33 |
id:${sessionScope.myInfo.id}
34 |
35 | 36 |
37 |
38 | 39 |
40 | 46 |
47 | 48 |
49 | 50 |
51 | 预览图: 52 |
53 |
54 |
55 | 56 | 57 |
58 |
59 | 60 | 61 |
62 |
63 | 64 | 65 |
66 | 67 | 108 | 109 |
110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/album_create.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/11 5 | Time: 19:12 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 创建相册 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 24 |
25 |
26 |
27 | 28 |
29 |
30 | 31 |
32 |
${sessionScope.myInfo.name}
33 |
id:${sessionScope.myInfo.id}
34 |
35 | 36 |
37 |
38 |
39 | 40 |
41 | 42 |
43 |
44 | 45 | 46 |
47 | 55 |
56 | 57 |
58 | 59 |
60 | 61 | 62 | 63 |
64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 |
72 | 73 |
74 |
75 | 76 | 77 |
78 |
79 | 80 | 81 |
82 | 83 | 118 | 119 |
120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/main/java/controller/MeController.java: -------------------------------------------------------------------------------- 1 | package controller; 2 | 3 | import entity.DataResult; 4 | import model.*; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.multipart.MultipartFile; 11 | import server.*; 12 | 13 | import javax.servlet.http.HttpSession; 14 | import java.util.List; 15 | 16 | @Controller 17 | @RequestMapping("/me") 18 | public class MeController { 19 | @RequestMapping("/info") 20 | public String enterMyInfo(HttpSession session,Model model){ 21 | User user = (User)session.getAttribute("myInfo"); 22 | model.addAttribute("myInfo",user); 23 | return "my_info"; 24 | } 25 | 26 | @RequestMapping("/albums") 27 | public String enterMyAlbums(HttpSession session,Model model){ 28 | User user = (User)session.getAttribute("myInfo"); 29 | model.addAttribute("myInfo",user); 30 | return "my_albums"; 31 | } 32 | 33 | @RequestMapping("/photos") 34 | public String enterMyPhotos(HttpSession session,Model model){ 35 | User user = (User)session.getAttribute("myInfo"); 36 | List albumList= (List)AlbumServer.getAlbumInfoListByUserId(user.getId()).getData(); 37 | model.addAttribute("myInfo",user); 38 | model.addAttribute("albumList",albumList); 39 | return "my_photos"; 40 | } 41 | 42 | @RequestMapping("/follow") 43 | public String enterMyFollows(HttpSession session,Model model){ 44 | User user = (User)session.getAttribute("myInfo"); 45 | 46 | List FollowList = (List) FollowServer.getFollowInfoById(user.getId()).getData(); 47 | 48 | model.addAttribute("followList",FollowList); 49 | return "my_follow"; 50 | } 51 | 52 | 53 | @RequestMapping("/messages") 54 | public String enterMyMessages(HttpSession session,Model model){ 55 | User user = (User)session.getAttribute("myInfo"); 56 | List reciveMessageList=(List) MessageServer.getMessageBytoId(user.getId()).getData(); 57 | ListsendMessageList=(List)MessageServer.getMessageByfromId(user.getId()).getData(); 58 | model.addAttribute("myInfo",user); 59 | model.addAttribute("reciveMessageList",reciveMessageList); 60 | model.addAttribute("sendMessageList",sendMessageList); 61 | return "my_messages"; 62 | } 63 | 64 | @RequestMapping("/editInfo") 65 | @ResponseBody 66 | public DataResult sumbitEditInfo(@RequestParam("name")String name, 67 | @RequestParam("desc")String desc, HttpSession session){ 68 | User user = (User)session.getAttribute("myInfo"); 69 | DataResult dataResult = UserServer.editBaseInfo(user.getId(),name,desc); 70 | if(dataResult.getStatus() == 0){ 71 | //更新session 72 | session.setAttribute("myInfo",dataResult.getData()); 73 | } 74 | return dataResult; 75 | } 76 | 77 | @RequestMapping("/changePhotoName") 78 | @ResponseBody 79 | public DataResult changePhotoName(@RequestParam("name")String name,@RequestParam("photoId")String photoId){ 80 | return PhotoServer.changePhotoName(name,photoId); 81 | } 82 | 83 | @RequestMapping("/uploadAvatar") 84 | @ResponseBody 85 | public DataResult uploadAvatar (@RequestParam("file") MultipartFile file,HttpSession session) throws Exception{ 86 | User user = (User)session.getAttribute("myInfo"); 87 | return UserServer.uploadAvatar(file,user.getId()); 88 | } 89 | 90 | @RequestMapping("/getMyAlbum") 91 | @ResponseBody 92 | public DataResult getMyAlbum(@RequestParam("limit")int limit, 93 | @RequestParam("page")int page,HttpSession session){ 94 | User user = (User)session.getAttribute("myInfo"); 95 | return AlbumServer.getAlbumInfoListByUserId(user.getId(),page,limit); 96 | } 97 | 98 | @RequestMapping("/getMyPhoto") 99 | @ResponseBody 100 | public DataResult getMyPhoto(@RequestParam("limit")int limit, 101 | @RequestParam("page")int page,@RequestParam("albumId")String albumId,HttpSession session){ 102 | User user = (User)session.getAttribute("myInfo"); 103 | return AlbumServer.getPhotoInfoListByAlbumId(albumId,page,limit); 104 | } 105 | 106 | @RequestMapping("/mysta") 107 | public String getStatistics(Model model,HttpSession session){ 108 | User user = (User)session.getAttribute("myInfo"); 109 | Statistics statistics = (Statistics) UserServer.getStatistics(user.getId()).getData(); 110 | model.addAttribute("mystatis",statistics); 111 | return "my_statistics"; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/album_edit.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/11 5 | Time: 19:12 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | ${album.name}|${album.category} -编辑相册 13 | 14 | 15 | 16 | 17 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | 32 |
33 |
34 | 35 |
36 |
${sessionScope.myInfo.name}
37 |
id:${sessionScope.myInfo.id}
38 |
39 | 40 |
41 |
42 |
43 | 44 |
45 | 46 |
47 |
48 | 49 | 50 |
51 | 59 |
60 | 61 |
62 | 63 |
64 | 65 | 66 |
67 |
68 | 69 |
70 | 71 |
72 | 73 |
74 |
75 | 76 |
77 |
78 | 79 | 80 |
81 |
82 | 83 | 84 |
85 | 86 | 122 | 123 |
124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /src/main/java/dao/AlbumDAO.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import constant.Constant; 4 | import util.DateHelper; 5 | import util.ShortUUID; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class AlbumDAO { 11 | 12 | public static List> getAlbumInfoListAll(){ 13 | return JDBCDAO.select(String.format("SELECT * FROM album ")); 14 | } 15 | 16 | public static List> getAlbumInfoListAll(int page,int limit){ 17 | int pre = limit*(page-1); 18 | return JDBCDAO.select(String.format("SELECT TOP %d * FROM album WHERE id NOT IN (SELECT TOP %d id FROM album)",limit,pre)); 19 | } 20 | 21 | public static List> getAlbumInfoListByUserId(String userId){ 22 | return JDBCDAO.select(String.format("SELECT * FROM album WHERE user_id = '%s'",userId)); 23 | } 24 | 25 | //有分页 26 | public static List> getAlbumInfoListByUserId(String userId,int page,int limit){ 27 | int pre = limit*(page - 1); 28 | //沙雕sqlserver 没有LIMIT 29 | String sql = String.format("SELECT TOP %d * FROM album WHERE id NOT IN (SELECT TOP %d id FROM album WHERE user_id = '%s' ORDER BY create_time DESC ) " + 30 | "AND user_id = '%s' ORDER BY create_time DESC ",limit,pre,userId,userId); 31 | //System.out.println(sql); 32 | return JDBCDAO.select(sql); 33 | } 34 | 35 | public static List> getPhotoInfoListByAlbumId(String albumId){ 36 | return JDBCDAO.select(String.format("SELECT * FROM photo WHERE id IN (SELECT photo_id FROM store WHERE album_id = '%s')",albumId)); 37 | } 38 | 39 | // 沙雕sqlserver *2 40 | public static List> getPhotoInfoListByAlbumId(String albumId,int page,int limit){ 41 | int pre = limit*(page - 1); 42 | String sql = String.format("SELECT TOP %d * FROM photo WHERE id IN (SELECT photo_id FROM store WHERE album_id = '%s') " + 43 | "AND id NOT IN ( SELECT TOP %d id FROM photo WHERE id IN (SELECT photo_id FROM store WHERE album_id = '%s') )" + 44 | "ORDER BY create_time DESC ",limit,albumId,pre,albumId); 45 | System.out.println(sql); 46 | return JDBCDAO.select(sql); 47 | } 48 | 49 | public static List> getPhotoInfoListByAlbumId(String albumId,String order){ 50 | String o = ""; 51 | switch (order){ 52 | case Constant.ORDER_DEFAULT: 53 | break; 54 | case Constant.ORDER_DATE_DESC: 55 | o = "ORDER BY CONVERT(DATETIME,create_time) DESC"; 56 | break; 57 | case Constant.ORDER_DATE_ASC: 58 | o = "ORDER BY CONVERT(DATETIME,create_time) ASC"; 59 | break; 60 | } 61 | return JDBCDAO.select(String.format("SELECT * FROM photo WHERE id IN (SELECT photo_id FROM store WHERE album_id = '%s') %s",albumId,o)); 62 | } 63 | 64 | public static Map getAlbumInfoById(String albumId){ 65 | return JDBCDAO.select(String.format("SELECT * FROM album WHERE id = '%s'",albumId)).get(0); 66 | } 67 | 68 | public static String createNewAlbum(String userId,String albumName,String albumDescp,String category){ 69 | String albumId = ShortUUID.generateShortUuid(); 70 | String curDate = DateHelper.getCurrentDate(); 71 | boolean res = JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO album VALUES('%s','%s','%s','%s','%s','%s','%s',%s,'%s')", 72 | albumId,albumName,userId,curDate,"default.jpg",albumDescp,"normal","0",category)); 73 | if(res){ 74 | return albumId; 75 | }else { 76 | return null; 77 | } 78 | } 79 | 80 | public static boolean editAlbumBaseInfo(String albumId,String albumName,String albumDescp,String category){ 81 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE album SET album_name = '%s',descp = '%s',category = '%s' WHERE id = '%s'" 82 | ,albumName,albumDescp,category,albumId)); 83 | } 84 | 85 | public static boolean delAlbum(String albumId){ 86 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("DELETE album WHERE id = '%s'",albumId)); 87 | } 88 | 89 | 90 | public static boolean uploadPhotoToAlbum(String photoId,String albumId){ 91 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("INSERT INTO store VALUES('%s','%s')",photoId,albumId)); 92 | } 93 | 94 | public static boolean setCover(String albumId,String photoId){ 95 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE album SET cover_id = '%s' WHERE id = '%s'",photoId,albumId)); 96 | } 97 | 98 | public static boolean setState(String albumId,String state){ 99 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE album SET album_state = '%s' WHERE id = '%s'",state,albumId)); 100 | } 101 | 102 | public static boolean addPraise(String albumId){ 103 | return JDBCDAO.insertOrDeleteOrUpdate(String.format("UPDATE album SET praise_count = praise_count + 1 WHERE id = '%s'",albumId)); 104 | } 105 | 106 | public static boolean isAlbumExist(String albumId){ 107 | List> res = JDBCDAO.select(String.format("SELECT * FROM album WHERE id = '%s'",albumId)); 108 | return !(res.size()==0); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/album_list.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/10 5 | Time: 15:41 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | 12 | 13 | 相册列表 14 | 15 | 16 | 17 | 18 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 | 54 |
55 |
56 | 57 | 58 |
59 |
60 | <%--到底传id还是直接传url好呢--%> 61 | 62 |
63 |
64 |
${album.name}[${album.category}]
65 |
${album.descp}
66 |
${album.praiseCount}
67 |
68 |
69 | 70 |
71 | 72 |
73 |
74 |
上传者:${album.userId}
75 |
${album.createTime}
76 |
77 |
78 |
79 | 80 |
81 |
82 | <%--到底传id还是直接传url好呢--%> 83 | 84 |
85 |
86 |
${album.name}[${album.category}]
87 |
${album.descp}
88 |
${album.praiseCount}
89 |
90 |
91 | 92 |
93 | 94 |
95 |
96 |
上传者:${album.userId}
97 |
${album.createTime}
98 |
99 |
100 |
101 |
102 |
103 |
104 | 105 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/transfer.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define(["laytpl","form"],function(e){"use strict";var a=layui.$,t=layui.laytpl,n=layui.form,i="transfer",l={config:{},index:layui[i]?layui[i].index+1e4:0,set:function(e){var t=this;return t.config=a.extend({},t.config,e),t},on:function(e,a){return layui.onevent.call(this,i,e,a)}},r=function(){var e=this,a=e.config,t=a.id||e.index;return r.that[t]=e,r.config[t]=a,{config:a,reload:function(a){e.reload.call(e,a)},getData:function(){return e.getData.call(e)}}},c="layui-hide",o="layui-btn-disabled",d="layui-none",s="layui-transfer-box",u="layui-transfer-header",h="layui-transfer-search",f="layui-transfer-active",y="layui-transfer-data",p=function(e){return e=e||{},['
','
','","
","{{# if(d.data.showSearch){ }}",'","{{# } }}",'
    ',"
    "].join("")},v=['
    ',p({index:0,checkAllName:"layTransferLeftCheckAll"}),'
    ','",'","
    ",p({index:1,checkAllName:"layTransferRightCheckAll"}),"
    "].join(""),x=function(e){var t=this;t.index=++l.index,t.config=a.extend({},t.config,l.config,e),t.render()};x.prototype.config={title:["列表一","列表二"],width:200,height:360,data:[],value:[],showSearch:!1,id:"",text:{none:"无数据",searchNone:"无匹配数据"}},x.prototype.reload=function(e){var t=this;layui.each(e,function(e,a){a.constructor===Array&&delete t.config[e]}),t.config=a.extend(!0,{},t.config,e),t.render()},x.prototype.render=function(){var e=this,n=e.config,i=e.elem=a(t(v).render({data:n,index:e.index})),l=n.elem=a(n.elem);l[0]&&(n.data=n.data||[],n.value=n.value||[],e.key=n.id||e.index,l.html(e.elem),e.layBox=e.elem.find("."+s),e.layHeader=e.elem.find("."+u),e.laySearch=e.elem.find("."+h),e.layData=i.find("."+y),e.layBtn=i.find("."+f+" .layui-btn"),e.layBox.css({width:n.width,height:n.height}),e.layData.css({height:function(){return n.height-e.layHeader.outerHeight()-e.laySearch.outerHeight()-2}()}),e.renderData(),e.events())},x.prototype.renderData=function(){var e=this,a=(e.config,[{checkName:"layTransferLeftCheck",views:[]},{checkName:"layTransferRightCheck",views:[]}]);e.parseData(function(e){var t=e.selected?1:0,n=["
  • ",'',"
  • "].join("");a[t].views.push(n),delete e.selected}),e.layData.eq(0).html(a[0].views.join("")),e.layData.eq(1).html(a[1].views.join("")),e.renderCheckBtn()},x.prototype.renderForm=function(e){n.render(e,"LAY-transfer-"+this.index)},x.prototype.renderCheckBtn=function(e){var t=this,n=t.config;e=e||{},t.layBox.each(function(i){var l=a(this),r=l.find("."+y),d=l.find("."+u).find('input[type="checkbox"]'),s=r.find('input[type="checkbox"]'),h=0,f=!1;if(s.each(function(){var e=a(this).data("hide");(this.checked||this.disabled||e)&&h++,this.checked&&!e&&(f=!0)}),d.prop("checked",f&&h===s.length),t.layBtn.eq(i)[f?"removeClass":"addClass"](o),!e.stopNone){var p=r.children("li:not(."+c+")").length;t.noneView(r,p?"":n.text.none)}}),t.renderForm("checkbox")},x.prototype.noneView=function(e,t){var n=a('

    '+(t||"")+"

    ");e.find("."+d)[0]&&e.find("."+d).remove(),t.replace(/\s/g,"")&&e.append(n)},x.prototype.setValue=function(){var e=this,t=e.config,n=[];return e.layBox.eq(1).find("."+y+' input[type="checkbox"]').each(function(){var e=a(this).data("hide");e||n.push(this.value)}),t.value=n,e},x.prototype.parseData=function(e){var t=this,n=t.config,i=[];return layui.each(n.data,function(t,l){l=("function"==typeof n.parseData?n.parseData(l):l)||l,i.push(l=a.extend({},l)),layui.each(n.value,function(e,a){a==l.value&&(l.selected=!0)}),e&&e(l)}),n.data=i,t},x.prototype.getData=function(e){var a=this,t=a.config,n=[];return a.setValue(),layui.each(e||t.value,function(e,a){layui.each(t.data,function(e,t){delete t.selected,a==t.value&&n.push(t)})}),n},x.prototype.events=function(){var e=this,t=e.config;e.elem.on("click",'input[lay-filter="layTransferCheckbox"]+',function(){var t=a(this).prev(),n=t[0].checked,i=t.parents("."+s).eq(0).find("."+y);t[0].disabled||("all"===t.attr("lay-type")&&i.find('input[type="checkbox"]').each(function(){this.disabled||(this.checked=n)}),e.renderCheckBtn({stopNone:!0}))}),e.layBtn.on("click",function(){var n=a(this),i=n.data("index"),l=e.layBox.eq(i),r=[];if(!n.hasClass(o)){e.layBox.eq(i).each(function(t){var n=a(this),i=n.find("."+y);i.children("li").each(function(){var t=a(this),n=t.find('input[type="checkbox"]'),i=n.data("hide");n[0].checked&&!i&&(n[0].checked=!1,l.siblings("."+s).find("."+y).append(t.clone()),t.remove(),r.push(n[0].value)),e.setValue()})}),e.renderCheckBtn();var c=l.siblings("."+s).find("."+h+" input");""===c.val()||c.trigger("keyup"),t.onchange&&t.onchange(e.getData(r),i)}}),e.laySearch.find("input").on("keyup",function(){var n=this.value,i=a(this).parents("."+h).eq(0).siblings("."+y),l=i.children("li");l.each(function(){var e=a(this),t=e.find('input[type="checkbox"]'),i=t[0].title.indexOf(n)!==-1;e[i?"removeClass":"addClass"](c),t.data("hide",!i)}),e.renderCheckBtn();var r=l.length===i.children("li."+c).length;e.noneView(i,r?t.text.searchNone:"")})},r.that={},r.config={},l.reload=function(e,a){var t=r.that[e];return t.reload(a),r.call(t)},l.getData=function(e){var a=r.that[e];return a.getData()},l.render=function(e){var a=new x(e);return r.call(a)},e(i,l)}); -------------------------------------------------------------------------------- /src/main/webapp/static/layui/layui.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;!function(e){"use strict";var t=document,o={modules:{},status:{},timeout:10,event:{}},n=function(){this.v="2.5.5"},r=function(){var e=t.currentScript?t.currentScript.src:function(){for(var e,o=t.scripts,n=o.length-1,r=n;r>0;r--)if("interactive"===o[r].readyState){e=o[r].src;break}return e||o[n].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),i=function(t){e.console&&console.error&&console.error("Layui hint: "+t)},a="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),u={layer:"modules/layer",laydate:"modules/laydate",laypage:"modules/laypage",laytpl:"modules/laytpl",layim:"modules/layim",layedit:"modules/layedit",form:"modules/form",upload:"modules/upload",transfer:"modules/transfer",tree:"modules/tree",table:"modules/table",element:"modules/element",rate:"modules/rate",colorpicker:"modules/colorpicker",slider:"modules/slider",carousel:"modules/carousel",flow:"modules/flow",util:"modules/util",code:"modules/code",jquery:"modules/jquery",mobile:"modules/mobile","layui.all":"../layui.all"};n.prototype.cache=o,n.prototype.define=function(e,t){var n=this,r="function"==typeof e,i=function(){var e=function(e,t){layui[e]=t,o.status[e]=!0};return"function"==typeof t&&t(function(n,r){e(n,r),o.callback[n]=function(){t(e)}}),this};return r&&(t=e,e=[]),!layui["layui.all"]&&layui["layui.mobile"]?i.call(n):(n.use(e,i),n)},n.prototype.use=function(e,n,l){function s(e,t){var n="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||n.test((e.currentTarget||e.srcElement).readyState))&&(o.modules[f]=t,d.removeChild(v),function r(){return++m>1e3*o.timeout/4?i(f+" is not a valid module"):void(o.status[f]?c():setTimeout(r,4))}())}function c(){l.push(layui[f]),e.length>1?y.use(e.slice(1),n,l):"function"==typeof n&&n.apply(layui,l)}var y=this,p=o.dir=o.dir?o.dir:r,d=t.getElementsByTagName("head")[0];e="string"==typeof e?[e]:e,window.jQuery&&jQuery.fn.on&&(y.each(e,function(t,o){"jquery"===o&&e.splice(t,1)}),layui.jquery=layui.$=jQuery);var f=e[0],m=0;if(l=l||[],o.host=o.host||(p.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===e.length||layui["layui.all"]&&u[f]||!layui["layui.all"]&&layui["layui.mobile"]&&u[f])return c(),y;if(o.modules[f])!function g(){return++m>1e3*o.timeout/4?i(f+" is not a valid module"):void("string"==typeof o.modules[f]&&o.status[f]?c():setTimeout(g,4))}();else{var v=t.createElement("script"),h=(u[f]?p+"lay/":/^\{\/\}/.test(y.modules[f])?"":o.base||"")+(y.modules[f]||f)+".js";h=h.replace(/^\{\/\}/,""),v.async=!0,v.charset="utf-8",v.src=h+function(){var e=o.version===!0?o.v||(new Date).getTime():o.version||"";return e?"?v="+e:""}(),d.appendChild(v),!v.attachEvent||v.attachEvent.toString&&v.attachEvent.toString().indexOf("[native code")<0||a?v.addEventListener("load",function(e){s(e,h)},!1):v.attachEvent("onreadystatechange",function(e){s(e,h)}),o.modules[f]=h}return y},n.prototype.getStyle=function(t,o){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](o)},n.prototype.link=function(e,n,r){var a=this,u=t.createElement("link"),l=t.getElementsByTagName("head")[0];"string"==typeof n&&(r=n);var s=(r||e).replace(/\.|\//g,""),c=u.id="layuicss-"+s,y=0;return u.rel="stylesheet",u.href=e+(o.debug?"?v="+(new Date).getTime():""),u.media="all",t.getElementById(c)||l.appendChild(u),"function"!=typeof n?a:(function p(){return++y>1e3*o.timeout/100?i(e+" timeout"):void(1989===parseInt(a.getStyle(t.getElementById(c),"width"))?function(){n()}():setTimeout(p,100))}(),a)},o.callback={},n.prototype.factory=function(e){if(layui[e])return"function"==typeof o.callback[e]?o.callback[e]:null},n.prototype.addcss=function(e,t,n){return layui.link(o.dir+"css/"+e,t,n)},n.prototype.img=function(e,t,o){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,"function"==typeof t&&t(n)},void(n.onerror=function(e){n.onerror=null,"function"==typeof o&&o(e)}))},n.prototype.config=function(e){e=e||{};for(var t in e)o[t]=e[t];return this},n.prototype.modules=function(){var e={};for(var t in u)e[t]=u[t];return e}(),n.prototype.extend=function(e){var t=this;e=e||{};for(var o in e)t[o]||t.modules[o]?i("模块名 "+o+" 已被占用"):t.modules[o]=e[o];return t},n.prototype.router=function(e){var t=this,e=e||location.hash,o={path:[],search:{},hash:(e.match(/[^#](#.*$)/)||[])[1]||""};return/^#\//.test(e)?(e=e.replace(/^#\//,""),o.href="/"+e,e=e.replace(/([^#])(#.*$)/,"$1").split("/")||[],t.each(e,function(e,t){/^\w+=/.test(t)?function(){t=t.split("="),o.search[t[0]]=t[1]}():o.path.push(t)}),o):o},n.prototype.data=function(t,o,n){if(t=t||"layui",n=n||localStorage,e.JSON&&e.JSON.parse){if(null===o)return delete n[t];o="object"==typeof o?o:{key:o};try{var r=JSON.parse(n[t])}catch(i){var r={}}return"value"in o&&(r[o.key]=o.value),o.remove&&delete r[o.key],n[t]=JSON.stringify(r),o.key?r[o.key]:r}},n.prototype.sessionData=function(e,t){return this.data(e,t,sessionStorage)},n.prototype.device=function(t){var o=navigator.userAgent.toLowerCase(),n=function(e){var t=new RegExp(e+"/([^\\s\\_\\-]+)");return e=(o.match(t)||[])[1],e||!1},r={os:function(){return/windows/.test(o)?"windows":/linux/.test(o)?"linux":/iphone|ipod|ipad|ios/.test(o)?"ios":/mac/.test(o)?"mac":void 0}(),ie:function(){return!!(e.ActiveXObject||"ActiveXObject"in e)&&((o.match(/msie\s(\d+)/)||[])[1]||"11")}(),weixin:n("micromessenger")};return t&&!r[t]&&(r[t]=n(t)),r.android=/android/.test(o),r.ios="ios"===r.os,r},n.prototype.hint=function(){return{error:i}},n.prototype.each=function(e,t){var o,n=this;if("function"!=typeof t)return n;if(e=e||[],e.constructor===Object){for(o in e)if(t.call(e[o],o,e[o]))break}else for(o=0;oi?1:r photoList = (List)AlbumServer.getPhotoInfoListByAlbumId(albumId, Constant.ORDER_DATE_ASC).getData(); 37 | Album album = (Album) AlbumServer.getAlbumInfoById(albumId).getData(); 38 | 39 | try { 40 | List albumCommentList = (List) CommentServer.getCommentInfoByAlbumId(albumId).getData(); 41 | model.addAttribute("commentInfo",albumCommentList); 42 | }catch (Exception e){ 43 | e.printStackTrace(); 44 | } 45 | 46 | User user= (User) session.getAttribute("myInfo"); 47 | int res = 0; 48 | if(user!= null){ 49 | if(FollowServer.checkFollow(user.getId(),album.getUserId()).getStatus() == 0){ 50 | res = 1; 51 | } 52 | } 53 | System.out.println("ALBUM FOLLOW:" + res); 54 | model.addAttribute("photoList",photoList); 55 | model.addAttribute("albumInfo",album); 56 | model.addAttribute("isFollow",res); 57 | return new ModelAndView("album_content"); 58 | } 59 | 60 | @RequestMapping("/editAlbum") 61 | public String editAlbum(@RequestParam("albumId")String albumId,Model model){ 62 | Album album = (Album)AlbumServer.getAlbumInfoById(albumId).getData(); 63 | model.addAttribute("album",album); 64 | return "album_edit"; 65 | } 66 | 67 | @RequestMapping("/submitEditAlbum") 68 | @ResponseBody 69 | public DataResult submitEditAlbum(@RequestParam("title")String title,@RequestParam("desc")String desc, 70 | @RequestParam("userId")String userId, @RequestParam("albumId")String albumId,@RequestParam("type")String category){ 71 | return AlbumServer.editAlbumBaseInfo(userId,albumId,title,desc,category); 72 | } 73 | 74 | @RequestMapping("/delAlbum") 75 | @ResponseBody 76 | public DataResult delAlbum(@RequestParam("albumId")String albumId, HttpSession session){ 77 | User user = (User)session.getAttribute("myInfo"); 78 | System.out.println("seesion myInfo:" + user.getId()); 79 | return AlbumServer.delAlbum(user.getId(),albumId); 80 | } 81 | 82 | 83 | //返回json格式的数据 84 | @RequestMapping("/upload") 85 | @ResponseBody 86 | public DataResult upload(@RequestParam("file") MultipartFile[] files, 87 | @RequestParam("albumId")String albumId,HttpSession session) throws Exception{ 88 | User user = (User)session.getAttribute("myInfo"); 89 | String userId = user.getId(); 90 | return AlbumServer.uploadPhoto(files,userId,albumId); 91 | } 92 | 93 | @RequestMapping("/delPhoto") 94 | @ResponseBody 95 | public DataResult delPhotoStore(@RequestParam("albumId")String albumId,@RequestParam("photoId")String photoId,HttpSession session){ 96 | User user = (User)session.getAttribute("myInfo"); 97 | return PhotoServer.delPhotoStore(albumId,photoId); 98 | } 99 | 100 | @RequestMapping("/setCover") 101 | @ResponseBody 102 | public DataResult setCover(@RequestParam("albumId")String albumId,@RequestParam("photoId")String photoId,HttpSession session){ 103 | User user = (User)session.getAttribute("myInfo"); 104 | return AlbumServer.setCover(albumId,photoId); 105 | } 106 | 107 | 108 | @RequestMapping("/addComment") 109 | @ResponseBody 110 | public DataResult addNewComment(@RequestParam("TEXT")String commentText, @RequestParam("AID")String aId,HttpSession session){ 111 | User user= (User) session.getAttribute("myInfo"); 112 | if(user!= null){ 113 | System.out.println("AddComment添加评论"); 114 | String uId = user.getId(); 115 | return CommentServer.addNewComment(uId,aId,commentText); 116 | }else{ 117 | System.out.println("AddComment 未登录"); 118 | DataResult dataResult = new DataResult(); 119 | dataResult.setStatus(2); 120 | dataResult.setMsg("没有登录"); 121 | return dataResult; 122 | } 123 | } 124 | 125 | @RequestMapping("/delcomment") 126 | @ResponseBody 127 | public DataResult delComment(@RequestParam("CID")String cId, @RequestParam("UID")String uId,HttpSession session){ 128 | User user= (User) session.getAttribute("myInfo"); 129 | System.out.println("删除评论!!!!!" + uId + "***" + user.getId()); 130 | if(user!= null && user.getId().equals(uId)){ 131 | System.out.println("DelComment删除评论"); 132 | return CommentServer.delComment(cId); 133 | }else{ 134 | System.out.println("删除无效"); 135 | DataResult dataResult = new DataResult(); 136 | dataResult.setStatus(2); 137 | dataResult.setMsg("没有删除权限"); 138 | return dataResult; 139 | } 140 | } 141 | 142 | @RequestMapping("/addPraise") 143 | @ResponseBody 144 | public DataResult addPraise(@RequestParam("albumId")String albumId){ 145 | return AlbumServer.addAlbumPraise(albumId); 146 | } 147 | 148 | 149 | 150 | } 151 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/my_albums.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/29 5 | Time: 15:48 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | ${myInfo.name} -相册管理 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
    22 | 23 |
    24 |
    25 |
    26 | 27 | 32 | 33 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/admin_manage_users.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/29 5 | Time: 23:52 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | ${myInfo.name} -管理后台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
    21 | 22 |
    23 |
    24 |
    25 |
    26 | 27 | 36 | 37 | 45 | 46 | 47 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/view/my_info.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: 52491 4 | Date: 2019/12/29 5 | Time: 13:25 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | Title 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 | 39 |
    40 |
    41 | 42 |
    43 | 44 |
    45 | 47 |
    48 |
    49 | 50 |
    51 | 52 |
    53 | 55 |
    56 |
    57 | 58 |
    59 | 60 |
    61 | 63 |
    64 |
    65 | 66 |
    67 |
    68 | 69 |
    70 |
    71 |
    72 |
    73 |
    74 |
    75 | <%--头像预览--%> 76 |
    77 | 78 |

    79 |
    80 | 81 | 82 |
    83 |
    84 |
    85 |
    86 |
    87 | 88 | 147 | 148 |
    149 | 150 | 151 | -------------------------------------------------------------------------------- /src/main/webapp/static/layui/lay/modules/slider.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var i=layui.jquery,t={config:{},index:layui.slider?layui.slider.index+1e4:0,set:function(e){var t=this;return t.config=i.extend({},t.config,e),t},on:function(e,i){return layui.onevent.call(this,n,e,i)}},a=function(){var e=this,i=e.config;return{setValue:function(i,t){return e.slide("set",i,t||0)},config:i}},n="slider",l="layui-disabled",s="layui-slider",r="layui-slider-bar",o="layui-slider-wrap",u="layui-slider-wrap-btn",d="layui-slider-tips",v="layui-slider-input",c="layui-slider-input-txt",m="layui-slider-input-btn",p="layui-slider-hover",f=function(e){var a=this;a.index=++t.index,a.config=i.extend({},a.config,t.config,e),a.render()};f.prototype.config={type:"default",min:0,max:100,value:0,step:1,showstep:!1,tips:!0,input:!1,range:!1,height:200,disabled:!1,theme:"#009688"},f.prototype.render=function(){var e=this,t=e.config;if(t.step<1&&(t.step=1),t.maxt.min?a:t.min,t.value[1]=n>t.min?n:t.min,t.value[0]=t.value[0]>t.max?t.max:t.value[0],t.value[1]=t.value[1]>t.max?t.max:t.value[1];var r=Math.floor((t.value[0]-t.min)/(t.max-t.min)*100),v=Math.floor((t.value[1]-t.min)/(t.max-t.min)*100),m=v-r+"%";r+="%",v+="%"}else{"object"==typeof t.value&&(t.value=Math.min.apply(null,t.value)),t.valuet.max&&(t.value=t.max);var m=Math.floor((t.value-t.min)/(t.max-t.min)*100)+"%"}var p=t.disabled?"#c2c2c2":t.theme,f='
    '+(t.tips?'
    ':"")+'
    '+(t.range?'
    ':"")+"
    ",h=i(t.elem),y=h.next("."+s);if(y[0]&&y.remove(),e.elemTemp=i(f),t.range?(e.elemTemp.find("."+o).eq(0).data("value",t.value[0]),e.elemTemp.find("."+o).eq(1).data("value",t.value[1])):e.elemTemp.find("."+o).data("value",t.value),h.html(e.elemTemp),"vertical"===t.type&&e.elemTemp.height(t.height+"px"),t.showstep){for(var g=(t.max-t.min)/t.step,b="",x=1;x
    ')}e.elemTemp.append(b)}if(t.input&&!t.range){var w=i('
    ');h.css("position","relative"),h.append(w),h.find("."+c).children("input").val(t.value),"vertical"===t.type?w.css({left:0,top:-48}):e.elemTemp.css("margin-right",w.outerWidth()+15)}t.disabled?(e.elemTemp.addClass(l),e.elemTemp.find("."+u).addClass(l)):e.slide(),e.elemTemp.find("."+u).on("mouseover",function(){var a="vertical"===t.type?t.height:e.elemTemp[0].offsetWidth,n=e.elemTemp.find("."+o),l="vertical"===t.type?a-i(this).parent()[0].offsetTop-n.height():i(this).parent()[0].offsetLeft,s=l/a*100,r=i(this).parent().data("value"),u=t.setTips?t.setTips(r):r;e.elemTemp.find("."+d).html(u),"vertical"===t.type?e.elemTemp.find("."+d).css({bottom:s+"%","margin-bottom":"20px",display:"inline-block"}):e.elemTemp.find("."+d).css({left:s+"%",display:"inline-block"})}).on("mouseout",function(){e.elemTemp.find("."+d).css("display","none")})},f.prototype.slide=function(e,t,a){var n=this,l=n.config,s=n.elemTemp,f=function(){return"vertical"===l.type?l.height:s[0].offsetWidth},h=s.find("."+o),y=s.next("."+v),g=y.children("."+c).children("input").val(),b=100/((l.max-l.min)/Math.ceil(l.step)),x=function(e,i){e=Math.ceil(e)*b>100?Math.ceil(e)*b:Math.round(e)*b,e=e>100?100:e,h.eq(i).css("vertical"===l.type?"bottom":"left",e+"%");var t=T(h[0].offsetLeft),a=l.range?T(h[1].offsetLeft):0;"vertical"===l.type?(s.find("."+d).css({bottom:e+"%","margin-bottom":"20px"}),t=T(f()-h[0].offsetTop-h.height()),a=l.range?T(f()-h[1].offsetTop-h.height()):0):s.find("."+d).css("left",e+"%"),t=t>100?100:t,a=a>100?100:a;var n=Math.min(t,a),o=Math.abs(t-a);"vertical"===l.type?s.find("."+r).css({height:o+"%",bottom:n+"%"}):s.find("."+r).css({width:o+"%",left:n+"%"});var u=l.min+Math.round((l.max-l.min)*e/100);if(g=u,y.children("."+c).children("input").val(g),h.eq(i).data("value",u),u=l.setTips?l.setTips(u):u,s.find("."+d).html(u),l.range){var v=[h.eq(0).data("value"),h.eq(1).data("value")];v[0]>v[1]&&v.reverse()}l.change&&l.change(l.range?v:u)},T=function(e){var i=e/f()*100/b,t=Math.round(i)*b;return e==f()&&(t=Math.ceil(i)*b),t},w=i(['
    f()&&(r=f());var o=r/f()*100/b;x(o,e),t.addClass(p),s.find("."+d).show(),i.preventDefault()},o=function(){t.removeClass(p),s.find("."+d).hide()};M(r,o)})}),s.on("click",function(e){var t=i("."+u);if(!t.is(event.target)&&0===t.has(event.target).length&&t.length){var a,n="vertical"===l.type?f()-e.clientY+i(this).offset().top:e.clientX-i(this).offset().left;n<0&&(n=0),n>f()&&(n=f());var s=n/f()*100/b;a=l.range?"vertical"===l.type?Math.abs(n-parseInt(i(h[0]).css("bottom")))>Math.abs(n-parseInt(i(h[1]).css("bottom")))?1:0:Math.abs(n-h[0].offsetLeft)>Math.abs(n-h[1].offsetLeft)?1:0:0,x(s,a),e.preventDefault()}}),y.hover(function(){var e=i(this);e.children("."+m).fadeIn("fast")},function(){var e=i(this);e.children("."+m).fadeOut("fast")}),y.children("."+m).children("i").each(function(e){i(this).on("click",function(){g=1==e?g-l.stepl.max?l.max:Number(g)+l.step;var i=(g-l.min)/(l.max-l.min)*100/b;x(i,0)})});var q=function(){var e=this.value;e=isNaN(e)?0:e,e=el.max?l.max:e,this.value=e;var i=(e-l.min)/(l.max-l.min)*100/b;x(i,0)};y.children("."+c).children("input").on("keydown",function(e){13===e.keyCode&&(e.preventDefault(),q.call(this))}).on("change",q)},f.prototype.events=function(){var e=this;e.config},t.render=function(e){var i=new f(e);return a.call(i)},e(n,t)}); --------------------------------------------------------------------------------