Commit f20048be by 阮思源

增加批量操作

parent 5d618de9
...@@ -874,20 +874,35 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz { ...@@ -874,20 +874,35 @@ public class AdvertisingSpaceBizImpl implements AdvertisingSpaceBiz {
advertisingAdviserPermissionDao.update(adviserPermission); advertisingAdviserPermissionDao.update(adviserPermission);
} }
} else { } else {
// 删除编辑所有数据 if (!ListUtils.isEmpty(adviserPermission.getBookAndChannelDTOS())) {
advertisingAdviserPermissionDao.deleteByAdviserId(adviserPermission.getAdviserId()); //一个一个更新
List<BookDto> bookList = bookDao.listBookIdAndChannelId4Adviser(paramMap); for (BookAndChannelDTO bookAndChannelDTO : adviserPermission.getBookAndChannelDTOS()) {
if (!ListUtils.isEmpty(bookList)) { if (bookAndChannelDTO != null && bookAndChannelDTO.getBookId() != null && bookAndChannelDTO.getChannelId() != null) {
List<AdvertisingAdviserPermission> list = new ArrayList<>(); paramMap.put("bookId", bookAndChannelDTO.getBookId());
for (BookDto bookDto : bookList) { paramMap.put("channelId", bookAndChannelDTO.getChannelId());
AdvertisingAdviserPermission permission = new AdvertisingAdviserPermission(); AdvertisingAdviserPermission permission = (AdvertisingAdviserPermission) advertisingAdviserPermissionDao.getBy(paramMap, "getByAdviserId");
permission.setAdviserId(adviserPermission.getAdviserId()); if (null != permission) {
permission.setIsOpen(adviserPermission.getIsOpen()); adviserPermission.setId(permission.getId());
permission.setBookId(bookDto.getBookId()); advertisingAdviserPermissionDao.update(adviserPermission);
permission.setChannelId(bookDto.getChannelId()); }
list.add(permission); }
}
} else {
// 删除编辑所有数据
advertisingAdviserPermissionDao.deleteByAdviserId(adviserPermission.getAdviserId());
List<BookDto> bookList = bookDao.listBookIdAndChannelId4Adviser(paramMap);
if (!ListUtils.isEmpty(bookList)) {
List<AdvertisingAdviserPermission> list = new ArrayList<>();
for (BookDto bookDto : bookList) {
AdvertisingAdviserPermission permission = new AdvertisingAdviserPermission();
permission.setAdviserId(adviserPermission.getAdviserId());
permission.setIsOpen(adviserPermission.getIsOpen());
permission.setBookId(bookDto.getBookId());
permission.setChannelId(bookDto.getChannelId());
list.add(permission);
}
advertisingAdviserPermissionDao.batchInsert(list);
} }
advertisingAdviserPermissionDao.batchInsert(list);
} }
} }
} }
......
package com.pcloud.book.advertising.dto; package com.pcloud.book.advertising.dto;
import java.io.Serializable;
/** /**
* @Description * @Description
* @Author ruansiyuan * @Author ruansiyuan
* @Date 2019/8/19 9:49 * @Date 2019/8/19 9:49
**/ **/
public class BookAndChannelDTO { public class BookAndChannelDTO implements Serializable {
private Long bookId;
private Long channelId;
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
} }
package com.pcloud.book.advertising.entity; package com.pcloud.book.advertising.entity;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.pcloud.book.advertising.dto.BookAndChannelDTO;
import com.pcloud.common.entity.BaseEntity; import com.pcloud.common.entity.BaseEntity;
/** /**
...@@ -50,6 +53,11 @@ public class AdvertisingAdviserPermission extends BaseEntity { ...@@ -50,6 +53,11 @@ public class AdvertisingAdviserPermission extends BaseEntity {
*/ */
private Boolean isBatchOperation; private Boolean isBatchOperation;
/**
* bookId和channelId集合
*/
private List<BookAndChannelDTO> bookAndChannelDTOS;
@Override @Override
public Long getId() { public Long getId() {
return id; return id;
...@@ -120,6 +128,14 @@ public class AdvertisingAdviserPermission extends BaseEntity { ...@@ -120,6 +128,14 @@ public class AdvertisingAdviserPermission extends BaseEntity {
this.isBatchOperation = isBatchOperation; this.isBatchOperation = isBatchOperation;
} }
public List<BookAndChannelDTO> getBookAndChannelDTOS() {
return bookAndChannelDTOS;
}
public void setBookAndChannelDTOS(List<BookAndChannelDTO> bookAndChannelDTOS) {
this.bookAndChannelDTOS = bookAndChannelDTOS;
}
@Override @Override
public String toString() { public String toString() {
return "AdvertisingAdviserPermission{" + return "AdvertisingAdviserPermission{" +
...@@ -128,9 +144,10 @@ public class AdvertisingAdviserPermission extends BaseEntity { ...@@ -128,9 +144,10 @@ public class AdvertisingAdviserPermission extends BaseEntity {
", bookId=" + bookId + ", bookId=" + bookId +
", channelId=" + channelId + ", channelId=" + channelId +
", isOpen=" + isOpen + ", isOpen=" + isOpen +
", isBatchOperation=" + isBatchOperation +
", createTime=" + createTime + ", createTime=" + createTime +
", updateTime=" + updateTime + ", updateTime=" + updateTime +
", isBatchOperation=" + isBatchOperation +
", bookAndChannelDTOS=" + bookAndChannelDTOS +
"} " + super.toString(); "} " + super.toString();
} }
} }
\ 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