Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-springboot-train
Project
Project
Details
Activity
Releases
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
Fcant
hls-springboot-train
Commits
b5cfcdc1
Commit
b5cfcdc1
authored
Dec 03, 2019
by
Fcant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Code-Updates]:1、完成数据库配置;2、完成Mapper映射文件和接口文件
parent
d13c6732
Pipeline
#4020
canceled with stages
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
357 additions
and
4 deletions
+357
-4
MavenWrapperDownloader.java
SpringBoot_HLS/.mvn/wrapper/MavenWrapperDownloader.java
+0
-3
pom.xml
SpringBoot_HLS/pom.xml
+5
-1
SpringbootApplication.java
...nd/train/springboot/springboot/SpringbootApplication.java
+2
-0
UserInfo.java
...a/org/hand/train/springboot/springboot/bean/UserInfo.java
+21
-0
UserController.java
...rain/springboot/springboot/controller/UserController.java
+87
-0
UserMapper.java
...g/hand/train/springboot/springboot/mapper/UserMapper.java
+65
-0
UserService.java
...hand/train/springboot/springboot/service/UserService.java
+65
-0
UserServiceImpl.java
...n/springboot/springboot/service/impl/UserServiceImpl.java
+49
-0
application.yml
SpringBoot_HLS/src/main/resources/application.yml
+8
-0
UserMapper.xml
SpringBoot_HLS/src/main/resources/mapper/UserMapper.xml
+55
-0
No files found.
SpringBoot_HLS/.mvn/wrapper/MavenWrapperDownloader.java
View file @
b5cfcdc1
...
...
@@ -14,9 +14,6 @@
* limitations under the License.
*/
import
java.net.*
;
import
java.io.*
;
import
java.nio.channels.*
;
import
java.util.Properties
;
public
class
MavenWrapperDownloader
{
...
...
SpringBoot_HLS/pom.xml
View file @
b5cfcdc1
...
...
@@ -19,6 +19,11 @@
</properties>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.17
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jdbc
</artifactId>
...
...
@@ -55,7 +60,6 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<exclusions>
<exclusion>
<groupId>
org.junit.vintage
</groupId>
...
...
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/SpringbootApplication.java
View file @
b5cfcdc1
package
org
.
hand
.
train
.
springboot
.
springboot
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
@MapperScan
(
"org.hand.train.springboot.springboot.mapper"
)
public
class
SpringbootApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/bean/UserInfo.java
0 → 100644
View file @
b5cfcdc1
package
org
.
hand
.
train
.
springboot
.
springboot
.
bean
;
import
lombok.Data
;
import
java.sql.Date
;
/**
* UserInfo
* <p>
* encoding:UTF-8
*
* @author Fcant
* @date 17:16 2019/12/3
*/
@Data
public
class
UserInfo
{
private
int
userId
;
private
String
userName
;
private
int
age
;
private
Date
createTime
;
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/controller/UserController.java
0 → 100644
View file @
b5cfcdc1
package
org
.
hand
.
train
.
springboot
.
springboot
.
controller
;
import
org.hand.train.springboot.springboot.bean.UserInfo
;
import
org.hand.train.springboot.springboot.service.impl.UserServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* UserController
* <p>
* encoding:UTF-8
*
* @author Fcant
* @date 17:25 2019/12/3
*/
@RestController
public
class
UserController
{
@Autowired
UserServiceImpl
userService
;
/**
* 查询所有用户
*
* @return List<UserInfo>
* @author Fcant
* @date 18:39 2019/12/3
*/
@GetMapping
(
"/getall"
)
public
List
<
UserInfo
>
selectAllUser
()
{
return
userService
.
selectAllUser
();
}
/**
* 根据用户ID查询用户信息
*
* @param id
* @return UserInfo
* @author Fcant
* @date 18:40 2019/12/3
*/
@GetMapping
(
"/get/{id}"
)
UserInfo
selectUserById
(
@PathVariable
int
id
)
{
return
userService
.
selectUserById
(
id
);
}
/**
* 添加用户
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:40 2019/12/3
*/
@PostMapping
(
"/add"
)
int
addUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userService
.
addUser
(
userInfo
);
}
/**
* 更新用户信息
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:41 2019/12/3
*/
@PutMapping
(
"/update"
)
int
updateUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userService
.
updateUser
(
userInfo
);
}
/**
* 删除用户
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:41 2019/12/3
*/
@DeleteMapping
(
"/del"
)
int
delUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userService
.
delUser
(
userInfo
);
}
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/mapper/UserMapper.java
0 → 100644
View file @
b5cfcdc1
package
org
.
hand
.
train
.
springboot
.
springboot
.
mapper
;
import
org.hand.train.springboot.springboot.bean.UserInfo
;
import
java.util.List
;
/**
* UserMapper
* <p>
* encoding:UTF-8
*
* @author Fcant
* @date 17:20 2019/12/3
*/
public
interface
UserMapper
{
/**
* 查询所有用户
*
* @return List<UserInfo>
* @author Fcant
* @date 18:39 2019/12/3
*/
List
<
UserInfo
>
selectAllUser
();
/**
* 根据用户ID查询用户信息
*
* @param id
* @return UserInfo
* @author Fcant
* @date 18:40 2019/12/3
*/
UserInfo
selectUserById
(
int
id
);
/**
* 添加用户
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:40 2019/12/3
*/
int
addUser
(
UserInfo
userInfo
);
/**
* 更新用户信息
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:41 2019/12/3
*/
int
updateUser
(
UserInfo
userInfo
);
/**
* 删除用户
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:41 2019/12/3
*/
int
delUser
(
UserInfo
userInfo
);
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/service/UserService.java
0 → 100644
View file @
b5cfcdc1
package
org
.
hand
.
train
.
springboot
.
springboot
.
service
;
import
org.hand.train.springboot.springboot.bean.UserInfo
;
import
java.util.List
;
/**
* UserService
* <p>
* encoding:UTF-8
*
* @author Fcant
* @date 17:25 2019/12/3
*/
public
interface
UserService
{
/**
* 查询所有用户
*
* @return List<UserInfo>
* @author Fcant
* @date 18:39 2019/12/3
*/
List
<
UserInfo
>
selectAllUser
();
/**
* 根据用户ID查询用户信息
*
* @param id
* @return UserInfo
* @author Fcant
* @date 18:40 2019/12/3
*/
UserInfo
selectUserById
(
int
id
);
/**
* 添加用户
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:40 2019/12/3
*/
int
addUser
(
UserInfo
userInfo
);
/**
* 更新用户信息
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:41 2019/12/3
*/
int
updateUser
(
UserInfo
userInfo
);
/**
* 删除用户
*
* @param userInfo
* @return int
* @author Fcant
* @date 18:41 2019/12/3
*/
int
delUser
(
UserInfo
userInfo
);
}
SpringBoot_HLS/src/main/java/org/hand/train/springboot/springboot/service/impl/UserServiceImpl.java
0 → 100644
View file @
b5cfcdc1
package
org
.
hand
.
train
.
springboot
.
springboot
.
service
.
impl
;
import
org.hand.train.springboot.springboot.bean.UserInfo
;
import
org.hand.train.springboot.springboot.mapper.UserMapper
;
import
org.hand.train.springboot.springboot.service.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* UserServiceImpl
* <p>
* encoding:UTF-8
*
* @author Fcant
* @date 17:27 2019/12/3
*/
@Service
public
class
UserServiceImpl
implements
UserService
{
@Autowired
UserMapper
userMapper
;
@Override
public
List
<
UserInfo
>
selectAllUser
()
{
return
userMapper
.
selectAllUser
();
}
@Override
public
UserInfo
selectUserById
(
int
id
)
{
return
userMapper
.
selectUserById
(
id
);
}
@Override
public
int
addUser
(
UserInfo
userInfo
)
{
return
userMapper
.
addUser
(
userInfo
);
}
@Override
public
int
updateUser
(
UserInfo
userInfo
)
{
return
userMapper
.
updateUser
(
userInfo
);
}
@Override
public
int
delUser
(
UserInfo
userInfo
)
{
return
userMapper
.
delUser
(
userInfo
);
}
}
SpringBoot_HLS/src/main/resources/application.yml
0 → 100644
View file @
b5cfcdc1
spring
:
datasource
:
url
:
jdbc:mysql:///hls_train?serverTimezone=UTC
username
:
root
password
:
123456
driver-class-name
:
com.mysql.cj.jdbc.Driver
mybatis
:
mapper-locations
:
classpath:mapper/*.xml
\ No newline at end of file
SpringBoot_HLS/src/main/resources/mapper/UserMapper.xml
0 → 100644
View file @
b5cfcdc1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"org.hand.train.springboot.springboot.mapper.UserMapper"
>
<resultMap
id=
"BaseResult"
type=
"org.hand.train.springboot.springboot.bean.UserInfo"
>
<id
column=
"user_id"
javaType=
"int"
property=
"userId"
></id>
<result
column=
"user_name"
javaType=
"String"
property=
"userName"
/>
<result
column=
"age"
javaType=
"int"
property=
"age"
/>
<result
column=
"create_time"
javaType=
"java.sql.Date"
property=
"createTime"
/>
</resultMap>
<select
id=
"selectAllUser"
resultMap=
"BaseResult"
>
SELECT
user_id,
user_name,
age,
create_time
FROM
user_info
</select>
<select
id=
"selectUserById"
parameterType=
"int"
resultMap=
"BaseResult"
>
SELECT
user_id,
user_name,
age,
create_time
FROM
user_info
WHERE
user_id =#{id}
</select>
<insert
id=
"addUser"
keyProperty=
"userId"
useGeneratedKeys=
"true"
parameterType=
"org.hand.train.springboot.springboot.bean.UserInfo"
>
INSERT INTO user_info(user_id, user_name, age, create_time)
VALUES (#{userId}, #{userName}, #{age}, #{createTime})
</insert>
<update
id=
"updateUser"
parameterType=
"org.hand.train.springboot.springboot.bean.UserInfo"
>
UPDATE
user_info
set
user_name = #{userName},
age= #{age}
WHERE user_id= #{userId}
</update>
<delete
id=
"delUser"
parameterType=
"org.hand.train.springboot.springboot.bean.UserInfo"
>
DELETE FROM
user_info
WHERE user_id=#{userId}
</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