Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级项目 #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>me.danwi.sqlex</groupId>
<artifactId>example</artifactId>
<artifactId>maven-example</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
Expand All @@ -17,20 +17,25 @@
<dependency>
<groupId>me.danwi.sqlex</groupId>
<artifactId>core</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
</dependencies>

<build>
<resources>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不是资源目录吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,添加sqlex目录为资源目录后,新启动idea工程,就不用手动设置为源码目录,idea插件也可以使用了

java源码目录和maven默认源码目录有歧义,已经删除

<!--指定sqlex为编译资源目录方便idea插件自动识别,无需手动idea设置为源码目录-->
<resource>
<directory>${basedir}/src/main/sqlex</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>me.danwi.sqlex</groupId>
<artifactId>sqlex-maven-plugin</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
<executions>
<execution>
<goals>
<goal>add-source</goal>
<goal>generate</goal>
</goals>
<configuration>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/me/danwi/sqlex/example/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public static void main(String[] args) {
UserDao userDao = dataSource.getInstance(UserDao.class);
RoleDao roleDao = dataSource.getInstance(RoleDao.class);

userDao.getAll(10, "123", null);
userDao.getAll(10, "123", new ArrayList());
userDao.getAllByRole("123");
userDao.getCountsByRole();
userDao.findAll(10, "123", null);
userDao.findAll(10, "123", new ArrayList());
userDao.findAllByRole("123");
userDao.findCountsByRole();

roleDao.getAll("管");
roleDao.findAll("管");
}
}
3 changes: 2 additions & 1 deletion src/main/sqlex/me/danwi/sqlex/example/dao/RoleDao.sqlm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
getAll(name:String) {
# 模糊查询指定名称角色信息
findAll(name:String) {
select *
from role
where name like concat('?', :name, '?')
Expand Down
9 changes: 6 additions & 3 deletions src/main/sqlex/me/danwi/sqlex/example/dao/UserDao.sqlm
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
getAll(age:Integer, name:String, names:String*) {
# 测试 in 查询
findAll(age:Integer, name:String, names:String*) {
select *
from user
where age > :age
and name like concat('%', :name, '%')
and name in (:names)
}

getAllByRole(roleId:String) {
# 根据角色id查询用户
findAllByRole(roleId:String) {
select u.*
from user u
inner join user_role_mapping m on u.id = m.user
where m.role = :roleId
}

getCountsByRole() {
# 查询每个用户充当角色数量
findCountsByRole() {
select u.id, count(1) as amount
from user u
inner join user_role_mapping m on u.id = m.user
Expand Down