Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
cf8a390b
Commit
cf8a390b
authored
Mar 19, 2022
by
284718418@qq.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature_20220222_huayi
# Conflicts: # src/main/resources/application-pro.yml
parents
663f5dde
f0d60fa1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
19 deletions
+54
-19
src/main/java/cn/timer/api/bean/disk/DiskFiles.java
+7
-2
src/main/java/cn/timer/api/controller/disk/DiskFilesController.java
+29
-10
src/main/java/cn/timer/api/controller/disk/sevice/DiskFilesService.java
+3
-2
src/main/java/cn/timer/api/controller/disk/sevice/DiskFilesServiceImpl.java
+3
-2
src/main/java/cn/timer/api/dao/disk/DiskFilesMapper.java
+3
-2
src/main/resources/mapping/disk/DiskFilesMapper.xml
+9
-1
No files found.
src/main/java/cn/timer/api/bean/disk/DiskFiles.java
View file @
cf8a390b
...
...
@@ -78,11 +78,16 @@ public class DiskFiles extends Model<DiskFiles> {
@ApiModelProperty
(
value
=
"上传文件时的IP"
)
private
String
uploadIp
;
/**
* 逻辑删除标记0.未删除 1.删除
*/
* 逻辑删除标记0.未删除 1.删除
*/
@ApiModelProperty
(
value
=
""
)
private
Integer
deleteFlag
;
/**
* 当前企业id
*/
@ApiModelProperty
(
value
=
"当前企业id"
)
private
Integer
orgId
;
/**
* 创建者
*/
@ApiModelProperty
(
value
=
""
)
...
...
src/main/java/cn/timer/api/controller/disk/DiskFilesController.java
View file @
cf8a390b
...
...
@@ -4,6 +4,7 @@ import cn.timer.api.bean.disk.DiskCatalogue;
import
cn.timer.api.bean.disk.DiskCatalogueFiles
;
import
cn.timer.api.bean.disk.DiskFiles
;
import
cn.timer.api.bean.disk.DiskFilesLog
;
import
cn.timer.api.bean.qyzx.QyzxEmpLogin
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.config.enuminterface.JxglEnumInterface
;
...
...
@@ -75,23 +76,45 @@ public class DiskFilesController {
@PostMapping
(
"/upload"
)
@ApiOperation
(
value
=
"上传普通文件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Object
>
upload
(
@CurrentUser
UserBean
userBean
,
@RequestParam
(
required
=
true
)
MultipartFile
[]
file
,
@ApiParam
(
"文件文件夹或共享空间ID"
)
@RequestParam
(
required
=
tru
e
)
Integer
catalogueId
,
HttpServletRequest
request
)
{
@ApiParam
(
"文件文件夹或共享空间ID"
)
@RequestParam
(
required
=
fals
e
)
Integer
catalogueId
,
HttpServletRequest
request
)
{
if
(
catalogueId
<=
0
){
return
ResultUtil
.
error
(
"上传失败,请选择文件夹"
);
DiskCatalogue
diskCatalogue
=
DiskCatalogue
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
DiskCatalogue
>().
select
(
"id"
)
.
eq
(
"org_id"
,
userBean
.
getOrgCode
())
.
eq
(
"delete_flag"
,
0
)
.
eq
(
"create_user_id"
,
userBean
.
getEmpNum
()).
orderByAsc
(
"create_time"
)
);
if
(
StringUtils
.
isEmpty
(
diskCatalogue
)){
diskCatalogue
=
new
DiskCatalogue
();
diskCatalogue
.
setCreateUserId
(
userBean
.
getEmpNum
());
diskCatalogue
.
setOrgId
(
userBean
.
getOrgCode
());
diskCatalogue
.
setParentIds
(
""
);
diskCatalogue
.
setName
(
"我的文件夹"
);
diskCatalogue
.
setUserName
(
userBean
.
getUserInfo
().
getName
());
diskCatalogue
.
setType
(
JxglEnumInterface
.
DiskCatalogueType
.
DISK_FILE
.
getType
());
diskCatalogue
.
insert
();
}
catalogueId
=
diskCatalogue
.
getId
();
//return ResultUtil.error("上传失败,请选择文件夹");
}
if
(
file
==
null
||
file
.
length
==
0
)
{
return
ResultUtil
.
error
(
"上传失败,请选择上传文件"
);
}
DiskFiles
diskFiles
=
new
DiskFiles
();
diskFiles
.
setOrgId
(
userBean
.
getOrgCode
());
diskFiles
.
setCreateUserId
(
userBean
.
getEmpNum
());
diskFiles
.
setUploadIp
(
UserIp
.
getIpAddr
(
request
));
diskFiles
.
setUserName
(
userBean
.
getQyzxEmpLogin
().
getUsername
());
DiskCatalogueFiles
diskCatalogueFiles
=
new
DiskCatalogueFiles
();
DiskFilesLog
diskFilesLog
=
new
DiskFilesLog
();
diskFilesLog
.
setUserId
(
userBean
.
getEmpNum
());
diskFilesLog
.
setUserName
(
userBean
.
getQyzxEmpLogin
().
getUsername
());
List
<
FileInfoDto
>
imageUrls
;
try
{
//上传文件到服务器
imageUrls
=
ftpService
.
uploadFile
(
targetPath
,
file
,
reservedName
);
for
(
FileInfoDto
dto
:
imageUrls
)
{
//新增资源上传文件
diskFiles
.
setCreateUserId
(
userBean
.
getEmpNum
());
diskFiles
.
setFileType
(
dto
.
getFileSuffix
());
//"/home/disk/123456.jpg"
diskFiles
.
setDiskPath
(
root
+
targetPath
+
"/"
+
dto
.
getFileName
());
...
...
@@ -100,8 +123,6 @@ public class DiskFilesController {
diskFiles
.
setFileSize
(
dto
.
getFileSize
());
// 显示大小:10KB,5M,2G
diskFiles
.
setShowSize
(
FileUtils
.
getSize
(
dto
.
getFileSize
()));
diskFiles
.
setUserName
(
userBean
.
getQyzxEmpLogin
().
getUsername
());
diskFiles
.
setUploadIp
(
UserIp
.
getIpAddr
(
request
));
diskFiles
.
insert
();
//新增中间关系
...
...
@@ -115,8 +136,6 @@ public class DiskFilesController {
diskFilesLog
.
setFileSize
(
dto
.
getFileSize
()
+
"B"
);
diskFilesLog
.
setTitle
(
dto
.
getResourceFileName
());
diskFilesLog
.
setType
(
JxglEnumInterface
.
DiskFilesLogType
.
CREATE_LOG
.
getType
());
diskFilesLog
.
setUserId
(
userBean
.
getEmpNum
());
diskFilesLog
.
setUserName
(
userBean
.
getQyzxEmpLogin
().
getUsername
());
diskFilesLog
.
insert
();
}
...
...
@@ -212,11 +231,11 @@ public class DiskFilesController {
* @param userBean
* @return
*/
@GetMapping
(
value
=
"/mycatalogue"
)
@GetMapping
(
value
=
"/mycatalogue
/{type}
"
)
@ApiOperation
(
value
=
"我的文件空间大小"
,
httpMethod
=
"GET"
,
notes
=
"我的文件空间大小"
)
public
Result
<
Object
>
myCatalogue
(
@CurrentUser
UserBean
userBean
)
{
public
Result
<
Object
>
myCatalogue
(
@
PathVariable
(
"type"
)
Integer
type
,
@
CurrentUser
UserBean
userBean
)
{
try
{
DiskFileCatalogueDto
diskFileCatalogueDto
=
diskFilesService
.
getFileCount
(
userBean
.
getEmpNum
()
);
DiskFileCatalogueDto
diskFileCatalogueDto
=
diskFilesService
.
getFileCount
(
userBean
,
type
);
return
ResultUtil
.
data
(
diskFileCatalogueDto
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
src/main/java/cn/timer/api/controller/disk/sevice/DiskFilesService.java
View file @
cf8a390b
...
...
@@ -2,6 +2,7 @@ package cn.timer.api.controller.disk.sevice;
import
cn.timer.api.bean.disk.DiskCatalogue
;
import
cn.timer.api.bean.disk.DiskFiles
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.dto.disk.DiskCatalogueParam
;
import
cn.timer.api.dto.disk.DiskFileCatalogueDto
;
...
...
@@ -24,10 +25,10 @@ public interface DiskFilesService {
/**
* 获取用户文件空间大小
* @param user
Id
* @param user
Bean
* @return
*/
DiskFileCatalogueDto
getFileCount
(
Integer
userId
);
DiskFileCatalogueDto
getFileCount
(
UserBean
userBean
,
Integer
type
);
/**
* 删除文件
...
...
src/main/java/cn/timer/api/controller/disk/sevice/DiskFilesServiceImpl.java
View file @
cf8a390b
package
cn
.
timer
.
api
.
controller
.
disk
.
sevice
;
import
cn.timer.api.bean.disk.DiskFiles
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.dao.disk.DiskFilesMapper
;
import
cn.timer.api.dto.disk.DiskCatalogueParam
;
import
cn.timer.api.dto.disk.DiskFileCatalogueDto
;
...
...
@@ -29,8 +30,8 @@ public class DiskFilesServiceImpl implements DiskFilesService {
}
@Override
public
DiskFileCatalogueDto
getFileCount
(
Integer
userId
)
{
DiskFileCatalogueDto
dto
=
diskFilesMapper
.
selectFileCount
(
user
Id
);
public
DiskFileCatalogueDto
getFileCount
(
UserBean
userBean
,
Integer
type
)
{
DiskFileCatalogueDto
dto
=
diskFilesMapper
.
selectFileCount
(
user
Bean
,
type
);
if
(
StringUtils
.
isEmpty
(
dto
)){
dto
=
new
DiskFileCatalogueDto
();
}
...
...
src/main/java/cn/timer/api/dao/disk/DiskFilesMapper.java
View file @
cf8a390b
...
...
@@ -2,6 +2,7 @@ package cn.timer.api.dao.disk;
import
cn.timer.api.bean.disk.DiskFiles
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.dto.disk.DiskCatalogueParam
;
import
cn.timer.api.dto.disk.DiskFileCatalogueDto
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
...
...
@@ -30,10 +31,10 @@ public interface DiskFilesMapper extends BaseMapper<DiskFiles> {
/**
* 获取用户文件空间大小
* @param user
Id
* @param user
Bean
* @return
*/
DiskFileCatalogueDto
selectFileCount
(
@Param
(
"
userId"
)
Integer
userId
);
DiskFileCatalogueDto
selectFileCount
(
@Param
(
"
param"
)
UserBean
userBean
,
@Param
(
"type"
)
Integer
type
);
/**
* 删除文件
...
...
src/main/resources/mapping/disk/DiskFilesMapper.xml
View file @
cf8a390b
...
...
@@ -13,6 +13,7 @@
<result
property=
"showSize"
column=
"show_size"
/>
<result
property=
"fileType"
column=
"file_type"
/>
<result
property=
"uploadIp"
column=
"upload_ip"
/>
<result
property=
"orgId"
column=
"org_id"
/>
<result
property=
"deleteFlag"
column=
"delete_flag"
/>
<result
property=
"createUserId"
column=
"create_user_id"
/>
<result
property=
"userName"
column=
"user_name"
/>
...
...
@@ -33,7 +34,14 @@
</select>
<select
id=
"selectFileCount"
resultType=
"cn.timer.api.dto.disk.DiskFileCatalogueDto"
>
SELECT COALESCE(sum(file_size),0) as countSize FROM `disk_files` where create_user_id = #{userId} AND delete_flag=0
SELECT COALESCE(sum(df.file_size),0) as countSize FROM `disk_files` df
LEFT JOIN disk_catalogue_files dcf ON df.id = dcf.files_id
LEFT JOIN disk_catalogue dc ON dc.id = dcf.catalogue_id
WHERE df.delete_flag=0
<if
test=
"type == 1"
>
AND df.create_user_id = #{param.empNum}
</if>
AND df.org_id=#{param.orgCode} AND dcf.delete_flag=0 AND dc.delete_flag=0 AND dc.type = #{type}
</select>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment