Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
precision-effect
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
耿迪迪
precision-effect
Commits
0155f7ef
Commit
0155f7ef
authored
Jul 14, 2023
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
多账户关联
parent
b54fe7f7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
23 deletions
+53
-23
TUserRelationController.java
.../web/controller/userRelation/TUserRelationController.java
+29
-19
TUserRelationMapper.java
...in/java/com/zehong/system/mapper/TUserRelationMapper.java
+4
-0
TUserRelationServiceImpl.java
.../zehong/system/service/impl/TUserRelationServiceImpl.java
+16
-4
TUserRelationMapper.xml
...rc/main/resources/mapper/business/TUserRelationMapper.xml
+4
-0
No files found.
precision-effect-admin/src/main/java/com/zehong/web/controller/userRelation/TUserRelationController.java
View file @
0155f7ef
package
com
.
zehong
.
web
.
controller
.
userRelation
;
import
java.util.List
;
import
com.zehong.common.annotation.Log
;
import
com.zehong.common.core.controller.BaseController
;
import
com.zehong.common.core.domain.AjaxResult
;
import
com.zehong.common.core.domain.entity.SysUser
;
import
com.zehong.common.core.exception.BusinessException
;
import
com.zehong.common.core.page.TableDataInfo
;
import
com.zehong.common.enums.BusinessType
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.common.utils.StringUtils
;
import
com.zehong.common.utils.poi.ExcelUtil
;
import
com.zehong.system.domain.TUserRelation
;
import
com.zehong.system.service.ISysUserService
;
import
org.springframework.security.access.prepost.PreAuthoriz
e
;
import
com.zehong.system.service.ITUserRelationServic
e
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zehong.common.annotation.Log
;
import
com.zehong.common.core.controller.BaseController
;
import
com.zehong.common.core.domain.AjaxResult
;
import
com.zehong.common.enums.BusinessType
;
import
com.zehong.system.domain.TUserRelation
;
import
com.zehong.system.service.ITUserRelationService
;
import
com.zehong.common.utils.poi.ExcelUtil
;
import
com.zehong.common.core.page.TableDataInfo
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 用户关联Controller
...
...
@@ -91,6 +83,7 @@ public class TUserRelationController extends BaseController
return
toAjax
(
tUserRelationService
.
insertTUserRelation
(
tUserRelation
));
}
/**
* 校验关联信息
* @param tUserRelation 关联信息
...
...
@@ -115,6 +108,23 @@ public class TUserRelationController extends BaseController
throw
new
BusinessException
(
"不能关联当前账户"
);
}
tUserRelation
.
setRelationUserId
(
sysUser
.
getUserId
());
//关联对方账号
relationEachOther
(
sysUser
.
getUserId
(),
tUserRelation
.
getUserId
());
}
/**
* 关联对方账号
* @param userId 账号
* @param relationUserId 对方账号
*/
private
void
relationEachOther
(
Long
userId
,
Long
relationUserId
)
{
TUserRelation
relation
=
new
TUserRelation
();
relation
.
setUserId
(
userId
);
relation
.
setRelationUserId
(
relationUserId
);
List
<
TUserRelation
>
relations
=
tUserRelationService
.
selectTUserRelationList
(
relation
);
if
(
CollectionUtils
.
isEmpty
(
relations
)){
tUserRelationService
.
insertTUserRelation
(
relation
);
}
}
/**
...
...
precision-effect-system/src/main/java/com/zehong/system/mapper/TUserRelationMapper.java
View file @
0155f7ef
package
com
.
zehong
.
system
.
mapper
;
import
java.util.List
;
import
java.util.Map
;
import
com.zehong.system.domain.TUserRelation
;
/**
...
...
@@ -58,4 +60,6 @@ public interface TUserRelationMapper
* @return 结果
*/
public
int
deleteTUserRelationByIds
(
Long
[]
relationIds
);
int
deleteUserRelationByUserIdAndRelationUserId
(
Map
<
String
,
Long
>
map
);
}
precision-effect-system/src/main/java/com/zehong/system/service/impl/TUserRelationServiceImpl.java
View file @
0155f7ef
package
com
.
zehong
.
system
.
service
.
impl
;
import
java.util.List
;
import
com.zehong.common.utils.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zehong.system.mapper.TUserRelationMapper
;
import
com.zehong.system.domain.TUserRelation
;
import
com.zehong.system.mapper.TUserRelationMapper
;
import
com.zehong.system.service.ITUserRelationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户关联Service业务层处理
...
...
@@ -77,8 +81,16 @@ public class TUserRelationServiceImpl implements ITUserRelationService
* @return 结果
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
deleteTUserRelationByIds
(
Long
[]
relationIds
)
{
for
(
Long
relationId
:
relationIds
){
TUserRelation
relation
=
tUserRelationMapper
.
selectTUserRelationById
(
relationId
);
Map
<
String
,
Long
>
map
=
new
HashMap
<>();
map
.
put
(
"userId"
,
relation
.
getRelationUserId
());
map
.
put
(
"relationUserId"
,
relation
.
getUserId
());
tUserRelationMapper
.
deleteUserRelationByUserIdAndRelationUserId
(
map
);
}
return
tUserRelationMapper
.
deleteTUserRelationByIds
(
relationIds
);
}
...
...
precision-effect-system/src/main/resources/mapper/business/TUserRelationMapper.xml
View file @
0155f7ef
...
...
@@ -89,4 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{relationId}
</foreach>
</delete>
<delete
id=
"deleteUserRelationByUserIdAndRelationUserId"
parameterType=
"Map"
>
delete from t_user_relation where user_id = #{userId} AND relation_user_id = #{relationUserId}
</delete>
</mapper>
\ No newline at end of file
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