Commit bc33e762 by 田超

Merge branch 'feature/1005149' into 'master'

feat: [1005149] 授权优化

See merge request rays/pcloud-book!1370
parents eabe5217 e150e32b
...@@ -833,6 +833,16 @@ public class BookDto extends BaseDto { ...@@ -833,6 +833,16 @@ public class BookDto extends BaseDto {
//是否开启手机号登录 //是否开启手机号登录
private Integer bookPhoneAuth; private Integer bookPhoneAuth;
private Integer isWechatAuth;
public Integer getIsWechatAuth() {
return isWechatAuth;
}
public void setIsWechatAuth(Integer isWechatAuth) {
this.isWechatAuth = isWechatAuth;
}
public Integer getUploadUserId() { public Integer getUploadUserId() {
return uploadUserId; return uploadUserId;
} }
......
...@@ -459,4 +459,8 @@ public interface BookAdviserBiz { ...@@ -459,4 +459,8 @@ public interface BookAdviserBiz {
* @return * @return
*/ */
Integer getBookPhoneAuth(Long sceneId, Long bookId, Long adviserId, Long channelId); Integer getBookPhoneAuth(Long sceneId, Long bookId, Long adviserId, Long channelId);
void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth);
Integer getBookWechatAuth(Long sceneId, Long bookId, Long adviserId, Long channelId);
} }
...@@ -3296,4 +3296,37 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -3296,4 +3296,37 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
return bookPhoneAuth; return bookPhoneAuth;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth) {
if (null == bookId || null == adviserId || null == channelId || null == isWechatAuth) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "参数为空请确认");
}
bookAdviserDao.updateBookWechatAuth(bookId, adviserId, channelId, isWechatAuth);
}
@Override
public Integer getBookWechatAuth(Long sceneId, Long bookId, Long adviserId, Long channelId) {
Integer isWechatAuth = YesOrNoEnums.YES.getValue();
if(null == sceneId && null == bookId && null == adviserId && null == channelId) {
return isWechatAuth;
}
if (null != bookId) {
isWechatAuth = bookAdviserDao.getBookWechatAuth(bookId, adviserId, channelId);
} else if (null != sceneId) {
//根据sceneId获取二维码信息
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = qrcodeSceneConsr.listBaseInfoByIds(Lists.newArrayList(sceneId));
if (MapUtils.isEmpty(qrcodeSceneDtoMap) || null == qrcodeSceneDtoMap.get(sceneId)) {
return isWechatAuth;
}
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(sceneId);
if (null == qrcodeSceneDto || null == qrcodeSceneDto.getAdviserBookId()) {
return isWechatAuth;
}
isWechatAuth = bookAdviserDao.getBookPhoneAuth(qrcodeSceneDto.getAdviserBookId(), qrcodeSceneDto.getCreatedByUserLogin(),qrcodeSceneDto.getChannelPartyId());
}
return isWechatAuth;
}
} }
...@@ -335,4 +335,8 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> { ...@@ -335,4 +335,8 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> {
void updateBookPhoneAuth(Long bookId, Long adviserId, Long channelId, Integer bookPhoneAuth); void updateBookPhoneAuth(Long bookId, Long adviserId, Long channelId, Integer bookPhoneAuth);
Integer getBookPhoneAuth(Long bookId, Long adviserId, Long channelId); Integer getBookPhoneAuth(Long bookId, Long adviserId, Long channelId);
void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth);
Integer getBookWechatAuth(Long bookId, Long adviserId, Long channelId);
} }
...@@ -466,4 +466,23 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book ...@@ -466,4 +466,23 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book
paramMap.put("adviserId", adviserId); paramMap.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookPhoneAuth"), paramMap); return getSessionTemplate().selectOne(getStatement("getBookPhoneAuth"), paramMap);
} }
@Override
public void updateBookWechatAuth(Long bookId, Long adviserId, Long channelId, Integer isWechatAuth) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
paramMap.put("isWechatAuth", isWechatAuth);
getSessionTemplate().update(getStatement("updateBookWechatAuth"), paramMap);
}
@Override
public Integer getBookWechatAuth(Long bookId, Long adviserId, Long channelId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId", channelId);
paramMap.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookWechatAuth"), paramMap);
}
} }
...@@ -468,4 +468,29 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade { ...@@ -468,4 +468,29 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
Cookie.getUserInfo(userInfo); Cookie.getUserInfo(userInfo);
return new ResponseDto<Integer>(bookAdviserBiz.getBookPhoneAuth(sceneId,bookId, adviserId, channelId)); return new ResponseDto<Integer>(bookAdviserBiz.getBookPhoneAuth(sceneId,bookId, adviserId, channelId));
} }
/**
* 设置书刊二维码进入是否需要授权用户信息
*/
@RequestMapping(value = "updateBookWechatAuth", method = RequestMethod.GET)
public ResponseDto<?> updateBookWechatAuth(@RequestHeader("token") String token,
@RequestParam(value = "bookId") Long bookId,
@RequestParam(value = "channelId") Long channelId,
@RequestParam(value = "isWechatAuth") Integer isWechatAuth) throws PermissionException {
Long adviserId = (Long)SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAdviserBiz.updateBookWechatAuth(bookId, adviserId, channelId, isWechatAuth);
return new ResponseDto<>();
}
/**
* 获取书刊二维码进入是否需要授权用户信息
*/
@RequestMapping(value = "getBookWechatAuth", method = RequestMethod.GET)
public ResponseDto<?> getBookWechatAuth(
@RequestParam(value = "sceneId",required = false) Long sceneId,
@RequestParam(value = "bookId",required = false) Long bookId,
@RequestParam(value = "adviserId",required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId) throws PermissionException {
return new ResponseDto<Integer>(bookAdviserBiz.getBookWechatAuth(sceneId,bookId, adviserId, channelId));
}
} }
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<result column="is_approval" property="isApproval" jdbcType="BIT" /> <result column="is_approval" property="isApproval" jdbcType="BIT" />
<result column="is_relate" property="isRelate" jdbcType="BIT" /> <result column="is_relate" property="isRelate" jdbcType="BIT" />
<result column="book_phone_auth" property="bookPhoneAuth" jdbcType="BIT" /> <result column="book_phone_auth" property="bookPhoneAuth" jdbcType="BIT" />
<result column="is_wechat_auth" property="isWechatAuth" jdbcType="BIT" />
</resultMap> </resultMap>
<resultMap id="bookListPageMap" type="bookDto" extends ="bookMap"> <resultMap id="bookListPageMap" type="bookDto" extends ="bookMap">
...@@ -320,7 +321,7 @@ ...@@ -320,7 +321,7 @@
BA.GRA_LABEL_ID,BA.SUB_LABEL_ID,BA.VER_LABEL_ID,BA.AREA_LABEL_ID, BA.IS_PRINT isPrint, BA.is_relate, BA.GRA_LABEL_ID,BA.SUB_LABEL_ID,BA.VER_LABEL_ID,BA.AREA_LABEL_ID, BA.IS_PRINT isPrint, BA.is_relate,
BA.pro_label_id, BA.dep_label_id,BA.pur_label_id,BA.vol_label_id,if(G.ID IS NULL, 0, 1) isBookGroup, G.id BOOK_GROUP_ID,G.join_group_type, BA.pro_label_id, BA.dep_label_id,BA.pur_label_id,BA.vol_label_id,if(G.ID IS NULL, 0, 1) isBookGroup, G.id BOOK_GROUP_ID,G.join_group_type,
BA.is_open_robot_process,BA.vol_label_id,b.unique_number,BA.CREATED_DATE,b.edition,BA.is_send_mini_url, BA.is_open_robot_process,BA.vol_label_id,b.unique_number,BA.CREATED_DATE,b.edition,BA.is_send_mini_url,
BA.is_open_catalog ,BA.is_approval, BA.book_phone_auth BA.is_open_catalog ,BA.is_approval, BA.book_phone_auth,BA.is_wechat_auth
FROM FROM
BOOK_ADVISER BA BOOK_ADVISER BA
INNER JOIN INNER JOIN
......
...@@ -1270,4 +1270,37 @@ ...@@ -1270,4 +1270,37 @@
is_delete = 0 is_delete = 0
limit 1 limit 1
</select> </select>
<update id="updateBookWechatAuth" parameterType="map">
update
book_adviser
set
is_wechat_auth = #{isWechatAuth}, LAST_MODIFIED_DATE = NOW()
where
BOOK_ID = #{bookId, jdbcType=BIGINT}
AND
ADVISER_ID = #{adviserId, jdbcType=BIGINT}
AND
CHANNEL_ID = #{channelId, jdbcType=BIGINT}
and
IS_DELETE = 0
</update>
<select id="getBookWechatAuth" parameterType="map" resultType="integer">
select
is_wechat_auth
from
book_adviser
where
book_id = #{bookId}
<if test="adviserId != null">
and adviser_id = #{adviserId}
</if>
<if test="channelId != null">
and channel_id = #{channelId}
</if>
and
is_delete = 0
limit 1
</select>
</mapper> </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