Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hubin
long-tern-care-service
Commits
57da0972
Commit
57da0972
authored
May 25, 2021
by
zhangch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件上传相关接口
parent
eb2ad4fc
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
350 additions
and
30 deletions
+350
-30
pom.xml
apply/apply-service/pom.xml
+13
-0
ApplyApplication.java
...vice/src/main/java/com/hungraim/ltc/ApplyApplication.java
+2
-0
DisableController.java
...n/java/com/hungraim/ltc/controller/DisableController.java
+43
-0
DisableServiceImpl.java
...ava/com/hungraim/ltc/service/impl/DisableServiceImpl.java
+57
-23
ChDisableApply.java
.../com/hungraim/ltc/pojo/entity/disable/ChDisableApply.java
+6
-4
DisableExamineInfoVO.java
...om/hungraim/ltc/pojo/vo/disable/DisableExamineInfoVO.java
+3
-0
AttachUpdateVo.java
.../java/com/hungraim/ltc/pojo/vo/system/AttachUpdateVo.java
+25
-0
AttachVo.java
...c/main/java/com/hungraim/ltc/pojo/vo/system/AttachVo.java
+12
-0
FileUploadController.java
.../hungraim/ltc/system/controller/FileUploadController.java
+39
-3
AttachService.java
...n/java/com/hungraim/ltc/system/service/AttachService.java
+23
-0
AttachServiceImpl.java
...m/hungraim/ltc/system/service/impl/AttachServiceImpl.java
+86
-0
AttachFeignService.java
...rc/main/java/com/hungraim/ltc/api/AttachFeignService.java
+41
-0
No files found.
apply/apply-service/pom.xml
View file @
57da0972
...
@@ -23,6 +23,19 @@
...
@@ -23,6 +23,19 @@
<version>
2.2.5.RELEASE
</version>
<version>
2.2.5.RELEASE
</version>
</dependency>
</dependency>
<!--feign服务调用-->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
<!--系统服务api-->
<dependency>
<groupId>
com.hungraim.ltc
</groupId>
<artifactId>
system-api
</artifactId>
<version>
0.0.1
</version>
</dependency>
<!--基础包-->
<!--基础包-->
<dependency>
<dependency>
...
...
apply/apply-service/src/main/java/com/hungraim/ltc/ApplyApplication.java
View file @
57da0972
...
@@ -4,6 +4,7 @@ package com.hungraim.ltc;
...
@@ -4,6 +4,7 @@ package com.hungraim.ltc;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
/**
/**
...
@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
...
@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@SpringBootApplication
@EnableDiscoveryClient
@EnableDiscoveryClient
@EnableTransactionManagement
@EnableTransactionManagement
@EnableFeignClients
public
class
ApplyApplication
{
public
class
ApplyApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ApplyApplication
.
class
,
args
);
SpringApplication
.
run
(
ApplyApplication
.
class
,
args
);
...
...
apply/apply-service/src/main/java/com/hungraim/ltc/controller/DisableController.java
View file @
57da0972
...
@@ -196,6 +196,49 @@ public class DisableController {
...
@@ -196,6 +196,49 @@ public class DisableController {
if
(
chDisableApply
.
getApplyId
()
==
null
)
{
if
(
chDisableApply
.
getApplyId
()
==
null
)
{
return
Result
.
failed
(
"请求参数错误"
);
return
Result
.
failed
(
"请求参数错误"
);
}
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getDistrictProvincial
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getDistrictCity
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getDistrictArea
()))
{
return
Result
.
failed
(
"所在省市不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getRealName
()))
{
return
Result
.
failed
(
"申请人姓名不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getCertiCode
()))
{
return
Result
.
failed
(
"身份证号码不能为空!"
);
}
if
(
chDisableApply
.
getBirthday
()
==
null
)
{
return
Result
.
failed
(
"出生年月日不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getGender
()))
{
return
Result
.
failed
(
"性别不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getTel
()))
{
return
Result
.
failed
(
"手机号不能为空!"
);
}
if
(
chDisableApply
.
getRegist
()
==
null
)
{
return
Result
.
failed
(
"所在户籍不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getAcptProvincial
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptCity
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptArea
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptStreet
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptAddress
()))
{
return
Result
.
failed
(
"接受评定地址不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getAcptSrvProvincial
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptSrvCity
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptSrvArea
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptSrvStreet
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAcptSrvAddress
()))
{
return
Result
.
failed
(
"接受服务地址不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getAdressDistrictProvincial
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAdressDistrictCity
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAdressDistrictCode
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getStreet
())
||
StringUtils
.
isBlank
(
chDisableApply
.
getAdressDetail
()))
{
return
Result
.
failed
(
"现住址不能为空!"
);
}
if
(
chDisableApply
.
getDiseTypeF
()
==
null
||
chDisableApply
.
getDiseTypeS
()
==
null
)
{
return
Result
.
failed
(
"诊断疾病不能为空!"
);
}
if
(
chDisableApply
.
getSrvModeId
()
==
null
)
{
return
Result
.
failed
(
"申请服务方式不能为空!"
);
}
if
(
StringUtils
.
isBlank
(
chDisableApply
.
getDiseaseDesc
()))
{
return
Result
.
failed
(
"疾病描述及诊断不能为空!"
);
}
if
(
chDisableApply
.
getMedicalType
()
==
null
)
{
return
Result
.
failed
(
"医保类型不能为空!"
);
}
disableService
.
updateDisable
(
chDisableApply
);
disableService
.
updateDisable
(
chDisableApply
);
return
Result
.
success
();
return
Result
.
success
();
}
}
...
...
apply/apply-service/src/main/java/com/hungraim/ltc/service/impl/DisableServiceImpl.java
View file @
57da0972
...
@@ -4,44 +4,44 @@ import cn.hutool.core.bean.BeanUtil;
...
@@ -4,44 +4,44 @@ import cn.hutool.core.bean.BeanUtil;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.hungraim.ltc.api.AttachFeignService
;
import
com.hungraim.ltc.dao.*
;
import
com.hungraim.ltc.dao.*
;
import
com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach
;
import
com.hungraim.ltc.pojo.entity.assessment.ChAprTask
;
import
com.hungraim.ltc.pojo.entity.assessment.ChAprTask
;
import
com.hungraim.ltc.pojo.entity.disable.*
;
import
com.hungraim.ltc.pojo.entity.disable.*
;
import
com.hungraim.ltc.pojo.entity.serviceManage.ChCfgPara
;
import
com.hungraim.ltc.pojo.entity.serviceManage.ChCfgPara
;
import
com.hungraim.ltc.pojo.vo.disable.*
;
import
com.hungraim.ltc.pojo.vo.disable.*
;
import
com.hungraim.ltc.pojo.vo.system.AttachUpdateVo
;
import
com.hungraim.ltc.pojo.vo.system.AttachVo
;
import
com.hungraim.ltc.service.DisableService
;
import
com.hungraim.ltc.service.DisableService
;
import
com.hungraim.ltc.util.AttachType
;
import
com.hungraim.ltc.util.Result
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
java.util.*
;
@Service
@Service
@Slf4j
@AllArgsConstructor
public
class
DisableServiceImpl
implements
DisableService
{
public
class
DisableServiceImpl
implements
DisableService
{
@Autowired
private
final
DisableApplyMapper
disableApplyMapper
;
private
DisableApplyMapper
disableApplyMapper
;
private
final
FndDistrictMapper
districtMapper
;
@Autowired
private
final
FndOrganMapper
fndOrganMapper
;
private
FndDistrictMapper
districtMapper
;
private
final
FndStreetMapper
fndStreetMapper
;
@Autowired
private
final
SrvModeMapper
srvModeMapper
;
private
FndOrganMapper
fndOrganMapper
;
private
final
SrvOrganMapper
srvOrganMapper
;
@Autowired
private
final
FndDiseaseTypeMapper
fndDiseaseTypeMapper
;
private
FndStreetMapper
fndStreetMapper
;
private
final
DisableApplyHisMapper
disableApplyHisMapper
;
@Autowired
private
final
DisableInfoMapper
disableInfoMapper
;
private
SrvModeMapper
srvModeMapper
;
private
final
AprTaskMapper
aprTaskMapper
;
@Autowired
private
final
CfgParaMapper
cfgParaMapper
;
private
SrvOrganMapper
srvOrganMapper
;
private
final
AttachFeignService
attachFeignService
;
@Autowired
private
FndDiseaseTypeMapper
fndDiseaseTypeMapper
;
@Autowired
private
DisableApplyHisMapper
disableApplyHisMapper
;
@Autowired
private
DisableInfoMapper
disableInfoMapper
;
@Autowired
private
AprTaskMapper
aprTaskMapper
;
@Autowired
private
CfgParaMapper
cfgParaMapper
;
/**
/**
* 获取机构ids
* 获取机构ids
...
@@ -96,15 +96,46 @@ public class DisableServiceImpl implements DisableService {
...
@@ -96,15 +96,46 @@ public class DisableServiceImpl implements DisableService {
DisableExamineInfoVO
disableExamineInfoVO
=
disableApplyMapper
.
selectDisableExamineInfoByApplyId
(
applyId
);
DisableExamineInfoVO
disableExamineInfoVO
=
disableApplyMapper
.
selectDisableExamineInfoByApplyId
(
applyId
);
List
<
ExamineRecord
>
examineRecords
=
disableApplyMapper
.
listExamineRecordByApplyId
(
applyId
);
List
<
ExamineRecord
>
examineRecords
=
disableApplyMapper
.
listExamineRecordByApplyId
(
applyId
);
disableExamineInfoVO
.
setExamineRecords
(
examineRecords
);
disableExamineInfoVO
.
setExamineRecords
(
examineRecords
);
try
{
// zhangch 20210525 新增返回对应的附件列表
Result
<
List
<
AttachVo
>>
listResult
=
attachFeignService
.
selectAttachs
(
Long
.
valueOf
(
applyId
),
(
short
)
1
);
if
(
listResult
.
getCode
().
equals
(
"00000"
))
{
disableExamineInfoVO
.
setFileDataList
(
listResult
.
getData
());
}
else
{
log
.
info
(
"请求获取附件列表错误:错误码{},错误信息:{}"
,
listResult
.
getCode
(),
listResult
.
getMsg
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
e
.
printStackTrace
();
}
return
disableExamineInfoVO
;
return
disableExamineInfoVO
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
addDisable
(
ChDisableApply
chDisableApply
)
{
public
void
addDisable
(
ChDisableApply
chDisableApply
)
{
chDisableApply
.
setEffTime
(
new
Date
());
chDisableApply
.
setEffTime
(
new
Date
());
disableApplyMapper
.
insert
(
chDisableApply
);
disableApplyMapper
.
insert
(
chDisableApply
);
this
.
updateAttachs
(
chDisableApply
);
}
/**
* 调用feign api来修改附件数据
*
* @param chDisableApply
*/
private
void
updateAttachs
(
ChDisableApply
chDisableApply
)
{
// zhangch 20210525 新增附件修改逻辑
List
<
ChFndAttach
>
fileDataList
=
chDisableApply
.
getFileDataList
();
AttachUpdateVo
attachUpdateVo
=
new
AttachUpdateVo
();
attachUpdateVo
.
setCtrlId
(
chDisableApply
.
getApplyId
());
attachUpdateVo
.
setAttachType
(
AttachType
.
DISABLE
.
getUploadType
());
attachUpdateVo
.
setChFndAttachs
(
fileDataList
);
attachFeignService
.
updateAttachs
(
attachUpdateVo
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
disableExamine
(
String
applyId
,
String
checkName
,
Short
applyStatus
,
String
checkRemark
)
{
public
void
disableExamine
(
String
applyId
,
String
checkName
,
Short
applyStatus
,
String
checkRemark
)
{
Date
date
=
new
Date
();
Date
date
=
new
Date
();
...
@@ -219,9 +250,12 @@ public class DisableServiceImpl implements DisableService {
...
@@ -219,9 +250,12 @@ public class DisableServiceImpl implements DisableService {
return
sb
.
toString
();
return
sb
.
toString
();
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
updateDisable
(
ChDisableApply
chDisableApply
)
{
public
void
updateDisable
(
ChDisableApply
chDisableApply
)
{
disableApplyMapper
.
updateById
(
chDisableApply
);
disableApplyMapper
.
updateById
(
chDisableApply
);
// zhangch 20210525 新增附件修改逻辑
this
.
updateAttachs
(
chDisableApply
);
}
}
@Override
@Override
...
...
common/common-core/src/main/java/com/hungraim/ltc/pojo/entity/disable/ChDisableApply.java
View file @
57da0972
package
com
.
hungraim
.
ltc
.
pojo
.
entity
.
disable
;
package
com
.
hungraim
.
ltc
.
pojo
.
entity
.
disable
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.baomidou.mybatisplus.annotation.KeySequence
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.hungraim.ltc.pojo.entity.PageInfo
;
import
com.hungraim.ltc.pojo.entity.PageInfo
;
import
com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach
;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* 失能人员申请
* 失能人员申请
...
@@ -598,5 +597,8 @@ public class ChDisableApply extends PageInfo implements Serializable {
...
@@ -598,5 +597,8 @@ public class ChDisableApply extends PageInfo implements Serializable {
*/
*/
private
Short
treatmentType
;
private
Short
treatmentType
;
@TableField
(
exist
=
false
)
private
List
<
ChFndAttach
>
fileDataList
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
}
}
common/common-core/src/main/java/com/hungraim/ltc/pojo/vo/disable/DisableExamineInfoVO.java
View file @
57da0972
package
com
.
hungraim
.
ltc
.
pojo
.
vo
.
disable
;
package
com
.
hungraim
.
ltc
.
pojo
.
vo
.
disable
;
import
com.hungraim.ltc.pojo.vo.system.AttachVo
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -105,4 +106,6 @@ public class DisableExamineInfoVO {
...
@@ -105,4 +106,6 @@ public class DisableExamineInfoVO {
private
String
applyStatus
;
private
String
applyStatus
;
//备注
//备注
private
String
checkRemark
;
private
String
checkRemark
;
private
List
<
AttachVo
>
fileDataList
;
}
}
common/common-core/src/main/java/com/hungraim/ltc/pojo/vo/system/AttachUpdateVo.java
0 → 100644
View file @
57da0972
package
com
.
hungraim
.
ltc
.
pojo
.
vo
.
system
;
import
com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
AttachUpdateVo
{
/**
* 关联id
*/
private
Long
ctrlId
;
/**
* 附件类型(1:失能人员附件;2:鉴定任务附件;3:服务方案附件;4:稽核巡查;5:护理机构基金结算申请新增;6:无锡长护保险自评申请;7:失能信息变更附件;8:评估结论书;9:参保人员及家属;10:评定人员1;11:评定人员2;12:鉴定机构附件;13:护理机构附件;14:鉴定人员附件;15:护理人员附件 16-护理人员服务项目结束附件,17:建床,18:撤床)
*/
private
Short
attachType
;
/**
* 文件对象列表
*/
private
List
<
ChFndAttach
>
chFndAttachs
;
}
common/common-core/src/main/java/com/hungraim/ltc/pojo/vo/system/AttachVo.java
0 → 100644
View file @
57da0972
package
com
.
hungraim
.
ltc
.
pojo
.
vo
.
system
;
import
lombok.Data
;
@Data
public
class
AttachVo
{
private
Long
attachId
;
private
String
fileName
;
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/FileUploadController.java
View file @
57da0972
package
com
.
hungraim
.
ltc
.
system
.
controller
;
package
com
.
hungraim
.
ltc
.
system
.
controller
;
import
com.hungraim.ltc.pojo.vo.system.AttachUpdateVo
;
import
com.hungraim.ltc.pojo.vo.system.AttachVo
;
import
com.hungraim.ltc.system.config.FileUploadConfig
;
import
com.hungraim.ltc.system.config.FileUploadConfig
;
import
com.hungraim.ltc.system.service.AttachService
;
import
com.hungraim.ltc.system.service.AttachService
;
import
com.hungraim.ltc.util.FileUtils
;
import
com.hungraim.ltc.util.FileUtils
;
...
@@ -7,11 +9,11 @@ import com.hungraim.ltc.util.Result;
...
@@ -7,11 +9,11 @@ import com.hungraim.ltc.util.Result;
import
com.hungraim.ltc.util.ResultCode
;
import
com.hungraim.ltc.util.ResultCode
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
@RestController
@RestController
@RequestMapping
(
"/api.system/resource"
)
@RequestMapping
(
"/api.system/resource"
)
@Slf4j
@Slf4j
...
@@ -43,4 +45,38 @@ public class FileUploadController {
...
@@ -43,4 +45,38 @@ public class FileUploadController {
log
.
info
(
"保存成功,文件id:{}"
,
attachId
);
log
.
info
(
"保存成功,文件id:{}"
,
attachId
);
return
Result
.
success
(
attachId
);
return
Result
.
success
(
attachId
);
}
}
/**
* 修改数据库文件表关联数据
* 参数attachUpdateVo对象中,必须要有ctrlId字段的值以及attachType的值,
* 方法会以新传入的这个列表作为ctrlId所关联的所有对象,对于旧的关联数据中这次没有传入的attachId数据进行舍弃
*
* @param attachUpdateVo 文件对象列表
* @return 返回执行结果
*/
@PutMapping
(
"/attachs"
)
Result
updateAttachs
(
@RequestBody
AttachUpdateVo
attachUpdateVo
)
{
if
(
null
==
attachUpdateVo
||
null
==
attachUpdateVo
.
getCtrlId
()
||
0
==
attachUpdateVo
.
getCtrlId
()
||
null
==
attachUpdateVo
.
getAttachType
()
||
0
==
attachUpdateVo
.
getAttachType
())
{
return
Result
.
failed
(
ResultCode
.
REQUEST_PARAM_ERROR
);
}
attachService
.
updateAttachs
(
attachUpdateVo
);
return
Result
.
success
();
}
/**
* 根据ctrlId和attachType查询其对应的数据列表
*
* @param ctrlId 关联id
* @param attachType 附件类型
* @return 返回对应的数据列表
*/
@GetMapping
(
"/attachs"
)
Result
<
List
<
AttachVo
>>
selectAttachs
(
Long
ctrlId
,
Short
attachType
)
{
if
(
null
==
ctrlId
||
0
==
ctrlId
||
null
==
attachType
)
{
return
Result
.
failed
(
ResultCode
.
REQUEST_PARAM_ERROR
);
}
List
<
AttachVo
>
attachVos
=
attachService
.
selectAttachs
(
ctrlId
,
attachType
);
return
Result
.
success
(
attachVos
);
}
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/AttachService.java
View file @
57da0972
package
com
.
hungraim
.
ltc
.
system
.
service
;
package
com
.
hungraim
.
ltc
.
system
.
service
;
import
com.hungraim.ltc.pojo.vo.system.AttachUpdateVo
;
import
com.hungraim.ltc.pojo.vo.system.AttachVo
;
import
java.util.List
;
public
interface
AttachService
{
public
interface
AttachService
{
/**
/**
...
@@ -12,4 +17,22 @@ public interface AttachService {
...
@@ -12,4 +17,22 @@ public interface AttachService {
*/
*/
Long
saveFileInfo
(
String
originalFilename
,
String
realPath
,
Short
attachType
);
Long
saveFileInfo
(
String
originalFilename
,
String
realPath
,
Short
attachType
);
/**
* 修改数据库文件表关联数据
* 参数attachUpdateVo对象中,必须要有ctrlId字段的值以及attachType的值,
* 方法会以新传入的这个列表作为ctrlId所关联的所有对象,对于旧的关联数据中这次没有传入的attachId数据进行舍弃
*
* @param attachUpdateVo 文件对象列表
* @return 返回执行结果
*/
void
updateAttachs
(
AttachUpdateVo
attachUpdateVo
);
/**
* 根据ctrlId和attachType查询其对应的数据列表
*
* @param ctrlId 关联id
* @param attachType 附件类型
* @return 返回对应的数据列表
*/
List
<
AttachVo
>
selectAttachs
(
Long
ctrlId
,
Short
attachType
);
}
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/service/impl/AttachServiceImpl.java
View file @
57da0972
package
com
.
hungraim
.
ltc
.
system
.
service
.
impl
;
package
com
.
hungraim
.
ltc
.
system
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach
;
import
com.hungraim.ltc.pojo.entity.SysConfig.ChFndAttach
;
import
com.hungraim.ltc.pojo.vo.system.AttachUpdateVo
;
import
com.hungraim.ltc.pojo.vo.system.AttachVo
;
import
com.hungraim.ltc.system.dao.ChFndAttachMapper
;
import
com.hungraim.ltc.system.dao.ChFndAttachMapper
;
import
com.hungraim.ltc.system.service.AttachService
;
import
com.hungraim.ltc.system.service.AttachService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
@Service
@Service
public
class
AttachServiceImpl
implements
AttachService
{
public
class
AttachServiceImpl
implements
AttachService
{
...
@@ -27,4 +33,84 @@ public class AttachServiceImpl implements AttachService {
...
@@ -27,4 +33,84 @@ public class AttachServiceImpl implements AttachService {
chFndAttachMapper
.
insert
(
chFndAttach
);
chFndAttachMapper
.
insert
(
chFndAttach
);
return
chFndAttach
.
getAttachId
();
return
chFndAttach
.
getAttachId
();
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
updateAttachs
(
AttachUpdateVo
attachUpdateVo
)
{
Long
ctrlId
=
attachUpdateVo
.
getCtrlId
();
Short
attachType
=
attachUpdateVo
.
getAttachType
();
List
<
ChFndAttach
>
chFndAttachs
=
attachUpdateVo
.
getChFndAttachs
();
if
(
chFndAttachs
!=
null
)
{
for
(
ChFndAttach
chFndAttach
:
chFndAttachs
)
{
chFndAttach
.
setCtrlId
(
ctrlId
);
chFndAttach
.
setAttachType
(
attachType
);
}
}
List
<
ChFndAttach
>
dbChFndAttachs
=
this
.
getChFndAttaches
(
ctrlId
,
attachType
);
if
(
dbChFndAttachs
!=
null
&&
dbChFndAttachs
.
size
()
>
0
)
{
/**
* 如果查询到了对应该ctrlId对应的数据,就是更新ctrlId对应的数据集.分2步
* 1->先把原有数据列表中在新数据列表中找不到的数据改为失效状态
* 2->把新数据列表中在原有数据中找不到的数据的增加ctrlId字段的修改
*/
// step 1
for
(
ChFndAttach
dbChFndAttach
:
dbChFndAttachs
)
{
boolean
deleteFlag
=
true
;
if
(
chFndAttachs
!=
null
)
{
for
(
ChFndAttach
chfndAttach
:
chFndAttachs
)
{
if
(
dbChFndAttach
.
getAttachId
().
equals
(
chfndAttach
.
getAttachId
()))
{
deleteFlag
=
false
;
}
}
}
if
(
deleteFlag
)
{
dbChFndAttach
.
setStatus
((
short
)
1
);
chFndAttachMapper
.
updateById
(
dbChFndAttach
);
}
}
// step 2
if
(
chFndAttachs
!=
null
)
{
for
(
ChFndAttach
chFndAttach
:
chFndAttachs
)
{
boolean
updateFlag
=
true
;
for
(
ChFndAttach
dbChFndAttach
:
dbChFndAttachs
)
{
if
(
chFndAttach
.
getAttachId
().
equals
(
dbChFndAttach
.
getAttachId
()))
{
updateFlag
=
false
;
}
}
if
(
updateFlag
)
{
chFndAttachMapper
.
updateById
(
chFndAttach
);
}
}
}
}
else
{
if
(
chFndAttachs
!=
null
)
{
// 如果没有查询到该ctrlId对应的数据,就是直接更新对应attachId的ctrlId字段
for
(
ChFndAttach
chFndAttach
:
chFndAttachs
)
{
chFndAttachMapper
.
updateById
(
chFndAttach
);
}
}
}
}
private
List
<
ChFndAttach
>
getChFndAttaches
(
Long
ctrlId
,
Short
attachType
)
{
// 查询出数据库中原有的该ctrlId关联的数据
QueryWrapper
<
ChFndAttach
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"CTRL_ID"
,
ctrlId
);
queryWrapper
.
eq
(
"ATTACH_TYPE"
,
attachType
);
queryWrapper
.
eq
(
"STATUS"
,
(
short
)
0
);
List
<
ChFndAttach
>
dbChFndAttachs
=
chFndAttachMapper
.
selectList
(
queryWrapper
);
return
dbChFndAttachs
;
}
@Override
public
List
<
AttachVo
>
selectAttachs
(
Long
ctrlId
,
Short
attachType
)
{
List
<
AttachVo
>
attachVos
=
new
ArrayList
<>();
List
<
ChFndAttach
>
chFndAttaches
=
this
.
getChFndAttaches
(
ctrlId
,
attachType
);
for
(
ChFndAttach
chFndAttach
:
chFndAttaches
)
{
AttachVo
attachVo
=
new
AttachVo
();
BeanUtils
.
copyProperties
(
chFndAttach
,
attachVo
);
attachVos
.
add
(
attachVo
);
}
return
attachVos
;
}
}
}
system/system-api/src/main/java/com/hungraim/ltc/api/AttachFeignService.java
0 → 100644
View file @
57da0972
package
com
.
hungraim
.
ltc
.
api
;
import
com.hungraim.ltc.pojo.vo.system.AttachUpdateVo
;
import
com.hungraim.ltc.pojo.vo.system.AttachVo
;
import
com.hungraim.ltc.util.Result
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
@FeignClient
(
"LTC-SYSTEM-ADMIN-SERVICE"
)
public
interface
AttachFeignService
{
/**
* feign api
* <p>
* 修改数据库文件表关联数据
* 参数chFndAttachs对象列表的对象中,必须要有ctrlId字段的值以及attachType的值,
* 方法会以新传入的这个列表作为ctrlId所关联的所有对象,对于旧的关联数据中这次没有传入的attachId数据进行舍弃
*
* @param attachUpdateVo 文件对象列表
* @return 返回执行结果
*/
@PutMapping
(
"/api.system/resource/attachs"
)
Result
updateAttachs
(
@RequestBody
AttachUpdateVo
attachUpdateVo
);
/**
* feign api
* <p>
* 根据ctrlId和attachType查询其对应的数据列表
*
* @param ctrlId 关联id
* @param attachType 附件类型
* @return 返回对应的数据列表
*/
@GetMapping
(
"/api.system/resource/attachs"
)
Result
<
List
<
AttachVo
>>
selectAttachs
(
@RequestParam
(
"ctrlId"
)
Long
ctrlId
,
@RequestParam
(
"attachType"
)
Short
attachType
);
}
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