From 82c7f08a0c208fccd34c86491ada4ce8fcf370a4 Mon Sep 17 00:00:00 2001 From: cuibaocheng Date: Tue, 1 Jun 2021 18:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A5=97=E7=89=88=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../materialdata/MaterialDataService.java | 12 ++++ .../impl/MaterialDataServiceImpl.java | 56 ++++++++++++++++++- .../materialaudio/material-audio-mapper.xml | 3 + .../materiallink/material-link-mapper.xml | 3 + .../materialmap/material-map-mapper.xml | 3 + .../materialphoto/material-photo-mapper.xml | 3 + .../materialtext/material-text-mapper.xml | 3 + .../materialvideo/material-video-mapper.xml | 3 + .../materialstore/pojo/MaterialTypeEnum.java | 31 ++++++++++ 9 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 pojo-material-store/src/main/java/cn/com/tenlion/materialstore/pojo/MaterialTypeEnum.java diff --git a/interface-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/MaterialDataService.java b/interface-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/MaterialDataService.java index b1b2655..d5b0550 100644 --- a/interface-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/MaterialDataService.java +++ b/interface-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/MaterialDataService.java @@ -1,7 +1,11 @@ package cn.com.tenlion.materialstore.service.materialdata; +import cn.com.tenlion.materialstore.pojo.MaterialTypeEnum; import cn.com.tenlion.materialstore.pojo.dtos.materialdata.MaterialDataDTO; import cn.com.tenlion.materialstore.pojo.vos.materialdata.MaterialDataVO; +import ink.wgink.util.ReflectUtil; + +import java.util.List; public interface MaterialDataService { @@ -19,4 +23,12 @@ public interface MaterialDataService { */ public MaterialDataDTO getByMaterialId(String materialId); + /** + * 查询素材包素材 + * @param token + * @param typeEnum + * @return 素材集对象 + */ + public MaterialDataDTO getByToken(String token, MaterialTypeEnum typeEnum) throws ReflectUtil.ReflectException, Exception; + } diff --git a/module-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/impl/MaterialDataServiceImpl.java b/module-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/impl/MaterialDataServiceImpl.java index 2450668..3993694 100644 --- a/module-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/impl/MaterialDataServiceImpl.java +++ b/module-material-store/src/main/java/cn/com/tenlion/materialstore/service/materialdata/impl/MaterialDataServiceImpl.java @@ -1,5 +1,6 @@ package cn.com.tenlion.materialstore.service.materialdata.impl; +import cn.com.tenlion.materialstore.pojo.MaterialTypeEnum; import cn.com.tenlion.materialstore.pojo.dtos.materialaudio.MaterialAudioDTO; import cn.com.tenlion.materialstore.pojo.dtos.materialdata.MaterialDataDTO; import cn.com.tenlion.materialstore.pojo.dtos.materiallink.MaterialLinkDTO; @@ -21,14 +22,22 @@ import cn.com.tenlion.materialstore.service.materialmap.IMaterialMapService; import cn.com.tenlion.materialstore.service.materialphoto.IMaterialPhotoService; import cn.com.tenlion.materialstore.service.materialtext.IMaterialTextService; import cn.com.tenlion.materialstore.service.materialvideo.IMaterialVideoService; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.SearchException; +import ink.wgink.pojo.app.AppTokenUser; +import ink.wgink.util.ReflectUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; + +import java.util.HashMap; import java.util.List; +import java.util.Map; @Primary @Service -public class MaterialDataServiceImpl implements MaterialDataService { +public class MaterialDataServiceImpl extends DefaultBaseService implements MaterialDataService { @Autowired private IMaterialTextService materialTextService; @@ -131,4 +140,49 @@ public class MaterialDataServiceImpl implements MaterialDataService { return dataDTO; } + @Override + public MaterialDataDTO getByToken(String token, MaterialTypeEnum typeEnum) throws Exception { + MaterialDataDTO dataDTO = new MaterialDataDTO(); + Map query = new HashMap(); + AppTokenUser user = securityComponent.getAppTokenUser(token); + if(user == null || StringUtils.isEmpty(user.getId())) { + throw new SearchException("用户信息不存在"); + } + query.put("creator", user.getId()); + switch (typeEnum) { + case TEXT: + List textDTOList = materialTextService.list(query); + dataDTO.setText(textDTOList); + break; + case PHOTO: + List photoDTOList = materialPhotoService.list(query); + dataDTO.setPhoto(photoDTOList); + break; + case AUDIO: + List audioDTOList = materialAudioService.list(query); + dataDTO.setAudio(audioDTOList); + break; + case VIDEO: + List videoDTOList = materialVideoService.list(query); + dataDTO.setVideo(videoDTOList); + break; + case MAP: + List mapDTOList = materialMapService.list(query); + dataDTO.setMap(mapDTOList); + break; + case LINK: + List linkDTOList = materialLinkService.list(query); + dataDTO.setLink(linkDTOList); + break; + default: + dataDTO.setText(materialTextService.list(query)); + dataDTO.setPhoto(materialPhotoService.list(query)); + dataDTO.setAudio(materialAudioService.list(query)); + dataDTO.setVideo(materialVideoService.list(query)); + dataDTO.setMap(materialMapService.list(query)); + dataDTO.setLink(materialLinkService.list(query)); + } + return dataDTO; + } + } diff --git a/module-material-store/src/main/resources/mybatis/mapper/materialaudio/material-audio-mapper.xml b/module-material-store/src/main/resources/mybatis/mapper/materialaudio/material-audio-mapper.xml index 4da6ba9..d0cae93 100644 --- a/module-material-store/src/main/resources/mybatis/mapper/materialaudio/material-audio-mapper.xml +++ b/module-material-store/src/main/resources/mybatis/mapper/materialaudio/material-audio-mapper.xml @@ -258,6 +258,9 @@ AND t1.material_id = #{materialId} + + AND t1.creator = #{creator} + ORDER BY t1.gmt_create DESC, t1.material_order diff --git a/module-material-store/src/main/resources/mybatis/mapper/materiallink/material-link-mapper.xml b/module-material-store/src/main/resources/mybatis/mapper/materiallink/material-link-mapper.xml index 5044847..c7e8b59 100644 --- a/module-material-store/src/main/resources/mybatis/mapper/materiallink/material-link-mapper.xml +++ b/module-material-store/src/main/resources/mybatis/mapper/materiallink/material-link-mapper.xml @@ -272,6 +272,9 @@ AND t1.material_id = #{materialId} + + AND t1.creator = #{creator} + ORDER BY t1.gmt_create DESC, t1.material_order diff --git a/module-material-store/src/main/resources/mybatis/mapper/materialmap/material-map-mapper.xml b/module-material-store/src/main/resources/mybatis/mapper/materialmap/material-map-mapper.xml index 3942c9f..7043251 100644 --- a/module-material-store/src/main/resources/mybatis/mapper/materialmap/material-map-mapper.xml +++ b/module-material-store/src/main/resources/mybatis/mapper/materialmap/material-map-mapper.xml @@ -284,6 +284,9 @@ AND t1.material_id = #{materialId} + + AND t1.creator = #{creator} + ORDER BY t1.gmt_create DESC, t1.material_order diff --git a/module-material-store/src/main/resources/mybatis/mapper/materialphoto/material-photo-mapper.xml b/module-material-store/src/main/resources/mybatis/mapper/materialphoto/material-photo-mapper.xml index 34b2500..7d5b2aa 100644 --- a/module-material-store/src/main/resources/mybatis/mapper/materialphoto/material-photo-mapper.xml +++ b/module-material-store/src/main/resources/mybatis/mapper/materialphoto/material-photo-mapper.xml @@ -262,6 +262,9 @@ AND t1.material_id = #{materialId} + + AND t1.creator = #{creator} + ORDER BY t1.gmt_create DESC, t1.material_order diff --git a/module-material-store/src/main/resources/mybatis/mapper/materialtext/material-text-mapper.xml b/module-material-store/src/main/resources/mybatis/mapper/materialtext/material-text-mapper.xml index eaa97b1..7ce9cb7 100644 --- a/module-material-store/src/main/resources/mybatis/mapper/materialtext/material-text-mapper.xml +++ b/module-material-store/src/main/resources/mybatis/mapper/materialtext/material-text-mapper.xml @@ -274,6 +274,9 @@ AND t1.material_id = #{materialId} + + AND t1.creator = #{creator} + ORDER BY t1.gmt_create DESC, t1.material_order diff --git a/module-material-store/src/main/resources/mybatis/mapper/materialvideo/material-video-mapper.xml b/module-material-store/src/main/resources/mybatis/mapper/materialvideo/material-video-mapper.xml index b9b2682..d0bed90 100644 --- a/module-material-store/src/main/resources/mybatis/mapper/materialvideo/material-video-mapper.xml +++ b/module-material-store/src/main/resources/mybatis/mapper/materialvideo/material-video-mapper.xml @@ -258,6 +258,9 @@ AND t1.material_id = #{materialId} + + AND t1.creator = #{creator} + ORDER BY t1.gmt_create DESC, t1.material_order diff --git a/pojo-material-store/src/main/java/cn/com/tenlion/materialstore/pojo/MaterialTypeEnum.java b/pojo-material-store/src/main/java/cn/com/tenlion/materialstore/pojo/MaterialTypeEnum.java new file mode 100644 index 0000000..86128e5 --- /dev/null +++ b/pojo-material-store/src/main/java/cn/com/tenlion/materialstore/pojo/MaterialTypeEnum.java @@ -0,0 +1,31 @@ +package cn.com.tenlion.materialstore.pojo; + +public enum MaterialTypeEnum { + + TEXT("TEXT", "文本"), + PHOTO("PHOTO", "图片"), + AUDIO("AUDIO", "音频"), + VIDEO("VIDEO", "视频"), + MAP("MAP", "经纬度"), + LINK("LINK", "链接"); + + private String type; + + private String typeName; + + MaterialTypeEnum(String type, String typeName) { + this.type = type; + this.typeName = typeName; + } + public String getType() { + return type; + } + + public String getTypeName() { + return typeName; + } + +// public static ArrayList> getType() { +// return type; +// } +}