基于ssm+vue的综合项目 健康体检管理系统-第六章---移动端体检预约

移动端开发对体检预约进行的查询

在这里插入图片描述
在这里插入图片描述

  • 当页面加载完毕时,利用vue的钩子函数
  • 已加载页面就直接查询数据将数据进行渲染
created() {
            axios.post("/setmeal/getSetmeal.do").then((response) => {
                if (response.data.flag) {
                    this.setmealList = response.data.data;
                } else {
                    this.$message.error(response.data.message);
                }
            });
        }

在这里插入图片描述

根据套餐查询套餐信息和检查组、检查项的信息

  • 点击套餐前台进行js截取id以及传递的参数传递给后台
  • 后台接受到数据就进行查询
  • 由于传递到后台的只有一个id
  • 这里需要多表查询需要使用到mybatis的高级特性
    /**
     * 查询套餐的基础信息
     * @param id 套餐的id
     * @return 套餐实体类
     */
    Setmeal findAssociationById(Integer id);
    <!--查询套餐的基础信息-->
    <resultMap id="SetmealResultMap" type="com.itheima.pojo.Setmeal">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="code" property="code"/>
        <result column="helpCode" property="helpCode"/>
        <result column="sex" property="sex"/>
        <result column="age" property="age"/>
        <result column="price" property="price"/>
        <result column="remark" property="remark"/>
        <result column="attention" property="attention"/>
        <result column="img" property="img"/>
    </resultMap>
    <resultMap id="findByIdResult" type="com.itheima.pojo.Setmeal" extends="SetmealResultMap">
        <collection
                property="checkGroups"
                ofType="com.itheima.pojo.CheckGroup"
                javaType="java.util.List"
                column="id"
                select="com.itheima.dao.CheckgroupDao.findCheckgroupBySetmealId"/>
    </resultMap>
    <select id="findAssociationById" resultMap="findByIdResult">
        select id,
               name,
               code,
               helpCode,
               sex,
               age,
               price,
               remark,
               attention,
               img
        from t_setmeal where id=#{id}
    </select>
  • select * from t_setmeal

  • 查询套餐的基础信息,将查询出来的结果的id
    在这里插入图片描述

  • 传递到CheckgroupDao的findCheckgroupBySetmealId

  • CheckGroup findCheckgroupBySetmealId(Integer id);

  <!--根据套餐的id查询检查组的对应的id的信息-->
    <resultMap id="CheckgroupResult" type="com.itheima.pojo.CheckGroup">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="name" property="name"/>
        <result column="helpCode" property="helpCode"/>
        <result column="sex" property="sex"/>
        <result column="remark" property="remark"/>
        <result column="attention" property="attention"/>
    </resultMap>
    <resultMap id="findCheckgroupById" type="com.itheima.pojo.CheckGroup" extends="CheckgroupResult">
        <collection
                property="checkItems"
                javaType="java.util.List"
                ofType="com.itheima.pojo.CheckItem"
                column="id"
                select="com.itheima.dao.CheckItemDao.findCheckitemByCheckgroup"/>
    </resultMap>
    <select id="findCheckgroupBySetmealId" resultMap="findCheckgroupById">
        select id, code, name, helpCode, sex, remark, attention
        from t_checkgroup
        where id in (select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id})
    </select>
  • 根据套餐的id查询套餐和检查组的中间表的检查组的id
  • 然后在根据检查组的id查询检查组的信息
  • SELECT * FROM t_checkgroup WHERE id in(SELECT checkgroup_id FROM t_setmeal_checkgroup where setmeal_id=12)
    在这里插入图片描述
  • 再将查询出来的id带到检查项去查询检查项的信息
    <!--根据检查组的id查询检查项信息-->
    <select id="findCheckitemByCheckgroup" resultType="com.itheima.pojo.CheckItem">
        select id,
               code,
               name,
               sex,
               age,
               price,
               type,
               attention,
               remark
        from t_checkitem
        where id in (select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id})
    </select>

在这里插入图片描述

Freemarker入门案例

 @Test
    public void test1() throws Exception {
        /*
        1.创建freemarker的配置
        Freemarker为了兼容不同版本,使用配置类的构造方法来创建不同的运行环境2.3.23
         */
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);

        /*
        2.对配置进行配置  (配置模板的指定目录,使用类加载器获取ftl目录的路径)
         */
        String ftlDirectory = FreemarkerTest.class.getResource("/ftl/").getPath();

        //3.设置模板所在的目录
        configuration.setDirectoryForTemplateLoading(new File(ftlDirectory));

        //4.配置模板文件的默认字符集
        configuration.setDefaultEncoding("utf-8");

        //5.获取指定模板文件的对象
        Template template = configuration.getTemplate("freemarkertest.ftl");

        //6.构建出数据模型
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "kobe");
        map.put("address", "beijing");

        //7.生成静态化文件
        FileWriter fileWriter = new FileWriter("d:/index.html");
        template.process(map, fileWriter);

        //释放资源
        fileWriter.close();
    }
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>freemarker入门案例</title>
</head>
<body>
你好${name},欢迎来到${address}。
</body>
</html>
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值