11 changed files with 426 additions and 5 deletions
@ -0,0 +1,15 @@ |
|||
package com.elink.esua.epdc.vaccine.constant; |
|||
|
|||
/** |
|||
* 图片常量 |
|||
* @Author zy |
|||
* @Date 2019/9/8 17:07 |
|||
*/ |
|||
public interface ImageConstant { |
|||
|
|||
/** |
|||
* 图片类型-疫苗接种证明材料 |
|||
*/ |
|||
public final static String TYPE_IMAGE_VIM_EPIDEMIC_IMG = "vim_epidemic_img"; |
|||
|
|||
} |
@ -0,0 +1,55 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.vaccine.vim.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.vaccine.vim.dto.EpidemicImagesDTO; |
|||
import com.elink.esua.epdc.vaccine.vim.entity.VimImgEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* customer 库共用图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2021-09-14 |
|||
*/ |
|||
@Mapper |
|||
public interface VimImgDao extends BaseDao<VimImgEntity> { |
|||
|
|||
/** |
|||
* 删除 |
|||
* |
|||
* @param referenceId |
|||
* @return void |
|||
* @Author zhangyong |
|||
* @Date 17:51 2021-09-14 |
|||
**/ |
|||
void deleteByReferenceId(@Param("referenceId") String referenceId); |
|||
|
|||
/** |
|||
* 根据 referenceId,查询图片路径 |
|||
* @param referenceId |
|||
* @return java.util.List<java.lang.String> |
|||
* @Author zhangyong |
|||
* @Date 14:07 2021-12-06 |
|||
**/ |
|||
List<EpidemicImagesDTO> selectListImgUrlsByIds(@Param("referenceId") String referenceId, @Param("imgType") String imgType); |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.elink.esua.epdc.vaccine.vim.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 图片详情 |
|||
* @auther: zhangyong |
|||
* @date: 2021-12-06 14:25 |
|||
*/ |
|||
@Data |
|||
public class EpidemicImagesDTO { |
|||
|
|||
private String name; |
|||
|
|||
private String url; |
|||
} |
@ -0,0 +1,53 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.vaccine.vim.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* customer 库共用图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2021-09-14 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_custom_img") |
|||
public class VimImgEntity extends BaseEpdcEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 引用ID |
|||
*/ |
|||
private String referenceId; |
|||
|
|||
/** |
|||
* 图片地址 |
|||
*/ |
|||
private String imgUrl; |
|||
|
|||
/** |
|||
* 图片类型 |
|||
*/ |
|||
private String imgType; |
|||
|
|||
} |
@ -0,0 +1,118 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.vaccine.vim.service; |
|||
|
|||
|
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.dto.suggestion.CustomImgDTO; |
|||
import com.elink.esua.epdc.vaccine.vim.dto.EpidemicImagesDTO; |
|||
import com.elink.esua.epdc.vaccine.vim.entity.VimImgEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* customer 库共用图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2021-09-14 |
|||
*/ |
|||
public interface VimImgService extends BaseService<VimImgEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<CustomImgDTO> |
|||
* @author generator |
|||
* @date 2021-09-14 |
|||
*/ |
|||
PageData<CustomImgDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<CustomImgDTO> |
|||
* @author generator |
|||
* @date 2021-09-14 |
|||
*/ |
|||
List<CustomImgDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return CustomImgDTO |
|||
* @author generator |
|||
* @date 2021-09-14 |
|||
*/ |
|||
CustomImgDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2021-09-14 |
|||
*/ |
|||
void save(CustomImgDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2021-09-14 |
|||
*/ |
|||
void update(CustomImgDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2021-09-14 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* 删除 |
|||
* |
|||
* @param referenceId |
|||
* @return void |
|||
* @Author zhangyong |
|||
* @Date 17:51 2021-09-14 |
|||
**/ |
|||
void deleteByReferenceId(String referenceId); |
|||
|
|||
/** |
|||
* 保存图片 |
|||
* |
|||
* @Params: [images, eventId, imgType] |
|||
* @Return: boolean |
|||
* @Author: zy |
|||
* @Date: 2019/9/8 17:12 |
|||
*/ |
|||
boolean saveImages(List<EpidemicImagesDTO> images, String referenceId, String imgType); |
|||
} |
@ -0,0 +1,123 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.vaccine.vim.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.dto.suggestion.CustomImgDTO; |
|||
import com.elink.esua.epdc.vaccine.vim.dao.VimImgDao; |
|||
import com.elink.esua.epdc.vaccine.vim.dto.EpidemicImagesDTO; |
|||
import com.elink.esua.epdc.vaccine.vim.entity.VimImgEntity; |
|||
import com.elink.esua.epdc.vaccine.vim.service.VimImgService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* customer 库共用图片表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2021-09-14 |
|||
*/ |
|||
@Service |
|||
public class VimImgServiceImpl extends BaseServiceImpl<VimImgDao, VimImgEntity> implements VimImgService { |
|||
|
|||
@Override |
|||
public PageData<CustomImgDTO> page(Map<String, Object> params) { |
|||
IPage<VimImgEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, CustomImgDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<CustomImgDTO> list(Map<String, Object> params) { |
|||
List<VimImgEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, CustomImgDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<VimImgEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<VimImgEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public CustomImgDTO get(String id) { |
|||
VimImgEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, CustomImgDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(CustomImgDTO dto) { |
|||
VimImgEntity entity = ConvertUtils.sourceToTarget(dto, VimImgEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(CustomImgDTO dto) { |
|||
VimImgEntity entity = ConvertUtils.sourceToTarget(dto, VimImgEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteByReferenceId(String referenceId) { |
|||
baseDao.deleteByReferenceId(referenceId); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public boolean saveImages(List<EpidemicImagesDTO> images, String referenceId, String imgType) { |
|||
if (null == images || images.isEmpty()) { |
|||
return true; |
|||
} |
|||
List<VimImgEntity> imgEntities = new ArrayList<>(images.size()); |
|||
VimImgEntity entity = null; |
|||
for (int i = 0; i < images.size(); i++) { |
|||
entity = new VimImgEntity(); |
|||
entity.setReferenceId(referenceId); |
|||
entity.setImgUrl(images.get(i).getUrl()); |
|||
entity.setImgType(imgType); |
|||
imgEntities.add(entity); |
|||
} |
|||
return insertBatch(imgEntities); |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.elink.esua.epdc.vaccine.vim.dao.VimImgDao"> |
|||
|
|||
<update id="deleteByReferenceId"> |
|||
update epdc_custom_img set DEL_FLAG = '1' where REFERENCE_ID = #{referenceId} |
|||
</update> |
|||
|
|||
<select id="selectListImgUrlsByIds" resultType="com.elink.esua.epdc.vaccine.vim.dto.EpidemicImagesDTO"> |
|||
SELECT |
|||
IMG_URL url |
|||
FROM epdc_custom_img |
|||
WHERE DEL_FLAG ='0' |
|||
AND REFERENCE_ID = #{referenceId} |
|||
AND IMG_TYPE = #{imgType} |
|||
</select> |
|||
</mapper> |
Loading…
Reference in new issue