Commit 91e1a9a1 by 阮思源

Merge branch 'feat-fix500' into 'master'

fix500

See merge request rays/pcloud-book!335
parents 2b6937de a7b25e07
...@@ -18,5 +18,4 @@ public interface SelfRobotKeywordBiz { ...@@ -18,5 +18,4 @@ public interface SelfRobotKeywordBiz {
String getAppOrProductServeUrl(Long bookGroupId, Long serveId, String serveType, String serveUrl); String getAppOrProductServeUrl(Long bookGroupId, Long serveId, String serveType, String serveUrl);
String getMaxKeyword(Long bookGroupId);
} }
...@@ -180,18 +180,6 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz { ...@@ -180,18 +180,6 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
return linkUrl; return linkUrl;
} }
@Override
public String getMaxKeyword(Long bookGroupId) {
List<String> keywords = selfRobotKeywordDao.getKeywords(bookGroupId);
Integer max = 0;
for (String keyword : keywords) {
Integer iKeyword = new Integer(keyword);
if (iKeyword > max) {
max = iKeyword;
}
}
return max.toString();
}
@ParamLog("填充列表") @ParamLog("填充列表")
private void fillSelfRobotKeyword(List<SelfRobotKeyword> selfRobotKeywords) { private void fillSelfRobotKeyword(List<SelfRobotKeyword> selfRobotKeywords) {
...@@ -274,8 +262,23 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz { ...@@ -274,8 +262,23 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
if (ListUtils.isEmpty(selfRobotKeywords)) { if (ListUtils.isEmpty(selfRobotKeywords)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数为空!");
} }
List<Long> bookGroupIds = selfRobotKeywords.stream().map(SelfRobotKeyword::getBookGroupId).distinct().collect(Collectors.toList());
List<SelfRobotKeyword> list = selfRobotKeywordDao.getListByBookGroupIds(bookGroupIds);
Map<Long,List<SelfRobotKeyword>> map=new HashMap<>();
if (!ListUtils.isEmpty(list)){
map=list.stream().filter(s->s.getBookGroupId()!=null).collect(Collectors.groupingBy(SelfRobotKeyword::getBookGroupId));
}
for (SelfRobotKeyword selfRobotKeyword : selfRobotKeywords) { for (SelfRobotKeyword selfRobotKeyword : selfRobotKeywords) {
checkAddSelfRobotKeyword(selfRobotKeyword); checkAddSelfRobotKeyword(selfRobotKeyword);
List<SelfRobotKeyword> keywordList = map.get(selfRobotKeyword.getBookGroupId());
if (!ListUtils.isEmpty(keywordList)){
List<String> keywords=keywordList.stream().map(SelfRobotKeyword::getKeyword).collect(Collectors.toList());
if (!ListUtils.isEmpty(keywords)){
if (keywords.contains(selfRobotKeyword.getKeyword())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "关键词不能重复!");
}
}
}
} }
} }
...@@ -287,6 +290,10 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz { ...@@ -287,6 +290,10 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
if (selfRobotKeyword.getId()==null){ if (selfRobotKeyword.getId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "id不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "id不能为空!");
} }
List<String> keywords = selfRobotKeywordDao.getKeywords(selfRobotKeyword.getBookGroupId());
if (!ListUtils.isEmpty(keywords)&&keywords.contains(selfRobotKeyword.getKeyword())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "关键词不能重复!");
}
checkAddSelfRobotKeyword(selfRobotKeyword); checkAddSelfRobotKeyword(selfRobotKeyword);
} }
......
...@@ -29,4 +29,6 @@ public interface SelfRobotKeywordDao extends BaseDao<SelfRobotKeyword> { ...@@ -29,4 +29,6 @@ public interface SelfRobotKeywordDao extends BaseDao<SelfRobotKeyword> {
void updateSeqNum(Long id, Integer seqNum); void updateSeqNum(Long id, Integer seqNum);
List<String> getKeywords(Long bookGroupId); List<String> getKeywords(Long bookGroupId);
List<SelfRobotKeyword> getListByBookGroupIds(List<Long> bookGroupIds);
} }
...@@ -77,4 +77,11 @@ public class SelfRobotKeywordDaoImpl extends BaseDaoImpl<SelfRobotKeyword> imple ...@@ -77,4 +77,11 @@ public class SelfRobotKeywordDaoImpl extends BaseDaoImpl<SelfRobotKeyword> imple
map.put("bookGroupId", bookGroupId); map.put("bookGroupId", bookGroupId);
return this.getSqlSession().selectList(this.getStatement("getKeywords"), map); return this.getSqlSession().selectList(this.getStatement("getKeywords"), map);
} }
@Override
public List<SelfRobotKeyword> getListByBookGroupIds(List<Long> bookGroupIds) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
return this.getSqlSession().selectList(this.getStatement("getListByBookGroupIds"), map);
}
} }
...@@ -78,10 +78,4 @@ public interface SelfRobotKeywordFacade { ...@@ -78,10 +78,4 @@ public interface SelfRobotKeywordFacade {
@RequestParam("serveUrl") @ApiParam("作品或应用链接") String serveUrl @RequestParam("serveUrl") @ApiParam("作品或应用链接") String serveUrl
) throws BizException, PermissionException; ) throws BizException, PermissionException;
@ApiOperation("获取最大关键词")
@GetMapping("getMaxKeyword")
ResponseDto<?> getMaxKeyword(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId
) throws BizException, PermissionException;
} }
...@@ -124,14 +124,4 @@ public class SelfRobotKeywordFacadeImpl implements SelfRobotKeywordFacade { ...@@ -124,14 +124,4 @@ public class SelfRobotKeywordFacadeImpl implements SelfRobotKeywordFacade {
return new ResponseDto<>(selfRobotKeywordBiz.getAppOrProductServeUrl(bookGroupId,serveId,serveType,serveUrl)); return new ResponseDto<>(selfRobotKeywordBiz.getAppOrProductServeUrl(bookGroupId,serveId,serveType,serveUrl));
} }
@ApiOperation("获取最大关键词")
@GetMapping("getMaxKeyword")
@Override
public ResponseDto<?> getMaxKeyword(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(selfRobotKeywordBiz.getMaxKeyword(bookGroupId));
}
} }
...@@ -194,4 +194,13 @@ ...@@ -194,4 +194,13 @@
select keyword from self_robot_keyword select keyword from self_robot_keyword
where book_group_id=#{bookGroupId} where book_group_id=#{bookGroupId}
</select> </select>
<select id="getListByBookGroupIds" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from self_robot_keyword
where book_group_id in
<foreach collection="bookGroupIds" item="item" open="(" separator="," close=")">
${item}
</foreach>
</select>
</mapper> </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