Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 045ca186
authored
Jul 08, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add] 添加文件更新接口
[chg] 代码优化
1 parent
4aa3ec52
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
31 additions
and
56 deletions
pom.xml
src/main/java/vion/controller/FileController.java
src/main/java/vion/controller/InspectController.java
src/main/java/vion/controller/PaymentController.java
src/main/java/vion/controller/RoleController.java
src/main/java/vion/dto/FileInfoDTO.java
src/main/java/vion/service/impl/ContractServiceImpl.java
src/main/java/vion/service/impl/StoreServiceImpl.java
src/main/java/vion/service/impl/TaskServiceImpl.java
pom.xml
View file @
045ca18
...
...
@@ -14,8 +14,6 @@
<artifactId>
Vion-DevOps
</artifactId>
<version>
1
</version>
<properties>
<pg.version>
42.7.3
</pg.version>
<lombok.version>
1.18.34
</lombok.version>
<hutool.version>
6.0.0-M13
</hutool.version>
<redisson.verion>
3.32.0
</redisson.verion>
<mapstruct-plus.version>
1.4.3
</mapstruct-plus.version>
...
...
@@ -30,12 +28,10 @@
<dependency>
<groupId>
org.postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
<version>
${pg.version}
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
${lombok.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
...
...
src/main/java/vion/controller/FileController.java
View file @
045ca18
...
...
@@ -10,6 +10,7 @@ import org.dromara.hutool.core.collection.CollUtil;
import
org.dromara.hutool.core.date.DateUtil
;
import
org.dromara.hutool.core.io.file.FileNameUtil
;
import
org.dromara.hutool.core.io.file.FileUtil
;
import
org.dromara.hutool.core.lang.Assert
;
import
org.dromara.hutool.core.net.url.UrlEncoder
;
import
org.dromara.hutool.core.text.StrUtil
;
import
org.dromara.hutool.core.util.ObjUtil
;
...
...
@@ -94,13 +95,23 @@ public class FileController {
return
"文件删除成功"
;
}
@PostMapping
(
"/file/{id}"
)
@SaCheckPermission
(
value
=
"file:update"
,
orRole
=
"admin"
)
public
String
updateFile
(
@PathVariable
Long
id
,
@RequestBody
FileInfoDTO
dto
)
{
Assert
.
notNull
(
dto
.
getUpdFlag
(),
"更新标识符不能为空!"
);
return
fileService
.
lambdaUpdate
()
.
eq
(
FileInfo:
:
getId
,
id
)
.
set
(
ObjUtil
.
isNotNull
(
dto
.
getSourceType
()),
FileInfo:
:
getSourceType
,
dto
.
getSourceType
())
.
set
(
ObjUtil
.
isNotNull
(
dto
.
getContractId
()),
FileInfo:
:
getContractId
,
dto
.
getContractId
())
.
update
()
?
"修改成功"
:
"修改失败"
;
}
@PostMapping
(
"/file/formFileUpload"
)
@SaCheckPermission
(
value
=
"file:form:upload"
,
orRole
=
"admin"
)
public
String
uploadFile
(
FileInfoDTO
dto
,
@RequestParam
(
name
=
"file"
)
MultipartFile
infile
)
throws
IOException
{
String
orgName
=
infile
.
getOriginalFilename
();
String
mainName
=
FileNameUtil
.
mainName
(
orgName
);
String
fileExt
=
FileNameUtil
.
extName
(
orgName
);
String
filename
=
StrUtil
.
format
(
"{}_{}.{}"
,
mainName
,
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmssSSS"
),
fileExt
);
String
filename
=
FileNameUtil
.
mainName
(
infile
.
getOriginalFilename
())
+
"_"
+
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmssSSS"
)
+
"."
+
FileNameUtil
.
extName
(
infile
.
getOriginalFilename
());
String
path
=
getPath
(
dto
,
filename
);
File
file
=
FileUtil
.
touch
(
path
);
infile
.
transferTo
(
file
);
...
...
@@ -113,12 +124,7 @@ public class FileController {
tempFileInfo
.
setType
(
FileNameUtil
.
extName
(
file
));
tempFileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
tempFileInfo
.
setUploader
(
dto
.
getUploader
());
if
(
fileService
.
save
(
tempFileInfo
))
{
return
path
;
}
else
{
return
"文件保存失败"
;
}
return
fileService
.
save
(
tempFileInfo
)
?
path
:
"文件保存失败"
;
}
private
String
getPath
(
FileInfoDTO
dto
,
String
filename
)
{
...
...
@@ -135,10 +141,9 @@ public class FileController {
@SaCheckPermission
(
value
=
"file:upload"
,
orRole
=
"admin"
)
public
String
uploadFile1
(
FileInfo
fileInfo
,
@RequestParam
(
name
=
"files"
)
MultipartFile
[]
files
)
throws
IOException
{
for
(
MultipartFile
infile
:
files
)
{
String
orgName
=
infile
.
getOriginalFilename
();
String
mainName
=
FileNameUtil
.
mainName
(
orgName
);
String
fileExt
=
FileNameUtil
.
extName
(
orgName
);
String
filename
=
StrUtil
.
format
(
"{}_{}.{}"
,
mainName
,
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmssSSS"
),
fileExt
);
String
filename
=
FileNameUtil
.
mainName
(
infile
.
getOriginalFilename
())
+
"_"
+
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd_HHmmssSSS"
)
+
"."
+
FileNameUtil
.
extName
(
infile
.
getOriginalFilename
());
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
fileInfo
.
getStoreId
()
+
FileUtil
.
FILE_SEPARATOR
+
fileInfo
.
getSourceId
()
+
FileUtil
.
FILE_SEPARATOR
+
filename
;
File
file
=
FileUtil
.
touch
(
path
);
infile
.
transferTo
(
file
);
...
...
@@ -153,7 +158,6 @@ public class FileController {
tempFileInfo
.
setType
(
FileNameUtil
.
extName
(
file
));
tempFileInfo
.
setSha256
(
SecureUtil
.
sha256
(
file
).
toUpperCase
());
tempFileInfo
.
setUploader
(
fileInfo
.
getUploader
());
fileService
.
save
(
tempFileInfo
);
}
return
"文件保存成功"
;
...
...
src/main/java/vion/controller/InspectController.java
View file @
045ca18
...
...
@@ -52,10 +52,6 @@ public class InspectController {
//审核状态为已完成的时候更新完成时间(0进行中、1待审核、2已完成、3、驳回)
.
set
(
data
.
getStatus
()
==
2
,
Inspect:
:
getFinishDate
,
new
Date
())
.
update
();
if
(
result
)
{
return
"更新巡检状态成功"
;
}
else
{
return
"更新巡检状态失败"
;
}
return
result
?
"更新巡检状态成功"
:
"更新巡检状态失败"
;
}
}
src/main/java/vion/controller/PaymentController.java
View file @
045ca18
...
...
@@ -85,14 +85,4 @@ public class PaymentController {
}
}
@GetMapping
(
"/openSafe"
)
public
String
openSafe
(
String
code
)
{
// 校验 redis 里查询 code 相关信息
if
(
true
)
{
StpUtil
.
openSafe
(
"payment"
,
600
);
return
"认证成功"
;
}
return
"认证失败"
;
}
}
src/main/java/vion/controller/RoleController.java
View file @
045ca18
...
...
@@ -3,11 +3,13 @@ package vion.controller;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
org.dromara.hutool.core.collection.CollUtil
;
import
org.dromara.hutool.core.collection.ListUtil
;
import
org.dromara.hutool.core.lang.Assert
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.dromara.hutool.core.text.StrUtil
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.github.linpeilie.Converter
;
import
lombok.RequiredArgsConstructor
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
org.springframework.web.bind.annotation.*
;
import
vion.dto.RoleDTO
;
import
vion.model.*
;
...
...
@@ -50,9 +52,7 @@ public class RoleController {
@PostMapping
(
"/role"
)
@SaCheckPermission
(
value
=
"role:save"
,
orRole
=
"admin"
)
public
String
save
(
@RequestBody
RoleDTO
dto
)
{
if
(
StrUtil
.
equals
(
dto
.
getCode
(),
"admin"
))
{
return
"管理员角色编码[admin]已存在,不允许再次创建"
;
}
Assert
.
isFalse
(
StrUtil
.
equals
(
dto
.
getCode
(),
"admin"
),
"管理员角色编码[admin]已存在,不允许再次创建"
);
Role
role
=
converter
.
convert
(
dto
,
Role
.
class
);
return
roleService
.
save
(
role
)
?
"创建成功"
:
"创建失败"
;
}
...
...
@@ -60,9 +60,7 @@ public class RoleController {
@PostMapping
(
"/role/{id}"
)
@SaCheckPermission
(
value
=
"role:edit"
,
orRole
=
"admin"
)
public
String
update
(
@PathVariable
Long
id
,
@RequestBody
RoleDTO
dto
)
{
if
(
id
==
1
)
{
return
"管理员角色不允许修改"
;
}
Assert
.
isFalse
(
ObjUtil
.
equals
(
id
,
1
),
"管理员角色不允许修改"
);
Role
role
=
converter
.
convert
(
dto
,
Role
.
class
);
role
.
setId
(
id
);
return
roleService
.
updateById
(
role
)
?
"更新成功"
:
"更新失败"
;
...
...
@@ -71,9 +69,7 @@ public class RoleController {
@DeleteMapping
(
"/role/{id}"
)
@SaCheckPermission
(
value
=
"role:remove"
,
orRole
=
"admin"
)
public
String
remove
(
@PathVariable
Long
id
)
{
if
(
id
==
1
)
{
return
"管理员角色不允许删除"
;
}
Assert
.
isFalse
(
ObjUtil
.
equals
(
id
,
1
),
"管理员角色不允许修改"
);
return
roleService
.
removeById
(
id
)
?
"删除成功"
:
"删除失败"
;
}
...
...
src/main/java/vion/dto/FileInfoDTO.java
View file @
045ca18
...
...
@@ -32,6 +32,8 @@ public class FileInfoDTO extends BaseDTO {
private
String
sha256
;
/** 上传人 */
private
String
uploader
;
/** 标识:storeLog */
/** 标识:storeLog
,用于区分项目日志的表单文件的提交存储和其他通用表单的文件存储
*/
private
String
flag
;
/** 更新标识,更新接口不传该字段,不允许更新文件:1.项目资料 */
private
Integer
updFlag
;
}
src/main/java/vion/service/impl/ContractServiceImpl.java
View file @
045ca18
This diff is collapsed.
Click to expand it.
src/main/java/vion/service/impl/StoreServiceImpl.java
View file @
045ca18
...
...
@@ -116,7 +116,7 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
.
map
(
l
->
fileService
.
lambdaQuery
()
.
in
(
FileInfo:
:
getSourceId
,
l
)
.
in
(
FileInfo:
:
getStoreId
,
l
)
.
in
(
FileInfo:
:
getSourceType
,
1
,
24
,
25
,
26
,
27
,
28
)
.
in
(
FileInfo:
:
getSourceType
,
1
,
24
,
25
,
26
,
27
,
28
,
29
,
30
)
.
list
())
.
map
(
fileList
->
fileList
.
stream
().
collect
(
Collectors
.
groupingBy
(
FileInfo:
:
getStoreId
,
Collectors
.
counting
())))
.
orElse
(
MapUtil
.
empty
());
...
...
@@ -570,7 +570,6 @@ public class StoreServiceImpl extends MPJBaseServiceImpl<StoreMapper, Store> imp
String
fileNameStr
=
Arrays
.
stream
(
fileNameArr
).
map
(
v
->
StrUtil
.
format
(
"{}.{}"
,
Arrays
.
asList
(
fileNameArr
).
indexOf
(
v
)
+
1
,
v
)).
collect
(
Collectors
.
joining
(
"\n"
));
content
.
set
(
"title"
,
"项目资料提交提醒"
)
.
set
(
"text"
,
StrUtil
.
format
(
"""
#### 项目名称:{}
...
...
src/main/java/vion/service/impl/TaskServiceImpl.java
View file @
045ca18
...
...
@@ -405,11 +405,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
JSONObject
msg
=
buildMsg3
(
forwardUser
,
store
.
getName
(),
task
);
String
pushRes
=
dingMod
.
workMsg
(
msg
);
if
(
StrUtil
.
contains
(
pushRes
,
"ok"
))
{
return
"成功"
;
}
else
{
return
"失败"
;
}
return
StrUtil
.
contains
(
pushRes
,
"ok"
)
?
"成功"
:
"失败"
;
}
@Override
...
...
@@ -424,11 +420,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
JSONObject
msg
=
buildMsg4
(
userid
,
store
.
getName
(),
task
,
remark
);
String
pushRes
=
dingMod
.
workMsg
(
msg
);
if
(
StrUtil
.
contains
(
pushRes
,
"ok"
))
{
return
"成功"
;
}
else
{
return
"失败"
;
}
return
StrUtil
.
contains
(
pushRes
,
"ok"
)
?
"成功"
:
"失败"
;
}
@Override
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment