Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
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
Administrator
dsk-cr20g
Commits
119a2d1b
Commit
119a2d1b
authored
Jun 06, 2023
by
lixiaolei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submit
parent
fbfb6af1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
10 deletions
+152
-10
BusinessFileController.java
...m/dsk/web/controller/business/BusinessFileController.java
+78
-0
BusinessInfoController.java
...m/dsk/web/controller/business/BusinessInfoController.java
+3
-3
BusinessRelateCompany.java
.../dsk/common/core/domain/entity/BusinessRelateCompany.java
+5
-0
FileUtils.java
...on/src/main/java/com/dsk/common/utils/file/FileUtils.java
+57
-3
BusinessInfoServiceImpl.java
.../com/dsk/system/service/impl/BusinessInfoServiceImpl.java
+2
-3
BusinessRelateCompanyMapper.xml
...resources/mapper/business/BusinessRelateCompanyMapper.xml
+7
-1
No files found.
dsk-admin/src/main/java/com/dsk/web/controller/business/BusinessFileController.java
0 → 100644
View file @
119a2d1b
package
com
.
dsk
.
web
.
controller
.
business
;
import
com.dsk.common.config.RuoYiConfig
;
import
com.dsk.common.core.controller.BaseController
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.utils.file.FileUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.IOException
;
import
java.util.List
;
/**
* @author lxl
* @Description: 项目文件管理Controller
* @Date 2023/5/30 上午 8:44
**/
@Slf4j
@RestController
@RequestMapping
(
"/business/file"
)
public
class
BusinessFileController
extends
BaseController
{
// 本地资源路径
public
static
final
String
LOCALPATH
=
RuoYiConfig
.
getProfile
();
/**
* 新建文件夹
*/
// @PreAuthorize("@ss.hasPermi('system:file:add')")
// @Log(title = "项目资料文档", businessType = BusinessType.INSERT)
@GetMapping
(
"/new/{filePath}"
)
public
AjaxResult
newFolder
(
@PathVariable
String
filePath
)
{
return
FileUtils
.
newFolder
(
LOCALPATH
+
filePath
)
?
AjaxResult
.
success
()
:
AjaxResult
.
error
();
}
/**
* 删除某个文件或整个文件夹
*/
@GetMapping
(
"/remove/{filePath}"
)
public
AjaxResult
removeFile
(
@PathVariable
String
filePath
)
{
boolean
deleteFile
=
FileUtils
.
deleteFile
(
LOCALPATH
+
filePath
);
return
deleteFile
?
AjaxResult
.
success
()
:
AjaxResult
.
error
();
}
/**
* 获取文件夹中所有文件
*/
@GetMapping
(
"/all/{folderPath}"
)
public
AjaxResult
getAllFiles
(
@PathVariable
String
folderPath
)
{
List
<
String
>
allFiles
=
FileUtils
.
getAllFiles
(
LOCALPATH
+
folderPath
);
return
AjaxResult
.
success
(
allFiles
);
}
/**
* 上传文件及文件夹
* @param url
* @param folderPath
* @return
*/
@GetMapping
(
"/upload/{url}/{folderPath}"
)
public
AjaxResult
uploadFolder
(
@PathVariable
(
"url"
)
String
url
,
@PathVariable
(
"folderPath"
)
String
folderPath
)
throws
IOException
{
return
toAjax
(
FileUtils
.
uploadFolder
(
url
,
LOCALPATH
+
folderPath
));
}
/**
* 下载文件
* @param url
* @param targetFolder
* @return
*/
@GetMapping
(
"/download/{url}/{targetFolder}"
)
public
AjaxResult
downloadFolder
(
@PathVariable
(
"url"
)
String
url
,
@PathVariable
(
"targetFolder"
)
String
targetFolder
)
throws
IOException
{
return
toAjax
(
FileUtils
.
downloadFolder
(
url
,
targetFolder
));
}
}
dsk-admin/src/main/java/com/dsk/web/controller/business/BusinessInfoController.java
View file @
119a2d1b
...
...
@@ -90,7 +90,7 @@ public class BusinessInfoController extends BaseController
* 删除项目列表
*/
// @PreAuthorize("@ss.hasPermi('system:business:remove')")
@Log
(
title
=
"项目管理"
,
businessType
=
BusinessType
.
DELETE
)
//
@Log(title = "项目管理", businessType = BusinessType.DELETE)
@DeleteMapping
(
"/remove/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
(
value
=
"ids"
,
required
=
false
)
Long
[]
ids
)
{
...
...
@@ -101,7 +101,7 @@ public class BusinessInfoController extends BaseController
* 新增项目详情
*/
// @PreAuthorize("@ss.hasPermi('system:business:add')")
@Log
(
title
=
"项目管理"
,
businessType
=
BusinessType
.
INSERT
)
//
@Log(title = "项目管理", businessType = BusinessType.INSERT)
@PostMapping
(
"/add"
)
public
AjaxResult
add
(
@RequestBody
BusinessAddDto
dto
)
{
...
...
@@ -112,7 +112,7 @@ public class BusinessInfoController extends BaseController
* 修改项目详情
*/
// @PreAuthorize("@ss.hasPermi('system:business:edit')")
@Log
(
title
=
"项目管理"
,
businessType
=
BusinessType
.
UPDATE
)
//
@Log(title = "项目管理", businessType = BusinessType.UPDATE)
@PostMapping
(
"/edit"
)
public
AjaxResult
edit
(
@RequestBody
BusinessInfo
businessInfo
)
{
...
...
dsk-common/src/main/java/com/dsk/common/core/domain/entity/BusinessRelateCompany.java
View file @
119a2d1b
...
...
@@ -53,6 +53,10 @@ public class BusinessRelateCompany extends BaseEntity
@Excel
(
name
=
"对接深度/竞争力度"
)
private
String
depth
;
/** 企业类型 */
@Excel
(
name
=
"企业类型"
)
private
String
companyType
;
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
...
...
@@ -66,6 +70,7 @@ public class BusinessRelateCompany extends BaseEntity
.
append
(
"createTime"
,
getCreateTime
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"depth"
,
getDepth
())
.
append
(
"companyType"
,
getCompanyType
())
.
toString
();
}
...
...
dsk-common/src/main/java/com/dsk/common/utils/file/FileUtils.java
View file @
119a2d1b
...
...
@@ -26,6 +26,14 @@ import org.apache.commons.lang3.ArrayUtils;
import
com.dsk.common.config.RuoYiConfig
;
import
com.dsk.common.utils.uuid.IdUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.ContentType
;
import
org.apache.http.entity.mime.MultipartEntityBuilder
;
import
org.apache.http.entity.mime.content.FileBody
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
/**
* 文件处理工具类
...
...
@@ -292,12 +300,12 @@ public class FileUtils
/**
* 下载文件
*
* @param url 要下载的文件链接
* @param targetFolder 目标文件
* @return
* @throws IOException
*/
public
static
void
downloadFolder
(
String
url
,
String
targetFolder
)
throws
IOException
{
public
static
boolean
downloadFolder
(
String
url
,
String
targetFolder
)
throws
IOException
{
URL
downloadUrl
=
new
URL
(
url
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
downloadUrl
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
...
...
@@ -330,6 +338,52 @@ public class FileUtils
}
}
}
return
true
;
}
/**
* 上传文件
* @param url 上传链接
* @param folderPath 文件路径
* @return
* @throws IOException
*/
public
static
boolean
uploadFolder
(
String
url
,
String
folderPath
)
throws
IOException
{
File
folder
=
new
File
(
folderPath
);
if
(!
folder
.
exists
()
||
!
folder
.
isDirectory
())
{
throw
new
IllegalArgumentException
(
"文件夹路径无效: "
+
folderPath
);
}
List
<
File
>
files
=
new
ArrayList
<>();
listFiles
(
folder
,
files
);
try
(
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
())
{
HttpPost
httpPost
=
new
HttpPost
(
url
);
MultipartEntityBuilder
builder
=
MultipartEntityBuilder
.
create
();
for
(
File
file
:
files
)
{
FileBody
fileBody
=
new
FileBody
(
file
,
ContentType
.
DEFAULT_BINARY
);
builder
.
addPart
(
"file"
,
fileBody
);
}
HttpEntity
multipart
=
builder
.
build
();
httpPost
.
setEntity
(
multipart
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
statusCode
!=
200
)
{
throw
new
RuntimeException
(
"上传文件夹失败: "
+
response
.
getStatusLine
().
getReasonPhrase
());
}
}
return
true
;
}
private
static
void
listFiles
(
File
folder
,
List
<
File
>
files
)
{
File
[]
subFiles
=
folder
.
listFiles
();
for
(
File
subFile
:
subFiles
)
{
if
(
subFile
.
isDirectory
())
{
listFiles
(
subFile
,
files
);
}
else
{
files
.
add
(
subFile
);
}
}
}
...
...
dsk-system/src/main/java/com/dsk/system/service/impl/BusinessInfoServiceImpl.java
View file @
119a2d1b
...
...
@@ -169,6 +169,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
//新增项目主信息
BusinessInfo
businessInfo
=
new
BusinessInfo
();
BeanUtil
.
copyProperties
(
dto
,
businessInfo
);
businessInfo
.
setConstructionUnit
(
dto
.
getOwnerCompany
());
int
addBusiness
=
businessInfoMapper
.
insertBusinessInfo
(
businessInfo
);
if
(
addBusiness
>
0
)
{
//获取登陆用户的部门id
...
...
@@ -176,9 +177,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
// Long deptId = 100l;
//新增用户-项目关系信息
int
addbusinessUser
=
businessUserMapper
.
insertBusinessUser
(
new
BusinessUser
(
businessInfo
.
getId
(),
deptId
.
intValue
(),
dto
.
getUserId
(),
1
));
//新增项目-关联企业信息
int
addRelateCompany
=
businessRelateCompanyMapper
.
insertBusinessRelateCompany
(
new
BusinessRelateCompany
(
businessInfo
.
getId
(),
dto
.
getCompanyId
(),
dto
.
getOwnerCompany
(),
"业主"
));
return
addbusinessUser
>
0
&&
addRelateCompany
>
0
?
AjaxResult
.
success
()
:
AjaxResult
.
error
();
return
addbusinessUser
>
0
?
AjaxResult
.
success
()
:
AjaxResult
.
error
();
}
return
AjaxResult
.
error
();
...
...
dsk-system/src/main/resources/mapper/business/BusinessRelateCompanyMapper.xml
View file @
119a2d1b
...
...
@@ -15,6 +15,7 @@
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"depth"
column=
"depth"
/>
<result
property=
"companyType"
column=
"company_type"
/>
</resultMap>
<sql
id=
"selectBusinessRelateCompanyVo"
>
...
...
@@ -27,7 +28,8 @@
phone,
depth,
create_time,
update_time
update_time,
company_type
from business_relate_company
</sql>
...
...
@@ -46,6 +48,7 @@
#{responsiblePerson}
</if>
<if
test=
"phone != null and phone != ''"
>
and phone = #{phone}
</if>
<if
test=
"companyType != null and companyType != ''"
>
and company_type = #{companyType}
</if>
</where>
</select>
...
...
@@ -67,6 +70,7 @@
<if
test=
"phone != null"
>
phone,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"companyType != null"
>
company_type,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"businessId != null"
>
#{businessId},
</if>
...
...
@@ -78,6 +82,7 @@
<if
test=
"phone != null"
>
#{phone},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"companyType != null"
>
#{companyType},
</if>
</trim>
</insert>
...
...
@@ -93,6 +98,7 @@
<if
test=
"phone != null"
>
phone = #{phone},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"companyType != null"
>
company_type = #{companyType},
</if>
</trim>
where id = #{id}
</update>
...
...
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