增加动态表单自动排版配置界面的保存回显逻辑

This commit is contained in:
cuibaocheng 2021-08-13 14:02:37 +08:00
parent 09d8b61803
commit 6ea2e1f36c
7 changed files with 182 additions and 3 deletions

View File

@ -163,6 +163,13 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.com.tenlion</groupId>
<artifactId>module-project-config</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -8,7 +8,9 @@ import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.common.component.SecurityComponent;
import ink.wgink.exceptions.SearchException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.app.AppToken;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.util.ReflectUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -1,10 +1,17 @@
package cn.com.tenlion.systemcard.controller.app.api.shoptemplateconfig;
import cn.com.tenlion.projectconfig.util.ProjectConfigUtil;
import cn.com.tenlion.systemcard.dao.cardtemplateuse.ICardTemplateUseDao;
import cn.com.tenlion.systemcard.pojo.dtos.cardtemplateuse.CardTemplateUseDTO;
import cn.com.tenlion.systemcard.pojo.dtos.cardtemplateusearea.CardTemplateUseAreaDTO;
import cn.com.tenlion.systemcard.pojo.dtos.shopposition.ShopPositionDTO;
import cn.com.tenlion.systemcard.pojo.dtos.shoptemplateconfig.ShopTemplateConfigDTO;
import cn.com.tenlion.systemcard.pojo.vos.shoptemplateconfig.ShopTemplateConfigVO;
import cn.com.tenlion.systemcard.service.cardtemplateuse.ICardTemplateUseService;
import cn.com.tenlion.systemcard.service.shoptemplateconfig.IShopTemplateConfigService;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
@ -12,9 +19,12 @@ import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -34,6 +44,48 @@ public class ShopTemplateConfigAppController extends DefaultBaseController {
@Autowired
private IShopTemplateConfigService shopTemplateConfigService;
@Autowired
private ICardTemplateUseService iCardTemplateUseService;
@ApiOperation(value = "服务页面的跳转", notes = "服务页面的跳转接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "creator", value = "当前名片创建人的ID", paramType = "query")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("page" + ISystemConstant.RELEASE_SUFFIX + "/{userId}")
public ModelAndView page(@PathVariable("userId") String userId) {
ModelAndView modelAndView = new ModelAndView("shoptemplateconfig/baseinfo");
List<String> fileList = new ArrayList<String>();
fileList.add("8b4bc4ac-1ad0-4c12-b034-e0cb6ee755d8");
fileList.add("fe02a4da-297e-4610-b38c-4179b2640f7d");
modelAndView.addObject("fileList", fileList);
// 如果商店跳转开启 , 则查询商店进行跳转
if(ProjectConfigUtil.getSwitch("shopTargetSwitch")) {
// 如果创建了商店 , 则跳转至商店的静态页 , 如果没有创建则接着往下走
modelAndView.setViewName("shoptemplateconfig/shoptest");
return modelAndView;
}
// 如果当前访问的是系统默认名片
CardTemplateUseDTO cardTemplateUseDTO = iCardTemplateUseService.getSystemCard();
if(cardTemplateUseDTO != null && userId.equals(cardTemplateUseDTO.getCreator())) {
// 显示公司介绍页面
modelAndView.setViewName("shoptemplateconfig/companyinfo");
// 查询当前人在栏目中发布的商家信息
return modelAndView;
}
// 如果访问的是某人的名片
CardTemplateUseDTO cardTemplateUseDTOTop = iCardTemplateUseService.getTopCard(userId);
if(cardTemplateUseDTOTop != null && userId.equals(cardTemplateUseDTOTop.getCreator())) {
modelAndView.setViewName("shoptemplateconfig/companyinfo");
// 显示个人介绍页面
return modelAndView;
}
// 首次初始化没有默认名片跳转到空白页
return modelAndView;
}
@ApiOperation(value = "新增CBC行业店铺装修模板配置表", notes = "新增CBC行业店铺装修模板配置表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")

View File

@ -32,7 +32,7 @@ public class ShopTemplateConfigRouteController extends DefaultBaseController {
@GetMapping("list")
public ModelAndView list() {
return new ModelAndView("shoptemplateconfig/list");
return new ModelAndView("companyinfo");
}
}

View File

@ -215,4 +215,15 @@ public interface ICardTemplateUseService {
*/
void saveAddDispatchNumber(String cardTemplateUseId);
/**
* 系统默认的名片
* @return
*/
CardTemplateUseDTO getSystemCard();
/**
* 我的默认名片
* @return
*/
CardTemplateUseDTO getTopCard(String creator);
}

View File

@ -91,6 +91,53 @@ public class CardTemplateUseServiceImpl extends DefaultBaseService implements IC
@Autowired
private IDataService iDataService;
private static BufferedImage viewButtonBuffer;
static {
try {
String viewButton = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAA4CAYAAAB6+vMDAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAKCSURBVHhe7dm9TvMwGIZhTorj4XSQ2FnZGZhYmZiQkJgZQGyVGKsyG+fHpW2cxq/j5EnLbeniQwolpb5jp/0u1uu1A1TqAC9ur4FZXd7fueevDwKEThUhAUKLACFFgJAiQEgRIKQIEFIECCkChBQBQooAIUWAkCJASBEgpAgQUgQIKQKE1EkE+PTuVs6517fIMZw2Aoy7+tz4M3ZH/nN4ca/+8avPx8ixcW6+/S/+eXdXkWON5tzu+yVyTGwJAfZNtnkMvcBvVcZpo2wobQD+Mnp4IsA9y14BH93DT/XibuoVcOX/Pf5Cj1DHufGBRI6NEuJLH9b4CXAKu9tu5/vcUOwxHA7bFtyeL+Wiaf/GnAuMAIuKTFrnHjCsjPbJiqknsPTqF4JKmfRwa5AZCAGWECbMf73pOdZZfbaPGRGPJZRE4Z42bKVN4PGtNRyzraz7wu/IGoUu4mz6AHdWvG1QueNIiIY3IIPjyKQ18XWfxzaSEHp4PgUCGF4BF2xRW3DfStfH+vMHmlgiK+5E9leqcls+AZYyY4A5H/2M2Sb/zlf4XtMjwFIyt2BzGNvtODGGrNDbN0oZw/YxTNk3ZLP7bytgvRJVk5VxTzh8nt3oqrit7z6bn88KMHFYP2Oc3H8KcG+rqgOccgWszBjg0Dnav4EAj2lfJOtICaNzn3Q2ASY+hgATWCc6Owxvki340AwBpl5IBLgwZ7ICJr8DJsCFOYcA21U86XkRYJ92kooMw4fKc27BxpEWiTFuAlyYE18Bzf+LQ4BABAFCigAhRYCQIkBIESCkCBBSBAgpAoQUAUKKACFFgJAiQEgRIKQIEFIECCkChMrl/R0BQqOK7/nrw/0CYJK8QSzpQMEAAAAASUVORK5CYII=";
BASE64Decoder decoder = new sun.misc.BASE64Decoder();
byte[] bytes = decoder.decodeBuffer(viewButton.replaceAll("data:image/png;base64,", ""));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
viewButtonBuffer = ImageIO.read(bais);
}catch (Exception e) {
e.printStackTrace();
}
}
private static String wXDispatchImage(BufferedImage buffer) throws IOException {
int currentWidth = buffer.getWidth();
int currentHeight = buffer.getHeight();
int height = currentWidth / 5 * 4;
BufferedImage tag = new BufferedImage(currentWidth, height, BufferedImage.TYPE_INT_RGB);
// 得到图片操作对象
Graphics2D imageGraphics = tag.createGraphics();
tag = imageGraphics.getDeviceConfiguration().createCompatibleImage(tag.getWidth(), tag.getHeight(), Transparency.TRANSLUCENT);
Graphics2D g = tag.createGraphics();
//消除文字锯齿
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
//消除图片锯齿
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(buffer, 0, 0, null);
// 添加按钮
int buttonY = currentHeight + ( (height - currentHeight - viewButtonBuffer.getHeight() ) / 2 );
g.drawImage(viewButtonBuffer, ( currentWidth - viewButtonBuffer.getWidth() ) / 2, buttonY, null);
g.dispose();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(tag, "png", stream);
// 对字节数组Base64编码
org.apache.commons.codec.binary.Base64 base = new Base64();
String base64 = base.encodeToString(stream.toByteArray());
return "data:image/png;base64," + base64;
}
/**
* 图片压缩-按照固定宽高原图压缩
* @Title : thumbnail
@ -210,7 +257,8 @@ public class CardTemplateUseServiceImpl extends DefaultBaseService implements IC
try {
cardTemplateUsePhoto = iPicturesTemplateBuildingService.buildingPictures(cardTemplateAppDTO.getPicturesTemplateCode(), buildingPicturesMap);
BufferedImage bufferedImage = base64ToBufferedImage(cardTemplateUsePhoto);
cardTemplateUseDispatchPhoto = thumbnailImage(bufferedImage, 220 , 176);
// cardTemplateUseDispatchPhoto = thumbnailImage(bufferedImage, 220 , 176);
cardTemplateUseDispatchPhoto = wXDispatchImage(bufferedImage);
cardTemplateUsePhotoUrl = iPicturesTemplateBuildingService.saveBase64ToFile(cardTemplateUsePhoto);
} catch (Exception e) {
e.printStackTrace();
@ -371,7 +419,8 @@ public class CardTemplateUseServiceImpl extends DefaultBaseService implements IC
try {
cardTemplateUsePhoto = iPicturesTemplateBuildingService.buildingPictures(useDTO.getCardTemplateUseCode(), buildingPicturesMap);
BufferedImage bufferedImage = base64ToBufferedImage(cardTemplateUsePhoto);
cardTemplateUseDispatchPhoto = thumbnailImage(bufferedImage, 220 , 176);
// cardTemplateUseDispatchPhoto = thumbnailImage(bufferedImage, 220 , 176);
cardTemplateUseDispatchPhoto = wXDispatchImage(bufferedImage);
cardTemplateUsePhotoUrl = iPicturesTemplateBuildingService.saveBase64ToFile(cardTemplateUsePhoto);
} catch (Exception e) {
e.printStackTrace();
@ -558,6 +607,38 @@ public class CardTemplateUseServiceImpl extends DefaultBaseService implements IC
cardTemplateUseDao.saveAddDispatchNumber(cardTemplateUseId);
}
@Override
public CardTemplateUseDTO getSystemCard() {
Map<String, Object> params = getHashMap(3);
// 没有创建名片 , 显示系统默认名片
CardTemplateUseDTO cardTemplateUseDTO = cardTemplateUseDao.getSystem(params);
if(cardTemplateUseDTO == null) {
return null;
}
params.clear();
params.put("cardTemplateUseId", cardTemplateUseDTO.getCardTemplateUseId());
List<CardTemplateUseAreaDTO> useAreaList = iCardTemplateUseAreaService.list(params);
cardTemplateUseDTO.setAreaList(useAreaList);
return cardTemplateUseDTO;
}
@Override
public CardTemplateUseDTO getTopCard(String userId) {
Map<String, Object> params = getHashMap(3);
params.put("userId", userId);
// 创建了名片 , 加载我的默认名片
CardTemplateUseDTO cardTemplateUseDTO = cardTemplateUseDao.getDefault(params);
if(cardTemplateUseDTO == null) {
return null;
}
params.clear();
params.put("cardTemplateUseId", cardTemplateUseDTO.getCardTemplateUseId());
List<CardTemplateUseAreaDTO> useAreaList = iCardTemplateUseAreaService.list(params);
cardTemplateUseDTO.setAreaList(useAreaList);
return cardTemplateUseDTO;
}
private String getUserId(String token) {
String userId = "1";
if (StringUtils.isBlank(token)) {

View File

@ -0,0 +1,26 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row" id="viewer">
<div class="layui-col-md12" th:each="file,fileStat : ${fileList}">
<div class="layui-card">
<img th:src="${'route/file/download/false/'+ file}" style="width:100%">
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
</body>
</html>