当前位置:   article > 正文

python222网站实战(SpringBoot+SpringSecurity+MybatisPlus+thymeleaf+layui)-系统属性管理实现

python222网站实战(SpringBoot+SpringSecurity+MybatisPlus+thymeleaf+layui)-系统属性管理实现

锋哥原创的Springboot+Layui python222网站实战:

python222网站实战课程视频教程(SpringBoot+Python爬虫实战) ( 火爆连载更新中... )_哔哩哔哩_bilibilipython222网站实战课程视频教程(SpringBoot+Python爬虫实战) ( 火爆连载更新中... )共计23条视频,包括:python222网站实战课程视频教程(SpringBoot+Python爬虫实战) ( 火爆连载更新中... )、第2讲 架构搭建实现、第3讲 页面系统属性动态化设计实现等,UP主更多精彩视频,请关注UP账号。icon-default.png?t=N7T8https://www.bilibili.com/video/BV1yX4y1a7qM/

新建PropertyAdminController 类

  1. package com.python222.controller.admin;
  2. import com.python222.entity.Property;
  3. import com.python222.service.PropertyService;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. /**
  11. * 管理员-系统属性控制器
  12. * @author Administrator
  13. *
  14. */
  15. @RestController
  16. @RequestMapping(value = "/admin/property")
  17. public class PropertyAdminController {
  18. @Autowired
  19. private PropertyService propertyService;
  20. /**
  21. * 根据条件分页查询系统属性
  22. * @return
  23. * @throws Exception
  24. */
  25. @RequestMapping(value = "/list")
  26. public Map<String,Object> list()throws Exception{
  27. Map<String, Object> resultMap = new HashMap<>();
  28. List<Property> propertyList=propertyService.list();
  29. resultMap.put("code", 0);
  30. resultMap.put("data", propertyList);
  31. return resultMap;
  32. }
  33. /**
  34. *修改系统属性
  35. * @param property
  36. * @return
  37. */
  38. @RequestMapping("/update")
  39. public Map<String,Object> update(Property property)throws Exception{
  40. propertyService.updateById(property);
  41. Map<String, Object> resultMap = new HashMap<>();
  42. resultMap.put("success", true);
  43. return resultMap;
  44. }
  45. /**
  46. * 根据id查询系统属性实体
  47. * @param id
  48. * @return
  49. * @throws Exception
  50. */
  51. @RequestMapping("/findById")
  52. public Map<String,Object> findById(Integer id)throws Exception{
  53. Map<String, Object> resultMap = new HashMap<>();
  54. Property property=propertyService.getById(id);
  55. resultMap.put("property", property);
  56. resultMap.put("success", true);
  57. return resultMap;
  58. }
  59. }

propertyManage.html

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>系统属性管理</title>
  6. <link rel="stylesheet" href="/static/layui/css/layui.css"></link>
  7. <link rel="stylesheet" href="/static/css/css.css"></link>
  8. </head>
  9. <body>
  10. <div style="padding: 20px">
  11. <span class="layui-breadcrumb">
  12. <a>首页</a>
  13. <a><cite>系统属性管理</cite></a>
  14. </span>
  15. <div style="padding-top: 20px;">
  16. <div>
  17. <table width="100%" id="linkListTable" ></table>
  18. </div>
  19. </div>
  20. </div>
  21. <script src="/static/layui/layui.js"></script>
  22. <script src="/static/js/jquery.js"></script>
  23. <script src="/static/js/common.js"></script>
  24. <script type="text/javascript">
  25. layui.use(['element','form','table'], function(){
  26. var form=layui.form;
  27. var element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
  28. $ = layui.jquery; // 使用jquery
  29. table = layui.table;
  30. table.render({
  31. elem: '#linkListTable'
  32. ,url:'/admin/property/list'
  33. ,cols: [[
  34. {type:'checkbox'}
  35. ,{field:'id', width:100,title: '编号'}
  36. ,{field:'k', width:150,title: '系统属性key'}
  37. ,{field:'v', width:500,title: '系统属性值'}
  38. ,{field:'remark', title: '描述',align:'center'}
  39. ,{field:'action', width:150, title: '操作',align:'center',templet:formatAction}
  40. ]]
  41. });
  42. });
  43. function modifyLink(id){
  44. layer.open({
  45. type: 2,
  46. title: '修改系统属性',
  47. area: ['600px', '700px'],
  48. content: '/admin/updateProperty.html?id='+id //iframe的url
  49. });
  50. }
  51. function formatAction(d){
  52. return "<button class='layui-btn layui-btn-normal layui-btn-xs' onclick='modifyLink("+d.id+")'><i class='layui-icon layui-icon-edit'></i>编辑</button>";
  53. }
  54. </script>
  55. </body>
  56. </html>

updateProperty.html

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>修改系统属性</title>
  6. <link rel="stylesheet" href="/static/layui/css/layui.css"></link>
  7. <style type="text/css">
  8. table tr td{
  9. padding: 10px;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14. <div style="padding: 20px">
  15. <form method="post">
  16. <table>
  17. <tr>
  18. <td>系统属性Key:</td>
  19. <td><input type="text" disabled id="k" name="k" class="layui-input" style="width: 300px"/></td>
  20. </tr>
  21. <tr>
  22. <td>系统属性值:</td>
  23. <td><textarea type="text" id="v" name="v" class="layui-input" style="width: 300px;height: 100px" ></textarea></td>
  24. </tr>
  25. <tr>
  26. <td>系统属性默认值:</td>
  27. <td>
  28. <textarea type="text" id="defaultValue" name="defaultValue" class="layui-input" style="width: 300px;height: 100px" ></textarea></td>
  29. </tr>
  30. <tr>
  31. <td>系统属性描述:</td>
  32. <td>
  33. <textarea type="text" id="remark" name="remark" class="layui-input" style="width: 300px;height: 100px" ></textarea>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td><button class="layui-btn" onclick="submitData();return false;">提交</button></td>
  38. <td><font id="errorInfo" color="red"></font></td>
  39. </tr>
  40. </table>
  41. </form>
  42. </div>
  43. <script src="/static/layui/layui.js"></script>
  44. <script src="/static/js/jquery.js"></script>
  45. <script src="/static/js/common.js"></script>
  46. <script type="text/javascript">
  47. layui.use(['form'], function(){
  48. });
  49. function submitData(){
  50. var v=$("#v").val().trim();
  51. var remark=$("#remark").val().trim();
  52. if(v=="") {
  53.      $("#errorInfo").text("请输入友情链接值!");
  54. $("#v").focus();
  55.       return false;
  56.    }
  57. var id=getQueryVariable("id");
  58. if(id){
  59. $.post("/admin/property/update",{id:id,v:v,remark:remark},function(result){
  60. if(result.success){
  61. layer.alert('修改成功!',function () {
  62. parent.reloadPage();
  63. });
  64. }else{
  65. $("#errorInfo").text(result.errorInfo);
  66. }
  67. },"json");
  68. }
  69. }
  70. function getQueryVariable(variable){
  71. var query = window.location.search.substring(1);
  72. var vars = query.split("&");
  73. for (var i=0;i<vars.length;i++) {
  74. var pair = vars[i].split("=");
  75. if(pair[0] == variable){return pair[1];}
  76. }
  77. return(false);
  78. }
  79. $(function(){
  80.   
  81. var id=getQueryVariable("id");
  82. if(id){
  83. $.post("/admin/property/findById",{id:id},function(result){
  84. if(result.success){
  85. var property=result.property;
  86. $("#k").val(property.k);
  87. $("#v").val(property.v);
  88. $("#defaultValue").val(property.defaultValue);
  89. $("#remark").val(property.remark);
  90. }else{
  91. layer.alert('服务器加载有问题,请联系管理员!');
  92. }
  93. },"json");
  94. }
  95. });
  96. </script>
  97. </body>
  98. </html>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/50002
推荐阅读
相关标签
  

闽ICP备14008679号