Przeglądaj źródła

[移动端数据塔台][修改]:同一个租户的管理员才能登陆自己的数据塔台

release_toaliyun_real
Stormeye Wu 7 lat temu
rodzic
commit
3c339233e7
6 zmienionych plików z 39 dodań i 12 usunięć
  1. +17
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/HomeController.java
  2. +6
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java
  3. +2
    -2
      mallinkService/src/main/java/com/iformall/mapper/MallUserInfoMapper.java
  4. +3
    -2
      mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java
  5. +5
    -4
      mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java
  6. +6
    -0
      mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml

+ 17
- 2
mallinkAdmin/src/main/java/com/iformall/controller/HomeController.java Wyświetl plik

@@ -8,10 +8,12 @@ import com.iformall.common.ResultData;
import com.iformall.domain.po.MallRolePermission; import com.iformall.domain.po.MallRolePermission;
import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.MallUserRole; import com.iformall.domain.po.MallUserRole;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.service.MallRolePermissionService; import com.iformall.service.MallRolePermissionService;
import com.iformall.service.MallUserInfoService; import com.iformall.service.MallUserInfoService;
import com.iformall.service.MallUserRoleService; import com.iformall.service.MallUserRoleService;
import com.iformall.service.WxAppinfoService;
import com.iformall.shiro.UserSession; import com.iformall.shiro.UserSession;
import com.iformall.shiro.UseriFormallToken; import com.iformall.shiro.UseriFormallToken;
import com.iformall.utils.ShiroUtils; import com.iformall.utils.ShiroUtils;
@@ -56,6 +58,9 @@ public class HomeController extends BaseController {
@Autowired @Autowired
private MallRolePermissionService mallRolePermissionService; private MallRolePermissionService mallRolePermissionService;


@Autowired
private WxAppinfoService appinfoService;

@GetMapping("/captcha.jpg") @GetMapping("/captcha.jpg")
public void captcha(HttpServletResponse response)throws ServletException, IOException { public void captcha(HttpServletResponse response)throws ServletException, IOException {
logger.debug("[" + getIpAddr() + "] HomeController::captcha"); logger.debug("[" + getIpAddr() + "] HomeController::captcha");
@@ -167,15 +172,25 @@ public class HomeController extends BaseController {
public ResultData bLogin(@RequestBody MallUserInfo user) { public ResultData bLogin(@RequestBody MallUserInfo user) {
logger.debug("[" + getIpAddr() + "] HomeController::bHidLogin"); logger.debug("[" + getIpAddr() + "] HomeController::bHidLogin");
ResultData data = new ResultData(); ResultData data = new ResultData();
// tenantId is appId
if(StringUtils.isBlank(user.getTenantId())) {
logger.error("appid信息未提供");
return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND);
}
WxAppinfo appinfo = appinfoService.getByAppId(user.getTenantId());
if(appinfo == null) {
logger.error("appid未找到");
return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND);
}
if(StringUtils.isNotBlank(user.getPhone())) { if(StringUtils.isNotBlank(user.getPhone())) {
// 领导登录 // 领导登录
user = mallUserInfoService.getByPhone(user.getPhone());
user = mallUserInfoService.getByPhone(user.getPhone(), appinfo.getTenantId());
if(user == null || !isInMobileAdmin(user)) { if(user == null || !isInMobileAdmin(user)) {
return new ResultData(ErrorCode.USER_NOT_ADMIN); return new ResultData(ErrorCode.USER_NOT_ADMIN);
} }
} else if(StringUtils.isNotBlank(user.getOpenId())) { } else if(StringUtils.isNotBlank(user.getOpenId())) {
// 领导登录 // 领导登录
user = mallUserInfoService.getByOpenId(user.getOpenId());
user = mallUserInfoService.getByOpenId(user.getOpenId(), appinfo.getTenantId());
if(user == null || !isInMobileAdmin(user)) { if(user == null || !isInMobileAdmin(user)) {
return new ResultData(ErrorCode.USER_NOT_ADMIN); return new ResultData(ErrorCode.USER_NOT_ADMIN);
} }


+ 6
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxInfoController.java Wyświetl plik

@@ -86,10 +86,12 @@ public class WxInfoController extends BaseController {
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "code不能为空"); return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "code不能为空");
} }

WxAppinfo wxAppinfo = getAppInfo(appId);
try { try {
Map<String, String> retMap = getOpenIdInfo(appId, code); Map<String, String> retMap = getOpenIdInfo(appId, code);
String openId = retMap.get("openId"); String openId = retMap.get("openId");
MallUserInfo user = mallUserInfoService.getByOpenId(openId);
MallUserInfo user = mallUserInfoService.getByOpenId(openId, wxAppinfo.getTenantId());
if(user == null) { if(user == null) {
return new ResultData(ErrorCode.USER_NO_PERMISSION, retMap); return new ResultData(ErrorCode.USER_NO_PERMISSION, retMap);
} }
@@ -218,6 +220,8 @@ public class WxInfoController extends BaseController {
} }


WxMaService wxMaService = getWeappService(appId); WxMaService wxMaService = getWeappService(appId);

WxAppinfo wxAppinfo = getAppInfo(appId);
try { try {
// 解密 // 解密
WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(session_key, encryptedData, iv); WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(session_key, encryptedData, iv);
@@ -226,7 +230,7 @@ public class WxInfoController extends BaseController {
String phone = phoneNoInfo.getPhoneNumber(); String phone = phoneNoInfo.getPhoneNumber();
resultMap.put("phone", phone); resultMap.put("phone", phone);


MallUserInfo user = mallUserInfoService.getByPhone(phone);
MallUserInfo user = mallUserInfoService.getByPhone(phone, wxAppinfo.getTenantId());
if(user == null) { if(user == null) {
return new ResultData(ErrorCode.USER_NO_PERMISSION, resultMap); return new ResultData(ErrorCode.USER_NO_PERMISSION, resultMap);
} }


+ 2
- 2
mallinkService/src/main/java/com/iformall/mapper/MallUserInfoMapper.java Wyświetl plik

@@ -13,9 +13,9 @@ public interface MallUserInfoMapper extends CommonMapper<MallUserInfo, String> {


MallUserInfo selectByUserName(@Param("username") String username); MallUserInfo selectByUserName(@Param("username") String username);


MallUserInfo selectByOpenId(@Param("openId") String openId);
MallUserInfo selectByOpenId(@Param("openId") String openId, @Param("tenantId") String tenantId);


MallUserInfo selectByPhone(@Param("phone") String phone);
MallUserInfo selectByPhone(@Param("phone") String phone, @Param("tenantId") String tenantId);
Integer hasButtonPermission(@Param("userId") Long userId, @Param("permission") String permission); Integer hasButtonPermission(@Param("userId") Long userId, @Param("permission") String permission);




+ 3
- 2
mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java Wyświetl plik

@@ -3,6 +3,7 @@ package com.iformall.service;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxAppinfo;


import java.util.List; import java.util.List;


@@ -87,14 +88,14 @@ public interface MallUserInfoService {
* @param phone * @param phone
* @return * @return
*/ */
MallUserInfo getByPhone(String phone);
MallUserInfo getByPhone(String phone, String tenantId);
/** /**
* 根据OpenId获得实体 * 根据OpenId获得实体
* *
* @param openId * @param openId
* @return * @return
*/ */
MallUserInfo getByOpenId(String openId);
MallUserInfo getByOpenId(String openId, String tenantId);


/** /**
* 根据条件用户列表 * 根据条件用户列表


+ 5
- 4
mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java Wyświetl plik

@@ -8,6 +8,7 @@ import com.iformall.common.Result;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.MallUserRole; import com.iformall.domain.po.MallUserRole;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxMsgValidationcode; import com.iformall.domain.po.WxMsgValidationcode;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.mapper.MallUserInfoMapper; import com.iformall.mapper.MallUserInfoMapper;
@@ -57,13 +58,13 @@ public class MallUserInfoServiceImpl implements MallUserInfoService {
} }


@Override @Override
public MallUserInfo getByOpenId(String openId) {
return mallUserInfoMapper.selectByOpenId(openId);
public MallUserInfo getByOpenId(String openId, String tenantId) {
return mallUserInfoMapper.selectByOpenId(openId, tenantId);
} }


@Override @Override
public MallUserInfo getByPhone(String phone) {
return mallUserInfoMapper.selectByPhone(phone);
public MallUserInfo getByPhone(String phone, String tenantId) {
return mallUserInfoMapper.selectByPhone(phone, tenantId);
} }


@Override @Override


+ 6
- 0
mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml Wyświetl plik

@@ -103,6 +103,9 @@
<include refid="allColumns"/> <include refid="allColumns"/>
from mall_user_info from mall_user_info
where 1=1 where 1=1
<if test=" null != tenantId ">
and `tenant_id`=#{tenantId}
</if>
<if test=" null != openId "> <if test=" null != openId ">
and `open_id`=#{openId} and `open_id`=#{openId}
</if> </if>
@@ -113,6 +116,9 @@
<include refid="allColumns"/> <include refid="allColumns"/>
from mall_user_info from mall_user_info
where 1=1 where 1=1
<if test=" null != tenantId ">
and `tenant_id`=#{tenantId}
</if>
<if test=" null != phone "> <if test=" null != phone ">
and `phone`=#{phone} and `phone`=#{phone}
</if> </if>


Ładowanie…
Anuluj
Zapisz