Commit 13d05208 by 高鹏

Merge branch 'feat-1001857' into 'master'

ID1001857社群码配置服务不限制渠道

See merge request rays/pcloud-book!205
parents b382a120 05feca4c
......@@ -109,4 +109,8 @@ public interface BookGroupService {
@GetMapping("fillSelfBookGroupCipher")
void fillSelfBookGroupCipher();
@ApiOperation("将之前的配置资源取的社群码运营更新为应用本身的运营")
@GetMapping("dealBookGroupServerChannel")
void dealBookGroupServerChannel();
}
......@@ -454,4 +454,9 @@ public interface BookGroupBiz {
* 补充1v1旧数据的暗号
*/
void fillSelfBookGroupCipher();
/**
* 将之前的配置资源取的社群码运营更新为应用本身的运营
*/
void dealBookGroupServerChannel();
}
......@@ -2152,6 +2152,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(dto.getChannelId());
for (BookGroupServe bookGroupServe : bookGroupServes) {
if ("APP".equalsIgnoreCase(bookGroupServe.getServeType())) {
AppDto appDto = appConsr.getBaseById(bookGroupServe.getServeId());
if (appDto != null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
}
}
// 处理链接地址
String endUrl = bookGroupServe.getServeUrl() + "&book_group_id=" + bookGroupId;
String linkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, endUrl);
......@@ -2241,7 +2247,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
@ParamLog("校验字段")
private void checkBookGroupServe(List<BookGroupServe> bookGroupServes){
if (ListUtils.isEmpty(bookGroupServes)) {
return;
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数不能为空!");
}
for (BookGroupServe bookGroupServe : bookGroupServes) {
if (bookGroupServe == null) {
......@@ -2262,6 +2268,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("批量更新资源配置")
@Override
public void batchUpdateBookGroupServe(Long partyId, List<BookGroupServe> bookGroupServes) {
......@@ -2309,6 +2316,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
// 处理链接地址
String endUrl = bookGroupServe.getServeUrl() + "&book_group_id=" + bookGroupId;
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(bookGroup.getChannelId());
if ("APP".equalsIgnoreCase(bookGroupServe.getServeType())) {
AppDto appDto = appConsr.getBaseById(bookGroupServe.getServeId());
if (appDto != null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
}
}
String linkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, endUrl);
//转短链
String resultUrl = UrlUtils.getShortUrl4Own(linkUrl);
......@@ -2337,6 +2350,45 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
}
@ParamLog("将之前的配置资源取的社群码运营更新为应用本身的运营")
@Override
public void dealBookGroupServerChannel() {
List<BookGroupServe> bookGroupServes=bookGroupServeDao.getListByServerType("APP");
if (ListUtils.isEmpty(bookGroupServes)) {
return;
}
List<Long> appIds=new ArrayList<>();
List<Long> bookGroupIds=new ArrayList<>();
for (BookGroupServe bookGroupServe:bookGroupServes){
if (!appIds.contains(bookGroupServe.getServeId())){
appIds.add(bookGroupServe.getServeId());
}
if (!bookGroupIds.contains(bookGroupServe.getBookGroupId())){
bookGroupIds.add(bookGroupServe.getBookGroupId());
}
}
Map<Long, AppDto> appDtoMap = appConsr.getBaseByIds(appIds);
List<BookGroupDTO> bookGroupDTOList = bookGroupDao.getDTOByIds(bookGroupIds);
Map<Long, BookGroupDTO> bookGroupMap=new HashMap<>();
for (BookGroupDTO bookGroupDTO:bookGroupDTOList){
bookGroupMap.put(bookGroupDTO.getId(),bookGroupDTO);
}
for (BookGroupServe bookGroupServe : bookGroupServes) {
AppDto appDto = appDtoMap.get(bookGroupServe.getServeId());
BookGroupDTO bookGroupDTO = bookGroupMap.get(bookGroupServe.getBookGroupId());
if (appDto != null && bookGroupDTO != null && !appDto.getChannelId().equals(bookGroupDTO.getChannelId())) {
//换链接
String endUrl = bookGroupServe.getServeUrl() + "&book_group_id=" + bookGroupServe.getBookGroupId();
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
String linkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, endUrl);
//转短链
String resultUrl = UrlUtils.getShortUrl4Own(linkUrl);
bookGroupServeDao.updateShortUrl(bookGroupServe.getId(), resultUrl);
}
}
}
@ParamLog("生成暗号")
private String createBookGroupCipher(){
//生成暗号规则:abc1234,前三位小写字母,后四位数字
......
......@@ -11,4 +11,8 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> {
List<BookGroupServe> getListByBookGroupId(Long bookGroupId);
void deleteByBookGroupId(Long bookGroupId);
List<BookGroupServe> getListByServerType(String serveType);
void updateShortUrl(Long id, String shortUrl);
}
......@@ -5,7 +5,9 @@ import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
......@@ -28,4 +30,17 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
public void deleteByBookGroupId(Long bookGroupId) {
super.getSqlSession().delete(getStatement("deleteByBookGroupId"), bookGroupId);
}
@Override
public List<BookGroupServe> getListByServerType(String serveType) {
return super.getSqlSession().selectList(getStatement("getListByServerType"), serveType);
}
@Override
public void updateShortUrl(Long id, String shortUrl) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("shortUrl", shortUrl);
super.getSqlSession().update(getStatement("updateShortUrl"), map);
}
}
......@@ -183,4 +183,12 @@ public class BookGroupServiceImpl implements BookGroupService {
bookGroupBiz.fillSelfBookGroupCipher();
}
@ApiOperation("将之前的配置资源取的社群码运营更新为应用本身的运营")
@GetMapping("dealBookGroupServerChannel")
@Override
public void dealBookGroupServerChannel() {
bookGroupBiz.dealBookGroupServerChannel();
}
}
......@@ -82,4 +82,18 @@
delete from book_group_serve
where book_group_id=#{bookGroupId}
</delete>
<!--根据类型查询集合-->
<select id="getListByServerType" parameterType="String" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_group_serve
where serve_type=#{serveType}
</select>
<!--根据id更新短链-->
<update id="updateShortUrl" parameterType="map">
update book_group_serve set
short_url=#{shortUrl}
where id=#{id}
</update>
</mapper>
\ No newline at end of file
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