Commit c25bfc8cc885ab970f81b42e37aae305824db042
1 parent
ce18fe8b
session数据使用
Showing
5 changed files
with
21 additions
and
10 deletions
src/main/java/com/cnlive/shenhe/ShenheApplication.java
| ... | ... | @@ -8,7 +8,6 @@ import org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter |
| 8 | 8 | import org.springframework.boot.SpringApplication; |
| 9 | 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 10 | 10 | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| 11 | -import org.springframework.boot.web.servlet.ServletComponentScan; | |
| 12 | 11 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| 13 | 12 | import org.springframework.context.annotation.Bean; |
| 14 | 13 | import tk.mybatis.spring.annotation.MapperScan; |
| ... | ... | @@ -17,7 +16,6 @@ import java.util.HashMap; |
| 17 | 16 | import java.util.Map; |
| 18 | 17 | |
| 19 | 18 | @SpringBootApplication |
| 20 | -@ServletComponentScan | |
| 21 | 19 | @MapperScan(basePackages= {"com.cnlive.shenhe.mapper"}) |
| 22 | 20 | public class ShenheApplication extends SpringBootServletInitializer { |
| 23 | 21 | ... | ... |
src/main/java/com/cnlive/shenhe/controller/SitesController.java
| 1 | 1 | package com.cnlive.shenhe.controller; |
| 2 | 2 | |
| 3 | +import com.cnlive.shenhe.bean.SessionUser; | |
| 3 | 4 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; |
| 4 | 5 | import com.cnlive.shenhe.utils.CommonUtils; |
| 5 | 6 | import org.slf4j.Logger; |
| ... | ... | @@ -10,6 +11,8 @@ import org.springframework.web.bind.annotation.GetMapping; |
| 10 | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | 12 | import org.springframework.web.bind.annotation.ResponseBody; |
| 12 | 13 | |
| 14 | +import javax.servlet.http.HttpSession; | |
| 15 | + | |
| 13 | 16 | /** |
| 14 | 17 | * @Auther: 周伟鹏 |
| 15 | 18 | * @Date: 2018/11/30 17:28 |
| ... | ... | @@ -30,12 +33,14 @@ public class SitesController { |
| 30 | 33 | * @param pageSize |
| 31 | 34 | * @param orderByClause |
| 32 | 35 | * @param key |
| 33 | - * @param spid | |
| 34 | 36 | * @return |
| 35 | 37 | */ |
| 36 | 38 | @GetMapping(value = "/page") |
| 37 | 39 | @ResponseBody |
| 38 | - public Object getTest(Integer page,Integer pageSize,String orderByClause,String key,Integer spid){ | |
| 40 | + public Object getTest(Integer page, Integer pageSize, String orderByClause, String key, HttpSession session){ | |
| 41 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | |
| 42 | + Integer spid = sessionUser.getSpid(); | |
| 43 | + if(spid==0)spid=82; | |
| 39 | 44 | if(CommonUtils.isNull(page))page=1; |
| 40 | 45 | if(CommonUtils.isNull(pageSize))pageSize=10; |
| 41 | 46 | return sitesService.getPage(page,pageSize,orderByClause,key,spid); | ... | ... |
src/main/java/com/cnlive/shenhe/controller/UsersController.java
| ... | ... | @@ -34,8 +34,10 @@ public class UsersController { |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | @RequestMapping("/index") |
| 37 | - public String index() { | |
| 38 | - return "error.html"; | |
| 37 | + public String index(HttpSession session) { | |
| 38 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | |
| 39 | + System.out.println(sessionUser.getUserId()); | |
| 40 | + return "page/head.html"; | |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | 43 | @RequestMapping("/login") | ... | ... |
src/main/java/com/cnlive/shenhe/controller/VideosController.java
| ... | ... | @@ -3,6 +3,7 @@ package com.cnlive.shenhe.controller; |
| 3 | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | 4 | import com.cnlive.shenhe.bean.ErrorEnum; |
| 5 | 5 | import com.cnlive.shenhe.bean.ResponseBean; |
| 6 | +import com.cnlive.shenhe.bean.SessionUser; | |
| 6 | 7 | import com.cnlive.shenhe.entity.ShySites; |
| 7 | 8 | import com.cnlive.shenhe.entity.ShyVideos; |
| 8 | 9 | import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; |
| ... | ... | @@ -12,6 +13,8 @@ import com.cnlive.shenhe.utils.CommonUtils; |
| 12 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | 14 | import org.springframework.stereotype.Controller; |
| 14 | 15 | import org.springframework.web.bind.annotation.*; |
| 16 | + | |
| 17 | +import javax.servlet.http.HttpSession; | |
| 15 | 18 | import java.util.Arrays; |
| 16 | 19 | import java.util.Date; |
| 17 | 20 | import java.util.List; |
| ... | ... | @@ -106,12 +109,13 @@ public class VideosController { |
| 106 | 109 | * @param page |
| 107 | 110 | * @param pageSize |
| 108 | 111 | * @param orderByClause |
| 109 | - * @param spid | |
| 110 | 112 | * @return |
| 111 | 113 | */ |
| 112 | - @RequestMapping("/table") | |
| 114 | + @RequestMapping("/page") | |
| 113 | 115 | @ResponseBody |
| 114 | - public Object getListVideos(String video_title,String start_date,String end_date,Integer state,Integer page,Integer pageSize,String orderByClause,Integer spid){ | |
| 116 | + public Object getListVideos(String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String orderByClause, HttpSession session){ | |
| 117 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | |
| 118 | + Integer spid = sessionUser.getSpid(); | |
| 115 | 119 | if(CommonUtils.isNull(page))page=1; |
| 116 | 120 | if(CommonUtils.isNull(pageSize))pageSize=10; |
| 117 | 121 | if(CommonUtils.isNotNull(spid)&&spid==0){spid=82;} |
| ... | ... | @@ -123,7 +127,7 @@ public class VideosController { |
| 123 | 127 | * @param id |
| 124 | 128 | * @return |
| 125 | 129 | */ |
| 126 | - @RequestMapping("/Details") | |
| 130 | + @RequestMapping("/details") | |
| 127 | 131 | @ResponseBody |
| 128 | 132 | public Object getDetailsVideo(Integer id){ |
| 129 | 133 | return videosService.getDetailsContent(id); | ... | ... |
src/main/java/com/cnlive/shenhe/job/UsersSiteJob.java
| ... | ... | @@ -71,6 +71,7 @@ public class UsersSiteJob { |
| 71 | 71 | //用户信息入库 |
| 72 | 72 | JSONObject user = data.getJSONObject(i); |
| 73 | 73 | Integer id = user.getInteger("sid"); |
| 74 | + String user_id = CommonUtils.md5(id+""); | |
| 74 | 75 | String email = user.getString("email"); |
| 75 | 76 | Integer spid = user.getInteger("new_sp_id"); |
| 76 | 77 | String userLogo = user.getString("userLogo"); |
| ... | ... | @@ -87,6 +88,7 @@ public class UsersSiteJob { |
| 87 | 88 | ShyUsers shyUsers = new ShyUsers(); |
| 88 | 89 | shyUsers.setEmail(email); |
| 89 | 90 | shyUsers.setId(id); |
| 91 | + shyUsers.setUser_id(user_id); | |
| 90 | 92 | shyUsers.setSp_id(spid); |
| 91 | 93 | shyUsers.setMaster(master); |
| 92 | 94 | shyUsers.setState(status); | ... | ... |