|
@@ -60,40 +60,46 @@ public class BytedanceGeneralCopywriterController {
|
|
|
@ApiOperation(value="通用文案库-上传excel", notes="通用文案库-上传excel")
|
|
|
@PostMapping("/loadExcel")
|
|
|
public Result<ByteDanceGeneralCopywriter> loadExcel(
|
|
|
- @RequestParam("accountId") Long accountId,
|
|
|
+ @RequestParam("accountId") String accountId,
|
|
|
@RequestParam("excelFile") MultipartFile excelFile){
|
|
|
Result<ByteDanceGeneralCopywriter> result = new Result<>();
|
|
|
List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = new ArrayList<ByteDanceGeneralCopywriter>();
|
|
|
+ String[] accountIds = new String[]{accountId};
|
|
|
+ if(accountId.contains(",")){
|
|
|
+ accountIds = accountId.split(",");
|
|
|
+ }
|
|
|
try {
|
|
|
List<String> list = ExcelUtil.readExcel(excelFile);
|
|
|
|
|
|
- for (String str: list) {
|
|
|
- ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = new ByteDanceGeneralCopywriter(accountId,str);
|
|
|
- int len = StringUtils.lengthAsSlogan(str);
|
|
|
- int left = str.indexOf("{");
|
|
|
- int right = str.indexOf("}");
|
|
|
- if(left >= 0 && right >= 0){
|
|
|
- List<String> strs = new ArrayList<>();
|
|
|
- ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(str.substring(left+1, right));
|
|
|
- strs.add(creativeWordPackage.getCreativeWordId().toString());
|
|
|
- len = len - (right - left) + creativeWordPackage.getMaxWordLen();
|
|
|
- String nextStr = str.substring(right+1,str.length());
|
|
|
- left = nextStr.indexOf("{");
|
|
|
- right = nextStr.indexOf("}");
|
|
|
+ for (String accountIdStr:accountIds) {
|
|
|
+ for (String str: list) {
|
|
|
+ ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = new ByteDanceGeneralCopywriter(Long.parseLong(accountIdStr),str);
|
|
|
+ int len = StringUtils.lengthAsSlogan(str);
|
|
|
+ int left = str.indexOf("{");
|
|
|
+ int right = str.indexOf("}");
|
|
|
if(left >= 0 && right >= 0){
|
|
|
- ByteDanceCreativeWordPackage creativeWordPackage2 = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(nextStr.substring(left+1, right));
|
|
|
- strs.add(creativeWordPackage2.getCreativeWordId().toString());
|
|
|
- len = len - (right - left) + creativeWordPackage2.getMaxWordLen();
|
|
|
+ List<String> strs = new ArrayList<>();
|
|
|
+ ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(str.substring(left+1, right));
|
|
|
+ strs.add(creativeWordPackage.getCreativeWordId().toString());
|
|
|
+ len = len - (right - left) + creativeWordPackage.getMaxWordLen();
|
|
|
+ String nextStr = str.substring(right+1,str.length());
|
|
|
+ left = nextStr.indexOf("{");
|
|
|
+ right = nextStr.indexOf("}");
|
|
|
+ if(left >= 0 && right >= 0){
|
|
|
+ ByteDanceCreativeWordPackage creativeWordPackage2 = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(nextStr.substring(left+1, right));
|
|
|
+ strs.add(creativeWordPackage2.getCreativeWordId().toString());
|
|
|
+ len = len - (right - left) + creativeWordPackage2.getMaxWordLen();
|
|
|
+ }
|
|
|
+ byteDanceGeneralCopywriter.setCreativeWordIds(Arrays.toString(strs.toArray()).replaceAll(" ",""));
|
|
|
+ }
|
|
|
+ //校验标题长度,长度小于5和大于30的全部过滤
|
|
|
+ if(len<5 || len>30){
|
|
|
+ continue;
|
|
|
}
|
|
|
- byteDanceGeneralCopywriter.setCreativeWordIds(Arrays.toString(strs.toArray()).replaceAll(" ",""));
|
|
|
- }
|
|
|
- //校验标题长度,长度小于5和大于30的全部过滤
|
|
|
- if(len<5 || len>30){
|
|
|
- continue;
|
|
|
- }
|
|
|
|
|
|
- //截取{}中的内容,匹配动态词包id,拼接数组存储
|
|
|
- byteDanceGeneralCopywriterList.add(byteDanceGeneralCopywriter);
|
|
|
+ //截取{}中的内容,匹配动态词包id,拼接数组存储
|
|
|
+ byteDanceGeneralCopywriterList.add(byteDanceGeneralCopywriter);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|