Commit 1c21910d by guojuxing

登录添加国际区码

parent 64e9aebf
......@@ -94,10 +94,19 @@ public interface UserApiService {
*/
ServiceResponse<UserDTO> getUserByEnterpriseId(Integer enterpriseId);
ServiceResponse<List<UserDTO>> listUserByPhoneNumber(String phoneNumber);
/**
* 根据登录账号查询商户列
* @Title: listUserByPhoneNumber

* @Description:

* @author guojuxing
* @param phoneNumber
* @param nationCode
国际区码
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.UserDTO>>


*/
ServiceResponse<List<UserDTO>> listUserByPhoneNumber(String phoneNumber, String nationCode);
/**
* 手机号和企业查询用户
* 手机号和企业查询用户,给好办用的
* @Title: listUserByPhoneNumber

* @Description:

 * @author guojuxing
......@@ -107,7 +116,9 @@ public interface UserApiService {

 */
ServiceResponse<UserDTO> listUserByPhoneNumber(String phoneNumber, Integer enterpriseId);
ServiceResponse<UserDTO> login(String phoneNumber, Integer enterpriseId, String password);
ServiceResponse<UserDTO> listUserByPhoneNumber(String nationCode, String phoneNumber, Integer enterpriseId);
ServiceResponse<UserDTO> login(String nationCode, String phoneNumber, Integer enterpriseId, String password);
/**
* 分页查询管理员列表数据
......
......@@ -78,14 +78,15 @@ public interface TabSysUserMapper {
* @return int


 */
int countByPhoneAndLoginType(@Param("phone") String phone, @Param("userId") Integer userId,
@Param("enterpriseId") Integer enterpriseId, @Param("loginType") Integer loginType);
@Param("enterpriseId") Integer enterpriseId, @Param("loginType") Integer loginType);
TabSysUser selectByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
List<TabSysUser> listAllUserByPhoneNumber(@Param("phoneNumber") String phoneNumber);
List<TabSysUser> listUserByPhoneNumberAndEnterprise(@Param("phoneNumber") String phoneNumber,
@Param("nationCode") String nationCode, @Param("enterpriseId") Integer enterpriseId);
TabSysUser login(@Param("phoneNumber") String phoneNumber, @Param("password") String password,
@Param("enterpriseId") Integer enterpriseId);
TabSysUser login(@Param("nationCode") String nationCode, @Param("phoneNumber") String phoneNumber,
@Param("password") String password, @Param("enterpriseId") Integer enterpriseId);
/**
* 列表查询
......
......@@ -20,6 +20,7 @@ public interface UserService {
* @return
*/
int saveUser(UserDTO userDTO);
/**
* 新增运营实施管理员
* @Title: saveOperationUser

......@@ -63,9 +64,11 @@ public interface UserService {
TabSysUser getUserByEnterpriseId(Integer enterpriseId);
List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber);
List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber, String nationCode);
List<TabSysUser> listUserByPhoneNumberAndEnterprise(String phoneNumber, String nationCode, Integer enterpriseId);
TabSysUser login(String phoneNumber, Integer enterpriseId, String password);
TabSysUser login(String nationCode, String phoneNumber, Integer enterpriseId, String password);
/**
* 查询管理员列表数据
......
......@@ -92,13 +92,19 @@ public class UserServiceImpl implements UserService {
}
@Override
public List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber) {
return this.tabSysUserMapper.listAllUserByPhoneNumber(phoneNumber);
public List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber, String nationCode) {
return tabSysUserMapper.listUserByPhoneNumberAndEnterprise(phoneNumber, nationCode, null);
}
@Override
public TabSysUser login(String phoneNumber, Integer enterpriseId, String password) {
return this.tabSysUserMapper.login(phoneNumber, password, enterpriseId);
public List<TabSysUser> listUserByPhoneNumberAndEnterprise(String phoneNumber, String nationCode,
Integer enterpriseId) {
return tabSysUserMapper.listUserByPhoneNumberAndEnterprise(phoneNumber, nationCode, enterpriseId);
}
@Override
public TabSysUser login(String nationCode, String phoneNumber, Integer enterpriseId, String password) {
return this.tabSysUserMapper.login(nationCode, phoneNumber, password, enterpriseId);
}
@Override
......
......@@ -307,8 +307,8 @@ public class UserApiServiceImpl implements UserApiService {
}
@Override
public ServiceResponse<List<UserDTO>> listUserByPhoneNumber(String phoneNumber) {
List<TabSysUser> list = this.userService.listAllUserByPhoneNumber(phoneNumber);
public ServiceResponse<List<UserDTO>> listUserByPhoneNumber(String phoneNumber, String nationCode) {
List<TabSysUser> list = this.userService.listAllUserByPhoneNumber(phoneNumber, nationCode);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(EntityUtil.changeEntityListByJSON(UserDTO.class, list));
}
......@@ -320,7 +320,7 @@ public class UserApiServiceImpl implements UserApiService {
if (enterpriseId == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户数据为空");
}
List<TabSysUser> list = this.userService.listAllUserByPhoneNumber(phoneNumber);
List<TabSysUser> list = this.userService.listAllUserByPhoneNumber(phoneNumber, Constants.NATION_CODE);
if (CollectionUtils.isNotEmpty(list)) {
for (TabSysUser user : list) {
if (enterpriseId.intValue() == user.getEnterpriseId().intValue()) {
......@@ -332,8 +332,22 @@ public class UserApiServiceImpl implements UserApiService {
}
@Override
public ServiceResponse<UserDTO> login(String phoneNumber, Integer enterpriseId, String password) {
TabSysUser user = this.userService.login(phoneNumber, enterpriseId, password);
public ServiceResponse<UserDTO> listUserByPhoneNumber(String nationCode, String phoneNumber, Integer enterpriseId) {
if (enterpriseId == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户数据为空");
}
List<TabSysUser> list = this.userService.listUserByPhoneNumberAndEnterprise(phoneNumber, nationCode,
enterpriseId);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(EntityUtil.changeEntityNew(UserDTO.class, list.get(0)));
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<UserDTO> login(String nationCode, String phoneNumber, Integer enterpriseId,
String password) {
TabSysUser user = this.userService.login(nationCode, phoneNumber, enterpriseId, password);
return ServiceResponse.success(EntityUtil.changeEntityByJSON(UserDTO.class, user));
}
......
......@@ -219,12 +219,20 @@
and login_type = 0
</select>
<select id="listAllUserByPhoneNumber" resultMap="BaseResultMap">
<select id="listUserByPhoneNumberAndEnterprise" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
where status = 1
<if test="enterpriseId != null">
and enterprise_id = #{enterpriseId}
</if>
<if test="phoneNumber != null and phoneNumber != '' ">
and phone_number = #{phoneNumber}
</if>
<if test="nationCode != null and nationCode != '' ">
and phone_area_code = #{nationCode}
</if>
</select>
<select id="login" resultMap="BaseResultMap">
......@@ -235,6 +243,7 @@
and status = 1
and enterprise_id = #{enterpriseId}
and password = #{password}
and phone_area_code = #{nationCode}
and login_type = 0
</select>
......
......@@ -14,6 +14,7 @@ import com.gic.auth.dto.ResourceDTO;
import com.gic.auth.dto.UserResourceDTO;
import com.gic.auth.service.*;
import com.gic.enterprise.base.UserResourceInfo;
import com.gic.enterprise.constants.Constants;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.LogManager;
......@@ -58,11 +59,15 @@ public class LoginController {
private ResourceApiService resourceApiService;
@RequestMapping("list-enterprise-by-phone")
public RestResponse listUserEnterprise(String phoneNumber) {
public RestResponse listUserEnterprise(String phoneNumber, String nationCode) {
if (StringUtils.isBlank(phoneNumber)) {
return EnterpriseRestResponse.failure(ErrorCode.PARAMETER_ERROR);
}
ServiceResponse<List<UserDTO>> listServiceResponse = this.userApiService.listUserByPhoneNumber(phoneNumber);
if (StringUtils.isBlank(nationCode)) {
nationCode = Constants.NATION_CODE;
}
ServiceResponse<List<UserDTO>> listServiceResponse = this.userApiService.listUserByPhoneNumber(phoneNumber,
nationCode);
if (listServiceResponse.isSuccess()) {
List<UserDTO> result = listServiceResponse.getResult();
if (CollectionUtils.isEmpty(result)) {
......@@ -91,16 +96,19 @@ public class LoginController {
}
@RequestMapping("login")
public RestResponse login(String phoneNumber, Integer enterpriseId, String password) {
public RestResponse login(String nationCode, String phoneNumber, Integer enterpriseId, String password) {
if (StringUtils.isBlank(password) || StringUtils.isBlank(phoneNumber) || enterpriseId == null) {
return EnterpriseRestResponse.failure(ErrorCode.PARAMETER_ERROR);
}
if (StringUtils.isBlank(nationCode)) {
nationCode = Constants.NATION_CODE;
}
Md5Util md5 = new Md5Util();
// password 自身作为盐值
if (password.length() != 32) {
password = md5.encrypt(password + password);
}
ServiceResponse<UserDTO> login = this.userApiService.login(phoneNumber, enterpriseId, password);
ServiceResponse<UserDTO> login = this.userApiService.login(nationCode, phoneNumber, enterpriseId, password);
if (login.isSuccess()) {
UserDTO userDTO = login.getResult();
if (userDTO == null) {
......@@ -131,7 +139,8 @@ public class LoginController {
}
//查询全部的操作模块
Map<String, MenuInfo> moduleMap = new HashMap<>(16);
ServiceResponse<List<MenuDTO>> allGicMenu = menuApiService.getSuperAdminMenuNotTree(enterpriseId);
ServiceResponse<List<MenuDTO>> allGicMenu = menuApiService
.getSuperAdminMenuNotTree(enterpriseId);
if (allGicMenu.isSuccess()) {
List<MenuDTO> temp = allGicMenu.getResult();
List<MenuInfo> tempMenuInfoList = EntityUtil.changeEntityListNew(MenuInfo.class, temp);
......@@ -196,12 +205,13 @@ public class LoginController {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "token错误");
}
private void setUserResource(UserDetail detail, Integer userId){
private void setUserResource(UserDetail detail, Integer userId) {
ServiceResponse<UserResourceDTO> resource = this.userResourceApiService.getResourceByUserId(userId);
detail.setUserResourceInfo(new UserResourceInfo());
if(resource.isSuccess() && resource.getResult() != null){
ServiceResponse<ResourceDTO> serviceResource = this.resourceApiService.getResource(resource.getResult().getResourceId());
if(serviceResource.isSuccess() && serviceResource.getResult() != null){
if (resource.isSuccess() && resource.getResult() != null) {
ServiceResponse<ResourceDTO> serviceResource = this.resourceApiService
.getResource(resource.getResult().getResourceId());
if (serviceResource.isSuccess() && serviceResource.getResult() != null) {
UserResourceInfo userResourceInfo = new UserResourceInfo();
userResourceInfo.setUserResource(serviceResource.getResult().getUserResource());
userResourceInfo.setStoreResource(serviceResource.getResult().getStoreResource());
......
......@@ -186,8 +186,8 @@ public class UserController {
UserDetail userDetail = UserDetailUtils.getUserDetail();
// password 自身作为盐值
String password = userDetail.getUserInfo().getPassword();
ServiceResponse<UserDTO> login = this.userApiService.login(userDetail.getUserInfo().getPhoneNumber(),
userDetail.getEnterpriseId(), password);
ServiceResponse<UserDTO> login = this.userApiService.login(nationCode,
userDetail.getUserInfo().getPhoneNumber(), userDetail.getEnterpriseId(), password);
ServiceResponse<String> result = userApiService.editPhoneOrPassword(login.getResult().getUserId(),
nationCode, phone, null);
if (result.isSuccess()) {
......@@ -234,18 +234,17 @@ public class UserController {
if (oldPassword.length() != 32) {
oldPassword = md5.encrypt(oldPassword + oldPassword);
}
ServiceResponse<UserDTO> login = this.userApiService.login(userDetail.getUserInfo().getPhoneNumber(),
userDetail.getEnterpriseId(), oldPassword);
ServiceResponse<UserDTO> login = this.userApiService.login(userDetail.getUserInfo().getPhoneAreaCode(),
userDetail.getUserInfo().getPhoneNumber(), userDetail.getEnterpriseId(), oldPassword);
if (!login.isSuccess()) {
return EnterpriseRestResponse.failure(login);
}
if (login.getResult() == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "旧密码错误");
}
ServiceResponse<String> result = userApiService.editPhoneOrPassword(login.getResult().getUserId(),
null, null, md5.encrypt(newPassword + newPassword));
return OperationResultUtils.operationResult(result, "修改密码",
OperationResultUtils.getOperationObject(result));
ServiceResponse<String> result = userApiService.editPhoneOrPassword(login.getResult().getUserId(), null, null,
md5.encrypt(newPassword + newPassword));
return OperationResultUtils.operationResult(result, "修改密码", OperationResultUtils.getOperationObject(result));
}
@RequestMapping("/list-user-nopage")
......
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