Commit 1429b774 by 阮思源

加接口,批量更新资源配置

parent a755a31a
......@@ -432,4 +432,11 @@ public interface BookGroupBiz {
* 获取社群码暗号
*/
String getBookGroupCipher();
/**
* 批量更新资源配置
* @param partyId
* @param bookGroupServes
*/
void batchUpdateBookGroupServe(Long partyId, List<BookGroupServe> bookGroupServes);
}
......@@ -2111,26 +2111,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
@Transactional(rollbackFor = Exception.class)
@Override
public void batchAddBookGroupServe(Long partyId, List<BookGroupServe> bookGroupServes) {
if (ListUtils.isEmpty(bookGroupServes)) {
return;
}
for (BookGroupServe bookGroupServe : bookGroupServes) {
if (bookGroupServe == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数不能为空!");
}
if (bookGroupServe.getBookGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数社群书id不能为空!");
}
if (bookGroupServe.getServeId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数应用或作品id不能为空!");
}
if (StringUtil.isEmpty(bookGroupServe.getServeUrl())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "链接不能为空!");
}
if (!("PRODUCT".equals(bookGroupServe.getServeType()) || "APP".equals(bookGroupServe.getServeType()))) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数应用或作品类型有误(APP或PRODUCT)!");
}
}
checkBookGroupServe(bookGroupServes);
Long bookGroupId=bookGroupServes.get(0).getBookGroupId();
BookGroupDTO dto = bookGroupDao.getDTOById(bookGroupId);
if (dto==null){
......@@ -2181,8 +2162,10 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
Map<Long, ProductDto> productDtoMap = new HashMap<>();
Map<Long, AppDto> appDtoMap = new HashMap<>();
Map<Long, Boolean> isSuperMap = new HashMap<>();
if (!ListUtils.isEmpty(productIds)) {
productDtoMap = productConsr.getProBasesByIds(productIds);
isSuperMap = productConsr.getIsSuperByProductIdList(productIds);
}
if (!ListUtils.isEmpty(appIds)) {
appDtoMap = appConsr.mapByIds(appIds);
......@@ -2192,12 +2175,15 @@ public class BookGroupBizImpl implements BookGroupBiz {
ProductDto productDto = productDtoMap.get(bookGroupServe.getServeId());
if (productDto != null) {
bookGroupServe.setServeName(productDto.getProductName());
bookGroupServe.setFromType(productDto.getProductTypeCode());
bookGroupServe.setIsSuper(isSuperMap.get(bookGroupServe.getServeId()));
}
}
if ("APP".equals(bookGroupServe.getServeType())) {
AppDto appDto = appDtoMap.get(bookGroupServe.getServeId());
if (appDto != null) {
bookGroupServe.setServeName(appDto.getTitle());
bookGroupServe.setFromType(appDto.getTypeCode());
}
}
}
......@@ -2217,6 +2203,41 @@ public class BookGroupBizImpl implements BookGroupBiz {
return bookGroupCipher;
}
@ParamLog("校验字段")
private void checkBookGroupServe(List<BookGroupServe> bookGroupServes){
if (ListUtils.isEmpty(bookGroupServes)) {
return;
}
for (BookGroupServe bookGroupServe : bookGroupServes) {
if (bookGroupServe == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数不能为空!");
}
if (bookGroupServe.getBookGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数社群书id不能为空!");
}
if (bookGroupServe.getServeId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数应用或作品id不能为空!");
}
if (StringUtil.isEmpty(bookGroupServe.getServeUrl())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "链接不能为空!");
}
if (!("PRODUCT".equals(bookGroupServe.getServeType()) || "APP".equals(bookGroupServe.getServeType()))) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数应用或作品类型有误(APP或PRODUCT)!");
}
}
}
@ParamLog("批量更新资源配置")
@Override
public void batchUpdateBookGroupServe(Long partyId, List<BookGroupServe> bookGroupServes) {
checkBookGroupServe(bookGroupServes);
Long bookGroupId = bookGroupServes.get(0).getBookGroupId();
//删除之前旧的
bookGroupServeDao.deleteByBookGroupId(bookGroupId);
//批量新增新的
batchAddBookGroupServe(partyId,bookGroupServes);
}
@ParamLog("生成暗号")
private String createBookGroupCipher(){
//生成暗号规则:abc1234,前三位小写字母,后四位数字
......
......@@ -9,4 +9,6 @@ public interface BookGroupServeDao extends BaseDao<BookGroupServe> {
Integer batchInsert(List<BookGroupServe> bookGroupServes);
List<BookGroupServe> getListByBookGroupId(Long bookGroupId);
void deleteByBookGroupId(Long bookGroupId);
}
......@@ -23,4 +23,9 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
public List<BookGroupServe> getListByBookGroupId(Long bookGroupId) {
return super.getSqlSession().selectList(getStatement("getListByBookGroupId"), bookGroupId);
}
@Override
public void deleteByBookGroupId(Long bookGroupId) {
super.getSqlSession().delete(getStatement("deleteByBookGroupId"), bookGroupId);
}
}
......@@ -32,6 +32,12 @@ public class BookGroupServe extends BaseEntity {
@ApiModelProperty("应用或作品名称")
private String serveName;
@ApiModelProperty("类型")
private String fromType;
@ApiModelProperty("是否超级作者")
private Boolean isSuper;
public Long getServeId() {
return serveId;
......@@ -90,16 +96,34 @@ public class BookGroupServe extends BaseEntity {
this.serveName = serveName;
}
public String getFromType() {
return fromType;
}
public void setFromType(String fromType) {
this.fromType = fromType;
}
public Boolean getIsSuper() {
return isSuper;
}
public void setIsSuper(Boolean isSuper) {
this.isSuper = isSuper;
}
@Override
public String toString() {
return "BookGroupServe{" +
"serveId=" + serveId +
", serveType=" + serveType +
", serveType='" + serveType + '\'' +
", serveUrl='" + serveUrl + '\'' +
", shortUrl='" + shortUrl + '\'' +
", bookGroupId=" + bookGroupId +
", createUser=" + createUser +
", serveName='" + serveName + '\'' +
", fromType='" + fromType + '\'' +
", isSuper=" + isSuper +
"} " + super.toString();
}
}
......@@ -403,6 +403,13 @@ public interface BookGroupFacade {
@RequestBody List<BookGroupServe> bookGroupServes
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("批量更新资源配置")
@PostMapping("batchUpdateBookGroupServe")
ResponseDto<?> batchUpdateBookGroupServe(
@RequestHeader("token") String token,
@RequestBody List<BookGroupServe> bookGroupServes
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("删除资源配置")
@GetMapping("deleteBookGroupServe")
ResponseDto<?> deleteBookGroupServe(
......
......@@ -566,6 +566,18 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
return new ResponseDto<>();
}
@ApiOperation("批量更新资源配置")
@PostMapping("batchUpdateBookGroupServe")
@Override
public ResponseDto<?> batchUpdateBookGroupServe(
@RequestHeader("token") String token,
@RequestBody List<BookGroupServe> bookGroupServes
) throws BizException, PermissionException, JsonParseException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookGroupBiz.batchUpdateBookGroupServe(partyId, bookGroupServes);
return new ResponseDto<>();
}
@ApiOperation("删除资源配置")
@GetMapping("deleteBookGroupServe")
@Override
......
......@@ -76,4 +76,10 @@
from book_group_serve
where book_group_id=#{bookGroupId}
</select>
<!--根据bookGroupId删除-->
<delete id="deleteByBookGroupId" parameterType="long" >
delete from book_group_serve
where book_group_id=#{bookGroupId}
</delete>
</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