Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
beauty_ssm
提交
8f1e40de
B
beauty_ssm
项目概览
爱吃血肠
/
beauty_ssm
通知
9
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beauty_ssm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8f1e40de
编写于
3月 04, 2018
作者:
爱吃血肠
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
引入普通用户的实体类 dao service
上级
012c9c1c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
377 addition
and
17 deletion
+377
-17
src/main/java/com/yingjun/ssm/dao/TUserDao.java
src/main/java/com/yingjun/ssm/dao/TUserDao.java
+63
-0
src/main/java/com/yingjun/ssm/entity/TUser.java
src/main/java/com/yingjun/ssm/entity/TUser.java
+49
-0
src/main/java/com/yingjun/ssm/service/TUserService.java
src/main/java/com/yingjun/ssm/service/TUserService.java
+63
-0
src/main/java/com/yingjun/ssm/service/impl/TUserServiceImpl.java
...n/java/com/yingjun/ssm/service/impl/TUserServiceImpl.java
+61
-0
src/main/java/com/yingjun/ssm/web/UserController.java
src/main/java/com/yingjun/ssm/web/UserController.java
+1
-1
src/main/resources/mapper/TUserMapper.xml
src/main/resources/mapper/TUserMapper.xml
+116
-0
src/main/webapp/WEB-INF/jsp/user/userLogin.jsp
src/main/webapp/WEB-INF/jsp/user/userLogin.jsp
+24
-16
未找到文件。
src/main/java/com/yingjun/ssm/dao/TUserDao.java
0 → 100644
浏览文件 @
8f1e40de
package
com.yingjun.ssm.dao
;
import
com.yingjun.ssm.entity.TUser
;
import
java.util.List
;
public
interface
TUserDao
{
/**
* 获得TUser数据的总行数
* @return
*/
long
getTUserRowCount
();
/**
* 获得TUser数据集合
* @return
*/
List
<
TUser
>
selectTUser
();
/**
* 获得一个TUser对象,以参数TUser对象中不为空的属性作为条件进行查询
* @param obj
* @return
*/
TUser
selectTUserByObj
(
TUser
obj
);
/**
* 通过TUser的id获得TUser对象
* @param id
* @return
*/
TUser
selectTUserById
(
Long
id
);
/**
* 插入TUser到数据库,包括null值
* @param value
* @return
*/
int
insertTUser
(
TUser
value
);
/**
* 插入TUser中属性值不为null的数据到数据库
* @param value
* @return
*/
int
insertNonEmptyTUser
(
TUser
value
);
/**
* 批量插入TUser到数据库,包括null值
* @param value
* @return
*/
int
insertTUserByBatch
(
List
<
TUser
>
value
);
/**
* 通过TUser的id删除TUser
* @param id
* @return
*/
int
deleteTUserById
(
Long
id
);
/**
* 通过TUser的id更新TUser中的数据,包括null值
* @param enti
* @return
*/
int
updateTUserById
(
TUser
enti
);
/**
* 通过TUser的id更新TUser中属性不为null的数据
* @param enti
* @return
*/
int
updateNonEmptyTUserById
(
TUser
enti
);
}
\ No newline at end of file
src/main/java/com/yingjun/ssm/entity/TUser.java
0 → 100644
浏览文件 @
8f1e40de
package
com.yingjun.ssm.entity
;
public
class
TUser
{
private
Long
id
;
//主键id
private
String
password
;
//密码
private
String
name
;
//姓名
private
String
email
;
//手机号码
public
TUser
()
{
super
();
}
public
TUser
(
Long
id
,
String
password
,
String
name
,
String
email
)
{
super
();
this
.
id
=
id
;
this
.
password
=
password
;
this
.
name
=
name
;
this
.
email
=
email
;
}
public
Long
getId
()
{
return
this
.
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getPassword
()
{
return
this
.
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getName
()
{
return
this
.
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getEmail
()
{
return
this
.
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
src/main/java/com/yingjun/ssm/service/TUserService.java
0 → 100644
浏览文件 @
8f1e40de
package
com.yingjun.ssm.service
;
import
java.util.List
;
import
com.yingjun.ssm.entity.TUser
;
public
interface
TUserService
{
/**
* 获得TUser数据的总行数
* @return
*/
long
getTUserRowCount
();
/**
* 获得TUser数据集合
* @return
*/
List
<
TUser
>
selectTUser
();
/**
* 获得一个TUser对象,以参数TUser对象中不为空的属性作为条件进行查询
* @param obj
* @return
*/
TUser
selectTUserByObj
(
TUser
obj
);
/**
* 通过TUser的id获得TUser对象
* @param id
* @return
*/
TUser
selectTUserById
(
Long
id
);
/**
* 插入TUser到数据库,包括null值
* @param value
* @return
*/
int
insertTUser
(
TUser
value
);
/**
* 插入TUser中属性值不为null的数据到数据库
* @param value
* @return
*/
int
insertNonEmptyTUser
(
TUser
value
);
/**
* 批量插入TUser到数据库
* @param value
* @return
*/
int
insertTUserByBatch
(
List
<
TUser
>
value
);
/**
* 通过TUser的id删除TUser
* @param id
* @return
*/
int
deleteTUserById
(
Long
id
);
/**
* 通过TUser的id更新TUser中的数据,包括null值
* @param enti
* @return
*/
int
updateTUserById
(
TUser
enti
);
/**
* 通过TUser的id更新TUser中属性不为null的数据
* @param enti
* @return
*/
int
updateNonEmptyTUserById
(
TUser
enti
);
}
\ No newline at end of file
src/main/java/com/yingjun/ssm/service/impl/TUserServiceImpl.java
0 → 100644
浏览文件 @
8f1e40de
package
com.yingjun.ssm.service.impl
;
import
java.util.List
;
import
com.yingjun.ssm.dao.TUserDao
;
import
com.yingjun.ssm.entity.TUser
;
import
com.yingjun.ssm.service.TUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
TUserServiceImpl
implements
TUserService
{
@Autowired
private
TUserDao
tUserDao
;
@Override
public
long
getTUserRowCount
(){
return
tUserDao
.
getTUserRowCount
();
}
@Override
public
List
<
TUser
>
selectTUser
(){
return
tUserDao
.
selectTUser
();
}
@Override
public
TUser
selectTUserByObj
(
TUser
obj
){
return
tUserDao
.
selectTUserByObj
(
obj
);
}
@Override
public
TUser
selectTUserById
(
Long
id
){
return
tUserDao
.
selectTUserById
(
id
);
}
@Override
public
int
insertTUser
(
TUser
value
){
return
tUserDao
.
insertTUser
(
value
);
}
@Override
public
int
insertNonEmptyTUser
(
TUser
value
){
return
tUserDao
.
insertNonEmptyTUser
(
value
);
}
@Override
public
int
insertTUserByBatch
(
List
<
TUser
>
value
){
return
tUserDao
.
insertTUserByBatch
(
value
);
}
@Override
public
int
deleteTUserById
(
Long
id
){
return
tUserDao
.
deleteTUserById
(
id
);
}
@Override
public
int
updateTUserById
(
TUser
enti
){
return
tUserDao
.
updateTUserById
(
enti
);
}
@Override
public
int
updateNonEmptyTUserById
(
TUser
enti
){
return
tUserDao
.
updateNonEmptyTUserById
(
enti
);
}
public
TUserDao
getTUserDao
()
{
return
this
.
tUserDao
;
}
public
void
setTUserDao
(
TUserDao
tUserDao
)
{
this
.
tUserDao
=
tUserDao
;
}
}
\ No newline at end of file
src/main/java/com/yingjun/ssm/web/UserController.java
浏览文件 @
8f1e40de
...
...
@@ -23,7 +23,7 @@ public class UserController {
* 用户登录
* @return
*/
@RequestMapping
(
value
=
"/userLogin"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/userLogin"
)
public
String
userLogin
()
{
LOG
.
info
(
"用户登录"
);
return
"/user/userLogin"
;
...
...
src/main/resources/mapper/TUserMapper.xml
0 → 100644
浏览文件 @
8f1e40de
<?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=
"com.yingjun.ssm.dao.TUserDao"
>
<!-- TUser的resultMap,column是给数据库列起的别名,它对应property类的属性-->
<resultMap
id=
"result_TUser_Map"
type=
"com.yingjun.ssm.entity.TUser"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"password"
property=
"password"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"email"
property=
"email"
/>
</resultMap>
<!-- 数据库中表名为:t_user的列名,as前是数据库的列明,as后是列的别名用于映射成实体类中的属性,需要注意的是别名必须与resultMap中的column别名一致 -->
<sql
id=
"t_user_Column"
>
t_user.id as id
,t_user.password as password
,t_user.name as name
,t_user.email as email
</sql>
<!--获得类名为:TUser对应的数据库表的数据总行数 -->
<select
id=
"getTUserRowCount"
resultType=
"java.lang.Long"
>
select count(id) from t_user
</select>
<!-- 获得类名为:TUser对应数据库中表的数据集合 -->
<select
id=
"selectTUser"
resultMap=
"result_TUser_Map"
>
select
<include
refid=
"t_user_Column"
/>
from t_user
</select>
<!-- 获得一个TUser对象,以参数TUser对象中不为空的属性作为条件进行查询-->
<select
id=
"selectTUserByObj"
parameterType=
"com.yingjun.ssm.entity.TUser"
resultMap=
"result_TUser_Map"
>
select
<include
refid=
"t_user_Column"
/>
from t_user
<where>
<if
test=
"email != null "
>
and t_user.email = #{email}
</if>
<if
test=
"name != null "
>
and t_user.name = #{name}
</if>
<if
test=
"password != null "
>
and t_user.password = #{password}
</if>
<if
test=
"id != null "
>
and t_user.id = #{id}
</if>
</where>
</select>
<!-- 通过TUser的id获得对应数据库中表的数据对象-->
<select
id=
"selectTUserById"
parameterType=
"java.lang.Long"
resultMap=
"result_TUser_Map"
>
select
<include
refid=
"t_user_Column"
/>
from t_user
where t_user.id = #{id}
</select>
<!-- 将TUser插入到对应数据库的表中,包括属性值为null的数据-->
<insert
id=
"insertTUser"
parameterType=
"com.yingjun.ssm.entity.TUser"
>
insert into t_user(id,password,name,email)
values(#{id},#{password},#{name},#{email})
</insert>
<!-- 将TUser中属性值不为null的数据,插入到对应数据库的表中-->
<insert
id=
"insertNonEmptyTUser"
parameterType=
"com.yingjun.ssm.entity.TUser"
>
insert into t_user
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"password != null"
>
password,
</if>
<if
test=
"name != null"
>
name,
</if>
<if
test=
"email != null"
>
email,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id},
</if>
<if
test=
"password != null"
>
#{password},
</if>
<if
test=
"name != null"
>
#{name},
</if>
<if
test=
"email != null"
>
#{email},
</if>
</trim>
</insert>
<!-- 将TUser批量插入到对应数据库的表中-->
<insert
id=
"insertTUserByBatch"
parameterType=
"ArrayList"
>
insert into t_user(id,password,name,email) values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.id},#{item.password},#{item.name},#{item.email})
</foreach>
</insert>
<!-- 通过TUser的id将数据库表中对应的数据删除-->
<delete
id=
"deleteTUserById"
parameterType=
"java.lang.Long"
>
delete from t_user
where id = #{id}
</delete>
<!-- 通过TUser的id将TUser的数据更新到数据库中对应的表,包括值null的数据-->
<update
id=
"updateTUserById"
parameterType=
"com.yingjun.ssm.entity.TUser"
>
update t_user set
password=#{password}
,name=#{name}
,email=#{email}
where id=#{id}
</update>
<!-- 通过TUser的id将TUser中属性值不为null的数据更新到数据库对应的表中-->
<update
id=
"updateNonEmptyTUserById"
parameterType=
"com.yingjun.ssm.entity.TUser"
>
update t_user
<set>
<if
test=
"password != null"
>
password=#{password},
</if>
<if
test=
"name != null"
>
name=#{name},
</if>
<if
test=
"email != null"
>
email=#{email},
</if>
</set>
where id=#{id}
</update>
</mapper>
\ No newline at end of file
src/main/webapp/WEB-INF/jsp/user/userLogin.jsp
浏览文件 @
8f1e40de
...
...
@@ -40,23 +40,25 @@
<div
class=
"header"
>
<h3>
用户登录
</h3>
</div>
<div
class=
"detail"
>
<ul>
<li>
<input
class=
"input telNum"
type=
"text"
name=
""
id=
""
value=
""
placeholder=
"请输入电话号码"
/>
</li>
<li>
<input
class=
"input pwd"
type=
"password"
name=
""
id=
"pwd"
value=
""
placeholder=
"请输入密码"
/>
</li>
</ul>
<div
class=
"forgatPwd"
>
<a
href=
"userResgiter.jsp"
>
新用户注册
</a>
<a
href=
"findPwd.html"
>
忘记密码
</a>
<form
id=
"userLogin"
action=
"/user/userLogin"
method=
"post"
>
<div
class=
"detail"
>
<ul>
<li>
<input
class=
"input telNum"
type=
"text"
name=
""
id=
""
value=
""
placeholder=
"请输入邮箱"
/>
</li>
<li>
<input
class=
"input pwd"
type=
"password"
name=
""
id=
"pwd"
value=
""
placeholder=
"请输入密码"
/>
</li>
</ul>
<div
class=
"forgatPwd"
>
<a
href=
"userResgiter.jsp"
>
新用户注册
</a>
<a
href=
"findPwd.html"
>
忘记密码
</a>
</div>
<div
id=
"loginBtn"
class=
"myBtn mar-t-30"
style=
""
>
<a>
立即登录
</a>
</div>
</div>
<div
class=
"myBtn mar-t-30"
style=
""
>
<a
href=
"javascript:login()"
>
立即登录
</a>
</div>
</div>
</form>
</div>
</div>
...
...
@@ -80,4 +82,10 @@
</div>
</footer>
</body>
<script>
//用户登录
$
(
'
#loginBtn
'
).
bind
(
"
click
"
,
function
(){
$
(
'
#userLogin
'
).
submit
();
});
</script>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录