From b978e32cb3e2ef81cf1d702d6963992616b4eb57 Mon Sep 17 00:00:00 2001 From: cuibaocheng Date: Mon, 15 Mar 2021 10:12:37 +0800 Subject: [PATCH] 1 --- .../CardTemplateUseAppController.java | 27 ++++++++++++------- .../CardTemplateUseAreaAppController.java | 7 ++--- .../CardTemplateUseAreaDTO.java | 11 ++++++++ .../cardtemplateuse/CardTemplateUseVO.java | 17 ++++++++++++ .../impl/CardTemplateUseServiceImpl.java | 13 +++++++++ .../impl/CardTemplateUseAreaServiceImpl.java | 18 +++++++++++-- .../cardtemplateuse-mapper.xml | 3 ++- .../cardtemplateusearea-mapper.xml | 4 +++ 8 files changed, 85 insertions(+), 15 deletions(-) diff --git a/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateuse/CardTemplateUseAppController.java b/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateuse/CardTemplateUseAppController.java index d37a4a6..b52f836 100644 --- a/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateuse/CardTemplateUseAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateuse/CardTemplateUseAppController.java @@ -1,13 +1,13 @@ package cn.com.tenlion.controller.app.apis.cardtemplateuse; +import cn.com.tenlion.accesstokenmanager.AccessTokenManager; import cn.com.tenlion.controller.AbstractController; import cn.com.tenlion.pojo.dtos.cardtemplateuse.CardTemplateUseDTO; +import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; import cn.com.tenlion.pojo.vos.cardtemplateuse.CardTemplateUseVO; import cn.com.tenlion.service.cardtemplateuse.ICardTemplateUseService; -import cn.com.tenlion.util.annotation.AccessRightsCheck; import cn.com.tenlion.util.check.CheckRequestBodyAnnotation; import cn.com.tenlion.util.cons.ISystemConstant; -import cn.com.tenlion.util.enumeration.Auth; import cn.com.tenlion.util.exception.RemoveException; import cn.com.tenlion.util.exception.SearchException; import cn.com.tenlion.util.page.ListPage; @@ -44,21 +44,20 @@ public class CardTemplateUseAppController extends AbstractController { @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("savecardtemplateuse") @CheckRequestBodyAnnotation - @AccessRightsCheck(auth= Auth.NOCHECK,authUrl="",operation="新增模板使用") - public SuccessResult saveCardTemplateUse(/*@RequestHeader("token") String token, */@RequestBody CardTemplateUseVO cardTemplateUseVO) throws Exception { - //CardUserDTO tokenManage = AccessTokenManager.getInstance().getKey(token); - return cardTemplateUseService.saveCardTemplateUseByToken("123456", cardTemplateUseVO); + public SuccessResult saveCardTemplateUse(@RequestHeader("token") String token, @RequestBody CardTemplateUseVO cardTemplateUseVO) throws Exception { + CardUserDTO tokenManage = AccessTokenManager.getInstance().getKey(token); + return cardTemplateUseService.saveCardTemplateUseByToken(tokenManage.getCardUserId(), cardTemplateUseVO); } @ApiOperation(value = "删除模板使用(id列表)", notes = "删除模板使用(id列表)接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + //@ApiImplicitParam(name = "token", value = "token", paramType = "header"), @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @DeleteMapping("removecardtemplateuse/{ids}") public SuccessResult removeCardTemplateUse(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException { - return cardTemplateUseService.removeCardTemplateUseByToken(token, ids); + return cardTemplateUseService.removeCardTemplateUseByToken("", ids); } @ApiOperation(value = "修改模板使用", notes = "修改模板使用接口") @@ -70,7 +69,7 @@ public class CardTemplateUseAppController extends AbstractController { @PutMapping("updatecardtemplateuse/{cardTemplateUseId}") @CheckRequestBodyAnnotation public SuccessResult updateCardTemplateUse(@RequestHeader("token") String token, @PathVariable("cardTemplateUseId") String cardTemplateUseId, @RequestBody CardTemplateUseVO cardTemplateUseVO) throws Exception { - return cardTemplateUseService.updateCardTemplateUseByToken(token, cardTemplateUseId, cardTemplateUseVO); + return cardTemplateUseService.updateCardTemplateUseByToken("", cardTemplateUseId, cardTemplateUseVO); } @ApiOperation(value = "模板使用详情(通过ID)", notes = "模板使用详情(通过ID)接口") @@ -92,6 +91,11 @@ public class CardTemplateUseAppController extends AbstractController { @GetMapping("listcardtemplateuse") public List listCardTemplateUse(@RequestHeader("token") String token) throws SearchException { Map params = requestParams(); + /** + * 显示登陆人使用的模板 + */ + CardUserDTO tokenManage = AccessTokenManager.getInstance().getKey(token); + params.put("creator", tokenManage.getCardUserId()); return cardTemplateUseService.listCardTemplateUse(params); } @@ -108,6 +112,11 @@ public class CardTemplateUseAppController extends AbstractController { @GetMapping("listpagecardtemplateuse") public SuccessResultList> listPageCardTemplateUse(@RequestHeader("token") String token, ListPage page) throws SearchException { Map params = requestParams(); + /** + * 显示登陆人使用的模板 + */ + CardUserDTO tokenManage = AccessTokenManager.getInstance().getKey(token); + params.put("creator", tokenManage.getCardUserId()); page.setParams(params); return cardTemplateUseService.listPageCardTemplateUse(page); } diff --git a/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateusearea/CardTemplateUseAreaAppController.java b/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateusearea/CardTemplateUseAreaAppController.java index c438909..3d29bdd 100644 --- a/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateusearea/CardTemplateUseAreaAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplateusearea/CardTemplateUseAreaAppController.java @@ -81,11 +81,12 @@ public class CardTemplateUseAreaAppController extends AbstractController { @ApiOperation(value = "模板使用区域数据列表", notes = "模板使用区域数据列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "token", value = "token", paramType = "header") + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + @ApiImplicitParam(name = "templateUseId", value = "使用模板ID", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listcardtemplateusearea") - public List listCardTemplateUseArea(@RequestHeader("token") String token) throws SearchException { + @GetMapping("listcardtemplateusearea/{templateUseId}") + public List listCardTemplateUseArea(@RequestHeader("token") String token, @PathVariable("templateUseId") String templateUseId) throws SearchException { Map params = requestParams(); return cardTemplateUseAreaService.listCardTemplateUseArea(params); } diff --git a/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplateusearea/CardTemplateUseAreaDTO.java b/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplateusearea/CardTemplateUseAreaDTO.java index d76e736..8a65a87 100644 --- a/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplateusearea/CardTemplateUseAreaDTO.java +++ b/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplateusearea/CardTemplateUseAreaDTO.java @@ -1,5 +1,6 @@ package cn.com.tenlion.pojo.dtos.cardtemplateusearea; +import cn.com.tenlion.pojo.dtos.cardtemplatearea.CardTemplateAreaDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -32,6 +33,16 @@ public class CardTemplateUseAreaDTO { private String templateAreaFontSize; @ApiModelProperty(name = "templateAreaFontSizeDictionaryName", value = "区域字体大小/预留功能(数据字典)字典名称") private String templateAreaFontSizeDictionaryName; + @ApiModelProperty(name = "cardTemplateAreaDTO", value = "区域原始数据对象") + private CardTemplateAreaDTO cardTemplateAreaDTO; + + public CardTemplateAreaDTO getCardTemplateAreaDTO() { + return cardTemplateAreaDTO; + } + + public void setCardTemplateAreaDTO(CardTemplateAreaDTO cardTemplateAreaDTO) { + this.cardTemplateAreaDTO = cardTemplateAreaDTO; + } public String getCardTemplateUseAreaId() { return cardTemplateUseAreaId == null ? "" : cardTemplateUseAreaId.trim(); diff --git a/src/main/java/cn/com/tenlion/pojo/vos/cardtemplateuse/CardTemplateUseVO.java b/src/main/java/cn/com/tenlion/pojo/vos/cardtemplateuse/CardTemplateUseVO.java index bb1c5d4..cf21ce8 100644 --- a/src/main/java/cn/com/tenlion/pojo/vos/cardtemplateuse/CardTemplateUseVO.java +++ b/src/main/java/cn/com/tenlion/pojo/vos/cardtemplateuse/CardTemplateUseVO.java @@ -1,10 +1,14 @@ package cn.com.tenlion.pojo.vos.cardtemplateuse; +import cn.com.tenlion.pojo.vos.cardtemplateusearea.CardTemplateUseAreaVO; import cn.com.tenlion.util.check.CheckEmptyAnnotation; import cn.com.tenlion.util.check.CheckNumberAnnotation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; + /** * * @ClassName: CardTemplateUseVO @@ -46,6 +50,19 @@ public class CardTemplateUseVO { private String templateUseCity; @ApiModelProperty(name = "templateUseUrl", value = "名片预览网络地址(全路径)") private String templateUseUrl; + @ApiModelProperty(name = "templateUseUrl", value = "区域数据") + private List useAreaVOList = new ArrayList(); + + public List getUseAreaVOList() { + if (useAreaVOList == null) { + return new ArrayList<>(); + } + return useAreaVOList; + } + + public void setUseAreaVOList(List useAreaVOList) { + this.useAreaVOList = useAreaVOList; + } public String getTemplateId() { return templateId == null ? "" : templateId.trim(); diff --git a/src/main/java/cn/com/tenlion/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java b/src/main/java/cn/com/tenlion/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java index 89dfc77..89d7aa5 100644 --- a/src/main/java/cn/com/tenlion/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/cardtemplateuse/impl/CardTemplateUseServiceImpl.java @@ -4,9 +4,11 @@ import cn.com.tenlion.dao.cardtemplateuse.ICardTemplateUseDao; import cn.com.tenlion.pojo.dtos.cardtemplate.CardTemplateDTO; import cn.com.tenlion.pojo.dtos.cardtemplateuse.CardTemplateUseDTO; import cn.com.tenlion.pojo.vos.cardtemplateuse.CardTemplateUseVO; +import cn.com.tenlion.pojo.vos.cardtemplateusearea.CardTemplateUseAreaVO; import cn.com.tenlion.service.AbstractService; import cn.com.tenlion.service.cardtemplate.ICardTemplateService; import cn.com.tenlion.service.cardtemplateuse.ICardTemplateUseService; +import cn.com.tenlion.service.cardtemplateusearea.ICardTemplateUseAreaService; import cn.com.tenlion.util.base.HashMapUtil; import cn.com.tenlion.util.base.QRCodeUtil; import cn.com.tenlion.util.base.UUIDUtil; @@ -40,6 +42,8 @@ public class CardTemplateUseServiceImpl extends AbstractService implements ICard private ICardTemplateUseDao cardTemplateUseDao; @Autowired private ICardTemplateService cardTemplateService; + @Autowired + private ICardTemplateUseAreaService cardTemplateUseAreaService; @Override public SuccessResultData saveCardTemplateUseByToken(String userId, CardTemplateUseVO cardTemplateUseVO) throws Exception { @@ -55,6 +59,15 @@ public class CardTemplateUseServiceImpl extends AbstractService implements ICard if(templateDto == null) { throw new SaveException("该模板不存在"); } + /** + * 保存区域数据 + */ + List useAreaVOList = cardTemplateUseVO.getUseAreaVOList(); + for (CardTemplateUseAreaVO vo : useAreaVOList) { + vo.setTemplateUseId(cardTemplateUseId);// 使用模板ID + vo.setTemplateId(cardTemplateUseVO.getTemplateId());// 模板ID + cardTemplateUseAreaService.saveCardTemplateUseAreaByToken(userId, vo); + } /** * 创建名片|海报二维码 , 给二维码是可以扫描后直接进入小程序的名片页面 . * 小程序路径 + 名片ID参数. 小程序页面渲染的时候 , 拿着ID查询判断 是否公开,是否需要密码,是否是该允许区域的用户 diff --git a/src/main/java/cn/com/tenlion/service/cardtemplateusearea/impl/CardTemplateUseAreaServiceImpl.java b/src/main/java/cn/com/tenlion/service/cardtemplateusearea/impl/CardTemplateUseAreaServiceImpl.java index 0494749..f58328c 100644 --- a/src/main/java/cn/com/tenlion/service/cardtemplateusearea/impl/CardTemplateUseAreaServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/cardtemplateusearea/impl/CardTemplateUseAreaServiceImpl.java @@ -1,9 +1,11 @@ package cn.com.tenlion.service.cardtemplateusearea.impl; import cn.com.tenlion.dao.cardtemplateusearea.ICardTemplateUseAreaDao; +import cn.com.tenlion.pojo.dtos.cardtemplatearea.CardTemplateAreaDTO; import cn.com.tenlion.pojo.dtos.cardtemplateusearea.CardTemplateUseAreaDTO; import cn.com.tenlion.pojo.vos.cardtemplateusearea.CardTemplateUseAreaVO; import cn.com.tenlion.service.AbstractService; +import cn.com.tenlion.service.cardtemplatearea.ICardTemplateAreaService; import cn.com.tenlion.service.cardtemplateusearea.ICardTemplateUseAreaService; import cn.com.tenlion.util.base.HashMapUtil; import cn.com.tenlion.util.base.UUIDUtil; @@ -17,6 +19,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import java.util.Arrays; import java.util.List; import java.util.Map; @@ -33,6 +36,8 @@ public class CardTemplateUseAreaServiceImpl extends AbstractService implements I @Autowired private ICardTemplateUseAreaDao cardTemplateUseAreaDao; + @Autowired + private ICardTemplateAreaService iCardTemplateAreaService; @Override public SuccessResultData saveCardTemplateUseAreaByToken(String userId, CardTemplateUseAreaVO cardTemplateUseAreaVO) throws Exception { @@ -66,12 +71,21 @@ public class CardTemplateUseAreaServiceImpl extends AbstractService implements I public CardTemplateUseAreaDTO getCardTemplateUseAreaById(String cardTemplateUseAreaId) throws SearchException { Map params = super.getHashMap(1); params.put("cardTemplateUseAreaId", cardTemplateUseAreaId); - return cardTemplateUseAreaDao.getCardTemplateUseArea(params); + CardTemplateUseAreaDTO useAreaDTO = cardTemplateUseAreaDao.getCardTemplateUseArea(params); + Map queryParams = super.getHashMap(1); + CardTemplateAreaDTO areaDTO = iCardTemplateAreaService.getCardTemplateAreaById(useAreaDTO.getTemplateAreaId()); + useAreaDTO.setCardTemplateAreaDTO(areaDTO); + return useAreaDTO; } @Override public List listCardTemplateUseArea(Map params) throws SearchException { - return cardTemplateUseAreaDao.listCardTemplateUseArea(params); + List useAreaDTOList = cardTemplateUseAreaDao.listCardTemplateUseArea(params); + for(CardTemplateUseAreaDTO useAreaDTO : useAreaDTOList) { + CardTemplateAreaDTO areaDTO = iCardTemplateAreaService.getCardTemplateAreaById(useAreaDTO.getTemplateAreaId()); + useAreaDTO.setCardTemplateAreaDTO(areaDTO); + } + return useAreaDTOList; } @Override diff --git a/src/main/resources/mybatis/mapper/cardtemplateuse/cardtemplateuse-mapper.xml b/src/main/resources/mybatis/mapper/cardtemplateuse/cardtemplateuse-mapper.xml index 7b7f089..d105e12 100644 --- a/src/main/resources/mybatis/mapper/cardtemplateuse/cardtemplateuse-mapper.xml +++ b/src/main/resources/mybatis/mapper/cardtemplateuse/cardtemplateuse-mapper.xml @@ -195,7 +195,7 @@ AND dt2.is_delete = 0 WHERE - t1.is_delete = 0 + t1.is_delete = 0 AND t1.creator = #{creator} AND ( t1.id LIKE CONCAT('%', #{keywords}, '%') @@ -219,6 +219,7 @@ #{cardTemplateUseIds[${index}]} + ORDER BY t1.gmt_create diff --git a/src/main/resources/mybatis/mapper/cardtemplateusearea/cardtemplateusearea-mapper.xml b/src/main/resources/mybatis/mapper/cardtemplateusearea/cardtemplateusearea-mapper.xml index 5336d1a..8037947 100644 --- a/src/main/resources/mybatis/mapper/cardtemplateusearea/cardtemplateusearea-mapper.xml +++ b/src/main/resources/mybatis/mapper/cardtemplateusearea/cardtemplateusearea-mapper.xml @@ -164,6 +164,9 @@ AND LEFT(t1.gmt_create, 10) #{endTime} + + AND t1.template_use_id = #{templateUseId} + AND t1.card_template_use_area_id IN @@ -171,6 +174,7 @@ #{cardTemplateUseAreaIds[${index}]} + ORDER BY t1.gmt_create