Commit f4bb1317 by 裴大威

Merge branch 'feature-checkIsHaveAuth4WeChat' into 'master'

判断用户对指定ServerId是否授权

See merge request rays/pcloud-book!156
parents 14343e0c e91e2c56
......@@ -46,6 +46,11 @@ public interface BookAuthUserBiz {
Boolean checkIsHaveAuth(Long bookId, Long channelId, Long adviserId, Long wechatUserId, Integer authBookType);
/**
* 校验用户针对指定的服务是否被授权
*/
Boolean checkIsHaveAuthWithServer(String userInfo, Long serverId);
/**
* 获取授权信息总的统计数据
*/
BookAuthCodeUserVO getAuthUserTotalCount(List<Long> adviserIds, List<Long> removeAdviserIds);
......
package com.pcloud.book.copyright.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.copyright.biz.BookAuthUserBiz;
import com.pcloud.book.copyright.dao.BookAuthServeDao;
import com.pcloud.book.copyright.dao.BookAuthUserDao;
import com.pcloud.book.copyright.dao.BookClickBuyRecordDao;
import com.pcloud.book.copyright.dto.CheckUserAuthDTO;
import com.pcloud.book.copyright.dto.DateDTO;
import com.pcloud.book.copyright.dto.ServeDTO;
import com.pcloud.book.copyright.entity.BookAuthUser;
import com.pcloud.book.copyright.entity.BookClickBuyRecord;
import com.pcloud.book.copyright.enums.AuthBookTypeEnum;
......@@ -19,6 +22,8 @@ import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -27,12 +32,11 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author lily
......@@ -45,6 +49,10 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
private BookAuthUserDao bookAuthUserDao;
@Autowired
private BookClickBuyRecordDao bookClickBuyRecordDao;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private BookAuthServeDao bookAuthServeDao;
@ParamLog(value = "获取授权用户数量")
......@@ -156,6 +164,25 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
}
@Override
public Boolean checkIsHaveAuthWithServer(String userInfo, Long serverId) {
Long bookId = qrcodeSceneConsr.getBookId4SceneId(Cookie.getId(userInfo,Cookie._SCENE_ID));
Long channelId = Cookie.getId(userInfo, Cookie._CHANNEL_ID);
Long adviserId = Cookie.getId(userInfo,Cookie._ADVISER_ID);
Long wecharUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
// 书类型指定为is_paper_book
Boolean isUserAuth = checkIsHaveAuth(bookId,channelId,adviserId,wecharUserId,0);
if(isUserAuth){
List<Long> serverIds = new ArrayList<>();
serverIds.add(serverId);
List<ServeDTO> serveDTOS = bookAuthServeDao.isSetServeAuth(bookId, channelId, adviserId, serverIds);
// 用户被授权, 且指定的应用也被版权保护时, 返回true
return !ListUtils.isEmpty(serveDTOS);
}
// 其余情况都是false
return false;
}
@Override
public BookAuthCodeUserVO getAuthUserTotalCount(List<Long> adviserIds, List<Long> removeAdviserIds) {
BookAuthCodeUserVO bookAuthCodeUserVO = bookAuthUserDao.getAuthUserTotalCount(adviserIds, removeAdviserIds);
if(bookAuthCodeUserVO != null){
......
......@@ -11,6 +11,7 @@ import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
......@@ -66,4 +67,9 @@ public interface BookAuthUserFacade {
@ApiOperation("校验用户是否授权过")
ResponseDto<?> checkIsHaveAuth(@CookieValue("userInfo") String userInfo, @RequestBody CheckUserParam checkUserParam)
throws BizException;
@GetMapping("checkIsHaveAuthWithServer")
@ApiOperation("校验用户针对指定的服务是否被授权")
ResponseDto<?> checkIsHaveAuthWithServer(@CookieValue("userInfo") String userInfo, @RequestParam("serveId") Long serveId)
throws BizException;
}
package com.pcloud.book.copyright.facade.impl;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.copyright.biz.BookAuthUserBiz;
import com.pcloud.book.copyright.facade.BookAuthUserFacade;
import com.pcloud.book.copyright.vo.BookAuthCodeUserVO;
......@@ -16,6 +17,7 @@ import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
......@@ -96,4 +98,10 @@ public class BookAuthUserFacadeImpl implements BookAuthUserFacade {
Boolean result = bookAuthUserBiz.checkIsHaveAuth(bookId, channelId, adviserId, wechatUserId, 1);
return new ResponseDto<>(result);
}
@Override
@GetMapping("checkIsHaveAuthWithServer")
public ResponseDto<?> checkIsHaveAuthWithServer(@CookieValue("userInfo") String userInfo, @RequestParam("serveId") Long serveId) throws BizException {
return new ResponseDto<>(bookAuthUserBiz.checkIsHaveAuthWithServer(userInfo,serveId));
}
}
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