Commit 6100504b authored by Quxl's avatar Quxl

x

parent c20e8def
package com.egolm.film.api.service;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
......@@ -13,7 +15,7 @@ public interface TokenService {
LoginToken getToken();
Object getTokenObj();
Map<String, Object> getTokenObj();
LoginToken doLogin(String username, String password);
......@@ -24,4 +26,5 @@ public interface TokenService {
boolean isLoginByToken(String token);
void doLog(HttpServletRequest request);
}
......@@ -6,4 +6,5 @@ public interface UserTokenService extends TokenService {
final String TOKEN_NAME = "FILM_USER_LOGIN_TOKEN_NAME";
final String LOG_TYPE = "USER";
}
......@@ -2,6 +2,7 @@ package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
......@@ -77,10 +78,9 @@ public class AdminTokenServiceImpl implements AdminTokenService {
}
@Override
public Object getTokenObj() {
public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId();
Fc_admin obj = jdbcTemplate.queryForBean("select * from fc_admin where adminid = ?", Fc_admin.class, id);
return obj;
return jdbcTemplate.queryForMap("select * from fc_admin where adminid = ?", id);
}
@Override
......
package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
......@@ -76,10 +77,9 @@ public class MemberTokenServiceImpl implements MemberTokenService {
}
@Override
public Object getTokenObj() {
public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId();
Fc_member obj = jdbcTemplate.queryForBean("select * from fc_member where id = ?", Fc_member.class, id);
return obj;
return jdbcTemplate.queryForMap("select * from fc_member where id = ?", id);
}
@Override
......
package com.egolm.film.api.service.impl;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
......@@ -73,10 +74,9 @@ public class UserTokenServiceImpl implements UserTokenService {
}
@Override
public Object getTokenObj() {
public Map<String, Object> getTokenObj() {
Integer id = (Integer)this.getToken().getId();
Fc_user obj = jdbcTemplate.queryForBean("select * from fc_user where uid = ?", Fc_user.class, id);
return obj;
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);
}
@Override
......@@ -122,4 +122,6 @@ public class UserTokenServiceImpl implements UserTokenService {
Object[] objs = new Object[]{LOG_TYPE, loginid, prefix, path, ip, content, user_agent, now};
jdbcTemplate.executeUpdate(sql, objs);
}
}
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminAuthService;
......@@ -191,7 +192,7 @@ public class AdminAuthController {
@PostMapping("adminAuth")
@ApiOperation("当前登陆管理员权限查询")
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());
return Rjx.jsonOk().set("admin", admin).setData(groupMenuList);
}
......
......@@ -79,7 +79,7 @@ public class AdminReviewController {
index = index == null ? 1 : index;
limit = limit == null ? 20 : 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(
keyword,
admin.getGroup_id(),
......
......@@ -57,7 +57,7 @@ public class WebUtilController {
@PostMapping("verifyAuth")
@ApiOperation("校验权限")
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")) {
throw new XRException("权限错误");
}
......
......@@ -51,4 +51,11 @@ public class UserLoginController {
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;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.Util;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.NewsService;
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_user;
......@@ -40,7 +42,7 @@ public class UserNewsController {
index = index == null ? 1 : index;
limit = limit == null ? 20 : 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 gid = user.getGroup_id();
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