|
|
<?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.campus.mapper.CampusMapper">
|
|
|
|
|
|
|
|
|
<!--用户信息-->
|
|
|
<resultMap id="user_List" type="User">
|
|
|
<id column="username" property="username"/>
|
|
|
<result column="password" property="password"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<!--查询用户-->
|
|
|
<select id="userLogin" resultMap="user_List" parameterType="User">
|
|
|
select
|
|
|
*
|
|
|
from user where username = #{username} and password = #{password}
|
|
|
<!--where>
|
|
|
<if test="username != null"> and username = #{username}</if>
|
|
|
<if test="passwork != null"> and passwork = #{passwork}</if>
|
|
|
</where-->
|
|
|
</select>
|
|
|
|
|
|
|
|
|
<!--用户注册-->
|
|
|
<insert id="newUser" parameterType="User">
|
|
|
insert into user value
|
|
|
(#{username},#{password})
|
|
|
</insert>
|
|
|
|
|
|
<!--用户密码更新-->
|
|
|
<update id="userUpdate" parameterType="User">
|
|
|
update user set password = #{password} where username=#{username}
|
|
|
</update>
|
|
|
|
|
|
|
|
|
<!--物品信息-->
|
|
|
<resultMap id="goods_List" type="Goods">
|
|
|
<id column="gid" property="gid"/>
|
|
|
<result column="username" property="username"/>
|
|
|
<result column="type" property="type"/>
|
|
|
<result column="price" property="price"/>
|
|
|
<result column="img" property="img"/>
|
|
|
<result column="commit" property="commit"/>
|
|
|
<result column="phone" property="phone"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<!--查找物品-->
|
|
|
<select id="goodsSelect" resultMap="goods_List" parameterType="Goods">
|
|
|
select * from goods
|
|
|
<where>
|
|
|
<if test="type != null">and type=#{type}</if>
|
|
|
<if test="gid != 0">and gid =#{gid}</if>
|
|
|
<if test="username != null">and username=#{username}</if>
|
|
|
</where>
|
|
|
order by gid desc
|
|
|
</select>
|
|
|
|
|
|
<!--物品信息更新-->
|
|
|
<update id="goodsUpdate" parameterType="Goods">
|
|
|
update goods
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
<if test="type != null">type=#{type},</if>
|
|
|
<if test="img != null">img=#{img},</if>
|
|
|
<if test="price != null">price=#{price},</if>
|
|
|
<if test="commit != null">commit =#{commit},</if>
|
|
|
<if test="phone != null">phone =#{phone}</if>
|
|
|
</trim>
|
|
|
where gid=#{gid}
|
|
|
</update>
|
|
|
|
|
|
<!--删除物品-->
|
|
|
<delete id="goodsDelete" parameterType="Goods">
|
|
|
delete from goods where gid=#{gid}
|
|
|
</delete>
|
|
|
|
|
|
<!--新增物品记录-->
|
|
|
<!--useGeneratedKeys="true"对应自增字段,keyProperty="id" 对应自己定义的类属性 ,keyColumn="id" 对应数据库表字段-->
|
|
|
<insert id="goodsInter" parameterType="Goods" useGeneratedKeys="true" keyProperty="gid" keyColumn="gid">
|
|
|
insert into goods values
|
|
|
(#{username},#{price},#{type},#{commit},#{img},#{gid},#{phone})
|
|
|
</insert>
|
|
|
|
|
|
</mapper>
|