forked from xuwujing/springBoot-study
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
7,294 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lDatasource/target/classes/META-INF/maven/1.0.0/springboot-mutilDatasource/pom.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package com.pancm; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
|
||
@SpringBootApplication | ||
public class App | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
// 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件 | ||
SpringApplication.run(App.class, args); | ||
System.out.println("程序正在运行..."); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
springboot-thymeleaf/src/main/java/com/pancm/dao/UserDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.pancm.dao; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.ibatis.annotations.Delete; | ||
import org.apache.ibatis.annotations.Insert; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Select; | ||
import org.apache.ibatis.annotations.Update; | ||
|
||
import com.pancm.pojo.User; | ||
|
||
/** | ||
* | ||
* Title: UserDao | ||
* Description: | ||
* 用户数据接口 | ||
* Version:1.0.0 | ||
* @author pancm | ||
* @date 2018年1月9日 | ||
*/ | ||
@Mapper | ||
public interface UserDao { | ||
|
||
|
||
@Insert("insert into t_user(id,name,password,age) values (#{id},#{name},#{password},#{age})") | ||
void addUser(User user); | ||
|
||
|
||
@Update("update t_user set name=#{name},password=#{password} age=#{age} where id=#{id}") | ||
void updateUser(User user); | ||
|
||
|
||
@Delete("delete from t_user where id=#{id}") | ||
void deleteUser(int id); | ||
|
||
@Select("SELECT * FROM t_user where id=#{id}") | ||
User findById(int id); | ||
|
||
|
||
@Select("SELECT * FROM t_user") | ||
List<User> findAll(); | ||
|
||
} |
102 changes: 102 additions & 0 deletions
102
springboot-thymeleaf/src/main/java/com/pancm/pojo/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.pancm.pojo; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
|
||
/** | ||
* | ||
* Title: User | ||
* Description:用户pojo类 | ||
* Version:1.0.0 | ||
* @author pancm | ||
* @date 2017年9月26日 | ||
*/ | ||
@Entity | ||
public class User { | ||
|
||
/** 编号 */ | ||
@Id | ||
@GeneratedValue | ||
private int id; | ||
/** 姓名 */ | ||
@Column(nullable = false, unique = true) | ||
private String name; | ||
/** 密码*/ | ||
@Column(nullable = false) | ||
private String password; | ||
/** 年龄 */ | ||
@Column(nullable = false) | ||
private int age; | ||
|
||
public User(){ | ||
} | ||
|
||
/** | ||
* 获取编号 | ||
* @return id | ||
*/ | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* 设置编号 | ||
* @param id | ||
*/ | ||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* 获取姓名 | ||
* @return name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* 设置姓名 | ||
* @param name | ||
*/ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
|
||
/** | ||
* 获取密码 | ||
* @return password | ||
*/ | ||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
/** | ||
* 设置密码 | ||
* @param String password | ||
*/ | ||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
/** | ||
* 获取年龄 | ||
* @return age | ||
*/ | ||
public int getAge() { | ||
return age; | ||
} | ||
/** | ||
* 设置年龄 | ||
* @param int age | ||
*/ | ||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
|
||
|
||
|
||
} |
51 changes: 51 additions & 0 deletions
51
springboot-thymeleaf/src/main/java/com/pancm/service/UserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.pancm.service; | ||
|
||
import java.util.List; | ||
|
||
import com.pancm.pojo.User; | ||
|
||
|
||
/** | ||
* | ||
* Title: UserService | ||
* Description: | ||
* 用户接口 | ||
* Version:1.0.0 | ||
* @author pancm | ||
* @date 2018年3月19日 | ||
*/ | ||
public interface UserService { | ||
|
||
/** | ||
* 新增用户 | ||
* @param user | ||
* @return | ||
*/ | ||
boolean addUser(User user); | ||
|
||
/** | ||
* 修改用户 | ||
* @param user | ||
* @return | ||
*/ | ||
boolean updateUser(User user); | ||
|
||
|
||
/** | ||
* 删除用户 | ||
* @param id | ||
* @return | ||
*/ | ||
boolean deleteUser(int id); | ||
|
||
/** | ||
* 根据用户名字查询用户信息 | ||
* @param userName | ||
*/ | ||
User findUserById(int id); | ||
/** | ||
* 查询所有 | ||
* @return | ||
*/ | ||
List<User> findAll(); | ||
} |
75 changes: 75 additions & 0 deletions
75
springboot-thymeleaf/src/main/java/com/pancm/service/impl/UserServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.pancm.service.impl; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.pancm.dao.UserDao; | ||
import com.pancm.pojo.User; | ||
import com.pancm.service.UserService; | ||
|
||
/** | ||
* | ||
* Title: UserServiceImpl | ||
* Description: | ||
* 用户操作实现类 | ||
* Version:1.0.0 | ||
* @author pancm | ||
* @date 2018年3月19日 | ||
*/ | ||
@Service | ||
public class UserServiceImpl implements UserService { | ||
@Autowired | ||
private UserDao userDao; | ||
|
||
|
||
@Override | ||
public boolean addUser(User user) { | ||
boolean flag=false; | ||
try{ | ||
userDao.addUser(user); | ||
flag=true; | ||
}catch(Exception e){ | ||
System.out.println("新增失败!"); | ||
e.printStackTrace(); | ||
} | ||
return flag; | ||
} | ||
|
||
@Override | ||
public boolean updateUser(User user) { | ||
boolean flag=false; | ||
try{ | ||
userDao.updateUser(user); | ||
flag=true; | ||
}catch(Exception e){ | ||
System.out.println("修改失败!"); | ||
e.printStackTrace(); | ||
} | ||
return flag; | ||
} | ||
|
||
@Override | ||
public boolean deleteUser(int id) { | ||
boolean flag=false; | ||
try{ | ||
userDao.deleteUser(id); | ||
flag=true; | ||
}catch(Exception e){ | ||
System.out.println("删除失败!"); | ||
e.printStackTrace(); | ||
} | ||
return flag; | ||
} | ||
|
||
@Override | ||
public User findUserById(int id) { | ||
return userDao.findById(id); | ||
} | ||
|
||
@Override | ||
public List<User> findAll() { | ||
return userDao.findAll(); | ||
} | ||
} |
Oops, something went wrong.