Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
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 0360e840
authored
Mar 23, 2021
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
车家智能数据服务开发 图片保存功能逻辑调整--think.wang
1 parent
b765872f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
23 deletions
src/main/java/com/glsx/smart/controller/SysFileController.java
src/main/java/com/glsx/smart/service/SmartSysFileService.java
src/main/java/com/glsx/smart/service/impl/SmartSysFileServiceImpl.java
src/main/java/com/glsx/smart/controller/SysFileController.java
View file @
0360e84
...
@@ -33,8 +33,8 @@ public class SysFileController {
...
@@ -33,8 +33,8 @@ public class SysFileController {
return
R
.
ok
().
data
(
sysFileService
.
findByType
(
type
));
return
R
.
ok
().
data
(
sysFileService
.
findByType
(
type
));
}
}
@RequestMapping
(
value
=
"/
s
aveFile"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/
batchS
aveFile"
,
method
=
{
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"保存图片"
)
@ApiOperation
(
value
=
"
批量
保存图片"
)
public
R
saveFile
(
@RequestBody
List
<
FileDTO
>
files
)
{
public
R
saveFile
(
@RequestBody
List
<
FileDTO
>
files
)
{
try
{
try
{
sysFileService
.
saveFile
(
files
);
sysFileService
.
saveFile
(
files
);
...
@@ -44,14 +44,14 @@ public class SysFileController {
...
@@ -44,14 +44,14 @@ public class SysFileController {
return
R
.
ok
();
return
R
.
ok
();
}
}
@RequestMapping
(
value
=
"/
updat
eFile"
,
method
=
{
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"/
sav
eFile"
,
method
=
{
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"更新图片"
)
@ApiOperation
(
value
=
"
保存
更新图片"
)
public
R
updateFile
(
@RequestBody
FileDTO
fileDTO
)
{
public
R
updateFile
(
@RequestBody
FileDTO
fileDTO
)
{
try
{
try
{
sysFileService
.
updateFile
(
fileDTO
);
return
R
.
ok
().
data
(
sysFileService
.
updateFile
(
fileDTO
)
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"保存图片失败:{}"
,
e
);
return
R
.
error
();
return
R
.
error
();
}
}
return
R
.
ok
();
}
}
}
}
src/main/java/com/glsx/smart/service/SmartSysFileService.java
View file @
0360e84
...
@@ -15,11 +15,11 @@ import java.util.List;
...
@@ -15,11 +15,11 @@ import java.util.List;
public
interface
SmartSysFileService
{
public
interface
SmartSysFileService
{
int
insertOrUpdate
(
SmartSysFile
record
);
Long
insertOrUpdate
(
SmartSysFile
record
);
List
<
FileDTO
>
findByType
(
Byte
type
);
List
<
FileDTO
>
findByType
(
Byte
type
);
void
saveFile
(
List
<
FileDTO
>
files
);
void
saveFile
(
List
<
FileDTO
>
files
);
void
updateFile
(
FileDTO
fileDTO
);
FileDTO
updateFile
(
FileDTO
fileDTO
);
}
}
src/main/java/com/glsx/smart/service/impl/SmartSysFileServiceImpl.java
View file @
0360e84
package
com
.
glsx
.
smart
.
service
.
impl
;
package
com
.
glsx
.
smart
.
service
.
impl
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
com.glsx.smart.dao.entity.SmartSysFile
;
import
com.glsx.smart.dao.entity.SmartSysFile
;
import
com.glsx.smart.dao.mapper.SmartSysFileMapper
;
import
com.glsx.smart.dao.mapper.SmartSysFileMapper
;
import
com.glsx.smart.exception.BusinessException
;
import
com.glsx.smart.exception.BusinessException
;
...
@@ -15,6 +10,11 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -15,6 +10,11 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* <p>Description:
* <p>Description:
* <p>Project: chejia-smart
* <p>Project: chejia-smart
...
@@ -26,21 +26,21 @@ import org.springframework.stereotype.Service;
...
@@ -26,21 +26,21 @@ import org.springframework.stereotype.Service;
@Service
@Service
public
class
SmartSysFileServiceImpl
implements
SmartSysFileService
{
public
class
SmartSysFileServiceImpl
implements
SmartSysFileService
{
@Resource
@Resource
private
SmartSysFileMapper
smartSysF
ileMapper
;
private
SmartSysFileMapper
f
ileMapper
;
@Override
@Override
public
int
insertOrUpdate
(
SmartSysFile
sysFile
)
{
public
Long
insertOrUpdate
(
SmartSysFile
sysFile
)
{
if
(
sysFile
.
getId
()
==
null
)
{
if
(
sysFile
.
getId
()
==
null
)
{
return
smartSysF
ileMapper
.
insertSelective
(
sysFile
);
f
ileMapper
.
insertSelective
(
sysFile
);
}
else
{
}
else
{
SmartSysFile
record
=
smartSysFileMapper
.
selectByPrimaryKey
(
SmartSysFile
record
=
fileMapper
.
selectByPrimaryKey
(
sysFile
.
getId
());
sysFile
.
getId
());
if
(
record
!=
null
)
{
if
(
record
!=
null
)
{
return
smartSysF
ileMapper
.
updateByPrimaryKeySelective
(
sysFile
);
f
ileMapper
.
updateByPrimaryKeySelective
(
sysFile
);
}
else
{
}
else
{
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
throw
new
BusinessException
(
ResultEnum
.
ID_NOT_FOUND
);
}
}
}
}
return
sysFile
.
getId
();
}
}
/**
/**
...
@@ -51,7 +51,7 @@ public class SmartSysFileServiceImpl implements SmartSysFileService {
...
@@ -51,7 +51,7 @@ public class SmartSysFileServiceImpl implements SmartSysFileService {
*/
*/
@Override
@Override
public
List
<
FileDTO
>
findByType
(
Byte
type
)
{
public
List
<
FileDTO
>
findByType
(
Byte
type
)
{
List
<
SmartSysFile
>
list
=
smartSysF
ileMapper
.
findByType
(
type
);
List
<
SmartSysFile
>
list
=
f
ileMapper
.
findByType
(
type
);
List
<
FileDTO
>
fileDTOS
=
list
.
stream
().
map
(
index
->
{
List
<
FileDTO
>
fileDTOS
=
list
.
stream
().
map
(
index
->
{
FileDTO
fileDTO
=
new
FileDTO
();
FileDTO
fileDTO
=
new
FileDTO
();
BeanUtils
.
copyProperties
(
index
,
fileDTO
);
BeanUtils
.
copyProperties
(
index
,
fileDTO
);
...
@@ -84,10 +84,11 @@ public class SmartSysFileServiceImpl implements SmartSysFileService {
...
@@ -84,10 +84,11 @@ public class SmartSysFileServiceImpl implements SmartSysFileService {
* @param fileDTO 文件
* @param fileDTO 文件
*/
*/
@Override
@Override
public
void
updateFile
(
FileDTO
fileDTO
)
{
public
FileDTO
updateFile
(
FileDTO
fileDTO
)
{
SmartSysFile
smartSysFile
=
new
SmartSysFile
();
SmartSysFile
smartSysFile
=
new
SmartSysFile
();
BeanUtils
.
copyProperties
(
fileDTO
,
smartSysFile
);
BeanUtils
.
copyProperties
(
fileDTO
,
smartSysFile
);
insertOrUpdate
(
smartSysFile
);
fileDTO
.
setId
(
insertOrUpdate
(
smartSysFile
));
return
fileDTO
;
}
}
}
}
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