diff --git a/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplate/CardTemplateAppController.java b/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplate/CardTemplateAppController.java index a80aa5d..f59374d 100644 --- a/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplate/CardTemplateAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/apis/cardtemplate/CardTemplateAppController.java @@ -26,6 +26,7 @@ import java.util.Map; * @Author: WenG * @Date: 2021-01-28 11:08 * @Version: 1.0 + * @Version: 1.0 **/ @Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "名片/海报模板接口") @RestController @@ -80,13 +81,15 @@ public class CardTemplateAppController extends AbstractController { @ApiOperation(value = "名片/海报模板详情(通过ID)", notes = "名片/海报模板详情(通过ID)接口") @ApiImplicitParams({ - //@ApiImplicitParam(name = "token", value = "token", paramType = "header"), - @ApiImplicitParam(name = "cardTemplateId", value = "名片/海报模板ID", paramType = "path") + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + @ApiImplicitParam(name = "cardTemplateId", value = "名片/海报模板ID", paramType = "path"), + @ApiImplicitParam(name = "cardPersonId", value = "个人名片ID", paramType = "query") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("getcardtemplatebyid/{cardTemplateId}") - public CardTemplateDTO getCardTemplateById(@PathVariable("cardTemplateId") String cardTemplateId) throws SearchException { - return cardTemplateService.getCardTemplateById(cardTemplateId); + public CardTemplateDTO getCardTemplateById(@RequestHeader("token") String token, @PathVariable("cardTemplateId") String cardTemplateId) throws SearchException { + Map params = requestParams(); + return cardTemplateService.getCardTemplateById(params, token, cardTemplateId); } @ApiOperation(value = "名片/海报模板列表", notes = "名片/海报模板列表接口") diff --git a/src/main/java/cn/com/tenlion/dao/templateperson/ITemplatePersonDao.java b/src/main/java/cn/com/tenlion/dao/templateperson/ITemplatePersonDao.java index 2cbf582..6e79c34 100644 --- a/src/main/java/cn/com/tenlion/dao/templateperson/ITemplatePersonDao.java +++ b/src/main/java/cn/com/tenlion/dao/templateperson/ITemplatePersonDao.java @@ -117,4 +117,10 @@ public interface ITemplatePersonDao { */ Integer count(Map params) throws SearchException; + /** + * 修改所有数据为非置顶状态 + * @param params + * @throws UpdateException + */ + void updateAllIsMain(Map params) throws UpdateException; } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/pojo/bos/templateperson/TemplatePersonBO.java b/src/main/java/cn/com/tenlion/pojo/bos/templateperson/TemplatePersonBO.java index dbf7ab1..cf5f3d5 100644 --- a/src/main/java/cn/com/tenlion/pojo/bos/templateperson/TemplatePersonBO.java +++ b/src/main/java/cn/com/tenlion/pojo/bos/templateperson/TemplatePersonBO.java @@ -16,6 +16,9 @@ public class TemplatePersonBO { private String templateId; private String content; private Integer source; + private Integer cardOrder; + private String thumbnail; + private Integer isMain; public String getCardPersonId() { return cardPersonId == null ? "" : cardPersonId.trim(); @@ -64,4 +67,28 @@ public class TemplatePersonBO { public void setSource(Integer source) { this.source = source; } + + public Integer getCardOrder() { + return cardOrder; + } + + public void setCardOrder(Integer cardOrder) { + this.cardOrder = cardOrder; + } + + public String getThumbnail() { + return thumbnail == null ? "" : thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public Integer getIsMain() { + return isMain; + } + + public void setIsMain(Integer isMain) { + this.isMain = isMain; + } } diff --git a/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplate/CardTemplateDTO.java b/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplate/CardTemplateDTO.java index e1efbc0..7a5df97 100644 --- a/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplate/CardTemplateDTO.java +++ b/src/main/java/cn/com/tenlion/pojo/dtos/cardtemplate/CardTemplateDTO.java @@ -44,6 +44,10 @@ public class CardTemplateDTO { private Integer templateCharge; @ApiModelProperty(name = "templatePreviewPhoto", value = "模板预览图片") private String templatePreviewPhoto; + @ApiModelProperty(name = "isMain", value = "是否主名片(0:否,1:是)") + private String isMain; + @ApiModelProperty(name = "cardPersonId", value = "个人名片ID") + private String cardPersonId; public String getCardTemplateId() { return cardTemplateId == null ? "" : cardTemplateId.trim(); @@ -164,5 +168,19 @@ public class CardTemplateDTO { this.templatePreviewPhoto = templatePreviewPhoto; } + public String getIsMain() { + return isMain == null ? "" : isMain; + } + public void setIsMain(String isMain) { + this.isMain = isMain; + } + + public String getCardPersonId() { + return cardPersonId == null ? "" : cardPersonId; + } + + public void setCardPersonId(String cardPersonId) { + this.cardPersonId = cardPersonId; + } } diff --git a/src/main/java/cn/com/tenlion/pojo/dtos/templateperson/TemplatePersonDTO.java b/src/main/java/cn/com/tenlion/pojo/dtos/templateperson/TemplatePersonDTO.java index a146417..50aca03 100644 --- a/src/main/java/cn/com/tenlion/pojo/dtos/templateperson/TemplatePersonDTO.java +++ b/src/main/java/cn/com/tenlion/pojo/dtos/templateperson/TemplatePersonDTO.java @@ -26,6 +26,12 @@ public class TemplatePersonDTO { private String content; @ApiModelProperty(name = "source", value = "数据来源,0:个人创建;1:扫码") private Integer source; + @ApiModelProperty(name = "cardOrder", value = "排序") + private Integer cardOrder; + @ApiModelProperty(name = "thumbnail", value = "预览图") + private String thumbnail; + @ApiModelProperty(name = "isMain", value = "是否指定(0:否,1:是)") + private Integer isMain; public String getCardPersonId() { return cardPersonId == null ? "" : cardPersonId.trim(); @@ -74,4 +80,28 @@ public class TemplatePersonDTO { public void setSource(Integer source) { this.source = source; } + + public Integer getCardOrder() { + return cardOrder; + } + + public void setCardOrder(Integer cardOrder) { + this.cardOrder = cardOrder; + } + + public String getThumbnail() { + return thumbnail == null ? "" : thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public Integer getIsMain() { + return isMain; + } + + public void setIsMain(Integer isMain) { + this.isMain = isMain; + } } diff --git a/src/main/java/cn/com/tenlion/pojo/pos/templateperson/TemplatePersonPO.java b/src/main/java/cn/com/tenlion/pojo/pos/templateperson/TemplatePersonPO.java index 4e8d3af..d577181 100644 --- a/src/main/java/cn/com/tenlion/pojo/pos/templateperson/TemplatePersonPO.java +++ b/src/main/java/cn/com/tenlion/pojo/pos/templateperson/TemplatePersonPO.java @@ -16,6 +16,9 @@ public class TemplatePersonPO { private String templateId; private String content; private Integer source; + private Integer cardOrder; + private String thumbnail; + private Integer isMain; public String getCardPersonId() { return cardPersonId == null ? "" : cardPersonId.trim(); @@ -64,4 +67,28 @@ public class TemplatePersonPO { public void setSource(Integer source) { this.source = source; } + + public Integer getCardOrder() { + return cardOrder; + } + + public void setCardOrder(Integer cardOrder) { + this.cardOrder = cardOrder; + } + + public String getThumbnail() { + return thumbnail == null ? "" : thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public Integer getIsMain() { + return isMain; + } + + public void setIsMain(Integer isMain) { + this.isMain = isMain; + } } diff --git a/src/main/java/cn/com/tenlion/pojo/vos/templateperson/TemplatePersonVO.java b/src/main/java/cn/com/tenlion/pojo/vos/templateperson/TemplatePersonVO.java index 7f2f79d..a94e93c 100644 --- a/src/main/java/cn/com/tenlion/pojo/vos/templateperson/TemplatePersonVO.java +++ b/src/main/java/cn/com/tenlion/pojo/vos/templateperson/TemplatePersonVO.java @@ -28,6 +28,12 @@ public class TemplatePersonVO { private String content; @ApiModelProperty(name = "source", value = "数据来源,0:个人创建;1:扫码") private Integer source; + @ApiModelProperty(name = "cardOrder", value = "排序") + private Integer cardOrder; + @ApiModelProperty(name = "thumbnail", value = "预览图") + private String thumbnail; + @ApiModelProperty(name = "isMain", value = "是否置顶(0:否,1:是)") + private Integer isMain; public String getCardPersonId() { return cardPersonId == null ? "" : cardPersonId.trim(); @@ -76,4 +82,28 @@ public class TemplatePersonVO { public void setSource(Integer source) { this.source = source; } + + public Integer getCardOrder() { + return cardOrder; + } + + public void setCardOrder(Integer cardOrder) { + this.cardOrder = cardOrder; + } + + public String getThumbnail() { + return thumbnail == null ? "" : thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } + + public Integer getIsMain() { + return isMain == null ? 0 : isMain; + } + + public void setIsMain(Integer isMain) { + this.isMain = isMain; + } } diff --git a/src/main/java/cn/com/tenlion/service/cardtemplate/ICardTemplateService.java b/src/main/java/cn/com/tenlion/service/cardtemplate/ICardTemplateService.java index 75fa27a..f141ca0 100644 --- a/src/main/java/cn/com/tenlion/service/cardtemplate/ICardTemplateService.java +++ b/src/main/java/cn/com/tenlion/service/cardtemplate/ICardTemplateService.java @@ -55,11 +55,13 @@ public interface ICardTemplateService { /** * 名片/海报模板详情(通过ID) * + * @param params + * @param token * @param cardTemplateId * @return * @throws SearchException */ - CardTemplateDTO getCardTemplateById(String cardTemplateId) throws SearchException; + CardTemplateDTO getCardTemplateById(Map params, String token, String cardTemplateId) throws SearchException; /** * 判断编码是否存在 diff --git a/src/main/java/cn/com/tenlion/service/cardtemplate/impl/CardTemplateServiceImpl.java b/src/main/java/cn/com/tenlion/service/cardtemplate/impl/CardTemplateServiceImpl.java index dc20f12..7a431ee 100644 --- a/src/main/java/cn/com/tenlion/service/cardtemplate/impl/CardTemplateServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/cardtemplate/impl/CardTemplateServiceImpl.java @@ -16,6 +16,7 @@ import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.util.UUIDUtil; import ink.wgink.util.map.HashMapUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @@ -76,8 +77,13 @@ public class CardTemplateServiceImpl extends AbstractService implements ICardTem } @Override - public CardTemplateDTO getCardTemplateById(String cardTemplateId) throws SearchException { - Map params = super.getHashMap(1); + public CardTemplateDTO getCardTemplateById(Map params, String token, String cardTemplateId) throws SearchException { + if(null == params) { + params = super.getHashMap(1); + } + if (!StringUtils.isBlank(token)) { + setAppUpdateInfo(token, params); + } params.put("cardTemplateId", cardTemplateId); return cardTemplateDao.getCardTemplate(params); } @@ -103,7 +109,7 @@ public class CardTemplateServiceImpl extends AbstractService implements ICardTem @Override public SuccessResult updateCardTemplateImage(String cardTemplateId, String templatePreviewPhoto) throws Exception { - Map params = HashMapUtil.beanToMap(null); + Map params = new HashMap<>(1); params.put("cardTemplateId", cardTemplateId); params.put("templatePreviewPhoto", templatePreviewPhoto); cardTemplateDao.updateCardTemplateImage(params); 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 866b7d9..73e5620 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 @@ -55,7 +55,7 @@ public class CardTemplateUseServiceImpl extends AbstractService implements ICard * 查询模板名称 * 存储快照名称 */ - CardTemplateDTO templateDto = cardTemplateService.getCardTemplateById(cardTemplateUseVO.getTemplateId()); + CardTemplateDTO templateDto = cardTemplateService.getCardTemplateById(null, null, cardTemplateUseVO.getTemplateId()); if(templateDto == null) { throw new SaveException("该模板不存在"); } diff --git a/src/main/java/cn/com/tenlion/service/templateperson/impl/TemplatePersonServiceImpl.java b/src/main/java/cn/com/tenlion/service/templateperson/impl/TemplatePersonServiceImpl.java index ae9ec3f..fb85644 100644 --- a/src/main/java/cn/com/tenlion/service/templateperson/impl/TemplatePersonServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/templateperson/impl/TemplatePersonServiceImpl.java @@ -115,6 +115,11 @@ public class TemplatePersonServiceImpl extends DefaultBaseService implements ITe } else { setAppUpdateInfo(token, params); } + if(!com.alibaba.excel.util.StringUtils.isEmpty(params.get("isMain"))) { + if("1".equals(params.get("isMain"))) { + templatePersonDao.updateAllIsMain(params); + } + } templatePersonDao.update(params); } diff --git a/src/main/resources/mybatis/mapper/cardtemplate/cardtemplate-mapper.xml b/src/main/resources/mybatis/mapper/cardtemplate/cardtemplate-mapper.xml index ccce09d..bbf1d96 100644 --- a/src/main/resources/mybatis/mapper/cardtemplate/cardtemplate-mapper.xml +++ b/src/main/resources/mybatis/mapper/cardtemplate/cardtemplate-mapper.xml @@ -18,6 +18,8 @@ + + @@ -163,9 +165,20 @@ t1.template_order, t1.template_charge, t1.template_preview_photo, - t1.card_template_id + t1.card_template_id, + t2.is_main, + t2.card_person_id FROM - card_template t1 + card_template t1 LEFT JOIN card_template_person t2 ON t1.card_template_id = t2.template_id + AND t2.is_delete = 0 + + AND + t2.modifier = #{modifier} + + + AND + t2.card_person_id = #{cardPersonId} + WHERE t1.is_delete = 0 diff --git a/src/main/resources/mybatis/mapper/templateperson/templatePerson-mapper.xml b/src/main/resources/mybatis/mapper/templateperson/templatePerson-mapper.xml index cf7c25e..3414dd6 100644 --- a/src/main/resources/mybatis/mapper/templateperson/templatePerson-mapper.xml +++ b/src/main/resources/mybatis/mapper/templateperson/templatePerson-mapper.xml @@ -9,6 +9,9 @@ + + + @@ -23,6 +26,9 @@ + + + @@ -37,6 +43,9 @@ + + + @@ -53,6 +62,9 @@ template_id, content, source, + card_order, + thumbnail, + is_main, creator, gmt_create, modifier, @@ -65,6 +77,9 @@ #{templateId}, #{content}, #{source}, + #{cardOrder}, + #{thumbnail}, + #{isMain}, #{creator}, #{gmtCreate}, #{modifier}, @@ -82,7 +97,10 @@ modifier = #{modifier}, is_delete = 1 WHERE - card_person_id = #{cardPersonId} + card_person_id IN + + #{templatePersonIds[${index}]} + @@ -116,6 +134,15 @@ source = #{source}, + + card_order = #{cardOrder}, + + + thumbnail = #{thumbnail}, + + + is_main = #{isMain}, + creator = #{creator}, @@ -144,6 +171,9 @@ t1.template_id, t1.content, t1.source, + t1.card_order, + t1.thumbnail, + t1.is_main, 1 FROM card_template_person t1 @@ -160,6 +190,9 @@ t1.card_name, t1.template_id, t1.content, + t1.card_order, + t1.thumbnail, + t1.is_main, t1.source FROM card_template_person t1 @@ -176,6 +209,9 @@ t1.card_name, t1.template_id, t1.content, + t1.card_order, + t1.thumbnail, + t1.is_main, t1.source FROM card_template_person t1 @@ -193,6 +229,9 @@ t1.template_id, t1.content, t1.source, + t1.card_order, + t1.thumbnail, + t1.is_main, 1 FROM card_template_person t1 @@ -212,6 +251,7 @@ AND LEFT(t1.gmt_create, 10) #{endTime} + ORDER BY t1.card_order @@ -222,6 +262,9 @@ t1.card_name, t1.template_id, t1.content, + t1.card_order, + t1.thumbnail, + t1.is_main, t1.source FROM card_template_person t1 @@ -241,6 +284,7 @@ AND LEFT(t1.gmt_create, 10) #{endTime} + ORDER BY t1.card_order @@ -251,6 +295,9 @@ t1.card_name, t1.template_id, t1.content, + t1.card_order, + t1.thumbnail, + t1.is_main, t1.source FROM card_template_person t1 @@ -270,6 +317,7 @@ AND LEFT(t1.gmt_create, 10) #{endTime} + ORDER BY t1.card_order @@ -282,4 +330,15 @@ t1.is_delete = 0 + + UPDATE + card_template_person + SET + is_main = 0 + WHERE + is_delete = 0 + AND creator = #{modifier} + OR modifier = #{modifier} + + \ No newline at end of file