Commit c984f7bacfd95dd1907e61de527fd39bbdd6bfa6
1 parent
35ae702f
页面用户信息使用修改
Showing
6 changed files
with
57 additions
and
47 deletions
src/main/java/com/cnlive/shenhe/bean/SessionUser.java
| ... | ... | @@ -10,8 +10,11 @@ public class SessionUser { |
| 10 | 10 | public static final String SESSION_KEY = "sessionUser"; |
| 11 | 11 | |
| 12 | 12 | private String userId; |
| 13 | - | |
| 13 | + private String userName; | |
| 14 | 14 | private Integer spid; |
| 15 | + private String company; | |
| 16 | + private String email; | |
| 17 | + private String logo; | |
| 15 | 18 | |
| 16 | 19 | public String getUserId() { |
| 17 | 20 | return userId; |
| ... | ... | @@ -32,4 +35,36 @@ public class SessionUser { |
| 32 | 35 | public void setSpid(Integer spid) { |
| 33 | 36 | this.spid = spid; |
| 34 | 37 | } |
| 38 | + | |
| 39 | + public String getUserName() { | |
| 40 | + return userName; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setUserName(String userName) { | |
| 44 | + this.userName = userName; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public String getCompany() { | |
| 48 | + return company; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void setCompany(String company) { | |
| 52 | + this.company = company; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public String getEmail() { | |
| 56 | + return email; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void setEmail(String email) { | |
| 60 | + this.email = email; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public String getLogo() { | |
| 64 | + return logo; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setLogo(String logo) { | |
| 68 | + this.logo = logo; | |
| 69 | + } | |
| 35 | 70 | } | ... | ... |
src/main/java/com/cnlive/shenhe/controller/SitesController.java
| 1 | 1 | package com.cnlive.shenhe.controller; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 4 | 3 | import com.cnlive.shenhe.bean.SessionUser; |
| 5 | 4 | import com.cnlive.shenhe.entity.ShySites; |
| 6 | -import com.cnlive.shenhe.entity.ShyUsers; | |
| 7 | 5 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; |
| 8 | -import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; | |
| 9 | 6 | import com.cnlive.shenhe.utils.CommonUtils; |
| 10 | 7 | import com.github.pagehelper.PageInfo; |
| 11 | 8 | import org.slf4j.Logger; |
| ... | ... | @@ -15,7 +12,6 @@ import org.springframework.stereotype.Controller; |
| 15 | 12 | import org.springframework.ui.Model; |
| 16 | 13 | import org.springframework.web.bind.annotation.GetMapping; |
| 17 | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 18 | -import org.springframework.web.bind.annotation.ResponseBody; | |
| 19 | 15 | |
| 20 | 16 | import javax.servlet.http.HttpSession; |
| 21 | 17 | |
| ... | ... | @@ -33,10 +29,9 @@ public class SitesController { |
| 33 | 29 | @Autowired |
| 34 | 30 | SitesServiceImpl sitesService; |
| 35 | 31 | |
| 36 | - @Autowired | |
| 37 | - UsersServiceImpl usersService; | |
| 38 | 32 | /** |
| 39 | 33 | * 站点白名单分页列表 |
| 34 | + * | |
| 40 | 35 | * @param page |
| 41 | 36 | * @param pageSize |
| 42 | 37 | * @param orderByClause |
| ... | ... | @@ -44,26 +39,15 @@ public class SitesController { |
| 44 | 39 | * @return |
| 45 | 40 | */ |
| 46 | 41 | @GetMapping(value = "/page") |
| 47 | - public String getTest(Model model, Integer page, Integer pageSize, String orderByClause, String key, HttpSession session){ | |
| 42 | + public String getTest(Model model, Integer page, Integer pageSize, String orderByClause, String key, HttpSession session) { | |
| 48 | 43 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 49 | - ShyUsers shyUsers = new ShyUsers(); | |
| 50 | - shyUsers.setUser_id(sessionUser.getUserId()); | |
| 51 | - shyUsers = usersService.select(shyUsers); | |
| 52 | - JSONObject user = new JSONObject(); | |
| 53 | - user.put("name", shyUsers.getUsername()); | |
| 54 | - user.put("company", shyUsers.getCompany_brief()); | |
| 55 | - user.put("spid", shyUsers.getSp_id()); | |
| 56 | - user.put("email", shyUsers.getEmail()); | |
| 57 | - user.put("logo", shyUsers.getUser_logo()); | |
| 58 | - model.addAttribute("user", user); | |
| 59 | - | |
| 60 | 44 | Integer spid = sessionUser.getSpid(); |
| 61 | - if(spid==0)spid=82; | |
| 62 | - if(CommonUtils.isNull(page))page=1; | |
| 63 | - if(CommonUtils.isNull(pageSize))pageSize=10; | |
| 45 | + if (spid == 0) spid = 82; | |
| 46 | + if (CommonUtils.isNull(page)) page = 1; | |
| 47 | + if (CommonUtils.isNull(pageSize)) pageSize = 10; | |
| 64 | 48 | PageInfo<ShySites> sitePage = sitesService.getPage(page, pageSize, orderByClause, key, spid); |
| 65 | 49 | model.addAttribute("sitePage", sitePage); |
| 66 | - return "page/site.html"; | |
| 50 | + return "page/site.html"; | |
| 67 | 51 | } |
| 68 | 52 | |
| 69 | 53 | } | ... | ... |
src/main/java/com/cnlive/shenhe/controller/UsersController.java
| ... | ... | @@ -54,6 +54,10 @@ public class UsersController { |
| 54 | 54 | SessionUser sessionUser = new SessionUser(); |
| 55 | 55 | sessionUser.setUserId(user.getUser_id()); |
| 56 | 56 | sessionUser.setSpid(Integer.parseInt(principal.getAttributes().get("new_sp_id").toString())); |
| 57 | + sessionUser.setUserName(user.getUsername()); | |
| 58 | + sessionUser.setCompany(user.getCompany_brief()); | |
| 59 | + sessionUser.setEmail(user.getEmail()); | |
| 60 | + sessionUser.setLogo(user.getUser_logo()); | |
| 57 | 61 | request.getSession().setAttribute(SessionUser.SESSION_KEY,sessionUser); |
| 58 | 62 | return "page/head.html"; |
| 59 | 63 | } | ... | ... |
src/main/java/com/cnlive/shenhe/controller/VideosController.java
| ... | ... | @@ -14,10 +14,8 @@ import com.github.pagehelper.PageInfo; |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.stereotype.Controller; |
| 16 | 16 | import org.springframework.ui.Model; |
| 17 | -import org.springframework.ui.ModelMap; | |
| 18 | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| 19 | 18 | import org.springframework.web.bind.annotation.ResponseBody; |
| 20 | -import org.springframework.web.servlet.ModelAndView; | |
| 21 | 19 | |
| 22 | 20 | import javax.servlet.http.HttpSession; |
| 23 | 21 | |
| ... | ... | @@ -87,19 +85,8 @@ public class VideosController { |
| 87 | 85 | * @return |
| 88 | 86 | */ |
| 89 | 87 | @RequestMapping("/page") |
| 90 | - public Object getListVideos(Model model,String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String orderByClause, HttpSession session) { | |
| 88 | + public Object getListVideos(Model model, String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String orderByClause, HttpSession session) { | |
| 91 | 89 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 92 | - ShyUsers shyUsers = new ShyUsers(); | |
| 93 | - shyUsers.setUser_id(sessionUser.getUserId()); | |
| 94 | - shyUsers = usersService.select(shyUsers); | |
| 95 | - JSONObject user = new JSONObject(); | |
| 96 | - user.put("name", shyUsers.getUsername()); | |
| 97 | - user.put("company", shyUsers.getCompany_brief()); | |
| 98 | - user.put("spid", shyUsers.getSp_id()); | |
| 99 | - user.put("email", shyUsers.getEmail()); | |
| 100 | - user.put("logo", shyUsers.getUser_logo()); | |
| 101 | - model.addAttribute("user", user); | |
| 102 | - | |
| 103 | 90 | Integer spid = sessionUser.getSpid(); |
| 104 | 91 | if (CommonUtils.isNull(page)) page = 1; |
| 105 | 92 | if (CommonUtils.isNull(pageSize)) pageSize = 10; | ... | ... |
src/main/resources/templates/page/site.html
| ... | ... | @@ -105,22 +105,22 @@ |
| 105 | 105 | <ul class="nav navbar-nav"> |
| 106 | 106 | <li class="dropdown messages-menu" style="margin: 0 auto"> |
| 107 | 107 | <span class="label label-primary" style="height: 2em; |
| 108 | -line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${user.company}+'('+${user.spid}+')'"> | |
| 108 | +line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${session.sessionUser.company}+'('+${session.sessionUser.spid}+')'"> | |
| 109 | 109 | </span> |
| 110 | 110 | </li> |
| 111 | 111 | <!-- User Account: style can be found in dropdown.less --> |
| 112 | 112 | <li class="dropdown user user-menu"> |
| 113 | 113 | <a href="http://shenhe.cnlive.com/videos#" class="dropdown-toggle" data-toggle="dropdown"> |
| 114 | - <img th:src="@{${user.logo}}" class="user-image" alt="User Image"> | |
| 115 | - <span class="hidden-xs" th:text="${user.name}"> | |
| 114 | + <img th:src="@{${session.sessionUser.logo}}" class="user-image" alt="User Image"> | |
| 115 | + <span class="hidden-xs" th:text="${session.sessionUser.userName}"> | |
| 116 | 116 | </span> |
| 117 | 117 | |
| 118 | 118 | </a> |
| 119 | 119 | <ul class="dropdown-menu"> |
| 120 | 120 | <!-- User image --> |
| 121 | 121 | <li class="user-header"> |
| 122 | - <img th:src="@{${user.logo}}" class="img-circle" alt="User Image"> | |
| 123 | - <p th:text="${user.email}"> | |
| 122 | + <img th:src="@{${session.sessionUser.logo}}" class="img-circle" alt="User Image"> | |
| 123 | + <p th:text="${session.sessionUser.email}"> | |
| 124 | 124 | |
| 125 | 125 | </p> |
| 126 | 126 | </li> | ... | ... |
src/main/resources/templates/page/video.html
| ... | ... | @@ -95,22 +95,22 @@ |
| 95 | 95 | <ul class="nav navbar-nav"> |
| 96 | 96 | <li class="dropdown messages-menu" style="margin: 0 auto"> |
| 97 | 97 | <span class="label label-primary" style="height: 2em; |
| 98 | -line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${user.company}+'('+${user.spid}+')'"> | |
| 98 | +line-height: 2em; margin: 0 auto;font-size: 2em" th:text="${session.sessionUser.company}+'('+${session.sessionUser.spid}+')'"> | |
| 99 | 99 | </span> |
| 100 | 100 | </li> |
| 101 | 101 | <!-- User Account: style can be found in dropdown.less --> |
| 102 | 102 | <li class="dropdown user user-menu"> |
| 103 | 103 | <a href="http://shenhe.cnlive.com/videos#" class="dropdown-toggle" data-toggle="dropdown"> |
| 104 | - <img th:src="@{${user.logo}}" class="user-image" alt="User Image"> | |
| 105 | - <span class="hidden-xs" th:text="${user.name}"> | |
| 104 | + <img th:src="@{${session.sessionUser.logo}}" class="user-image" alt="User Image"> | |
| 105 | + <span class="hidden-xs" th:text="${session.sessionUser.userName}"> | |
| 106 | 106 | </span> |
| 107 | 107 | |
| 108 | 108 | </a> |
| 109 | 109 | <ul class="dropdown-menu"> |
| 110 | 110 | <!-- User image --> |
| 111 | 111 | <li class="user-header"> |
| 112 | - <img th:src="@{${user.logo}}" class="img-circle" alt="User Image"> | |
| 113 | - <p th:text="${user.email}"> | |
| 112 | + <img th:src="@{${session.sessionUser.logo}}" class="img-circle" alt="User Image"> | |
| 113 | + <p th:text="${session.sessionUser.email}"> | |
| 114 | 114 | |
| 115 | 115 | </p> |
| 116 | 116 | </li> | ... | ... |