Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
laowu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 461bd570
authored
Apr 24, 2023
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oss
1 parent
9ede29d0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
130 additions
and
2 deletions
pom.xml
src/main/java/com/laowu/controller/OssController.java
src/main/java/com/laowu/mapper/MemberDictMapper.java
src/main/java/com/laowu/service/impl/TeamDictServiceImpl.java
src/main/java/com/laowu/vo/oss/GetSecretVO.java
src/main/java/com/laowu/vo/oss/UploadFileVO.java
src/main/resources/mapper/MemberDictMapper.xml
pom.xml
View file @
461bd57
...
...
@@ -130,6 +130,12 @@
<artifactId>
commons-lang3
</artifactId>
<version>
${lang3.version}
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
3.10.2
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/laowu/controller/OssController.java
0 → 100644
View file @
461bd57
package
com
.
laowu
.
controller
;
import
com.aliyun.oss.OSS
;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.aliyun.oss.model.PutObjectRequest
;
import
com.aliyun.oss.model.PutObjectResult
;
import
com.laowu.util.ResponseData
;
import
com.laowu.util.ResponseVO
;
import
com.laowu.vo.oss.GetSecretVO
;
import
com.laowu.vo.oss.UploadFileVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
@Api
(
tags
=
"oss"
)
@RestController
@RequestMapping
(
"/oss"
)
public
class
OssController
{
public
static
final
String
key
=
"0ueqhIfdAZyw5lWlBVSLpAxTtx37RY"
;
public
static
final
String
secret
=
"LTAI5tPAH7P7WQVeowo517BE"
;
@Value
(
"${spring.profiles.active}"
)
private
String
env
;
@PostMapping
(
"getSecret"
)
@ApiOperation
(
"oss秘钥"
)
public
ResponseVO
getSecret
(){
GetSecretVO
getSecretVO
=
new
GetSecretVO
();
getSecretVO
.
setKey
(
key
);
getSecretVO
.
setSecret
(
secret
);
return
ResponseData
.
generateCreatedResponse
(
0
,
getSecretVO
);
}
@PostMapping
(
"uploadFile"
)
@ApiOperation
(
"上传文件 file"
)
public
ResponseVO
uploadFile
(
@RequestParam
(
"file"
)
MultipartFile
file
){
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
"http://oss-cn-shanghai.aliyuncs.com"
,
secret
,
key
);
UploadFileVO
uploadFileVO
=
new
UploadFileVO
();
try
{
if
(
env
.
equals
(
"dev"
)){
env
=
"laowu-dev"
;
}
else
{
env
=
"laowu-pro"
;
}
// 创建PutObjectRequest对象。
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
env
,
System
.
currentTimeMillis
()+
"_"
+
file
.
getOriginalFilename
(),
file
.
getInputStream
());
// 设置该属性可以返回response。如果不设置,则返回的response为空。
putObjectRequest
.
setProcess
(
"true"
);
// 创建PutObject请求。
PutObjectResult
result
=
ossClient
.
putObject
(
putObjectRequest
);
// 如果上传成功,则返回200。
// System.out.println(result.getResponse().getUri());
uploadFileVO
.
setUrl
(
result
.
getResponse
().
getUri
());
}
catch
(
Exception
oe
)
{
oe
.
printStackTrace
();
}
finally
{
if
(
ossClient
!=
null
)
{
ossClient
.
shutdown
();
}
}
return
ResponseData
.
generateCreatedResponse
(
0
,
uploadFileVO
);
}
}
src/main/java/com/laowu/mapper/MemberDictMapper.java
View file @
461bd57
...
...
@@ -3,6 +3,7 @@ package com.laowu.mapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.laowu.model.MemberDictDO
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.laowu.model.PositionDictDO
;
import
com.laowu.vo.member.AllMembersVO
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -29,6 +30,11 @@ public interface MemberDictMapper extends BaseMapper<MemberDictDO> {
*/
List
<
Long
>
members
(
Long
teamId
);
/**
* 查询某个人的所有技能
*/
List
<
PositionDictDO
>
memberPositions
(
Long
memberId
);
}
src/main/java/com/laowu/service/impl/TeamDictServiceImpl.java
View file @
461bd57
...
...
@@ -317,8 +317,9 @@ public class TeamDictServiceImpl extends ServiceImpl<TeamDictMapper, TeamDictDO>
memberManagementVO
.
setCompanyCounty
(
recentJobInfoVO
.
getCounty
());
memberManagementVO
.
setCompanyAddress
(
recentJobInfoVO
.
getAddress
());
}
//技能
List
<
PositionDictDO
>
positionDictDOS
=
memberPositionsMapper
.
memberPositions
(
memberManagementVO
.
getId
());
//技能信息
List
<
PositionDictDO
>
positionDictDOS
=
memberDictMapper
.
memberPositions
(
memberManagementVO
.
getId
());
memberManagementVO
.
setPositionDictDOList
(
positionDictDOS
);
}
return
memberManagementVOIPage
;
...
...
src/main/java/com/laowu/vo/oss/GetSecretVO.java
0 → 100644
View file @
461bd57
package
com
.
laowu
.
vo
.
oss
;
import
lombok.Data
;
@Data
public
class
GetSecretVO
{
private
String
key
;
private
String
secret
;
}
src/main/java/com/laowu/vo/oss/UploadFileVO.java
0 → 100644
View file @
461bd57
package
com
.
laowu
.
vo
.
oss
;
import
lombok.Data
;
@Data
public
class
UploadFileVO
{
private
String
url
;
}
src/main/resources/mapper/MemberDictMapper.xml
View file @
461bd57
...
...
@@ -83,4 +83,17 @@
and t2.delete_date is null
AND t2.team_id = #{teamId}
</select>
<select
id=
"memberPositions"
parameterType=
"long"
resultType=
"com.laowu.model.PositionDictDO"
>
SELECT
t2.*
FROM
member_positions t
LEFT JOIN position_dict t2 ON t.position_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t.member_id = #{memberId}
</select>
</mapper>
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