Commit b1ae727e authored by Quxl's avatar Quxl

x

parent 91ab1302
...@@ -16,7 +16,7 @@ import com.egolm.common.web.ServletUtil; ...@@ -16,7 +16,7 @@ import com.egolm.common.web.ServletUtil;
import com.egolm.film.api.service.AdminTokenService; import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.bean.Fc_admin; import com.egolm.film.bean.Fc_admin;
import com.egolm.film.config.WebMvcConfig; import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common; import com.egolm.film.util.Common;
...@@ -52,20 +52,20 @@ public class AdminTokenServiceImpl implements AdminTokenService { ...@@ -52,20 +52,20 @@ public class AdminTokenServiceImpl implements AdminTokenService {
} }
return token; return token;
} else if(state == 2) { } else if(state == 2) {
throw new XException("用户已禁用"); throw new XRException("用户已禁用");
} else { } else {
throw new XException("用户状态未知"); throw new XRException("用户状态未知");
} }
} else { } else {
throw new XException("用户名或密码错误"); throw new XRException("用户名或密码错误");
} }
} else if(list.size() == 0) { } else if(list.size() == 0) {
throw new XException("用户名或密码错误"); throw new XRException("用户名或密码错误");
} else { } else {
throw new XException("用户登陆信息重复,请联系管理员"); throw new XRException("用户登陆信息重复,请联系管理员");
} }
} else { } else {
throw new XException("用户名或密码错误"); throw new XRException("用户名或密码错误");
} }
} }
......
...@@ -17,7 +17,7 @@ import com.egolm.film.api.service.MemberTokenService; ...@@ -17,7 +17,7 @@ import com.egolm.film.api.service.MemberTokenService;
import com.egolm.film.api.service.Messages; import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Fc_member; import com.egolm.film.bean.Fc_member;
import com.egolm.film.config.WebMvcConfig; import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common; import com.egolm.film.util.Common;
...@@ -40,7 +40,7 @@ public class MemberTokenServiceImpl implements MemberTokenService { ...@@ -40,7 +40,7 @@ public class MemberTokenServiceImpl implements MemberTokenService {
try { try {
member = memberService.getMemberByEmail(email); member = memberService.getMemberByEmail(email);
} catch (Exception e) { } catch (Exception e) {
throw new XException(messages.get("err.user_pwd_err")); throw new XRException(messages.get("err.user_pwd_err"));
} }
Integer state = member.getState(); Integer state = member.getState();
if(state == 1) { if(state == 1) {
...@@ -59,12 +59,12 @@ public class MemberTokenServiceImpl implements MemberTokenService { ...@@ -59,12 +59,12 @@ public class MemberTokenServiceImpl implements MemberTokenService {
logger.debug("member login success: " + email); logger.debug("member login success: " + email);
return token; return token;
} else { } else {
throw new XException(messages.get("err.user_pwd_err")); throw new XRException(messages.get("err.user_pwd_err"));
} }
} else if(state == 2) { } else if(state == 2) {
throw new XException(messages.get("err.user_disabled")); throw new XRException(messages.get("err.user_disabled"));
} else { } else {
throw new XException(messages.get("err")); throw new XRException(messages.get("err"));
} }
} }
......
...@@ -16,7 +16,7 @@ import com.egolm.film.api.service.Messages; ...@@ -16,7 +16,7 @@ import com.egolm.film.api.service.Messages;
import com.egolm.film.api.service.UserTokenService; import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.bean.Fc_user; import com.egolm.film.bean.Fc_user;
import com.egolm.film.config.WebMvcConfig; import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
import com.egolm.film.util.Common; import com.egolm.film.util.Common;
...@@ -36,7 +36,7 @@ public class UserTokenServiceImpl implements UserTokenService { ...@@ -36,7 +36,7 @@ public class UserTokenServiceImpl implements UserTokenService {
try { try {
user = this.jdbcTemplate.queryForBean("select * from fc_user where username = ?", Fc_user.class, username); user = this.jdbcTemplate.queryForBean("select * from fc_user where username = ?", Fc_user.class, username);
} catch (Exception e) { } catch (Exception e) {
throw new XException(messages.get("err.user_pwd_err")); throw new XRException(messages.get("err.user_pwd_err"));
} }
Integer state = user.getState(); Integer state = user.getState();
if(state == 1) { if(state == 1) {
...@@ -56,12 +56,12 @@ public class UserTokenServiceImpl implements UserTokenService { ...@@ -56,12 +56,12 @@ public class UserTokenServiceImpl implements UserTokenService {
logger.debug("user login success: " + username); logger.debug("user login success: " + username);
return token; return token;
} else { } else {
throw new XException(messages.get("err.user_pwd_err")); throw new XRException(messages.get("err.user_pwd_err"));
} }
} else if(state == 2) { } else if(state == 2) {
throw new XException(messages.get("err.user_disabled")); throw new XRException(messages.get("err.user_disabled"));
} else { } else {
throw new XException(messages.get("err")); throw new XRException(messages.get("err"));
} }
} }
......
...@@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.film.api.service.AdminTokenService; import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.config.XException;
import com.egolm.film.config.XRException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
...@@ -29,7 +28,7 @@ public class AdminLoginController { ...@@ -29,7 +28,7 @@ public class AdminLoginController {
@PostMapping("login") @PostMapping("login")
@ApiOperation("登陆") @ApiOperation("登陆")
public Object login(String username, String password, HttpServletRequest request) { public Object login(String username, String password, HttpServletRequest request) {
XException.assertNotBlank("用户名或密码不能为空", username, password); XRException.assertNotBlank("用户名或密码不能为空", username, password);
if(tokenService.isLogin()) { if(tokenService.isLogin()) {
throw new XRException("用户已登录", 200); throw new XRException("用户已登录", 200);
} else { } else {
...@@ -38,7 +37,7 @@ public class AdminLoginController { ...@@ -38,7 +37,7 @@ public class AdminLoginController {
tokenService.doLog(request); tokenService.doLog(request);
return Rjx.jsonOk().setData(token); return Rjx.jsonOk().setData(token);
} else { } else {
throw new XException("用户名或密码错误"); throw new XRException("用户名或密码错误");
} }
} }
} }
......
...@@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.film.api.service.MemberTokenService; import com.egolm.film.api.service.MemberTokenService;
import com.egolm.film.api.service.Messages; import com.egolm.film.api.service.Messages;
import com.egolm.film.config.XException;
import com.egolm.film.config.XRException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
...@@ -38,7 +37,7 @@ public class MemberLoginController { ...@@ -38,7 +37,7 @@ public class MemberLoginController {
@ApiImplicitParam(paramType="header", dataType="string", name="i18n_language") @ApiImplicitParam(paramType="header", dataType="string", name="i18n_language")
}) })
public Object login(String username, String password, HttpServletRequest request) { public Object login(String username, String password, HttpServletRequest request) {
XException.assertNotBlank(messages.get("err.user_pwd_null"), username, password); XRException.assertNotBlank(messages.get("err.user_pwd_null"), username, password);
if(tokenService.isLogin()) { if(tokenService.isLogin()) {
throw new XRException("用户已登陆", 200); throw new XRException("用户已登陆", 200);
} else { } else {
...@@ -47,7 +46,7 @@ public class MemberLoginController { ...@@ -47,7 +46,7 @@ public class MemberLoginController {
tokenService.doLog(request); tokenService.doLog(request);
return Rjx.jsonOk(); return Rjx.jsonOk();
} else { } else {
throw new XException(messages.get("err.user_or_pwd")); throw new XRException(messages.get("err.user_or_pwd"));
} }
} }
} }
......
...@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.film.api.service.Messages; import com.egolm.film.api.service.Messages;
import com.egolm.film.api.service.UserTokenService; import com.egolm.film.api.service.UserTokenService;
import com.egolm.film.config.XException;
import com.egolm.film.config.XRException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
...@@ -31,7 +30,7 @@ public class UserLoginController { ...@@ -31,7 +30,7 @@ public class UserLoginController {
@PostMapping("login") @PostMapping("login")
@ApiOperation("登陆") @ApiOperation("登陆")
public Object login(String username, String password) { public Object login(String username, String password) {
XException.assertNotBlank(messages.get("err.user_pwd_null"), username, password); XRException.assertNotBlank(messages.get("err.user_pwd_null"), username, password);
if(tokenService.isLogin()) { if(tokenService.isLogin()) {
throw new XRException("用户已登陆", 200); throw new XRException("用户已登陆", 200);
} else { } else {
...@@ -39,7 +38,7 @@ public class UserLoginController { ...@@ -39,7 +38,7 @@ public class UserLoginController {
if(token != null) { if(token != null) {
return Rjx.jsonOk().setData(token); return Rjx.jsonOk().setData(token);
} else { } else {
throw new XException(messages.get("err.user_or_pwd")); throw new XRException(messages.get("err.user_or_pwd"));
} }
} }
} }
......
...@@ -32,4 +32,12 @@ public class XRException extends XException { ...@@ -32,4 +32,12 @@ public class XRException extends XException {
return rjx; return rjx;
} }
public static void assertNotBlank(String message, Object... objs) {
for(Object obj : objs) {
if(obj == null || obj.toString().trim().equals("")) {
throw new XException((message == null || message.trim().equals("")) ? "对象不能为空" : message);
}
}
}
} }
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