Commit 4105db98 by ws

海报修改

1 parent 90418e0a
......@@ -5,22 +5,19 @@ import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeMaterial;
import com.linkwechat.wecom.domain.WePoster;
import com.linkwechat.wecom.domain.WePosterFont;
import com.linkwechat.wecom.domain.WePosterSubassembly;
import com.linkwechat.wecom.service.IWePosterFontService;
import com.linkwechat.wecom.service.IWePosterService;
import com.linkwechat.wecom.service.IWePosterSubassemblyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -46,8 +43,9 @@ public class WePosterController extends BaseController {
@PostMapping(value = "insert")
@ApiOperation("创建海报")
@PreAuthorize("@ss.hasAnyPermi('wecom:poster:insert')")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult insert(@RequestBody WePoster poster){
public AjaxResult insert(@RequestBody WePoster poster) {
wePosterService.generateSimpleImg(poster);
poster.setId(SnowFlakeUtil.nextId());
poster.setDelFlag(0);
......@@ -68,37 +66,38 @@ public class WePosterController extends BaseController {
@PutMapping(value = "update")
@ApiOperation("修改海报")
@PreAuthorize("@ss.hasAnyPermi('wecom:poster:update')")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult update(@RequestBody WePoster poster){
if(poster.getId() == null){
public AjaxResult update(@RequestBody WePoster poster) {
if (poster.getId() == null) {
return AjaxResult.error("id为空");
}
poster.setMediaType(null);
wePosterService.generateSimpleImg(poster);
wePosterService.saveOrUpdate(poster);
List<WePosterSubassembly> posterSubassemblyList = wePosterSubassemblyService.lambdaQuery().eq(WePosterSubassembly::getPosterId,poster.getId()).eq(WePosterSubassembly::getDelFlag,1).list();
Map<Long,WePosterSubassembly> posterSubassemblyMap = posterSubassemblyList.stream().collect(Collectors.toMap(WePosterSubassembly::getId,p->p));
List<WePosterSubassembly> posterSubassemblyList = wePosterSubassemblyService.lambdaQuery().eq(WePosterSubassembly::getPosterId, poster.getId()).eq(WePosterSubassembly::getDelFlag, 1).list();
Map<Long, WePosterSubassembly> posterSubassemblyMap = posterSubassemblyList.stream().collect(Collectors.toMap(WePosterSubassembly::getId, p -> p));
List<WePosterSubassembly> insertList = new ArrayList<>();
List<WePosterSubassembly> updateList = new ArrayList<>();
poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> {
if(wePosterSubassembly.getId() == null){
if (wePosterSubassembly.getId() == null) {
wePosterSubassembly.setId(SnowFlakeUtil.nextId());
wePosterSubassembly.setPosterId(poster.getId());
wePosterSubassembly.setDelFlag(0);
insertList.add(wePosterSubassembly);
}else {
} else {
posterSubassemblyMap.remove(wePosterSubassembly.getId());
updateList.add(wePosterSubassembly);
}
});
if(!CollectionUtils.isEmpty(insertList)) {
if (!CollectionUtils.isEmpty(insertList)) {
wePosterSubassemblyService.saveBatch(insertList);
}
if(!CollectionUtils.isEmpty(updateList)) {
if (!CollectionUtils.isEmpty(updateList)) {
wePosterSubassemblyService.updateBatchById(updateList);
}
List<WePosterSubassembly> deleteList = new ArrayList<>(posterSubassemblyMap.values());
if(!CollectionUtils.isEmpty(deleteList)){
if (!CollectionUtils.isEmpty(deleteList)) {
deleteList.forEach(wePosterSubassembly -> wePosterSubassembly.setDelFlag(1));
wePosterSubassemblyService.updateBatchById(deleteList);
}
......@@ -118,19 +117,21 @@ public class WePosterController extends BaseController {
}*/
@GetMapping(value = "entity/{id}")
@PreAuthorize("@ss.hasAnyPermi('wecom:poster:entity')")
@ApiOperation("查询海报详情")
public AjaxResult entity(@PathVariable Long id){
public AjaxResult entity(@PathVariable Long id) {
return AjaxResult.success(wePosterService.selectOne(id));
}
@GetMapping(value = "page")
@ApiOperation("分页查询海报")
public AjaxResult page(Long categoryId,String name){
@PreAuthorize("@ss.hasAnyPermi('wecom:poster:page')")
public AjaxResult page(Long categoryId, String name) {
startPage();
List<WePoster> fontList = wePosterService.lambdaQuery()
.eq(WePoster::getDelFlag,0)
.eq(categoryId != null,WePoster::getCategoryId,categoryId)
.like(StringUtils.isNotBlank(name),WePoster::getTitle,name)
.eq(WePoster::getDelFlag, 0)
.eq(categoryId != null, WePoster::getCategoryId, categoryId)
.like(StringUtils.isNotBlank(name), WePoster::getTitle, name)
.orderByDesc(WePoster::getCreateTime)
.list();
return AjaxResult.success(getDataTable(fontList));
......@@ -138,14 +139,15 @@ public class WePosterController extends BaseController {
@DeleteMapping(value = "delete/{id}")
@ApiOperation(value = "删除海报")
@PreAuthorize("@ss.hasAnyPermi('wecom:poster:delete')")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult deletePosterFont(@PathVariable Long id){
wePosterService.lambdaUpdate().set(WePoster::getDelFlag,1).eq(WePoster::getId,id);
wePosterSubassemblyService.lambdaUpdate().set(WePosterSubassembly::getDelFlag,1).eq(WePosterSubassembly::getPosterId,id);
public AjaxResult deletePosterFont(@PathVariable Long id) {
wePosterService.update(
wePosterService.lambdaUpdate().set(WePoster::getDelFlag, 1).eq(WePoster::getId, id));
wePosterSubassemblyService.update(
wePosterSubassemblyService.lambdaUpdate().set(WePosterSubassembly::getDelFlag, 1).eq(WePosterSubassembly::getPosterId, id));
return AjaxResult.success("删除成功");
}
}
......@@ -4,7 +4,6 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.web.controller.common.CommonController;
import com.linkwechat.wecom.domain.WePosterFont;
import com.linkwechat.wecom.service.IWePosterFontService;
import io.swagger.annotations.Api;
......@@ -30,7 +29,7 @@ public class WePosterFontController extends BaseController {
@PostMapping(value = "posterFont")
@ApiOperation("创建海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult insertPosterFont(@RequestBody WePosterFont posterFont){
public AjaxResult insertPosterFont(@RequestBody WePosterFont posterFont) {
posterFont.setId(SnowFlakeUtil.nextId());
posterFont.setDelFlag(0);
posterFont.setMediaType(MediaType.POSTER_FONT.getType());
......@@ -42,8 +41,8 @@ public class WePosterFontController extends BaseController {
@PutMapping(value = "posterFont")
@ApiOperation("修改海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult updatePosterFont(@RequestBody WePosterFont posterFont){
if(posterFont.getId() == null){
public AjaxResult updatePosterFont(@RequestBody WePosterFont posterFont) {
if (posterFont.getId() == null) {
return AjaxResult.error("id为空");
}
posterFont.setMediaType(null);
......@@ -53,9 +52,9 @@ public class WePosterFontController extends BaseController {
@GetMapping(value = "posterFontList")
@ApiOperation("列表查询海报字体")
public AjaxResult selectPosterFontList(){
public AjaxResult selectPosterFontList() {
List<WePosterFont> fontList = wePosterFontService.lambdaQuery()
.eq(WePosterFont::getDelFlag,0)
.eq(WePosterFont::getDelFlag, 0)
.orderByDesc(WePosterFont::getOrder)
.orderByDesc(WePosterFont::getCreateTime)
.list();
......@@ -64,10 +63,10 @@ public class WePosterFontController extends BaseController {
@GetMapping(value = "posterFontPage")
@ApiOperation("分页查询海报字体")
public AjaxResult selectPosterFontPage(){
public AjaxResult selectPosterFontPage() {
startPage();
List<WePosterFont> fontList = wePosterFontService.lambdaQuery()
.eq(WePosterFont::getDelFlag,0)
.eq(WePosterFont::getDelFlag, 0)
.orderByDesc(WePosterFont::getOrder)
.orderByDesc(WePosterFont::getCreateTime)
.list();
......@@ -77,11 +76,11 @@ public class WePosterFontController extends BaseController {
@DeleteMapping(value = "posterFont/{id}")
@ApiOperation("删除海报字体")
@Transactional(rollbackFor = RuntimeException.class)
public AjaxResult deletePosterFont(@PathVariable Long id){
wePosterFontService.lambdaUpdate().set(WePosterFont::getDelFlag,1).eq(WePosterFont::getId,id);
public AjaxResult deletePosterFont(@PathVariable Long id) {
wePosterFontService.update(
wePosterFontService.lambdaUpdate().set(WePosterFont::getDelFlag, 1).eq(WePosterFont::getId, id));
return AjaxResult.success("删除成功");
}
}
......@@ -25,19 +25,6 @@ public class NetFileUtils {
private static final WebClient webClient = WebClient.create(vertx);
public static void main(String[] args) {
FileCallable fileCallable = getNetFile("https://pc-index-skin.cdn.bcebos.com/hiphoto/51631423522.jpg?x-bce-process=image/crop,x_0,y_13,w_1999,h_1250");
ByteArrayOutputStream byteArrayOutputStream = getByteArrayOutputStream(fileCallable,true);
StreamMultipartFile file = new StreamMultipartFile("你好啊.jpg",byteArrayOutputStream.toByteArray());
File f = new File("D:/网页/2.jpg");
try {
file.transferTo(f);
} catch (IOException e) {
e.printStackTrace();
}
}
public static FileCallable getNetFile(String urlPath){
FileCallable fileCallable = new FileCallable();
......
......@@ -7,10 +7,12 @@ import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.common.utils.img.ImageUtils;
import com.linkwechat.common.utils.img.NetFileUtils;
import com.linkwechat.wecom.domain.WeCategory;
import com.linkwechat.wecom.domain.WePoster;
import com.linkwechat.wecom.domain.WePosterFont;
import com.linkwechat.wecom.domain.WePosterSubassembly;
import com.linkwechat.wecom.mapper.WePosterMapper;
import com.linkwechat.wecom.service.IWeCategoryService;
import com.linkwechat.wecom.service.IWePosterFontService;
import com.linkwechat.wecom.service.IWePosterService;
import com.linkwechat.wecom.service.IWePosterSubassemblyService;
......@@ -54,6 +56,9 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
@Resource
private ServerConfig serverConfig;
@Resource
private IWeCategoryService weCategoryService;
/**
* 查询一条
......@@ -86,8 +91,10 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
});
}
}
}
/*if(poster.getCategoryId() != null){
weCategoryService.findWeCategoryById(poster.getId());
}*/
return poster;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!