湖南省建设厅假网站,建设网站的命令,做网站内容图片多大,wordpress上传过大锋哥原创的SpringbootLayui python222网站实战#xff1a;
python222网站实战课程视频教程#xff08;SpringBootPython爬虫实战#xff09; ( 火爆连载更新中... )_哔哩哔哩_bilibilipython222网站实战课程视频教程#xff08;SpringBootPython爬虫实战#xff09; ( 火…锋哥原创的SpringbootLayui python222网站实战
python222网站实战课程视频教程SpringBootPython爬虫实战 ( 火爆连载更新中... )_哔哩哔哩_bilibilipython222网站实战课程视频教程SpringBootPython爬虫实战 ( 火爆连载更新中... )共计23条视频包括python222网站实战课程视频教程SpringBootPython爬虫实战 ( 火爆连载更新中... )、第2讲 架构搭建实现、第3讲 页面系统属性动态化设计实现等UP主更多精彩视频请关注UP账号。https://www.bilibili.com/video/BV1yX4y1a7qM/
我们有些文章比如自我介绍帖子vip课程帖子这种区别于正常发文文章的帖子我们可以单独管理设计成自定义帖子模块。
新建t_post表
create table t_post (id int (11),title varchar (600),content text
);
insert into t_post (id, title, content) values(2,2,NULL);
insert into t_post (id, title, content) values(3,3,p222/p\n);
insert into t_post (id, title, content) values(5,4测试444,p32324444img alt\\ src\/articleImages/20230615120852.jpg\ style\height:1372px; width:720px\ //p\n);用Mybatis-X生成代码
新建PostAdminController类
package com.python222.controller.admin;import com.python222.entity.Post;
import com.python222.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** 管理员-自定义帖子控制器* author python222小锋老师* site www.python222.com*/
RestController
RequestMapping(value /admin/post)
public class PostAdminController {Autowiredprivate PostService postService;/*** 根据条件查询自定义帖子* return* throws Exception*/RequestMapping(value /list)public MapString,Object list()throws Exception{MapString, Object resultMap new HashMap();ListPost postListpostService.list();resultMap.put(code, 0);resultMap.put(data, postList);return resultMap;}/*** 添加或者修改自定义帖子* param post* return*/RequestMapping(/save)public MapString,Object save(Post post){if(post.getId()null){postService.save(post);}else{postService.updateById(post);}MapString, Object resultMap new HashMap();resultMap.put(success, true);return resultMap;}/*** 删除自定义帖子* param id* return* throws Exception*/RequestMapping(/delete)public MapString,Object delete(Integer id)throws Exception{MapString, Object resultMap new HashMap();postService.removeById(id);resultMap.put(success, true);return resultMap;}/*** 根据id查询自定义帖子实体* param id* return* throws Exception*/RequestMapping(/findById)public MapString,Object findById(Integer id)throws Exception{MapString, Object resultMap new HashMap();Post postpostService.getById(id);resultMap.put(post, post);resultMap.put(success, true);return resultMap;}}
前端postManage.html
!DOCTYPE html
html
head
meta charsetUTF-8
title自定义帖子管理/title
link relstylesheet href/static/layui/css/layui.css/link
link relstylesheet href/static/css/css.css/link
/head
bodydiv stylepadding: 20pxspan classlayui-breadcrumba首页/aacite自定义帖子管理/cite/a/spandiv stylepadding-top: 20px;divdivbutton classlayui-btn layuiadmin-btn-list data-typebatchdel onclickaddPost()添加/button/div/divdivtable width100% idpostListTable /table/div/div
/divscript src/static/layui/layui.js/script
script src/static/js/jquery.js/script
script src/static/js/common.js/script
script typetext/javascriptlayui.use([element,form,table], function(){var formlayui.form;var element layui.element; //导航的hover效果、二级菜单等功能需要依赖element模块$ layui.jquery; // 使用jquerytable layui.table;table.render({elem: #postListTable,url:/admin/post/list,cols: [[{type:checkbox},{field:id, width:100,title: 编号},{field:title, title: 自定义帖子名称},{field:action, width:300, title: 操作,align:center,templet:formatAction}]],page: true});});function deleteOne(id){layer.confirm(您确定要删除这条记录吗, {title:系统提示,btn: [确定,取消] //按钮}, function(){layer.closeAll(dialog);$.post(/admin/post/delete,{id:id},function(result){if(result.success){layer.msg(删除成功);table.reload(postListTable,{});}else{layer.msg(删除失败请联系管理员);}},json);}, function(){});}function addPost(){layer.open({type: 2,title: 添加自定义帖子,area: [1000px, 730px],content: /admin/savePost.html //iframe的url});}function modifyPost(id){layer.open({type: 2,title: 修改自定义帖子,area: [1000px, 730px],content: /admin/savePost.html?idid //iframe的url});}function formatAction(d){return a classlayui-btn layui-btn-danger layui-btn-xs target_blank href/post/d.idi classlayui-icon layui-icon-read/i帖子预览/abutton classlayui-btn layui-btn-normal layui-btn-xs onclickmodifyPost(d.id)i classlayui-icon layui-icon-edit/i编辑/buttonbutton classlayui-btn layui-btn-warm layui-btn-xs onclickdeleteOne(d.id)i classlayui-icon layui-icon-delete /i删除/button;}/script
/body
/html再新建一个savePost.html
!DOCTYPE html
html
head
meta charsetUTF-8
title添加或者修改自定义帖子/title
link relstylesheet href/static/layui/css/layui.css/link
style typetext/csstable tr td{padding: 10px;}/style
/head
body
div stylepadding: 20pxform methodposttabletrtd标题/tdtdinput typetext autocompleteoff idtitle nametitle classlayui-input stylewidth: 360px//td/trtrtd valigntop内容/tdtdtextarea typetext classckeditor idcontent namecontent classlayui-input /textarea/td/trtrtdbutton classlayui-btn onclicksubmitData();return false;提交/button/tdtdfont iderrorInfo colorred/font/td/tr/table/form
/div
script src/static/ckeditor/ckeditor.js/script
script src/static/layui/layui.js/script
script src/static/js/jquery.js/script
script src/static/js/common.js/script
script typetext/javascriptlayui.use([form], function(){});function submitData(){var title$(#title).val().trim();var contentCKEDITOR.instances.content.getData();if(title) {$(#errorInfo).text(请输入自定义帖子标题);$(#name).focus();return false;}if(content) {$(#errorInfo).text(请输入自定义帖子内容);$(#url).focus();return false;}var idgetQueryVariable(id);if(id){$.post(/admin/post/save,{id:id,title:title,content:content},function(result){if(result.success){layer.alert(修改成功,function () {parent.reloadPage();});}else{$(#errorInfo).text(result.errorInfo);}},json);}else{$.post(/admin/post/save,{title:title,content:content},function(result){if(result.success){layer.alert(添加成功,function () {parent.reloadPage();});}else{$(#errorInfo).text(result.errorInfo);}},json);}}function getQueryVariable(variable){var query window.location.search.substring(1);var vars query.split();for (var i0;ivars.length;i) {var pair vars[i].split();if(pair[0] variable){return pair[1];}}return(false);}$(function(){var idgetQueryVariable(id);if(id){$.post(/admin/post/findById,{id:id},function(result){if(result.success){var postresult.post;$(#title).val(post.title);CKEDITOR.instances.content.setData(post.content);}else{layer.alert(服务器加载有问题请联系管理员);}},json);}});/script
/body
/html自定义帖子详情查看
新建PostController类
package com.python222.controller;import com.python222.entity.Post;
import com.python222.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;/*** 自定义帖子控制器* author python222小锋老师* site www.python222.com*/
Controller
RequestMapping(/post)
public class PostController {Autowiredprivate PostService postService;/*** 根据id查询自定义帖子详细信息* param id* return* throws Exception*/RequestMapping(/{id})public ModelAndView view(PathVariable(id)Integer id)throws Exception{ModelAndView mavnew ModelAndView();Post post postService.getById(id);mav.setViewName(post);mav.addObject(post,post);return mav;}}
前端新建模板post.html
!DOCTYPE html
html xmlns:thhttp://www.thymeleaf.org
head
meta http-equivContent-Type contenttext/html; charsetutf-8 /
title th:text${post.title}-${application.propertyMap[k1]}/title
meta namekeywords th:content${post.title}
meta namedescription th:content${post.title}
link href/systemImages/favicon.ico relSHORTCUT ICON
link relstylesheet href/static/layui/css/layui.css/
link relstylesheet href/static/css/css.css/
link relstylesheet typetext/css href/static/css/normalize.css /
link relstylesheet href/static/css/font-awesome.min.css/head
bodydiv classheader_top th:includecommon/head::#h /div classheader th:includecommon/menu::#m /div classmain_wrapperdiv classw1220 article_contentdiv classtitle th:text${post.title}/divdiv classcontent th:utext${post.content}/div/div/divdiv classfooter th:includecommon/footer::#f //body
/html