Commit b1ae727e authored by Quxl's avatar Quxl

x

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