Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
caopu16
whatsmars
提交
d1ec2af6
W
whatsmars
项目概览
caopu16
/
whatsmars
与 Fork 源项目一致
Fork自
武汉红喜 / whatsmars
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d1ec2af6
编写于
1月 24, 2018
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RequestBody - 以json格式接收参数
上级
52f49fdb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
12 deletion
+41
-12
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/NewController.java
...ongxi/whatsmars/spring/boot/controller/NewController.java
+10
-12
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java
...java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java
+4
-0
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/UserService.java
...org/hongxi/whatsmars/spring/boot/service/UserService.java
+5
-0
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java
...i/whatsmars/spring/boot/service/impl/UserServiceImpl.java
+10
-0
whatsmars-spring-boot/src/main/resources/mapper/UserMapper.xml
...mars-spring-boot/src/main/resources/mapper/UserMapper.xml
+12
-0
未找到文件。
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/controller/NewController.java
浏览文件 @
d1ec2af6
...
@@ -22,14 +22,14 @@ public class NewController {
...
@@ -22,14 +22,14 @@ public class NewController {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@
RequestMapping
(
value
=
"/t"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/t"
)
public
Map
<
String
,
Object
>
query
()
{
public
Map
<
String
,
Object
>
query
()
{
Map
<
String
,
Object
>
m
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
m
=
new
HashMap
<
String
,
Object
>();
m
.
put
(
"domain"
,
"toutiao.im"
);
m
.
put
(
"domain"
,
"toutiao.im"
);
return
m
;
return
m
;
}
}
@
RequestMapping
(
value
=
"/t"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/t"
)
public
HttpStatus
add
(
@RequestParam
(
name
=
"name"
)
String
username
,
public
HttpStatus
add
(
@RequestParam
(
name
=
"name"
)
String
username
,
@RequestParam
(
required
=
false
)
String
nickname
,
@RequestParam
(
required
=
false
)
String
nickname
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
gender
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
gender
,
...
@@ -43,18 +43,16 @@ public class NewController {
...
@@ -43,18 +43,16 @@ public class NewController {
return
HttpStatus
.
OK
;
return
HttpStatus
.
OK
;
}
}
@RequestMapping
(
value
=
"/t"
,
method
=
RequestMethod
.
PUT
)
@PutMapping
(
"/t"
)
public
Map
<
String
,
Object
>
update
()
{
public
HttpStatus
update
(
@RequestBody
User
user
)
{
// 以json格式接收参数
Map
<
String
,
Object
>
m
=
new
HashMap
<
String
,
Object
>();
userService
.
update
(
user
);
m
.
put
(
"domain"
,
"toutiao.im"
);
return
HttpStatus
.
OK
;
return
m
;
}
}
@RequestMapping
(
value
=
"/t"
,
method
=
RequestMethod
.
DELETE
)
@DeleteMapping
(
"/t"
)
public
Map
<
String
,
Object
>
delete
()
{
public
HttpStatus
delete
(
Long
id
)
{
Map
<
String
,
Object
>
m
=
new
HashMap
<
String
,
Object
>();
userService
.
delete
(
id
);
m
.
put
(
"domain"
,
"toutiao.im"
);
return
HttpStatus
.
OK
;
return
m
;
}
}
@RequestMapping
(
value
=
"/e"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/e"
,
method
=
RequestMethod
.
GET
)
...
...
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/dao/UserMapper.java
浏览文件 @
d1ec2af6
...
@@ -18,4 +18,8 @@ public interface UserMapper {
...
@@ -18,4 +18,8 @@ public interface UserMapper {
void
insertBatch
(
List
<
User
>
users
);
void
insertBatch
(
List
<
User
>
users
);
List
<
User
>
query
();
List
<
User
>
query
();
void
update
(
User
user
);
void
delete
(
Long
id
);
}
}
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/UserService.java
浏览文件 @
d1ec2af6
...
@@ -12,5 +12,10 @@ public interface UserService {
...
@@ -12,5 +12,10 @@ public interface UserService {
void
add
(
User
user
);
void
add
(
User
user
);
void
update
(
User
user
);
void
delete
(
Long
id
);
Page
<
User
>
query
(
int
offset
,
int
limit
);
Page
<
User
>
query
(
int
offset
,
int
limit
);
}
}
whatsmars-spring-boot/src/main/java/org/hongxi/whatsmars/spring/boot/service/impl/UserServiceImpl.java
浏览文件 @
d1ec2af6
...
@@ -32,6 +32,16 @@ public class UserServiceImpl implements UserService {
...
@@ -32,6 +32,16 @@ public class UserServiceImpl implements UserService {
logger
.
info
(
"add user success, username: {}"
,
user
.
getUsername
());
logger
.
info
(
"add user success, username: {}"
,
user
.
getUsername
());
}
}
@Override
public
void
update
(
User
user
)
{
userMapper
.
update
(
user
);
}
@Override
public
void
delete
(
Long
id
)
{
userMapper
.
delete
(
id
);
}
@Override
@Override
public
Page
<
User
>
query
(
int
offset
,
int
limit
)
{
public
Page
<
User
>
query
(
int
offset
,
int
limit
)
{
return
PageHelper
.
offsetPage
(
offset
,
limit
).
doSelectPage
(()
->
userMapper
.
query
());
return
PageHelper
.
offsetPage
(
offset
,
limit
).
doSelectPage
(()
->
userMapper
.
query
());
...
...
whatsmars-spring-boot/src/main/resources/mapper/UserMapper.xml
浏览文件 @
d1ec2af6
...
@@ -22,4 +22,16 @@
...
@@ -22,4 +22,16 @@
select * from user
select * from user
</select>
</select>
<update
id=
"update"
parameterType=
"User"
>
update user set update_date = NOW
<if
test=
"username != null"
>
, username = #{username}
</if>
<if
test=
"nickname != null"
>
, nickname = #{nickname}
</if>
<if
test=
"age != null"
>
, age = #{age}
</if>
where id = #{id}
</update>
<delete
id=
"delete"
>
delete from user where id = #{id}
</delete>
</mapper>
</mapper>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录