<?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="cn.smbms.dao.UserDao">
    <!--  登录-->
    <select id="findUser" parameterType="String" resultType="cn.smbms.pojo.User">
    		select *
	        from user
	        where userName=#{userName}
	        and userPassword =#{userPassword}
    </select>

	<!--判断管理员是否存在-->
	<select id="findUsersByUsername" resultType="cn.smbms.pojo.User">
			select * from user
			where userName=#{userName}
	</select>

	<!--修改密码-->
	<update id="updateUser" parameterType="cn.smbms.pojo.User" >
		update user set userPassword=#{userPassword} where userName=#{userName}
	</update>

</mapper>


<?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="cn.smbms.dao.MuseumDao">
    <!--查询所有 博物馆-->
    <select id="selectAllMuseum"  resultType="cn.smbms.pojo.Museum">
    		select * from museum
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.Museum">
        select * from  museum where museumId=#{museumId}
    </select>

    <!--更新-->
    <update id="updMuseumById" parameterType="cn.smbms.pojo.Museum">
    update museum set museumName=#{museumName} where museumId=#{museumId}
    </update>


    <!--新增-->
    <insert id="insertMuseum" parameterType="cn.smbms.pojo.Museum">
        INSERT INTO museum(museumName)
        VALUES (#{museumName})
    </insert>

</mapper>


<?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="cn.smbms.dao.CraftsDao">
    <!--查询所有 工艺品-->
    <select id="selectAllCrafts"  resultType="cn.smbms.pojo.Crafts">
    		select * from crafts
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.Crafts">
        select * from  crafts where craftsId=#{craftsId}
    </select>

    <!--更新-->
    <update id="updCraftsById" parameterType="cn.smbms.pojo.Crafts">
    update crafts set craftsName=#{craftsName},craftsAuthor=#{craftsAuthor},museumId=#{museumId} where craftsId=#{craftsId}
    </update>


    <!--新增-->
    <insert id="insertCrafts" parameterType="cn.smbms.pojo.Crafts">
        INSERT INTO crafts(craftsName,craftsAuthor,museumId)
        VALUES (#{craftsName},#{craftsAuthor},#{museumId})
    </insert>

</mapper>


<?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="cn.smbms.dao.AppointmentDao">
    <!-- 查询所有 预约-->
    <select id="selectAllAppointment"  resultType="cn.smbms.pojo.Appointment">
    		select * from appointment
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.Appointment">
        select * from  appointment where appointmentId=#{appointmentId}
    </select>

    <!--更新-->
    <update id="updAppointmentById" parameterType="cn.smbms.pojo.Appointment">
    update appointment set appointmentTime=#{appointmentTime},userId=#{userId},museumId=#{museumId} where appointmentId=#{appointmentId}
    </update>


    <!--新增-->
    <insert id="insertAppointment" parameterType="cn.smbms.pojo.Appointment">
        INSERT INTO appointment(appointmentTime,userId,museumId)
        VALUES (#{appointmentTime},#{userId},#{museumId})
    </insert>

</mapper>


<?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="cn.smbms.dao.CollectMuseumDao">
    <!-- 查询所有 收藏博物馆-->
    <select id="selectAllCollectMuseum"  resultType="cn.smbms.pojo.CollectMuseum">
    		select * from collect_museum
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.CollectMuseum">
        select * from  collect_museum where collectId=#{collectId}
    </select>

    <!--更新-->
    <update id="updCollectMuseumById" parameterType="cn.smbms.pojo.CollectMuseum">
    update collect_museum set collectTime=#{collectTime},userId=#{userId},museumId=#{museumId} where collectId=#{collectId}
    </update>


    <!--新增-->
    <insert id="insertCollectMuseum" parameterType="cn.smbms.pojo.CollectMuseum">
        INSERT INTO collect_museum(collectTime,userId,museumId)
        VALUES (#{collectTime},#{userId},#{museumId})
    </insert>

</mapper>


<?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="cn.smbms.dao.CollectCraftsDao">
    <!-- 查询所有 收藏工艺品-->
    <select id="selectAllCollectCrafts"  resultType="cn.smbms.pojo.CollectCrafts">
    		select * from collect_crafts
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.CollectCrafts">
        select * from  collect_crafts where collectId=#{collectId}
    </select>

    <!--更新-->
    <update id="updCollectCraftsById" parameterType="cn.smbms.pojo.CollectCrafts">
    update collect_crafts set collectTime=#{collectTime},userId=#{userId},craftsId=#{craftsId} where collectId=#{collectId}
    </update>


    <!--新增-->
    <insert id="insertCollectCrafts" parameterType="cn.smbms.pojo.CollectCrafts">
        INSERT INTO collect_crafts(collectTime,userId,craftsId)
        VALUES (#{collectTime},#{userId},#{craftsId})
    </insert>

</mapper>


<?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="cn.smbms.dao.BrowseMuseumDao">
    <!-- 查询所有 浏览博物馆记录-->
    <select id="selectAllBrowseMuseum"  resultType="cn.smbms.pojo.BrowseMuseum">
    		select * from browse_museum
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.BrowseMuseum">
        select * from  browse_museum where browseId=#{browseId}
    </select>

    <!--更新-->
    <update id="updBrowseMuseumById" parameterType="cn.smbms.pojo.BrowseMuseum">
    update browse_museum set browseTime=#{browseTime},userId=#{userId},museumId=#{museumId} where browseId=#{browseId}
    </update>


    <!--新增-->
    <insert id="insertBrowseMuseum" parameterType="cn.smbms.pojo.BrowseMuseum">
        INSERT INTO browse_museum(browseTime,userId,museumId)
        VALUES (#{browseTime},#{userId},#{museumId})
    </insert>

</mapper>


<?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="cn.smbms.dao.BrowseCraftsDao">
    <!-- 查询所有 浏览工艺品记录-->
    <select id="selectAllBrowseCrafts"  resultType="cn.smbms.pojo.BrowseCrafts">
    		select * from browse_crafts
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.BrowseCrafts">
        select * from  browse_crafts where browseId=#{browseId}
    </select>

    <!--更新-->
    <update id="updBrowseCraftsById" parameterType="cn.smbms.pojo.BrowseCrafts">
    update browse_crafts set browseTime=#{browseTime},userId=#{userId},craftsId=#{craftsId} where browseId=#{browseId}
    </update>


    <!--新增-->
    <insert id="insertBrowseCrafts" parameterType="cn.smbms.pojo.BrowseCrafts">
        INSERT INTO browse_crafts(browseTime,userId,craftsId)
        VALUES (#{browseTime},#{userId},#{craftsId})
    </insert>

</mapper>


<?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="cn.smbms.dao.CommentMuseumDao">
    <!-- 查询所有 评论博物馆记录-->
    <select id="selectAllCommentMuseum"  resultType="cn.smbms.pojo.CommentMuseum">
    		select * from comment_museum
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.CommentMuseum">
        select * from  comment_museum where commentId=#{commentId}
    </select>

    <!--更新-->
    <update id="updCommentMuseumById" parameterType="cn.smbms.pojo.CommentMuseum">
    update comment_museum set commentContent=#{commentContent},commentTime=#{commentTime},userId=#{userId},museumId=#{museumId} where commentId=#{commentId}
    </update>


    <!--新增-->
    <insert id="insertCommentMuseum" parameterType="cn.smbms.pojo.CommentMuseum">
        INSERT INTO comment_museum(commentContent,commentTime,userId,museumId)
        VALUES (#{commentContent},#{commentTime},#{userId},#{museumId})
    </insert>

</mapper>


<?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="cn.smbms.dao.CommentCraftsDao">
    <!-- 查询所有 评论工艺品记录-->
    <select id="selectAllCommentCrafts"  resultType="cn.smbms.pojo.CommentCrafts">
    		select * from comment_crafts
    </select>

    <!--id查询-->
    <select id="selectById" resultType="cn.smbms.pojo.CommentCrafts">
        select * from  comment_crafts where commentId=#{commentId}
    </select>

    <!--更新-->
    <update id="updCommentCraftsById" parameterType="cn.smbms.pojo.CommentCrafts">
    update comment_crafts set commentContent=#{commentContent},commentTime=#{commentTime},userId=#{userId},craftsId=#{craftsId} where commentId=#{commentId}
    </update>


    <!--新增-->
    <insert id="insertCommentCrafts" parameterType="cn.smbms.pojo.CommentCrafts">
        INSERT INTO comment_crafts(commentContent,commentTime,userId,craftsId)
        VALUES (#{commentContent},#{commentTime},#{userId},#{craftsId})
    </insert>

</mapper>

数据库逻辑设计如下:

用户表(user):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | ------------ | -------- | ---- | ---- | ---- | ---- | -------- | | userId | INT | 是 | 是 | 是 | | 用户ID | | userName | VARCHAR | | | 是 | | 用户名 | | userPassword | VARCHAR | | | 是 | | 用户密码 |

博物馆表(museum):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | ---------- | -------- | ---- | ---- | ---- | ---- | -------- | | museumId | INT | 是 | 是 | 是 | | 博物馆ID | | museumName | VARCHAR | | | 是 | | 博物馆名 |

工艺品表(crafts):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | ------------ | -------- | ---- | ---- | ---- | ------- | ---------- | | craftsId | INT | 是 | 是 | 是 | | 工艺品ID | | craftsName | VARCHAR | | | 是 | | 工艺品名 | | craftsAuthor | VARCHAR | | | | | 工艺品作者 | | museumId | INT | | | 是 | museum | 所属博物馆 |

管理员表(admin):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | ------------ | -------- | ---- | ---- | ---- | ---- | -------- | | adminId | INT | 是 | 是 | 是 | | 管理员ID | | adminName | VARCHAR | | | 是 | | 管理员名 | | adminPwd | VARCHAR | | | 是 | | 管理员密码 | | adminContact | VARCHAR | | | | | 管理员联系方式 |

预约表(appointment):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | -------------- | -------- | ---- | ---- | ---- | ---------- | ------------ | | appointmentId | INT | 是 | 是 | 是 | | 预约ID | | appointmentTime| DATETIME | | | 是 | | 预约时间 | | userId | INT | | | 是 | user | 预约用户ID | | museumId | INT | | | 是 | museum | 预约博物馆ID |

收藏博物馆表(collect_museum):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | ----------- | -------- | ---- | ---- | ---- | ------- | -------------- | | collectId | INT | 是 | 是 | 是 | | 收藏ID | | collectTime | DATETIME | | | 是 | | 收藏时间 | | userId | INT | | | 是 | user | 收藏用户ID | | museumId | INT | | | 是 | museum | 收藏博物馆ID |

收藏工艺品表(collect_crafts):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | ----------- | -------- | ---- | ---- | ---- | ------- | -------------- | | collectId | INT | 是 | 是 | 是 | | 收藏ID | | collectTime | DATETIME | | | 是 | | 收藏时间 | | userId | INT | | | 是 | user | 收藏用户ID | | craftsId | INT | | | 是 | crafts | 收藏工艺品ID |

浏览博物馆记录表(browse_museum):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | -------------- | -------- | ---- | ---- | ---- | ------- | -------------- | | browseId | INT | 是 | 是 | 是 | | 浏览ID | | browseTime | DATETIME | | | 是 | | 浏览时间 | | userId | INT | | | 是 | user | 浏览用户ID | | museumId | INT | | | 是 | museum | 浏览博物馆ID |

浏览工艺品记录表(browse_crafts):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | -------------- | -------- | ---- | ---- | ---- | ------- | -------------- | | browseId | INT | 是 | 是 | 是 | | 浏览ID | | browseTime | DATETIME | | | 是 | | 浏览时间 | | userId | INT | | | 是 | user | 浏览用户ID | | craftsId | INT | | | 是 | crafts | 浏览工艺品ID |

评论博物馆记录表(comment_museum):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | -------------- | -------- | ---- | ---- | ---- | ------- | -------------- | | commentId | INT | 是 | 是 | 是 | | 评论ID | | commentContent | VARCHAR | | | 是 | | 评论内容 | | commentTime | DATETIME | | | 是 | | 评论时间 | | userId | INT | | | 是 | user | 评论用户ID | | museumId | INT | | | 是 | museum | 评论博物馆ID |

评论工艺品记录表(comment_crafts):

| 字段名 | 数据类型 | 主键 | 自增 | 非空 | 外键 | 描述 | | -------------- | -------- | ---- | ---- | ---- | ------- | -------------- | | commentId | INT | 是 | 是 | 是 | | 评论ID | | commentContent | VARCHAR | | | 是 | | 评论内容 | | commentTime | DATETIME | | | 是 | | 评论时间 | | userId | INT | | | 是 | user | 评论用户ID | | craftsId | INT | | | 是 | crafts | 评论工艺品ID |

本系统使用MySQL数据库,使用关系数据模型。数据库有用户,博物馆,工艺品三个实体以及管理员这一流程外实体,共有用户,工艺品,博物馆,管理员,预约,收藏博物馆,收藏工艺品,浏览博物馆记录,浏览工艺品记录、评论工艺品记录、评论博物馆记录等11张表。

数据库表之间关系如下:

  • 用户表和预约表之间存在一对多关系,一个用户可以预约多个博物馆
  • 用户表和收藏博物馆表之间存在一对多关系,一个用户可以收藏多个博物馆
  • 用户表和收藏工艺品表之间存在一对多关系,一个用户可以收藏多个工艺品
  • 用户表和浏览博物馆记录表之间存在一对多关系,一个用户可以浏览多个博物馆
  • 用户表和浏览工艺品记录表之间存在一对多关系,一个用户可以浏览多个工艺品
  • 用户表和评论博物馆记录表之间存在一对多关系,一个用户可以评论多个博物馆
  • 用户表和评论工艺品记录表之间存在一对多关系,一个用户可以评论多个工艺品
  • 博物馆表和预约表之间存在一对多关系,一个博物馆可以被多个用户预约
  • 博物馆表和收藏博物馆表之间存在一对多关系,一个博物馆可以被多个用户收藏
  • 博物馆表和浏览博物馆记录表之间存在一对多关系,一个博物馆可以被多个用户浏览
  • 博物馆表和评论博物馆记录表之间存在一对多关系,一个博物馆可以被多个用户评论
  • 工艺品表和收藏工艺品表之间存在一对多关系,一个工艺品可以被多个用户收藏
  • 工艺品表和浏览工艺品记录表之间存在一对多关系,一个工艺品可以被多个用户浏览
  • 工艺品表和评论工艺品记录表之间存在一对多关系,一个工艺品可以被多个用户评论

以上是 MyBatis 映射文件示例和数据库逻辑设计,您可以根据自己的需求进行修改和扩展。

MyBatis 映射文件示例:用户管理、博物馆管理和工艺品管理

原文地址: https://www.cveoy.top/t/topic/lBpp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录