Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tagManager
Overview
Overview
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
lanmw
tagManager
Commits
d4371906
Commit
d4371906
authored
Feb 12, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增标签相关接口
parent
b02d7b5e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
0 deletions
+194
-0
TagRelCtrl.java
src/main/java/com/keymobile/tagmanager/api/TagRelCtrl.java
+56
-0
TagRelation.java
...main/java/com/keymobile/tagmanager/model/TagRelation.java
+91
-0
TagRelRepository.java
...om/keymobile/tagmanager/persistence/TagRelRepository.java
+14
-0
TagRelService.java
.../java/com/keymobile/tagmanager/service/TagRelService.java
+33
-0
No files found.
src/main/java/com/keymobile/tagmanager/api/TagRelCtrl.java
0 → 100644
View file @
d4371906
package
com
.
keymobile
.
tagmanager
.
api
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.auth.common.security.GrantedAuthHelper
;
import
com.keymobile.tagmanager.model.TagRelation
;
import
com.keymobile.tagmanager.service.TagRelService
;
import
com.keymobile.tagmanager.util.UserInfoUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
value
=
"标签关系"
,
tags
=
"标签关系"
)
@RestController
public
class
TagRelCtrl
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
TagRelCtrl
.
class
);
@Autowired
private
TagRelService
tagRelService
;
@ApiOperation
(
value
=
"新增标签关系"
,
notes
=
"新增标签关系"
)
@PostMapping
(
value
=
"/addTagRel"
)
public
TagRelation
add
(
@RequestParam
String
sourceId
,
@RequestParam
String
targetId
)
throws
Exception
{
//获取当前登录用户名和id
/**String userName = UserInfoUtils.getUserName();*/
String
userId
=
UserInfoUtils
.
getUserId
();
//获取当前登录用户所属机构
String
org
=
/**UserInfoUtils.getDataRoleOrg()*/
String
.
valueOf
(
GrantedAuthHelper
.
getUserOrg
());
return
tagRelService
.
addTagRel
(
sourceId
,
targetId
,
userId
,
org
);
}
@ApiOperation
(
value
=
"删除标签关系"
,
notes
=
"删除标签关系"
)
@PostMapping
(
value
=
"/deleteTagRel"
)
public
void
delete
(
@RequestParam
String
id
)
{
tagRelService
.
deleteTagRel
(
id
);
}
@ApiOperation
(
value
=
"根据当前标签id获取源标签"
,
notes
=
"根据当前标签id获取源标签"
)
@PostMapping
(
value
=
"/getSourceTags"
)
public
List
<
TagRelation
>
getSourceTags
(
String
tagId
){
return
tagRelService
.
getSource
(
tagId
);
}
@ApiOperation
(
value
=
"根据当前标签id获取目标标签"
,
notes
=
"根据当前标签id获目标标签"
)
@PostMapping
(
value
=
"/getTargetTags"
)
public
List
<
TagRelation
>
getTargetTags
(
String
tagId
){
return
tagRelService
.
getTarget
(
tagId
);
}
}
src/main/java/com/keymobile/tagmanager/model/TagRelation.java
0 → 100644
View file @
d4371906
package
com
.
keymobile
.
tagmanager
.
model
;
import
java.io.Serializable
;
import
javax.persistence.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
@Document
(
collection
=
"TagRelation"
)
public
class
TagRelation
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
private
String
sourceId
;
private
String
targetId
;
private
String
org
;
private
String
creater
;
private
String
createTime
=
String
.
valueOf
(
System
.
currentTimeMillis
());
public
TagRelation
()
{}
public
TagRelation
(
String
sourceId
,
String
targetId
)
{
this
.
sourceId
=
sourceId
;
this
.
targetId
=
targetId
;
}
public
TagRelation
(
String
sourceId
,
String
targetId
,
String
creater
,
String
org
)
{
this
.
sourceId
=
sourceId
;
this
.
targetId
=
targetId
;
this
.
creater
=
creater
;
this
.
org
=
org
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getSourceId
()
{
return
sourceId
;
}
public
void
setSourceId
(
String
sourceId
)
{
this
.
sourceId
=
sourceId
;
}
public
String
getTargetId
()
{
return
targetId
;
}
public
void
setTargetId
(
String
targetId
)
{
this
.
targetId
=
targetId
;
}
public
String
getCreater
()
{
return
creater
;
}
public
void
setCreater
(
String
creater
)
{
this
.
creater
=
creater
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getOrg
()
{
return
org
;
}
public
void
setOrg
(
String
org
)
{
this
.
org
=
org
;
}
}
src/main/java/com/keymobile/tagmanager/persistence/TagRelRepository.java
0 → 100644
View file @
d4371906
package
com
.
keymobile
.
tagmanager
.
persistence
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.keymobile.tagmanager.model.TagRelation
;
public
interface
TagRelRepository
extends
MongoRepository
<
TagRelation
,
String
>{
List
<
TagRelation
>
findBySourceId
(
String
sourceId
);
List
<
TagRelation
>
findByTargetId
(
String
targetId
);
}
src/main/java/com/keymobile/tagmanager/service/TagRelService.java
0 → 100644
View file @
d4371906
package
com
.
keymobile
.
tagmanager
.
service
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.tagmanager.model.TagRelation
;
import
com.keymobile.tagmanager.persistence.TagRelRepository
;
@Service
public
class
TagRelService
{
@Autowired
private
TagRelRepository
tagRelRepo
;
public
TagRelation
addTagRel
(
String
sourceId
,
String
targetId
,
String
userName
,
String
org
)
{
TagRelation
tagRel
=
new
TagRelation
(
sourceId
,
targetId
,
userName
,
org
);
return
tagRelRepo
.
save
(
tagRel
);
}
public
void
deleteTagRel
(
String
id
)
{
tagRelRepo
.
deleteById
(
id
);
}
public
List
<
TagRelation
>
getSource
(
String
tagId
){
return
tagRelRepo
.
findBySourceId
(
tagId
);
}
public
List
<
TagRelation
>
getTarget
(
String
tagId
){
return
tagRelRepo
.
findByTargetId
(
tagId
);
}
}
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