Skip to content

Commit

Permalink
🧂 add - Improved the way to view the directory
Browse files Browse the repository at this point in the history
  • Loading branch information
elonehoo committed Jul 5, 2021
1 parent 4f42c77 commit 6d9a5d5
Show file tree
Hide file tree
Showing 15 changed files with 317 additions and 10 deletions.
34 changes: 34 additions & 0 deletions src/main/java/com/zfile/code/controller/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.xiaoTools.core.result.Result;
import com.zfile.code.entity.user.dto.LoginUser;
import com.zfile.code.entity.user.dto.RegisterUser;
import com.zfile.code.entity.user.dto.UpdateUser;
import com.zfile.code.stents.UserStents;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
Expand Down Expand Up @@ -85,6 +86,39 @@ public Result login(@RequestBody LoginUser user){
return userStents.login(user,request.getRequestURI());
}

/**
* [展示用户的信息](Display user information)
* @description: zh - 展示用户的信息
* @description: en - Display user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 3:14 下午
* @return com.xiaoTools.core.result.Result
*/
@SaCheckLogin
@GetMapping("/show")
@Operation(summary = "展示用户的信息")
public Result show(){
return userStents.show(request.getRequestURI());
}

/**
* [修改用户的信息](Modify user information)
* @description: zh - 修改用户的信息
* @description: en - Modify user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 3:57 下午
* @param updateUser: 修改的用户的信息
* @return com.xiaoTools.core.result.Result
*/
@SaCheckLogin
@PutMapping("/user")
@Operation(summary = "修改用户的信息")
public Result update(@RequestBody UpdateUser updateUser){
return userStents.update(updateUser,request.getRequestURI());
}

/**
* [退出登陆](Log out)
* @description: zh - 退出登陆
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/zfile/code/entity/file/vo/FileVO.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.zfile.code.entity.file.vo;

import cn.hutool.core.date.DateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;

import java.util.Date;

/**
* 展示文件的展示类
* @author HCY
Expand All @@ -22,4 +26,15 @@ public class FileVO {
* 文件的类型
*/
private String fileType;

/**
* 文件大小
*/
private String fileSize;

/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date dateTime;
}
38 changes: 38 additions & 0 deletions src/main/java/com/zfile/code/entity/user/dto/UpdateUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.zfile.code.entity.user.dto;

import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
* [修改用户的信息](Modify user information)
* @description: zh - 修改用户的信息
* @description: en - Modify user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 3:29 下午
*/
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class UpdateUser implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
* 昵称
*/
private String nickName;

/**
* 头像
*/
private String photo;
}
16 changes: 12 additions & 4 deletions src/main/java/com/zfile/code/entity/user/po/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zfile.code.service.UserService;
import com.zfile.code.service.impl.UserServiceImpl;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import lombok.experimental.Accessors;

/**
Expand All @@ -22,7 +20,11 @@
* @author HCY
* @since 2021-04-28
*/
@Data
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tbl_user")
Expand Down Expand Up @@ -73,4 +75,10 @@ public User(String email, String nickName) {
this.email = email;
this.nickName = nickName;
}

public User(String id, String photo, String nickName) {
this.id = id;
this.photo = photo;
this.nickName = nickName;
}
}
44 changes: 44 additions & 0 deletions src/main/java/com/zfile/code/entity/user/vo/ShowUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.zfile.code.entity.user.vo;

import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
* [展示用户信息](Display user information)
* @description: zh - 展示用户信息
* @description: en - Display user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 2:56 下午
*/
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ShowUser implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
* 邮件
*/
private String email;

/**
* 用户信息
*/
private String nickName;

/**
* 头像
*/
private String photo;

}
12 changes: 12 additions & 0 deletions src/main/java/com/zfile/code/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.zfile.code.entity.user.po.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zfile.code.entity.user.vo.ShowUser;

/**
* <p>
Expand Down Expand Up @@ -37,4 +38,15 @@ public interface UserMapper extends BaseMapper<User> {
* @return com.zfile.code.entity.user.po.User
*/
User selectByLogin(String account, String cipher);

/**
* [展示用户的信息](Display user information)
* @description: zh - 展示用户的信息
* @description: en - Display user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 2:46 下午
* @return com.zfile.code.entity.user.vo.ShowUser
*/
ShowUser show();
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.zfile.code.resolver;

import com.zfile.code.entity.progress.vo.ProgressEntity;
import com.zfile.code.listener.UploadProgressListener;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/zfile/code/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.zfile.code.entity.user.po.User;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zfile.code.entity.user.vo.ShowUser;

/**
* <p>
Expand Down Expand Up @@ -48,4 +49,15 @@ public interface UserService extends IService<User> {
* @return com.zfile.code.entity.user.po.User
*/
User login(String account, String cipher);

/**
* [展示用户的信息](Display user information)
* @description: zh - 展示用户的信息
* @description: en - Display user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 2:46 下午
* @return com.zfile.code.entity.user.vo.ShowUser
*/
ShowUser show();
}
15 changes: 15 additions & 0 deletions src/main/java/com/zfile/code/service/impl/UserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zfile.code.service.impl;

import com.zfile.code.entity.user.po.User;
import com.zfile.code.entity.user.vo.ShowUser;
import com.zfile.code.mapper.UserMapper;
import com.zfile.code.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
Expand Down Expand Up @@ -70,4 +71,18 @@ public String getByEmail(String emailHex) {
public User login(String account, String cipher) {
return userMapper.selectByLogin(account,cipher);
}

/**
* [展示用户的信息](Display user information)
* @description: zh - 展示用户的信息
* @description: en - Display user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 2:46 下午
* @return com.zfile.code.entity.user.vo.ShowUser
*/
@Override
public ShowUser show() {
return userMapper.show();
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/zfile/code/stents/UserStents.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.zfile.code.entity.file.dto.Touch;
import com.zfile.code.entity.user.dto.LoginUser;
import com.zfile.code.entity.user.dto.RegisterUser;
import com.zfile.code.entity.user.dto.UpdateUser;

/**
* [外观模式的用户接口分层](User interface layering of appearance mode)
Expand Down Expand Up @@ -79,4 +80,29 @@ public interface UserStents {
* @return com.xiaoTools.core.result.Result
*/
Result log(String path);

/**
* [查看用户的信息](View user information)
* @description: zh - 查看用户的信息
* @description: en - View user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 3:16 下午
* @param path: URL路径
* @return com.xiaoTools.core.result.Result
*/
Result show(String path);

/**
* [修改用户的信息](Modify user information)
* @description: zh - 修改用户的信息
* @description: en - Modify user information
* @version: V1.0
* @author XiaoXunYao
* @since 2021/7/5 3:34 下午
* @param updateUser: 可以修改的用户信息
* @param path: URL路径
* @return com.xiaoTools.core.result.Result
*/
Result update(UpdateUser updateUser, String path);
}
6 changes: 4 additions & 2 deletions src/main/java/com/zfile/code/stents/impl/BaseStentsImpl.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.zfile.code.stents.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileTypeUtil;
import com.xiaoTools.core.fileUtil.fileUtil.FileUtil;
import com.xiaoTools.core.result.Result;
import com.zfile.code.entity.file.vo.FileVO;
import com.zfile.code.entity.systemInfo.systemInfo.vo.SystemInfo;
import com.zfile.code.service.UserService;
import com.zfile.code.stents.BaseStents;
import com.zfile.code.util.FileTemporaryUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -66,10 +68,10 @@ public Result getSeeContent(String value, String path) {
//判断文件是否是目录
if (!file.isDirectory()) {
//如果不是目录,则获取该文件的文件类型
lists.add(new FileVO(file.getName(),FileTypeUtil.getType(file)));
lists.add(new FileVO(file.getName(),FileTypeUtil.getType(file), FileTemporaryUtil.size(cn.hutool.core.io.FileUtil.size(file)),cn.hutool.core.io.FileUtil.lastModifiedTime(file)));
}else {
//是目录,则进行集合添加
lists.add(new FileVO(file.getName(), "Directory"));
lists.add(new FileVO(file.getName(), "Directory", FileTemporaryUtil.size(cn.hutool.core.io.FileUtil.size(file)),cn.hutool.core.io.FileUtil.lastModifiedTime(file)));
}
}
}catch (Exception e){ /*无任何需要制作的操作*/ }
Expand Down
Loading

0 comments on commit 6d9a5d5

Please sign in to comment.