feat(app-version): 加批量创建接口
This commit is contained in:
1 parent
47f19a98eb
commit
4f80a691d1
3 files changed
+69
No files matched your search
+24
@@ -64,6 +64,30 @@ public class AppVersionService {
|
||||
return v.getId();
|
||||
}
|
||||
|
||||
/** 批量新建:一次事务全插或全回滚。 */
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<Long> batchCreate(List<AppVersionSaveReqVO> reqs) {
|
||||
if (reqs == null || reqs.isEmpty()) {
|
||||
throw new ServiceException(ErrorCode.BAD_REQUEST, "请至少传一条");
|
||||
}
|
||||
if (reqs.size() > 16) {
|
||||
throw new ServiceException(ErrorCode.BAD_REQUEST, "单次不超过 16 条");
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<Long> ids = new java.util.ArrayList<>();
|
||||
for (AppVersionSaveReqVO req : reqs) {
|
||||
String platform = normalizePlatform(req.getPlatform());
|
||||
checkDuplicate(platform, req.getVersionCode(), null);
|
||||
AppVersion v = new AppVersion();
|
||||
applyFields(v, req, platform);
|
||||
v.setStatus(1);
|
||||
v.setReleasedAt(now);
|
||||
versionMapper.insert(v);
|
||||
ids.add(v.getId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Long id, AppVersionSaveReqVO req) {
|
||||
String platform = normalizePlatform(req.getPlatform());
|
||||
|
||||
Reference in new issue
Block a user