Commit e1c85a00 by 田超

Merge branch 'feature/authcode' into 'master'

feat:[none]重置授权码

See merge request rays/pcloud-book!1477
parents 66bdbe7a 6a46073c
......@@ -95,4 +95,11 @@ public interface BookAuthCodeBiz {
* 扫应用里面单个资源码也要版权保护
*/
CheckAppServeVO checkAppServe(CheckIsAuthServeParam checkIsAuthServeParam, Long channelId, Long wechatUserId);
/**
* @Description 清空授权码使用用户
* @Author zhuyajie
* @Date 16:27 2021/12/13
**/
void clearAuthCodeUser(Long adviserId, String fullCode, Long bookId);
}
......@@ -76,4 +76,10 @@ public interface BookAuthUserBiz {
* 获取使用授权码的用户
*/
Map<Long, List<BookAuthUserDTO>> getByAuthCodeIds(List<Long> authCodeIds,Long sceneId);
/**
* 获取使用授权码的用户
*/
BookAuthUserDTO getByAuthCodeId(Long authCodeId);
void deleteById(Long id);
}
......@@ -662,4 +662,17 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
result.setSceneId(sceneId);
return result;
}
@Override
public void clearAuthCodeUser(Long adviserId, String fullCode, Long bookId) {
BookAuthCode bookAuthCode = bookAuthCodeDao.getByAdviserAndCode(adviserId, fullCode, bookId);
if (null == bookAuthCode || (bookAuthCode.getUseCount() != null && bookAuthCode.getUseCount()<=0)) {
return;
}
BookAuthUserDTO bookAuthUserDTO = bookAuthUserBiz.getByAuthCodeId(bookAuthCode.getId());
if (null != bookAuthUserDTO) {
bookAuthUserBiz.deleteById(bookAuthUserDTO.getId());
}
bookAuthCodeDao.clearUseCount(bookAuthCode.getId());
}
}
......@@ -366,4 +366,14 @@ public class BookAuthUserBizImpl implements BookAuthUserBiz {
}
return bookAuthUserList.stream().collect(Collectors.groupingBy(x -> x.getBookAuthCodeId()));
}
@Override
public BookAuthUserDTO getByAuthCodeId(Long authCodeId) {
return bookAuthUserDao.getByAuthCodeId(authCodeId);
}
@Override
public void deleteById(Long id) {
bookAuthUserDao.deleteById(id);
}
}
......@@ -61,4 +61,8 @@ public interface BookAuthCodeDao extends BaseDao<BookAuthCode> {
BookAuthCode getByFullCode(String code);
List<Long> getCodeIdList(Long bookId, Long channelId, Long adviserId, String keyWord, Integer authBookType);
BookAuthCode getByAdviserAndCode(Long adviserId, String fullCode, Long bookId);
void clearUseCount(Long id);
}
......@@ -74,4 +74,6 @@ public interface BookAuthUserDao extends BaseDao<BookAuthUser> {
* 获取使用授权码的用户
*/
List<BookAuthUserDTO> getByAuthCodeIds(List<Long> authCodeIds,Long sceneId);
BookAuthUserDTO getByAuthCodeId(Long authCodeId);
}
......@@ -113,4 +113,18 @@ public class BookAuthCodeDaoImpl extends BaseDaoImpl<BookAuthCode> implements Bo
}
return this.getSqlSession().selectList(this.getStatement("getCodeIdList"), paramMap);
}
@Override
public BookAuthCode getByAdviserAndCode(Long adviserId, String fullCode, Long bookId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("fullCode",fullCode);
paramMap.put("adviserId",adviserId);
return getSessionTemplate().selectOne(getStatement("getByAdviserAndCode"), paramMap);
}
@Override
public void clearUseCount(Long id) {
getSessionTemplate().update(getStatement("clearUseCount"), id);
}
}
......@@ -143,4 +143,9 @@ public class BookAuthUserDaoImpl extends BaseDaoImpl<BookAuthUser> implements Bo
paramMap.put("sceneId", sceneId);
return this.getSessionTemplate().selectList(this.getStatement("getByAuthCodeIds"), paramMap);
}
@Override
public BookAuthUserDTO getByAuthCodeId(Long authCodeId) {
return getSessionTemplate().selectOne(getStatement("getByAuthCodeId"), authCodeId);
}
}
......@@ -47,6 +47,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import io.swagger.annotations.ApiOperation;
/**
* @author lily
* @date 2018/11/29 16:59
......@@ -310,4 +312,11 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade {
CheckAppServeVO result = bookAuthCodeBiz.checkAppServe(checkIsAuthServeParam, channelId, wechatUserId);
return new ResponseDto<>(result);
}
@ApiOperation("清空授权码使用用户")
@GetMapping("clearAuthCodeUser")
public ResponseDto<?> clearAuthCodeUser(@RequestParam("adviserId") Long adviserId,@RequestParam("bookId") Long bookId, @RequestParam("fullCode") String fullCode) {
bookAuthCodeBiz.clearAuthCodeUser(adviserId,fullCode,bookId);
return new ResponseDto<>();
}
}
......@@ -241,4 +241,32 @@
</if>
</select>
<select id="getByAdviserAndCode" resultType="com.pcloud.book.copyright.entity.BookAuthCode">
SELECT
id,
book_id bookId,
channel_id channelId,
adviser_id adviserId,
create_type createType,
auth_code authCode,
batch_num batchNum,
full_code fullCode,
use_count useCount,
created_date createdDate
FROM
BOOK_AUTH_CODE
WHERE
book_id = #{bookId}
AND full_code = #{fullCode}
AND adviser_id = #{adviserId}
limit 1
</select>
<update id="clearUseCount" parameterType="long">
UPDATE book_auth_code
SET use_count = 0,
last_modified_date = NOW()
where id = #{id}
</update>
</mapper>
......@@ -285,4 +285,18 @@
</if>-->
</select>
<select id="getByAuthCodeId" parameterType="map" resultType="com.pcloud.book.copyright.dto.BookAuthUserDTO">
SELECT
id, is_auth_code isAuthCode, created_time createdTime, wechat_user_id wechatUserId, book_auth_code_id bookAuthCodeId
FROM
BOOK_AUTH_USER
WHERE is_auth_code = 0
AND book_auth_code_id = #{authCodeId}
limit 1
</select>
<delete id="deleteById" parameterType="long">
DELETE FROM book_auth_user WHERE id = #{id}
</delete>
</mapper>
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