Commit 9c339ec7 by xmh

1

1 parent 8375bfa8
...@@ -36,10 +36,7 @@ public class CaptionController { ...@@ -36,10 +36,7 @@ public class CaptionController {
@GetMapping @GetMapping
public Message<List<Caption>> listAll(CaptionVo captionVo) { public Message<List<Caption>> listAll(CaptionVo captionVo) {
List<Caption> list = captionService.list( List<Caption> list = captionService.lambdaQuery().eq(Caption::getCaptionSetId, captionVo.getCaptionSetId()).list();
captionService.query().eq("caption_set_id", captionVo.getCaptionSetId())
.getWrapper()
);
List<Caption> collect = list.stream().map(CaptionVo::copy).collect(Collectors.toList()); List<Caption> collect = list.stream().map(CaptionVo::copy).collect(Collectors.toList());
return Message.success(collect); return Message.success(collect);
} }
......
package com.viontech.storage.controller; package com.viontech.storage.controller;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.viontech.storage.entity.Message; import com.viontech.storage.entity.Message;
import com.viontech.storage.model.CaptionSet; import com.viontech.storage.model.CaptionSet;
import com.viontech.storage.model.PicConfig;
import com.viontech.storage.service.CaptionSetService; import com.viontech.storage.service.CaptionSetService;
import com.viontech.storage.service.PicConfigService;
import com.viontech.storage.vo.CaptionSetVo; import com.viontech.storage.vo.CaptionSetVo;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -24,6 +27,8 @@ public class CaptionSetController { ...@@ -24,6 +27,8 @@ public class CaptionSetController {
@Resource @Resource
private CaptionSetService captionSetService; private CaptionSetService captionSetService;
@Resource
private PicConfigService picConfigService;
@GetMapping("/{id}") @GetMapping("/{id}")
public Message<CaptionSet> getById(@PathVariable("id") Long id) { public Message<CaptionSet> getById(@PathVariable("id") Long id) {
...@@ -33,9 +38,9 @@ public class CaptionSetController { ...@@ -33,9 +38,9 @@ public class CaptionSetController {
@GetMapping @GetMapping
public Message<List<CaptionSet>> listAll(CaptionSetVo captionSetVo) { public Message<List<CaptionSet>> listAll(CaptionSetVo captionSetVo) {
QueryChainWrapper<CaptionSet> query = captionSetService.query(); LambdaQueryChainWrapper<CaptionSet> query = captionSetService.lambdaQuery();
if (!StringUtils.isNullOrEmpty(captionSetVo.getNameLike())) { if (!StringUtils.isNullOrEmpty(captionSetVo.getNameLike())) {
query.like("name", captionSetVo.getNameLike()); query.like(CaptionSet::getName, captionSetVo.getNameLike());
} }
List<CaptionSet> list = captionSetService.list(query.getWrapper()); List<CaptionSet> list = captionSetService.list(query.getWrapper());
return Message.success(list); return Message.success(list);
...@@ -60,6 +65,11 @@ public class CaptionSetController { ...@@ -60,6 +65,11 @@ public class CaptionSetController {
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public Message<CaptionSet> deleteById(@PathVariable Long id) { public Message<CaptionSet> deleteById(@PathVariable Long id) {
List<PicConfig> list = picConfigService.list(picConfigService.lambdaQuery().eq(PicConfig::getCaptionSetId, id).getWrapper());
if (CollectionUtil.isNotEmpty(list)) {
return Message.error("字幕配置使用中");
}
boolean b = captionSetService.removeById(id); boolean b = captionSetService.removeById(id);
return Message.success(); return Message.success();
} }
......
...@@ -2,12 +2,15 @@ package com.viontech.storage.controller; ...@@ -2,12 +2,15 @@ package com.viontech.storage.controller;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.viontech.storage.entity.Context; import com.viontech.storage.entity.Context;
import com.viontech.storage.entity.Message; import com.viontech.storage.entity.Message;
import com.viontech.storage.model.PicConfig; import com.viontech.storage.model.PicConfig;
import com.viontech.storage.model.StorageConfig;
import com.viontech.storage.service.PicConfigService; import com.viontech.storage.service.PicConfigService;
import com.viontech.storage.service.StorageConfigService;
import com.viontech.storage.vo.PicConfigVo; import com.viontech.storage.vo.PicConfigVo;
import com.viontech.storage.vo.StorageConfigVo;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -28,6 +31,8 @@ public class PicConfigController { ...@@ -28,6 +31,8 @@ public class PicConfigController {
@Resource @Resource
private PicConfigService picConfigService; private PicConfigService picConfigService;
@Resource
private StorageConfigService storageConfigService;
@GetMapping("/{id}") @GetMapping("/{id}")
...@@ -39,17 +44,17 @@ public class PicConfigController { ...@@ -39,17 +44,17 @@ public class PicConfigController {
@GetMapping @GetMapping
public Message<List<PicConfig>> listAll(PicConfigVo configVo) { public Message<List<PicConfig>> listAll(PicConfigVo configVo) {
QueryChainWrapper<PicConfig> query = picConfigService.query(); LambdaQueryChainWrapper<PicConfig> query = picConfigService.lambdaQuery();
if (!StringUtils.isNullOrEmpty(configVo.getNameLike())) { if (!StringUtils.isNullOrEmpty(configVo.getNameLike())) {
query.like("name", configVo.getNameLike()); query.like(PicConfig::getName, configVo.getNameLike());
} }
if (configVo.getPictureQualityGte() != null) { if (configVo.getPictureQualityGte() != null) {
query.ge("picture_quality", configVo.getPictureQualityGte()); query.ge(PicConfig::getPictureQuality, configVo.getPictureQualityGte());
} }
if (configVo.getPictureQualityLte() != null) { if (configVo.getPictureQualityLte() != null) {
query.le("picture_quality", configVo.getPictureQualityLte()); query.le(PicConfig::getPictureQuality, configVo.getPictureQualityLte());
} }
List<PicConfig> list = picConfigService.list(query.getWrapper()); List<PicConfig> list = query.list();
List<PicConfig> collect = list.stream().map(PicConfigVo::copy).collect(Collectors.toList()); List<PicConfig> collect = list.stream().map(PicConfigVo::copy).collect(Collectors.toList());
return Message.success(collect); return Message.success(collect);
} }
...@@ -77,6 +82,18 @@ public class PicConfigController { ...@@ -77,6 +82,18 @@ public class PicConfigController {
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public Message<PicConfig> deleteById(@PathVariable Long id) { public Message<PicConfig> deleteById(@PathVariable Long id) {
List<StorageConfig> list = storageConfigService.list();
List<StorageConfigVo> collect = list.stream().map(StorageConfigVo::copy).collect(Collectors.toList());
for (StorageConfigVo item : collect) {
List<Context> contexts = item.getContexts();
if (contexts != null) {
boolean used = contexts.stream().anyMatch(x -> x.getPicConfigId().equals(id));
if (used) {
return Message.error("图片合成规则正在使用中");
}
}
}
boolean b = picConfigService.removeById(id); boolean b = picConfigService.removeById(id);
return Message.success(); return Message.success();
} }
......
...@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FastByteArrayOutputStream; import cn.hutool.core.io.FastByteArrayOutputStream;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.viontech.storage.entity.Context; import com.viontech.storage.entity.Context;
import com.viontech.storage.entity.Generator; import com.viontech.storage.entity.Generator;
import com.viontech.storage.entity.Message; import com.viontech.storage.entity.Message;
...@@ -57,15 +57,15 @@ public class StorageConfigController { ...@@ -57,15 +57,15 @@ public class StorageConfigController {
@GetMapping @GetMapping
public Message<List<StorageConfig>> listAll(StorageConfigVo vo, @RequestParam(required = false, defaultValue = "true") Boolean withoutConfig) { public Message<List<StorageConfig>> listAll(StorageConfigVo vo, @RequestParam(required = false, defaultValue = "true") Boolean withoutConfig) {
QueryChainWrapper<StorageConfig> query = storageConfigService.query(); LambdaQueryChainWrapper<StorageConfig> query = storageConfigService.lambdaQuery();
if (!StringUtils.isNullOrEmpty(vo.getNameLike())) { if (!StringUtils.isNullOrEmpty(vo.getNameLike())) {
query.like("name", vo.getNameLike()); query.like(StorageConfig::getName, vo.getNameLike());
} }
if (vo.getType() != null) { if (vo.getType() != null) {
query.eq("type", vo.getType()); query.eq(StorageConfig::getType, vo.getType());
} }
List<StorageConfig> list = storageConfigService.list(query.getWrapper()); List<StorageConfig> list = query.list();
Stream<StorageConfigVo> stream = list.stream().map(StorageConfigVo::copy); Stream<StorageConfigVo> stream = list.stream().map(StorageConfigVo::copy);
if (withoutConfig) { if (withoutConfig) {
stream = stream.peek(x -> x.setConfig(null)); stream = stream.peek(x -> x.setConfig(null));
...@@ -116,10 +116,7 @@ public class StorageConfigController { ...@@ -116,10 +116,7 @@ public class StorageConfigController {
@PostMapping("/upload") @PostMapping("/upload")
public Message<Object> upload(Long id, MultipartFile file) throws IOException { public Message<Object> upload(Long id, MultipartFile file) throws IOException {
FastByteArrayOutputStream read = IoUtil.read(file.getInputStream()); FastByteArrayOutputStream read = IoUtil.read(file.getInputStream());
StorageConfig byId = storageConfigService.getById(id) StorageConfig byId = storageConfigService.getById(id).setContext(null).setType(1).setConfig(read.toByteArray());
.setContext(null)
.setType(1)
.setConfig(read.toByteArray());
storageConfigService.updateById(byId); storageConfigService.updateById(byId);
return Message.success(); return Message.success();
...@@ -136,8 +133,7 @@ public class StorageConfigController { ...@@ -136,8 +133,7 @@ public class StorageConfigController {
} }
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition", response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(item.getName() + ".xml", "utf-8"));
"attachment;filename=" + URLEncoder.encode(item.getName() + ".xml", "utf-8"));
response.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK");
IoUtil.write(response.getOutputStream(), false, bytes); IoUtil.write(response.getOutputStream(), false, bytes);
} }
......
...@@ -193,7 +193,7 @@ public class Generator { ...@@ -193,7 +193,7 @@ public class Generator {
} }
List<Context> contexts = caption.getContexts(); List<Context> contexts = caption.getContexts();
String dateFormat = (caption.getMillisecond() != null && caption.getMillisecond()) ? caption.getDateFormat() + ":xxx" : caption.getDateFormat(); String dateFormat = (caption.getMillisecond() != null && caption.getMillisecond()) ? caption.getDateFormat() + ".xxx" : caption.getDateFormat();
Pair<String, Integer> combine = combineCaptionContent(picType, contexts, dateFormat); Pair<String, Integer> combine = combineCaptionContent(picType, contexts, dateFormat);
String content = combine.getKey(); String content = combine.getKey();
Integer wrapCount = combine.getValue(); Integer wrapCount = combine.getValue();
...@@ -247,9 +247,12 @@ public class Generator { ...@@ -247,9 +247,12 @@ public class Generator {
int wrapCount = 0; int wrapCount = 0;
for (Context context : contexts) { for (Context context : contexts) {
Integer type = context.getType(); Integer type = context.getType();
sb.append(Dict.INSTANCE.captionType.get(type)).append(": + "); sb.append(Dict.INSTANCE.captionType.get(type)).append(":+");
switch (type) { switch (type) {
case 1: case 1:
if (picTypeName.contains("特写")) {
picTypeName = "特写图";
}
sb.append("(").append(picTypeName).append("时间:").append(dateFormat).append(")"); sb.append("(").append(picTypeName).append("时间:").append(dateFormat).append(")");
break; break;
case 9: case 9:
......
...@@ -34,11 +34,19 @@ public class Message<T> { ...@@ -34,11 +34,19 @@ public class Message<T> {
return new Message<T>().setMsg("成功").setCode(200).setSuccess(true).setData(null); return new Message<T>().setMsg("成功").setCode(200).setSuccess(true).setData(null);
} }
public static <T> Message<T> success(String msg) {
return new Message<T>().setMsg(msg).setCode(200).setData(null);
}
public static <T> Message<T> error(String msg, T data) { public static <T> Message<T> error(String msg, T data) {
return new Message<T>().setMsg(msg).setCode(500).setData(data); return new Message<T>().setMsg(msg).setCode(500).setData(data);
} }
public static <T> Message<T> error(String msg) {
return new Message<T>().setMsg(msg).setCode(500).setData(null);
}
public static <T> Message<T> error(T data) { public static <T> Message<T> error(T data) {
return new Message<T>().setMsg("失败").setCode(500).setData(data); return new Message<T>().setMsg("失败").setCode(500).setData(data);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!