Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
huhu-partner
Project
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanchen
huhu-partner
Commits
efdcd319
Commit
efdcd319
authored
Jul 03, 2019
by
guanchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加动态sql
parent
a09be9fd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
11 deletions
+44
-11
UserAgentMapper.java
...ain/java/com/lanren/huhu/partner/dao/UserAgentMapper.java
+18
-11
UserAgentSqlProvider.java
...ava/com/lanren/huhu/partner/dao/UserAgentSqlProvider.java
+26
-0
No files found.
src/main/java/com/lanren/huhu/partner/dao/UserAgentMapper.java
View file @
efdcd319
...
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.lanren.huhu.partner.domain.UserAgent
;
import
com.lanren.huhu.partner.domain.UserAgent
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
Provider
;
import
java.util.List
;
import
java.util.List
;
...
@@ -24,18 +24,24 @@ public interface UserAgentMapper extends BaseMapper<UserAgent> {
...
@@ -24,18 +24,24 @@ public interface UserAgentMapper extends BaseMapper<UserAgent> {
* @param agentId
* @param agentId
* @return
* @return
*/
*/
@Select
(
"SELECT b.* "
+
// @Select("SELECT b.* " +
"FROM user_agent a "
+
// "FROM user_agent a " +
"JOIN user_agent b on a.#{parentColumnName}=b.agent_id "
+
// "JOIN user_agent b on a.#{parentColumnName}=b.agent_id " +
"WHERE a.agent_id=#{agentId} and b.agent_level<=4"
)
// "WHERE a.agent_id=#{agentId} and b.agent_level<=4")
UserAgent
getParentAgent
(
Integer
agentId
,
String
parentColumnName
);
// UserAgent getParentAgent(Integer agentId, String parentColumnName);
@SelectProvider
(
type
=
UserAgentSqlProvider
.
class
,
method
=
"getParentAgent"
)
UserAgent
getParentAgent
(
@Param
(
"agentId"
)
Integer
agentId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
/**
/**
* 按uid查找下级 UserAgent
* 按uid查找下级 UserAgent
*/
*/
@Select
(
"SELECT b.* "
+
// @Select("SELECT b.* " +
"FROM user_agent a "
+
// "FROM user_agent a " +
"JOIN user_agent b on a.#{parentColumnName}=b.agent_id "
+
// "JOIN user_agent b on a.#{parentColumnName}=b.agent_id " +
"WHERE a.user_id=#{userId}"
)
// "WHERE a.user_id=#{userId}")
List
<
UserAgent
>
getChildrenByUserId
(
Integer
userId
,
String
parentColumnName
);
// List<UserAgent> getChildrenByUserId(Integer userId, String parentColumnName);
@SelectProvider
(
type
=
UserAgentSqlProvider
.
class
,
method
=
"getChildrenByUserId"
)
List
<
UserAgent
>
getChildrenByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
}
}
\ No newline at end of file
src/main/java/com/lanren/huhu/partner/dao/UserAgentSqlProvider.java
0 → 100644
View file @
efdcd319
package
com
.
lanren
.
huhu
.
partner
.
dao
;
import
org.apache.ibatis.annotations.Param
;
/**
* @author chen
* @title: UserAgentSqlProvider
* @projectName partner
* @description: 提供动态sql
* @package com.lanren.huhu.partner.dao
* @date 2019-07-03 16:29
*/
public
class
UserAgentSqlProvider
{
public
String
getParentAgent
(
@Param
(
"agentId"
)
Integer
agentId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
)
{
return
"SELECT b.* "
+
"FROM user_agent a "
+
"JOIN user_agent b on a."
+
parentColumnName
+
"=b.agent_id "
+
"WHERE a.agent_id=#{agentId} and b.agent_level<=4"
;
}
public
String
getChildrenByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
)
{
return
"SELECT b.* "
+
"FROM user_agent a "
+
"JOIN user_agent b on a."
+
parentColumnName
+
"=b.agent_id "
+
"WHERE a.user_id=#{userId}"
;
}
}
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