Просмотр исходного кода

农科院最新代码 修改权限,排序

Administrator 4 лет назад
Родитель
Сommit
464d49cb59

+ 6 - 0
ruoyi-admin/pom.xml

@@ -17,6 +17,12 @@
 
     <dependencies>
 
+        <!--thumbnailator生成缩略图-->
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.8</version>
+        </dependency>
         <!-- spring-boot-devtools -->
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gallery/ZbCommentController.java

@@ -18,7 +18,7 @@ import java.util.Arrays;
 import java.util.List;
 
 /**
- * 【请填写功能名称】Controller
+ * 【图片管理】Controller
  *
  * @author ruoyi
  * @date 2020-11-25

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gallery/ZbPicToPicController.java

@@ -75,6 +75,7 @@ public class ZbPicToPicController extends BaseController {
      * 删除图来图往
      */
     @DeleteMapping("/{id}")
+    @PreAuthorize("@ss.hasPermi('system:pic:remove')")
     public AjaxResult remove(@PathVariable Long id) {
         if (id == null || id == 0) {
             return AjaxResult.error("参数不正确");

+ 2 - 1
ruoyi-admin/src/main/resources/application-druid.yml

@@ -6,7 +6,8 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://192.168.101.226:3306/bm_project?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+#                url: jdbc:mysql://192.168.101.226:3306/bm_project?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://192.168.101.11:3306/bm_project?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
                 password: 123456
 #            # 从库数据源

+ 4 - 3
ruoyi-admin/src/main/resources/application.yml

@@ -9,7 +9,8 @@ ruoyi:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-  profile: /home/ruoyi/uploadPath
+#  profile: /home/ruoyi/uploadPath
+  profile: D:/ruoyi/uploadPath
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数组计算 char 字符验证
@@ -48,8 +49,8 @@ spring:
   messages:
     # 国际化资源文件路径
     basename: i18n/messages
-#  profiles:
-#    active: druid
+  profiles:
+    active: druid
   # 文件上传
   servlet:
     multipart:

+ 6 - 0
ruoyi-system/pom.xml

@@ -30,6 +30,12 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-aop</artifactId>
         </dependency>
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.8</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
 

+ 12 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/ZbFile.java

@@ -84,4 +84,16 @@ public class ZbFile implements Serializable {
     @Excel(name = "详情")
     private String detail;
 
+    /**
+     * 缩略图访问路径
+     */
+    @Excel(name = "缩略图访问路径")
+    private String thumbnailUrl;
+
+    /**
+     * 缩略图存储路径
+     */
+    @Excel(name = "缩略图存储路径")
+    private String thumbnailPath;
+
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/grallery/ZbGalleryCategory.java

@@ -63,5 +63,5 @@ public class ZbGalleryCategory extends BaseEntity {
     private Integer show;
 
     @TableField("sort")
-    private Integer sort;
+    private String sort;
 }

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/dto/GalleryCategoryDto.java

@@ -84,6 +84,10 @@ public class GalleryCategoryDto implements Serializable {
     private String remark;
 
     private boolean show;
+    /**
+     * 排序
+     */
+    private String sort;
 
     private List<GalleryCategoryDto> children;
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/ZbGalleryMapper.java

@@ -26,5 +26,8 @@ public interface ZbGalleryMapper extends BaseMapper<ZbGallery> {
 
     List<GalleryDto> selectGalleryDto(@Param("categoryIds") List<Long> categoryIds, @Param("pageInfo") Page<GalleryDto> pageInfo);
 
+    List<GalleryDto> selectGalleryDtoThumbnail(@Param("categoryIds") List<Long> categoryIds, @Param("pageInfo") Page<GalleryDto> pageInfo);
+
+
     Integer checkCategoryHasValue(@Param("categoryId") Long categoryId);
 }

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FileServiceImpl.java

@@ -22,6 +22,7 @@ import com.ruoyi.system.service.IFileService;
 import com.ruoyi.system.service.IZbFileService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import net.coobird.thumbnailator.Thumbnails;
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -91,10 +92,20 @@ public class FileServiceImpl implements IFileService {
             String code = FileUtils.getRandomFileName(name);
             String pathname = timeFormat + code;
             ImgDetailInfo imgDetailInfo = new ImgDetailInfo();
+            //生成缩略图返回缩略图地址
+            String thumbnailPath = timeFormat + FileUtils.getRandomFileName(file.getOriginalFilename());
             try {
+                //组合File.separator = \
                 File saveFile = new File(profile + File.separator + pathname);
+                File saveFileThumbnail = new File(profile + File.separator + thumbnailPath);
+                //检查目录是否存在
                 FileUtils.checkOrCreateParentDir(saveFile);
                 file.transferTo(saveFile);
+
+                //生成缩略图返回缩略图地址
+                Thumbnails.of(saveFile)
+                        .size(36, 24)
+                        .toFile(saveFileThumbnail);
                 // 如果图片需要立即解析属性信息,就同步操作去执行
                 if (parse) {
                     imgDetailInfo = printImageTags(saveFile);
@@ -114,6 +125,8 @@ public class FileServiceImpl implements IFileService {
             xmFile.setSize(file.getSize());
             xmFile.setUrl("?path=" + URLEncoder.createDefault().encode(pathname, Charset.defaultCharset()));
             xmFile.setDetail(JSON.toJSONString(imgDetailInfo));
+            xmFile.setThumbnailPath(thumbnailPath);
+            xmFile.setThumbnailUrl("?path=" + URLEncoder.createDefault().encode(thumbnailPath, Charset.defaultCharset()));
             zbFileService.save(xmFile);
             // 如果图片需要立即解析属性信息
             if (!parse && isImg(name)) {

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZbGalleryCategoryServiceImpl.java

@@ -43,11 +43,13 @@ public class ZbGalleryCategoryServiceImpl extends ServiceImpl<ZbGalleryCategoryM
      */
     @Override
     public List<GalleryCategoryDto> selectZbGalleryCategoryList(ZbGalleryCategory zbGalleryCategory, Page<ZbGalleryCategory> page) {
-        return baseMapper.selectGalleryCategory(zbGalleryCategory, page).stream().peek(x -> {
+        List<GalleryCategoryDto> collect = baseMapper.selectGalleryCategory(zbGalleryCategory, page).stream().peek(x -> {
             if (StrUtil.isNotBlank(x.getThumbnail())) {
                 x.setThumbnail(ruoYiConfig.getUrl() + x.getThumbnail());
             }
         }).collect(Collectors.toList());
+
+        return collect;
     }
 
     /**

+ 6 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZbGalleryServiceImpl.java

@@ -195,7 +195,12 @@ public class ZbGalleryServiceImpl extends ServiceImpl<ZbGalleryMapper, ZbGallery
                     .stream().map(Long::valueOf).collect(Collectors.toList());
         }
         String profile = ruoYiConfig.getUrl();
-        List<GalleryDto> galleryDtos = baseMapper.selectGalleryDto(categorys, pageInfo)
+/*        List<GalleryDto> galleryDtos = baseMapper.selectGalleryDto(categorys, pageInfo)
+                .stream().peek(
+                        x -> x.getImgInfos().forEach(i -> i.setUrl(profile + i.getUrl()))
+                ).collect(Collectors.toList());*/
+
+        List<GalleryDto> galleryDtos = baseMapper.selectGalleryDtoThumbnail(categorys, pageInfo)
                 .stream().peek(
                         x -> x.getImgInfos().forEach(i -> i.setUrl(profile + i.getUrl()))
                 ).collect(Collectors.toList());

+ 3 - 3
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -98,15 +98,15 @@
     </select>
 
     <select id="checkUserNameUnique" parameterType="java.lang.String" resultType="int">
-		select count(1) from sys_user where user_name = #{userName} limit 1
+		select count(1) from sys_user where user_name = #{userName} and del_flag = '0' limit 1
 	</select>
 
     <select id="checkPhoneUnique" parameterType="java.lang.String" resultMap="SysUserResult">
-		select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} limit 1
+		select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
 	</select>
 
     <select id="checkEmailUnique" parameterType="java.lang.String" resultMap="SysUserResult">
-		select user_id, email from sys_user where email = #{email} limit 1
+		select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
 	</select>
 
     <insert id="insertUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser" useGeneratedKeys="true"

+ 1 - 2
ruoyi-system/src/main/resources/mapper/system/ZbGalleryCategoryMapper.xml

@@ -65,9 +65,8 @@
                     and zgc.parent_id = #{obj.parentId}
                 </if>
             </if>
-
         </where>
-        order by zgc.sort, zgc.name
+        order by zgc.sort , zgc.name
     </select>
     <select id="getDetailById" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
          SELECT

+ 22 - 0
ruoyi-system/src/main/resources/mapper/system/ZbGalleryMapper.xml

@@ -115,6 +115,28 @@
             </foreach>
         </if>
     </select>
+
+    <select id="selectGalleryDtoThumbnail" resultMap="GalleryDtoMap">
+        SELECT
+        zg.*,
+        zf.thumbnail_url as url,
+        zgi.watermark_type,
+        zgi.location,
+        zgi.author,
+        zgc.name categoryName
+        FROM
+        zb_gallery zg
+        JOIN zb_gallery_img zgi ON zg.id = zgi.gallert_id
+        LEFT JOIN zb_file zf ON zf.id = zgi.thumb_id
+        left join zb_gallery_category zgc on zgc.id = zg.category_id
+        <if test="categoryIds != null and categoryIds.size() > 0">
+            WHERE zg.category_id in
+            <foreach collection="categoryIds" open="(" close=")" item="item" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
     <select id="checkCategoryHasValue" resultType="java.lang.Integer">
         SELECT
             1