YaoShiHang 6 yıl önce
ebeveyn
işleme
4317917edd

+ 40 - 0
src/main/java/com/yc/education/controller/NewsController.java

@@ -0,0 +1,40 @@
+package com.yc.education.controller;
+
+import com.github.pagehelper.PageInfo;
+import com.yc.education.model.News;
+import com.yc.education.service.NewsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 新闻Controller 层
+ *
+ * @author YaoShiHang
+ * @Date 15:58 2018-04-13
+ */
+@RestController
+public class NewsController {
+
+    @Autowired
+    private NewsService newsService;
+
+
+    @RequestMapping(value = "newspage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
+    public PageInfo<News> listNews(@RequestParam(required = false, defaultValue = "0") int page,
+                                   @RequestParam(required = false, defaultValue = "1") int rows) {
+        List<News> newsList = newsService.listAll(page, rows);
+        return new PageInfo<News>(newsList);
+    }
+
+    @RequestMapping(value = "getnews", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
+    public News getNew(long id){
+        return newsService.selectByKey(id);
+    }
+
+}

+ 9 - 12
src/main/java/com/yc/education/controller/admin/AdminsBackController.java

@@ -26,9 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 
 /**
- * 后台——管理员类
- * @author Lock-玄清
- * @date 2017年3月16日 上午9:46:45
+ * 后台 统一操作controller
  */
 @Controller
 @RequestMapping("/admin")
@@ -36,7 +34,6 @@ public class AdminsBackController extends BaseController{
 	
 	@Autowired
 	private AdminsMapper adminsMapper;
-	
 
 	/**
 	 *验证账户是否存在  Lock-玄清
@@ -59,7 +56,6 @@ public class AdminsBackController extends BaseController{
 		return ajax;
 	}
 
-
 	/**
 	 * 修改密码   Lock-玄清
 	 * @param
@@ -98,16 +94,20 @@ public class AdminsBackController extends BaseController{
 	}
 	
 	/**
-	 * 注销会话  Lock-玄清
+	 * 注销会话
 	 * @return
 	 */
 	@RequestMapping("logout.html")
-	public ModelAndView logout(HttpServletRequest request,HttpServletResponse response,HttpSession session){
+	public String logout(HttpSession session){
 		session.removeAttribute(AppConst.Session_Admin);
-        System.err.println("logout ......");
-        return new ModelAndView("admin/login");
+        return "redirect:login.html";
 	}
 
+    /**
+     * 获取当前登录人名称
+     * @param session
+     * @return
+     */
 	@ResponseBody
     @RequestMapping(value="getloginname",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
     public String  getloginname(HttpSession session){
@@ -119,9 +119,6 @@ public class AdminsBackController extends BaseController{
         }
     }
 
-
-
-
 	/**
 	 * 跳转到操作成功页面   Lock-玄清
 	 * @return

+ 37 - 7
src/main/java/com/yc/education/controller/admin/NewsControllerAdmin.java

@@ -3,10 +3,9 @@ package com.yc.education.controller.admin;
 import com.baidu.ueditor.ActionEnter;
 import com.baidu.ueditor.define.ActionMap;
 import com.baidu.ueditor.define.BaseState;
-import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.yc.education.mapper.NewsMapper;
 import com.yc.education.model.News;
+import com.yc.education.service.NewsService;
 import com.yc.education.util.AjaxMessage;
 import com.yc.education.util.ViewUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,7 +13,6 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
@@ -29,15 +27,14 @@ import java.util.List;
 public class NewsControllerAdmin {
 
     @Autowired
-    private NewsMapper newsMapper;
+    private NewsService newsService;
 
     @ResponseBody
     @RequestMapping("newsbypage")
     public AjaxMessage<Object>  listAll(
                                         @RequestParam(required = false,defaultValue = "1")int page,
                                         @RequestParam(required = false,defaultValue = "10")int rows){
-        PageHelper.startPage(page, rows);
-        List<News> newsList = newsMapper.listAll();
+        List<News> newsList = newsService.listAll(page, rows);
         PageInfo<News> pageInfo = new PageInfo<>(newsList);
         return new AjaxMessage<>(true, "", pageInfo);
     }
@@ -49,11 +46,44 @@ public class NewsControllerAdmin {
         BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
         String url = state.getInfo("url");
         news.setImgsrc(url);
-        int  rows =  newsMapper.insert(news);
+        int  rows =  newsService.save(news);
         return ViewUtil.returnview(rows,"newslist.html","新闻管理");
     }
 
+    @ResponseBody
+    @RequestMapping("getnewbyid")
+    public News getByid(long id){
+        return newsService.selectByKey(id);
+    }
 
+    @RequestMapping("updatanews")
+    public ModelAndView updatanews(News news , HttpServletRequest request) {
+        String rootPath = request.getSession().getServletContext().getRealPath("/");
+        String contextPath = request.getSession().getServletContext().getContextPath();
+        BaseState state = (BaseState) new ActionEnter(request, rootPath, contextPath, "img").invoke(ActionMap.UPLOAD_FILE);
+        String url = state.getInfo("url");
+        if(url!=null&&!"".equals(url)){
+            news.setImgsrc(url);
+        }
+        int  rows =  newsService.updateNotNull(news);
+        return ViewUtil.returnview(rows,"newslist.html","新闻管理");
+    }
+    /**
+     * 删除 banner
+     * @param id
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping("deletenews")
+    public AjaxMessage<Object> delete(String id) {
+        String[] idlist = id.split(",");
+        int num = idlist.length;
+        int rows = 0;
+        for (String string : idlist) {
+            rows += newsService.delete(Long.parseLong(string));
+        }
+        return ViewUtil.returnajax(rows, num);
+    }
 
 
 }

+ 9 - 0
src/main/java/com/yc/education/interceptor/GlobalInterceptor.java

@@ -8,6 +8,7 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
+import java.io.PrintWriter;
 
 public class GlobalInterceptor extends HandlerInterceptorAdapter {
 
@@ -20,6 +21,14 @@ public class GlobalInterceptor extends HandlerInterceptorAdapter {
         if(admins!=null){
             return true;
         }else{
+
+            if (request.getHeader("x-requested-with") != null && request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")){ //如果是ajax请求响应头会有x-requested-with
+                PrintWriter out = response.getWriter();
+                out.print("loseSession");//session失效
+                out.flush();
+                return false;
+            }
+
             String contextPath=request.getContextPath();
             response.sendRedirect(contextPath + "/admin/login.html");
             return false;

+ 2 - 2
src/main/java/com/yc/education/mapper/NewsMapper.java

@@ -3,14 +3,14 @@ package com.yc.education.mapper;
 import com.yc.education.model.News;
 import com.yc.education.util.MyMapper;
 import org.apache.ibatis.annotations.Select;
-import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
-@Repository
 public interface NewsMapper extends MyMapper<News> {
 
     @Select("select * from news order by id desc")
     List<News> listAll();
 
+
+
 }

+ 28 - 0
src/main/java/com/yc/education/service/IService.java

@@ -0,0 +1,28 @@
+
+
+package com.yc.education.service;
+
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 通用接口
+ */
+@Service
+public interface IService<T> {
+
+    T selectByKey(Object key);
+
+    int save(T entity);
+
+    int delete(Object key);
+
+    int updateAll(T entity);
+
+    int updateNotNull(T entity);
+
+    List<T> selectByExample(Object example);
+
+    //TODO 其他...
+}

+ 15 - 0
src/main/java/com/yc/education/service/NewsService.java

@@ -0,0 +1,15 @@
+package com.yc.education.service;
+
+import com.yc.education.model.News;
+
+import java.util.List;
+
+/**
+ * @author YaoShiHang
+ * @Date 19:43 2018-04-12
+ */
+public interface NewsService extends  IService<News> {
+
+    List<News>  listAll(int page,int rows);
+
+}

+ 48 - 0
src/main/java/com/yc/education/service/impl/BaseService.java

@@ -0,0 +1,48 @@
+
+
+package com.yc.education.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.yc.education.service.IService;
+
+import tk.mybatis.mapper.common.Mapper;
+
+
+public abstract class BaseService<T> implements IService<T> {
+
+    @Autowired
+    protected Mapper<T> mapper;
+
+    public Mapper<T> getMapper() {
+        return mapper;
+    }
+
+    public T selectByKey(Object key) {
+        return mapper.selectByPrimaryKey(key);
+    }
+
+    public int save(T entity) {
+        return mapper.insert(entity);
+    }
+
+    public int delete(Object key) {
+        return mapper.deleteByPrimaryKey(key);
+    }
+
+    public int updateAll(T entity) {
+        return mapper.updateByPrimaryKey(entity);
+    }
+
+    public int updateNotNull(T entity) {
+        return mapper.updateByPrimaryKeySelective(entity);
+    }
+
+    public List<T> selectByExample(Object example) {
+        return mapper.selectByExample(example);
+    }
+
+    //TODO 其他...
+}

+ 27 - 0
src/main/java/com/yc/education/service/impl/NewsServiceImpl.java

@@ -0,0 +1,27 @@
+package com.yc.education.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.yc.education.mapper.NewsMapper;
+import com.yc.education.model.News;
+import com.yc.education.service.NewsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author YaoShiHang
+ * @Date 19:43 2018-04-12
+ */
+@Service
+public class NewsServiceImpl extends BaseService<News>  implements NewsService {
+
+    @Autowired
+    private NewsMapper mapper;
+
+    @Override
+    public List<News> listAll(int page, int rows) {
+        PageHelper.startPage(page, rows);
+        return mapper.listAll();
+    }
+}

+ 16 - 0
src/main/resources/mapper/NewsMapper.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.yc.education.mapper.NewsMapper" >
+  <resultMap id="BaseResultMap" type="com.yc.education.model.News" >
+    <!--
+      WARNING - @mbggenerated
+    -->
+    <id column="id" property="id" jdbcType="BIGINT" />
+    <result column="title" property="title" jdbcType="VARCHAR" />
+    <result column="outline" property="outline" jdbcType="VARCHAR" />
+    <result column="imgsrc" property="imgsrc" jdbcType="VARCHAR" />
+    <result column="content" property="content" jdbcType="LONGVARCHAR" />
+  </resultMap>
+
+
+</mapper>

+ 3 - 2
src/main/resources/mybatis-servlet.xml

@@ -20,6 +20,7 @@
     </mvc:message-converters>
   </mvc:annotation-driven>
   <context:component-scan base-package="com.yc.education.controller"/>
+  <context:component-scan base-package="com.yc.education.service"/>
   <!-- 全局拦截器配置文件   Start -->
   <context:component-scan base-package="com.yc.education.interceptor" />
   <mvc:interceptors>
@@ -100,8 +101,8 @@
       <list>
           <bean id="viewResolver"
                 class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver" p:cache="true">
-              <property name="prefix" value="/WEB-INF/jsp/"/>
-              <property name="suffix" value=".ftl"/>
+              <property name="prefix" value=""/>
+              <property name="suffix" value=".html"/>
               <property name="contentType" value="text/html;charset=UTF-8"/>
               <property name="requestContextAttribute" value="request"/>
               <property name="exposeSpringMacroHelpers" value="true"/>

+ 4 - 11
src/main/webapp/400.jsp

@@ -1,20 +1,13 @@
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
-<%@ page language="java" contentType="text/html; charset=utf-8"  isErrorPage="true" pageEncoding="utf-8"%>
-<%response.setStatus(HttpServletResponse.SC_OK);%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
 <!-- Viewport metatags -->
 <meta name="HandheldFriendly" content="true" />
 <meta name="MobileOptimized" content="320" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
-<link rel="icon" href="${pageContext.request.contextPath}/static/imgs/logos.ico" type="image/x-icon" />
-<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/admin/css/dandelion.css"  media="screen" />
-
+<link rel="icon" href="static/imgs/logos.ico" type="image/x-icon" />
+<link rel="stylesheet" type="text/css" href="static/admin/css/dandelion.css"  media="screen" />
 <title>400参数异常页面</title>
 
 </head>
@@ -46,7 +39,7 @@
         <!-- Footer -->
         <div id="da-footer">
         	<div class="da-container clearfix">
-           		<p> Copyright 2008 - 2017 Inc.</p>
+           		<p> Copyright 2008 - 2018 Inc.</p>
            		<p> All rights reserved  powered by </p>
         </div>
     </div>

+ 4 - 8
src/main/webapp/404.jsp

@@ -1,8 +1,4 @@
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
-<%@ page language="java" contentType="text/html; charset=utf-8"  isErrorPage="true" pageEncoding="utf-8"%>
-<%response.setStatus(HttpServletResponse.SC_OK);%>
+
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
@@ -11,8 +7,8 @@
 <meta name="HandheldFriendly" content="true" />
 <meta name="MobileOptimized" content="320" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
-<link rel="icon" href="${pageContext.request.contextPath}/static/imgs/logos.ico" type="image/x-icon" />
-<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/admin/css/dandelion.css"  media="screen" />
+<link rel="icon" href="static/imgs/logos.ico" type="image/x-icon" />
+<link rel="stylesheet" type="text/css" href="static/admin/css/dandelion.css"  media="screen" />
 
 <title>404错误页面</title>
 
@@ -45,7 +41,7 @@
         <!-- Footer -->
         <div id="da-footer">
         	<div class="da-container clearfix">
-           		<p> Copyright 2008 - 2017  Inc.</p>
+           		<p> Copyright 2008 - 2018  Inc.</p>
            		<p> All rights reserved  powered by </p>
         </div>
     </div>

+ 3 - 7
src/main/webapp/500.jsp

@@ -1,8 +1,4 @@
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
-<%@ page language="java" contentType="text/html; charset=utf-8"  isErrorPage="true" pageEncoding="utf-8"%>
-<%response.setStatus(HttpServletResponse.SC_OK);%>
+
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
@@ -12,8 +8,8 @@
 <meta name="HandheldFriendly" content="true" />
 <meta name="MobileOptimized" content="320" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
-<link rel="icon" href="${pageContext.request.contextPath}/static/imgs/logos.ico" type="image/x-icon" />
-<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/admin/css/dandelion.css"  media="screen" />
+<link rel="icon" href="static/imgs/logos.ico" type="image/x-icon" />
+<link rel="stylesheet" type="text/css" href="static/admin/css/dandelion.css"  media="screen" />
 
 <title>500服务器内部错误页面</title>
 

+ 7 - 9
src/main/webapp/WEB-INF/web.xml

@@ -49,20 +49,18 @@
     <url-pattern>/*</url-pattern>
   </filter-mapping>
     <welcome-file-list>
-        <welcome-file>news.html</welcome-file>
-    </welcome-file-list>
-<!--	<error-page>
+    <welcome-file>news.html</welcome-file>
+</welcome-file-list>
+	<error-page>
 	 <error-code>404</error-code>
-	 <location>/WEB-INF/jsp/404.jsp</location>
+	 <location>/404.html</location>
 	</error-page>
-	
 	<error-page>
 	 <error-code>500</error-code>
-	 <location>/WEB-INF/jsp/500.jsp</location>
+	 <location>/500.html</location>
 	</error-page>
-	   
 	<error-page>
 	 <error-code>400</error-code>
-	 <location>/WEB-INF/jsp/400.jsp</location>
-	</error-page>-->
+	 <location>/400.html</location>
+	</error-page>
 </web-app>

+ 8 - 7
src/main/webapp/admin/index.html

@@ -16,7 +16,6 @@
     <link rel="stylesheet" type="text/css" href="../static/admin/index/css/icheck.css" />
     <link rel="stylesheet" type="text/css" href="../static/admin/index/css/skin/skin.css" id="skin" />
     <link rel="stylesheet" type="text/css" href="../static/admin/index/css/style.css" />
-
     <script type="text/javascript" src="../static/admin/index/js/jquery.min.js"></script>
     <script type="text/javascript" src="../static/admin/index/js/layer.js"></script>
     <script type="text/javascript" src="../static/admin/index/js/H-ui.js"></script>
@@ -34,7 +33,7 @@
             <nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
                 <ul class="cl">
                     <li>欢迎您:</li>
-                    <li class="dropDown dropDown_hover"><a class="dropDown_A">${admin.name }</a>
+                    <li class="dropDown dropDown_hover"><a class="dropDown_A" id="username"></a>
                         <ul class="dropDown-menu menu radius box-shadow"></ul>
                     </li>
                     <li><a href="logout.html">[退出]</a></li>
@@ -103,12 +102,14 @@
 <script type="text/javascript">
 
     $(function(){
-        $.post("",function(){
-
-        })
-
+        $.post("getloginname",function(username){
+            if(username==""){
+                window.location = "login.html";
+            }else{
+                $("#username").html(username);
+            }
+        },"json")
     })
-
 </script>
 <script type="text/javascript">
     var _hmt = _hmt || [];

+ 4 - 1
src/main/webapp/admin/login.html

@@ -4,7 +4,10 @@
 <TITLE>【TEST】登录页面</TITLE>
 <link rel="icon" href="../static/imgs/logos.ico" type="image/x-icon" />
 <SCRIPT src="../static/admin/login/js/jquery-1.9.1.min.js" type="text/javascript"></SCRIPT>
- 
+    <script language="JavaScript">
+        if (window != top)
+            top.location.href = location.href;
+    </script>
 <STYLE>
 body{
 	background: #ebebeb;

+ 171 - 0
src/main/webapp/admin/newsedit.html

@@ -0,0 +1,171 @@
+<!DOCTYPE HTML>
+<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
+<head>
+    <meta charset="utf-8">
+    <script type="text/javascript">
+        var localObj = window.location;
+        var contextPath = localObj.pathname.split("/")[1];
+        console.log("contextPath "+contextPath);
+
+        if(contextPath!="admin"){
+            window.UEDITOR_SERVER_URL = "/"+contextPath;
+        }else{
+            window.UEDITOR_SERVER_URL = "";
+        }
+        console.log("window.UEDITOR_SERVER_URL "+window.UEDITOR_SERVER_URL );
+    </script>
+    <meta name="renderer" content="webkit|ie-comp|ie-stand">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+    <meta http-equiv="Cache-Control" content="no-siteapp" />
+    <LINK rel="Bookmark" href="/favicon.ico" >
+    <LINK rel="Shortcut Icon" href="/favicon.ico" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui/css/H-ui.min.css" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui.admin/css/H-ui.admin.css" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/manage/Hui-iconfont/1.0.7/iconfont.css" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/manage/icheck/icheck.css" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui.admin/skin/default/skin.css" id="skin" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui.admin/css/style.css" />
+    <link rel="stylesheet" type="text/css" href="../static/admin/css/layui.css" />
+    <title>新增文章 - 资讯管理 - H-ui.admin v2.3</title>
+    <meta name="keywords" content="H-ui.admin v2.3,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
+    <meta name="description" content="H-ui.admin v2.3,是一款由国人开发的轻量级扁平化网站后台模板,完全免费开源的网站后台管理系统模版,适合中小型CMS后台系统。">
+
+</head>
+<body>
+<nav class="breadcrumb">
+    <i class="Hui-iconfont">&#xe67f;</i> 首页
+    <span class="c-gray en">&gt;</span> 新闻资讯
+    <span class="c-gray en">&gt;</span> 新增新闻
+    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
+</nav>
+<article class="page-container" id="app" >
+    <form class="form form-horizontal" action="updatanews"  id="addtra" method="post" enctype="multipart/form-data"   >
+
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2">标题:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" v-bind:value="news.title" placeholder="请输入标题" id="title" name="title">
+                <input type="hidden"  v-bind:value="news.id"  name="id">
+            </div>
+        </div>
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2">概要说明:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text"  v-bind:value="news.outline" value="" placeholder="请输入概要说明" id="outline" name="outline">
+            </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2">封面图:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="file" class="input-text" value="" placeholder="请输入概要说明"  name="fileimg">
+            </div>
+        </div>
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2">详细信息:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <script id="editor"  name="content" type="text/plain" style="width:100%;height:400px;"  ></script></div>
+        </div>
+        <div class="row cl">
+            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
+                <input class="btn btn-primary radius" type="submit"    value="添加">
+                <a class="btn btn-primary radius"  href="newslist.html"   >关闭</a>
+            </div>
+        </div>
+    </form>
+</article>
+ <script type="text/javascript" src="../static/admin/js/jquery-1.7.2.min.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/icheck/jquery.icheck.min.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/h-ui/js/H-ui.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/js/layui.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/h-ui.admin/js/H-ui.admin.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/js/jquery.validate.min.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/js/validate-methods.js"></script>
+ <script type="text/javascript" src="../static/admin/manage/js/messages_zh.min.js"></script>
+ <!-- 百度文本编辑器   引用文件 -->
+ <link href="../static/ue/themes/default/css/ueditor.css" type="text/css" rel="stylesheet">
+ <script src="../static/ue/ueditor.config.js" type="text/javascript"></script>
+ <script src="../static/ue/ueditor.all.js" type="text/javascript"></script>
+ <script type="text/javascript" src="../static/ue/lang/zh-cn/zh-cn.js"></script>
+ <script type="text/javascript" src="../static/js/ajaxfileupload.js"></script>
+<script type="text/javascript" src="../static/admin/js/vue.js"></script>
+ <script type="text/javascript">
+
+                    $(function(){
+                        $("#addtra").validate({
+                            rules:{
+                                title:{
+                                    required:true,
+                                },
+                                outline:{
+                                    required:true,
+                                },
+                            },
+                            onkeyup:false,
+                            focusCleanup:true,
+                            success:"valid",
+                            submitHandler:function(form){
+                                $(form).ajaxSubmit();
+                                var index = parent.layer.getFrameIndex(window.name);
+                                parent.$('.btn-refresh').click();
+                                parent.layer.close(index);
+                            }
+                        });
+                    });
+                    var ue = UE.getEditor('editor');
+                    $(function(){
+                        $('.skin-minimal input').iCheck({
+                            checkboxClass: 'icheckbox-blue',
+                            radioClass: 'iradio-blue',
+                            increaseArea: '20%'
+                        })});
+                    var currentBrowserId;
+                    function browserImage(targetId){
+                        currentBrowserId = targetId;
+                        var weboxTemp = $.webox({
+                            height:600,
+                            width:1024,
+                            bgvisibel:true,
+                            title:'图片管理',
+                            iframe:'<%=base%>/admin/image/imgbox.html?'+Math.random()
+                        });
+                    }
+                    function setImagepath(imgPath){
+                        $('#'+currentBrowserId).val(imgPath);
+                    }
+                    function closeFrame(){
+                        $('#locked .span').click();
+                    }
+
+                    var app = new Vue({
+                        el: "#app",
+                        data:{
+                            news:""
+                        }
+                    });
+                    function getUrlParam(name) {
+                        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+                        var r = window.location.search.substr(1).match(reg);
+                        if (r != null)
+                            return unescape(r[2]);
+                        return null; //返回参数值
+                    }
+                    function init(){
+                        var id = getUrlParam("id");
+                        $.post("getnewbyid",{id:id},function(news){
+                            app.$data.news = news;
+                            ue.ready(function(){
+                                ue.setContent(news.content)
+                            })
+                        },"json")
+                    }
+                    init();
+
+
+ </script>
+
+</body>
+</html>

+ 25 - 22
src/main/webapp/admin/newslist.html

@@ -1,5 +1,5 @@
 <!DOCTYPE HTML>
-<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
+<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
 <head>
     <meta charset="utf-8">
     <meta name="renderer" content="webkit|ie-comp|ie-stand">
@@ -59,8 +59,9 @@
                     <td> <img  width="40px"  height="40px"  v-bind:src="item.imgsrc"  > </td>
                     <td>{{item.id}}</td>
                     <td class="f-14 td-manage">
-                        <a style="text-decoration:none;margin-left: 15px" class="ml-5" href="" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
-                        <a style="text-decoration:none;margin-left: 15px" class="ml-5"  href="javascript:;"  title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
+                        <a style="text-decoration:none;margin-left: 15px" class="ml-5" :href="'newsedit.html?id='+item.id" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
+                        <a style="text-decoration:none;margin-left: 15px" class="ml-5"  @click="deletethis(item.id);"  href="javascript:;"  title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
+
                     </td>
                 </tr>
             </tbody>
@@ -107,6 +108,18 @@
         methods:{
             pageinit:function(page,rows){
                 init(page,rows);
+            },
+            deletethis:function(id){
+                layer.confirm('确认要删除吗1?',function(index){
+                    $.post("deletenews.html",{id:id+","},function(data){
+                        if(data.is){
+                            init(app.$data.pageInfo.pageNum,app.$data.pageInfo.pageSize);
+                            layer.msg(data.msg,{icon:1,time:1000});
+                        }else{
+                            layer.msg(data.msg,{icon:2,time:1000});
+                        }
+                    },"json");
+                });
             }
         }
     })
@@ -115,6 +128,10 @@
     function init(page,rows){
         console.log("search : "+app.$data.search);
         $.post("newsbypage", {page:page,rows:rows}, function (result) {
+            if(result=="loseSession"){
+
+                window.location = "login.html";
+            }
             app.$data.pageInfo=result.data;
         }, "json");
     }
@@ -128,26 +145,10 @@
         return null; //返回参数值
     }
 
-
-
-
     $("#select").change(function () {
         var rows = $("#select").val();
         init(0,rows);
     });
-
-    function deleteloan(obj,id){
-        layer.confirm('确认要删除吗?',function(index){
-            $.post("deleteregister.html",{id:id+","},function(data){
-                if(data.is){
-                    $(obj).parents("tr").remove();
-                    layer.msg(data.msg,{icon:1,time:1000});
-                }else{
-                    layer.msg(data.msg,{icon:2,time:1000});
-                }
-            },"json");
-        });
-    }
     $("#delete").click(function(){
         //判断是否至少选择一项
         var checkedNum =$("input[name='ck_pro']:checked").length;
@@ -160,17 +161,19 @@
             $("input[name='ck_pro']:checked").each(function(){
                 checkList.push($(this).val());
             });
-
             $.ajax({
                 type:"POST",
-                url:"deleteregister.html",
+                url:"deletenews.html",
                 data:{
                     "id":checkList.toString()
                 },
                 dataType:"json",
                 success:function(ajax){
                     if(ajax.is){
-                        window.location=window.location;
+                       init(app.$data.pageInfo.pageNum,app.$data.pageInfo.pageSize);
+                        layer.closeAll();
+                        layer.msg("删除成功!",{icon:1,time:1000});
+                       $(":checkbox").prop("checked", false);
                     }else{
                         layer.msg(data.msg,{icon:2,time:1000});
                     }

+ 8 - 8
src/main/webapp/admin/password.html

@@ -7,15 +7,15 @@
   <meta name="Keywords" content="">
   <meta name="Description" content="">
   <title>修改密码</title>
-  <link rel="stylesheet" type="text/css" href="/static/admin/manage/h-ui/css/H-ui.min.css" />
-  <link rel="stylesheet" type="text/css" href="/static/admin/manage/h-ui.admin/css/H-ui.admin.css" />
-  <link rel="stylesheet" type="text/css" href="/static/admin/manage/Hui-iconfont/1.0.7/iconfont.css" />
-  <link rel="stylesheet" type="text/css" href="/static/admin/manage/icheck/icheck.css" />
-  <link rel="stylesheet" type="text/css" href="/static/admin/manage/h-ui.admin/skin/default/skin.css" id="skin" />
-  <link rel="stylesheet" type="text/css" href="/static/admin/manage/h-ui.admin/css/style.css" />
+  <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui/css/H-ui.min.css" />
+  <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui.admin/css/H-ui.admin.css" />
+  <link rel="stylesheet" type="text/css" href="../static/admin/manage/Hui-iconfont/1.0.7/iconfont.css" />
+  <link rel="stylesheet" type="text/css" href="../static/admin/manage/icheck/icheck.css" />
+  <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui.admin/skin/default/skin.css" id="skin" />
+  <link rel="stylesheet" type="text/css" href="../static/admin/manage/h-ui.admin/css/style.css" />
   
-  <script type="text/javascript" src="/static/admin/manage/js/jquery.min.js"></script>
-  <script type="text/javascript" src="/static/admin/manage/js/layer.js"></script>
+  <script type="text/javascript" src="../static/admin/manage/js/jquery.min.js"></script>
+  <script type="text/javascript" src="../static/admin/manage/js/layer.js"></script>
  </head>
  <script type="text/javascript">
  	$(function(){