Commit 9c339ec7 by xmh

1

1 parent 8375bfa8
......@@ -36,10 +36,7 @@ public class CaptionController {
@GetMapping
public Message<List<Caption>> listAll(CaptionVo captionVo) {
List<Caption> list = captionService.list(
captionService.query().eq("caption_set_id", captionVo.getCaptionSetId())
.getWrapper()
);
List<Caption> list = captionService.lambdaQuery().eq(Caption::getCaptionSetId, captionVo.getCaptionSetId()).list();
List<Caption> collect = list.stream().map(CaptionVo::copy).collect(Collectors.toList());
return Message.success(collect);
}
......
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.model.CaptionSet;
import com.viontech.storage.model.PicConfig;
import com.viontech.storage.service.CaptionSetService;
import com.viontech.storage.service.PicConfigService;
import com.viontech.storage.vo.CaptionSetVo;
import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*;
......@@ -24,6 +27,8 @@ public class CaptionSetController {
@Resource
private CaptionSetService captionSetService;
@Resource
private PicConfigService picConfigService;
@GetMapping("/{id}")
public Message<CaptionSet> getById(@PathVariable("id") Long id) {
......@@ -33,9 +38,9 @@ public class CaptionSetController {
@GetMapping
public Message<List<CaptionSet>> listAll(CaptionSetVo captionSetVo) {
QueryChainWrapper<CaptionSet> query = captionSetService.query();
LambdaQueryChainWrapper<CaptionSet> query = captionSetService.lambdaQuery();
if (!StringUtils.isNullOrEmpty(captionSetVo.getNameLike())) {
query.like("name", captionSetVo.getNameLike());
query.like(CaptionSet::getName, captionSetVo.getNameLike());
}
List<CaptionSet> list = captionSetService.list(query.getWrapper());
return Message.success(list);
......@@ -60,6 +65,11 @@ public class CaptionSetController {
@DeleteMapping("/{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);
return Message.success();
}
......
......@@ -2,12 +2,15 @@ package com.viontech.storage.controller;
import cn.hutool.core.collection.CollectionUtil;
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.Message;
import com.viontech.storage.model.PicConfig;
import com.viontech.storage.model.StorageConfig;
import com.viontech.storage.service.PicConfigService;
import com.viontech.storage.service.StorageConfigService;
import com.viontech.storage.vo.PicConfigVo;
import com.viontech.storage.vo.StorageConfigVo;
import org.h2.util.StringUtils;
import org.springframework.web.bind.annotation.*;
......@@ -28,6 +31,8 @@ public class PicConfigController {
@Resource
private PicConfigService picConfigService;
@Resource
private StorageConfigService storageConfigService;
@GetMapping("/{id}")
......@@ -39,17 +44,17 @@ public class PicConfigController {
@GetMapping
public Message<List<PicConfig>> listAll(PicConfigVo configVo) {
QueryChainWrapper<PicConfig> query = picConfigService.query();
LambdaQueryChainWrapper<PicConfig> query = picConfigService.lambdaQuery();
if (!StringUtils.isNullOrEmpty(configVo.getNameLike())) {
query.like("name", configVo.getNameLike());
query.like(PicConfig::getName, configVo.getNameLike());
}
if (configVo.getPictureQualityGte() != null) {
query.ge("picture_quality", configVo.getPictureQualityGte());
query.ge(PicConfig::getPictureQuality, configVo.getPictureQualityGte());
}
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());
return Message.success(collect);
}
......@@ -77,6 +82,18 @@ public class PicConfigController {
@DeleteMapping("/{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);
return Message.success();
}
......
......@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FastByteArrayOutputStream;
import cn.hutool.core.io.IoUtil;
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.Generator;
import com.viontech.storage.entity.Message;
......@@ -57,15 +57,15 @@ public class StorageConfigController {
@GetMapping
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())) {
query.like("name", vo.getNameLike());
query.like(StorageConfig::getName, vo.getNameLike());
}
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);
if (withoutConfig) {
stream = stream.peek(x -> x.setConfig(null));
......@@ -116,10 +116,7 @@ public class StorageConfigController {
@PostMapping("/upload")
public Message<Object> upload(Long id, MultipartFile file) throws IOException {
FastByteArrayOutputStream read = IoUtil.read(file.getInputStream());
StorageConfig byId = storageConfigService.getById(id)
.setContext(null)
.setType(1)
.setConfig(read.toByteArray());
StorageConfig byId = storageConfigService.getById(id).setContext(null).setType(1).setConfig(read.toByteArray());
storageConfigService.updateById(byId);
return Message.success();
......@@ -136,8 +133,7 @@ public class StorageConfigController {
}
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(item.getName() + ".xml", "utf-8"));
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(item.getName() + ".xml", "utf-8"));
response.setCharacterEncoding("GBK");
IoUtil.write(response.getOutputStream(), false, bytes);
}
......
......@@ -193,7 +193,7 @@ public class Generator {
}
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);
String content = combine.getKey();
Integer wrapCount = combine.getValue();
......@@ -247,9 +247,12 @@ public class Generator {
int wrapCount = 0;
for (Context context : contexts) {
Integer type = context.getType();
sb.append(Dict.INSTANCE.captionType.get(type)).append(": + ");
sb.append(Dict.INSTANCE.captionType.get(type)).append(":+");
switch (type) {
case 1:
if (picTypeName.contains("特写")) {
picTypeName = "特写图";
}
sb.append("(").append(picTypeName).append("时间:").append(dateFormat).append(")");
break;
case 9:
......
......@@ -34,11 +34,19 @@ public class Message<T> {
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) {
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) {
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!