Commit 47480c12df9f5f27de0e81f2397ea828b98c2afe
1 parent
7f2a643c
权限控制
Showing
4 changed files
with
32 additions
and
21 deletions
src/main/java/com/cnlive/shenhe/bean/SessionUser.java
| @@ -15,6 +15,7 @@ public class SessionUser { | @@ -15,6 +15,7 @@ public class SessionUser { | ||
| 15 | private String company; | 15 | private String company; |
| 16 | private String email; | 16 | private String email; |
| 17 | private String logo; | 17 | private String logo; |
| 18 | + private boolean master; | ||
| 18 | 19 | ||
| 19 | public String getUserId() { | 20 | public String getUserId() { |
| 20 | return userId; | 21 | return userId; |
| @@ -67,4 +68,12 @@ public class SessionUser { | @@ -67,4 +68,12 @@ public class SessionUser { | ||
| 67 | public void setLogo(String logo) { | 68 | public void setLogo(String logo) { |
| 68 | this.logo = logo; | 69 | this.logo = logo; |
| 69 | } | 70 | } |
| 71 | + | ||
| 72 | + public boolean isMaster() { | ||
| 73 | + return master; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setMaster(boolean master) { | ||
| 77 | + this.master = master; | ||
| 78 | + } | ||
| 70 | } | 79 | } |
src/main/java/com/cnlive/shenhe/controller/SitesController.java
| 1 | package com.cnlive.shenhe.controller; | 1 | package com.cnlive.shenhe.controller; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | -import com.cnlive.shenhe.bean.ErrorEnum; | ||
| 5 | -import com.cnlive.shenhe.bean.ResponseBean; | ||
| 6 | import com.cnlive.shenhe.bean.SessionUser; | 4 | import com.cnlive.shenhe.bean.SessionUser; |
| 7 | import com.cnlive.shenhe.entity.ShySites; | 5 | import com.cnlive.shenhe.entity.ShySites; |
| 8 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; | 6 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; |
| @@ -14,7 +12,9 @@ import org.slf4j.LoggerFactory; | @@ -14,7 +12,9 @@ import org.slf4j.LoggerFactory; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.stereotype.Controller; | 13 | import org.springframework.stereotype.Controller; |
| 16 | import org.springframework.ui.Model; | 14 | import org.springframework.ui.Model; |
| 17 | -import org.springframework.web.bind.annotation.*; | 15 | +import org.springframework.web.bind.annotation.GetMapping; |
| 16 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 18 | 18 | ||
| 19 | import javax.servlet.http.HttpSession; | 19 | import javax.servlet.http.HttpSession; |
| 20 | import java.util.List; | 20 | import java.util.List; |
| @@ -46,22 +46,23 @@ public class SitesController { | @@ -46,22 +46,23 @@ public class SitesController { | ||
| 46 | public String page(Model model, Integer page, Integer pageSize, String orderByClause, String keyword, HttpSession session) { | 46 | public String page(Model model, Integer page, Integer pageSize, String orderByClause, String keyword, HttpSession session) { |
| 47 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | 47 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 48 | Integer spid = sessionUser.getSpid(); | 48 | Integer spid = sessionUser.getSpid(); |
| 49 | - if (spid != 0){ | 49 | + if (!sessionUser.isMaster() && spid != 0) { |
| 50 | return "page/error.html"; | 50 | return "page/error.html"; |
| 51 | } | 51 | } |
| 52 | + if (spid == 0) spid = null; | ||
| 52 | if (CommonUtils.isNull(page)) page = 1; | 53 | if (CommonUtils.isNull(page)) page = 1; |
| 53 | if (CommonUtils.isNull(pageSize)) pageSize = 10; | 54 | if (CommonUtils.isNull(pageSize)) pageSize = 10; |
| 54 | - PageInfo<ShySites> sitePage = sitesService.getPage(page, pageSize, orderByClause, keyword, null); | 55 | + PageInfo<ShySites> sitePage = sitesService.getPage(page, pageSize, orderByClause, keyword, spid); |
| 55 | List<ShySites> list = sitePage.getList(); | 56 | List<ShySites> list = sitePage.getList(); |
| 56 | JSONObject business = CommonConst.BUSINESS; | 57 | JSONObject business = CommonConst.BUSINESS; |
| 57 | - if(!list.isEmpty()){ | ||
| 58 | - for (ShySites site:list) { | 58 | + if (!list.isEmpty()) { |
| 59 | + for (ShySites site : list) { | ||
| 59 | String write_business_name = site.getWrite_business(); | 60 | String write_business_name = site.getWrite_business(); |
| 60 | - if(CommonUtils.isNotEmpty(write_business_name)){ | ||
| 61 | - for (String bkey:business.keySet()) { | 61 | + if (CommonUtils.isNotEmpty(write_business_name)) { |
| 62 | + for (String bkey : business.keySet()) { | ||
| 62 | write_business_name = write_business_name.replace(bkey, business.getString(bkey)); | 63 | write_business_name = write_business_name.replace(bkey, business.getString(bkey)); |
| 63 | } | 64 | } |
| 64 | - }else{ | 65 | + } else { |
| 65 | write_business_name = "无"; | 66 | write_business_name = "无"; |
| 66 | } | 67 | } |
| 67 | site.setWrite_business_name(write_business_name); | 68 | site.setWrite_business_name(write_business_name); |
| @@ -74,25 +75,25 @@ public class SitesController { | @@ -74,25 +75,25 @@ public class SitesController { | ||
| 74 | 75 | ||
| 75 | 76 | ||
| 76 | @PostMapping(value = "/write") | 77 | @PostMapping(value = "/write") |
| 77 | - public String write(Integer siteId, String[] write_business, HttpSession session,String redirect_url) { | 78 | + public String write(Integer siteId, String[] write_business, HttpSession session, String redirect_url) { |
| 79 | + ShySites site = sitesService.get(siteId); | ||
| 78 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | 80 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 79 | Integer spid = sessionUser.getSpid(); | 81 | Integer spid = sessionUser.getSpid(); |
| 80 | - if (spid != 0){ | 82 | + if ((!sessionUser.isMaster() && spid != 0) || (sessionUser.isMaster() && site.getSpid() != spid)) { |
| 81 | return "page/error.html"; | 83 | return "page/error.html"; |
| 82 | } | 84 | } |
| 83 | - ShySites site = sitesService.get(siteId); | ||
| 84 | String write = ""; | 85 | String write = ""; |
| 85 | - if(CommonUtils.isNotNull(write_business)&&write_business.length>0){ | ||
| 86 | - for (String w:write_business) { | ||
| 87 | - write = write+","+w; | 86 | + if (CommonUtils.isNotNull(write_business) && write_business.length > 0) { |
| 87 | + for (String w : write_business) { | ||
| 88 | + write = write + "," + w; | ||
| 88 | } | 89 | } |
| 89 | write = write.substring(1); | 90 | write = write.substring(1); |
| 90 | } | 91 | } |
| 91 | site.setWrite_business(write); | 92 | site.setWrite_business(write); |
| 92 | boolean success = sitesService.update(site); | 93 | boolean success = sitesService.update(site); |
| 93 | - if(success){ | ||
| 94 | - return "redirect:"+redirect_url; | ||
| 95 | - }else{ | 94 | + if (success) { |
| 95 | + return "redirect:" + redirect_url; | ||
| 96 | + } else { | ||
| 96 | return "error.html"; | 97 | return "error.html"; |
| 97 | } | 98 | } |
| 98 | } | 99 | } |
src/main/java/com/cnlive/shenhe/controller/UsersController.java
| @@ -51,6 +51,7 @@ public class UsersController { | @@ -51,6 +51,7 @@ public class UsersController { | ||
| 51 | sessionUser.setCompany(user.getCompany_brief()); | 51 | sessionUser.setCompany(user.getCompany_brief()); |
| 52 | sessionUser.setEmail(user.getEmail()); | 52 | sessionUser.setEmail(user.getEmail()); |
| 53 | sessionUser.setLogo(user.getUser_logo()); | 53 | sessionUser.setLogo(user.getUser_logo()); |
| 54 | + sessionUser.setMaster(user.getMaster()); | ||
| 54 | request.getSession().setAttribute(SessionUser.SESSION_KEY,sessionUser); | 55 | request.getSession().setAttribute(SessionUser.SESSION_KEY,sessionUser); |
| 55 | return "redirect:/videos/page"; | 56 | return "redirect:/videos/page"; |
| 56 | } | 57 | } |
src/main/resources/templates/common/frame.html
| @@ -67,10 +67,10 @@ line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${session.sessionUser. | @@ -67,10 +67,10 @@ line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${session.sessionUser. | ||
| 67 | </a> | 67 | </a> |
| 68 | <ul class="treeview-menu"> | 68 | <ul class="treeview-menu"> |
| 69 | <li class="active"><a href="/videos/page"></i> 点播审核</a></li> | 69 | <li class="active"><a href="/videos/page"></i> 点播审核</a></li> |
| 70 | - <li><a href="/comments/page/list"> 评论审核</a></li> | 70 | + <li><a href="/comments/page"> 评论审核</a></li> |
| 71 | </ul> | 71 | </ul> |
| 72 | </li> | 72 | </li> |
| 73 | - <li class="treeview" th:if="${session.sessionUser.spid==0}"> | 73 | + <li class="treeview" th:if="${session.sessionUser.spid==0 or session.sessionUser.master}"> |
| 74 | <a href="http://shenhe.cnlive.com/videos#"> | 74 | <a href="http://shenhe.cnlive.com/videos#"> |
| 75 | <span class="menu-item-top">系统管理</span> | 75 | <span class="menu-item-top">系统管理</span> |
| 76 | </a> | 76 | </a> |