Commit 6100504b authored by Quxl's avatar Quxl

x

parent c20e8def
package com.egolm.film.api.service; package com.egolm.film.api.service;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -13,7 +15,7 @@ public interface TokenService { ...@@ -13,7 +15,7 @@ public interface TokenService {
LoginToken getToken(); LoginToken getToken();
Object getTokenObj(); Map<String, Object> getTokenObj();
LoginToken doLogin(String username, String password); LoginToken doLogin(String username, String password);
...@@ -24,4 +26,5 @@ public interface TokenService { ...@@ -24,4 +26,5 @@ public interface TokenService {
boolean isLoginByToken(String token); boolean isLoginByToken(String token);
void doLog(HttpServletRequest request); void doLog(HttpServletRequest request);
} }
...@@ -6,4 +6,5 @@ public interface UserTokenService extends TokenService { ...@@ -6,4 +6,5 @@ public interface UserTokenService extends TokenService {
final String TOKEN_NAME = "FILM_USER_LOGIN_TOKEN_NAME"; final String TOKEN_NAME = "FILM_USER_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "USER"; final String LOG_TYPE = "USER";
} }
...@@ -2,6 +2,7 @@ package com.egolm.film.api.service.impl; ...@@ -2,6 +2,7 @@ package com.egolm.film.api.service.impl;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -77,10 +78,9 @@ public class AdminTokenServiceImpl implements AdminTokenService { ...@@ -77,10 +78,9 @@ public class AdminTokenServiceImpl implements AdminTokenService {
} }
@Override @Override
public Object getTokenObj() { public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId(); Integer id = (Integer)this.getToken().getId();
Fc_admin obj = jdbcTemplate.queryForBean("select * from fc_admin where adminid = ?", Fc_admin.class, id); return jdbcTemplate.queryForMap("select * from fc_admin where adminid = ?", id);
return obj;
} }
@Override @Override
......
package com.egolm.film.api.service.impl; package com.egolm.film.api.service.impl;
import java.util.Date; import java.util.Date;
import java.util.Map;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -76,10 +77,9 @@ public class MemberTokenServiceImpl implements MemberTokenService { ...@@ -76,10 +77,9 @@ public class MemberTokenServiceImpl implements MemberTokenService {
} }
@Override @Override
public Object getTokenObj() { public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId(); Integer id = (Integer)this.getToken().getId();
Fc_member obj = jdbcTemplate.queryForBean("select * from fc_member where id = ?", Fc_member.class, id); return jdbcTemplate.queryForMap("select * from fc_member where id = ?", id);
return obj;
} }
@Override @Override
......
package com.egolm.film.api.service.impl; package com.egolm.film.api.service.impl;
import java.util.Date; import java.util.Date;
import java.util.Map;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -73,10 +74,9 @@ public class UserTokenServiceImpl implements UserTokenService { ...@@ -73,10 +74,9 @@ public class UserTokenServiceImpl implements UserTokenService {
} }
@Override @Override
public Object getTokenObj() { public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId(); Integer id = (Integer)this.getToken().getId();
Fc_user obj = jdbcTemplate.queryForBean("select * from fc_user where uid = ?", Fc_user.class, id); return jdbcTemplate.queryForMap("select u.*, ug.group_name from fc_user u left join fc_user_group ug on ug.group_id = u.group_id where u.uid = ?", id);
return obj;
} }
@Override @Override
...@@ -122,4 +122,6 @@ public class UserTokenServiceImpl implements UserTokenService { ...@@ -122,4 +122,6 @@ public class UserTokenServiceImpl implements UserTokenService {
Object[] objs = new Object[]{LOG_TYPE, loginid, prefix, path, ip, content, user_agent, now}; Object[] objs = new Object[]{LOG_TYPE, loginid, prefix, path, ip, content, user_agent, now};
jdbcTemplate.executeUpdate(sql, objs); jdbcTemplate.executeUpdate(sql, objs);
} }
} }
...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminAuthService; import com.egolm.film.api.service.AdminAuthService;
...@@ -191,7 +192,7 @@ public class AdminAuthController { ...@@ -191,7 +192,7 @@ public class AdminAuthController {
@PostMapping("adminAuth") @PostMapping("adminAuth")
@ApiOperation("当前登陆管理员权限查询") @ApiOperation("当前登陆管理员权限查询")
public Object getAdminAuth() throws FileNotFoundException { public Object getAdminAuth() throws FileNotFoundException {
Fc_admin admin = (Fc_admin)tokenService.getTokenObj(); Fc_admin admin = Util.mapTo(tokenService.getTokenObj(), Fc_admin.class);
List<Map<String, Object>> groupMenuList = service.queryGroupMenuList(admin.getGroup_id()); List<Map<String, Object>> groupMenuList = service.queryGroupMenuList(admin.getGroup_id());
return Rjx.jsonOk().set("admin", admin).setData(groupMenuList); return Rjx.jsonOk().set("admin", admin).setData(groupMenuList);
} }
......
...@@ -79,7 +79,7 @@ public class AdminReviewController { ...@@ -79,7 +79,7 @@ public class AdminReviewController {
index = index == null ? 1 : index; index = index == null ? 1 : index;
limit = limit == null ? 20 : limit; limit = limit == null ? 20 : limit;
Page page = new Page(index, limit); Page page = new Page(index, limit);
Fc_admin admin = (Fc_admin)tokenService.getTokenObj(); Fc_admin admin = Util.mapTo(tokenService.getTokenObj(), Fc_admin.class);
List<Map<String, Object>> list = reviewService.queryReviewListForAdmin( List<Map<String, Object>> list = reviewService.queryReviewListForAdmin(
keyword, keyword,
admin.getGroup_id(), admin.getGroup_id(),
......
...@@ -57,7 +57,7 @@ public class WebUtilController { ...@@ -57,7 +57,7 @@ public class WebUtilController {
@PostMapping("verifyAuth") @PostMapping("verifyAuth")
@ApiOperation("校验权限") @ApiOperation("校验权限")
public void verifyAuth() { public void verifyAuth() {
Fc_admin admin = (Fc_admin)tokenService.getTokenObj(); Fc_admin admin = Util.mapTo(tokenService.getTokenObj(), Fc_admin.class);
if(!admin.getUsername().equals("admin")) { if(!admin.getUsername().equals("admin")) {
throw new XRException("权限错误"); throw new XRException("权限错误");
} }
......
...@@ -51,4 +51,11 @@ public class UserLoginController { ...@@ -51,4 +51,11 @@ public class UserLoginController {
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
@ResponseBody
@PostMapping("info")
@ApiOperation("查询登陆信息")
public Object info() {
return Rjx.jsonOk().setData(tokenService.getTokenObj());
}
} }
...@@ -10,10 +10,12 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -10,10 +10,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.Util;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.NewsService; import com.egolm.film.api.service.NewsService;
import com.egolm.film.api.service.UserTokenService; import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.bean.Fc_admin;
import com.egolm.film.bean.Fc_news_read; import com.egolm.film.bean.Fc_news_read;
import com.egolm.film.bean.Fc_user; import com.egolm.film.bean.Fc_user;
...@@ -40,7 +42,7 @@ public class UserNewsController { ...@@ -40,7 +42,7 @@ public class UserNewsController {
index = index == null ? 1 : index; index = index == null ? 1 : index;
limit = limit == null ? 20 : limit; limit = limit == null ? 20 : limit;
Page page = new Page(index, limit); Page page = new Page(index, limit);
Fc_user user = (Fc_user)tokenService.getTokenObj(); Fc_user user = Util.mapTo(tokenService.getTokenObj(), Fc_user.class);
Integer uid = user.getUid(); Integer uid = user.getUid();
Integer gid = user.getGroup_id(); Integer gid = user.getGroup_id();
List<Map<String, Object>> list = service.queryListForUser(uid, gid, page); List<Map<String, Object>> list = service.queryListForUser(uid, gid, page);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment