From 6ea2e1f36cb214e0756f191d1852ec1de4bac738 Mon Sep 17 00:00:00 2001 From: cuibaocheng Date: Fri, 13 Aug 2021 14:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E8=87=AA=E5=8A=A8=E6=8E=92=E7=89=88=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=9A=84=E4=BF=9D=E5=AD=98=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 ++ .../CardConfigColumnGroupAppController.java | 2 + .../ShopTemplateConfigAppController.java | 52 ++++++++++++ .../ShopTemplateConfigRouteController.java | 2 +- .../ICardTemplateUseService.java | 11 +++ .../impl/CardTemplateUseServiceImpl.java | 85 ++++++++++++++++++- .../shoptemplateconfig/shoptest.html | 26 ++++++ 7 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/templates/shoptemplateconfig/shoptest.html diff --git a/pom.xml b/pom.xml index e657547..3f95ca0 100644 --- a/pom.xml +++ b/pom.xml @@ -163,6 +163,13 @@ 1.0-SNAPSHOT compile + + + cn.com.tenlion + module-project-config + 1.0-SNAPSHOT + compile + diff --git a/src/main/java/cn/com/tenlion/systemcard/controller/app/api/cardconfigcolumngroup/CardConfigColumnGroupAppController.java b/src/main/java/cn/com/tenlion/systemcard/controller/app/api/cardconfigcolumngroup/CardConfigColumnGroupAppController.java index 468f581..c3c0794 100644 --- a/src/main/java/cn/com/tenlion/systemcard/controller/app/api/cardconfigcolumngroup/CardConfigColumnGroupAppController.java +++ b/src/main/java/cn/com/tenlion/systemcard/controller/app/api/cardconfigcolumngroup/CardConfigColumnGroupAppController.java @@ -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; diff --git a/src/main/java/cn/com/tenlion/systemcard/controller/app/api/shoptemplateconfig/ShopTemplateConfigAppController.java b/src/main/java/cn/com/tenlion/systemcard/controller/app/api/shoptemplateconfig/ShopTemplateConfigAppController.java index 7916ea2..6228f12 100644 --- a/src/main/java/cn/com/tenlion/systemcard/controller/app/api/shoptemplateconfig/ShopTemplateConfigAppController.java +++ b/src/main/java/cn/com/tenlion/systemcard/controller/app/api/shoptemplateconfig/ShopTemplateConfigAppController.java @@ -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 fileList = new ArrayList(); + 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") diff --git a/src/main/java/cn/com/tenlion/systemcard/controller/route/shoptemplateconfig/ShopTemplateConfigRouteController.java b/src/main/java/cn/com/tenlion/systemcard/controller/route/shoptemplateconfig/ShopTemplateConfigRouteController.java index e7a18bc..50936e2 100644 --- a/src/main/java/cn/com/tenlion/systemcard/controller/route/shoptemplateconfig/ShopTemplateConfigRouteController.java +++ b/src/main/java/cn/com/tenlion/systemcard/controller/route/shoptemplateconfig/ShopTemplateConfigRouteController.java @@ -32,7 +32,7 @@ public class ShopTemplateConfigRouteController extends DefaultBaseController { @GetMapping("list") public ModelAndView list() { - return new ModelAndView("shoptemplateconfig/list"); + return new ModelAndView("companyinfo"); } } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/ICardTemplateUseService.java b/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/ICardTemplateUseService.java index d229778..cb4a5e4 100644 --- a/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/ICardTemplateUseService.java +++ b/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/ICardTemplateUseService.java @@ -215,4 +215,15 @@ public interface ICardTemplateUseService { */ void saveAddDispatchNumber(String cardTemplateUseId); + /** + * 系统默认的名片 + * @return + */ + CardTemplateUseDTO getSystemCard(); + + /** + * 我的默认名片 + * @return + */ + CardTemplateUseDTO getTopCard(String creator); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java b/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java index 8b82925..27a79cf 100644 --- a/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemcard/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java @@ -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 params = getHashMap(3); + // 没有创建名片 , 显示系统默认名片 + CardTemplateUseDTO cardTemplateUseDTO = cardTemplateUseDao.getSystem(params); + if(cardTemplateUseDTO == null) { + return null; + } + params.clear(); + params.put("cardTemplateUseId", cardTemplateUseDTO.getCardTemplateUseId()); + List useAreaList = iCardTemplateUseAreaService.list(params); + cardTemplateUseDTO.setAreaList(useAreaList); + return cardTemplateUseDTO; + } + + @Override + public CardTemplateUseDTO getTopCard(String userId) { + Map 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 useAreaList = iCardTemplateUseAreaService.list(params); + cardTemplateUseDTO.setAreaList(useAreaList); + return cardTemplateUseDTO; + } + + private String getUserId(String token) { String userId = "1"; if (StringUtils.isBlank(token)) { diff --git a/src/main/resources/templates/shoptemplateconfig/shoptest.html b/src/main/resources/templates/shoptemplateconfig/shoptest.html new file mode 100644 index 0000000..b885010 --- /dev/null +++ b/src/main/resources/templates/shoptemplateconfig/shoptest.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + +
+
+
+
+ +
+
+
+ + + + \ No newline at end of file