• Magic-Club开发--第十六天


    一、今日完成

      1.完成我的申请API接口开发与前端对接。

      

      加入社团申请          我的申请列表        数据库apply表单

      2.活动列表API开发。(暂未与前端对接)

        SQL查询代码:  

        <select id="getActivityList" resultType="com.example.demo.domin.Activity">
            select * from magic_club.activity
        </select>
        <select id="getActivityListByKeys" parameterType="java.lang.String" resultType="com.example.demo.domin.Activity">
            select * from magic_club.activity where `name` like #{keys};
        </select>
        <select id="getMyJoinList" parameterType="java.lang.String" resultType="com.example.demo.domin.Activity">
            select * from magic_club.activity as a natural join magic_club.activitypaticipants as b where userOpenid = #{openid} and a.activityId=b.activityId
        </select>
        <select id="getMyPublishList" parameterType="java.lang.String" resultType="com.example.demo.domin.Activity">
            SELECT * FROM magic_club.activity where creatorAssociationName in (select associationName from association where creatorOpenid=#{openid});
        </select>

    二、明日计划

      1.完成活动API前端对接工作。

      2.完成队友前端未完成界面。

    三、个人小结

      今日在开发我的申请API时,使用了多表查询,代码如下:  

        <select id="getMyApplyList" resultType="com.example.demo.domin.Apply" parameterType="java.lang.String">
            SELECT * FROM magic_club.apply
          natural join
          (select realName as creatorName,openid as creatorOpenid from `user`)as `person`
          natural join
          (select associationName,associationId,iconPath,creatorOpenid from association)as ass
          where apply.associationId=ass.associationId and ass.creatorOpenid=person.creatorOpenid and apply.applyOpenid=#{applyOpenid};
        </select>

      之前在搭建Spring框架时,所有的SQL语句都为单一实体类对应单一表单操作,在进行多表查询时产生疑惑:是否应该增加实体类属性?因为插入申请只涉及到apply表单操作(详见昨日博客),两个SQL语句使用相同实体类(想到了拆分为两个实体类,但是为了节约文件资源,做出了尝试),若增加属性,在插入操作时,会产生很多属性为空值。

      思考不如行动,我决定进行测试,测试结果并没有报错。由此引发思考,实体类仅为对象参数的承载,实体类仅仅规定了接受最大参数个数与类型,并不规定最少个数,仅在SQL调用参数时检查其属性值。

      附spring后端目录:

      

  • 相关阅读:
    一次与客户端合作的走坑之旅!
    ecplise打不开提示Eclipse中...No java virtual machine was found...
    eclipse配置tomcat,让java web项目运行起来!
    Tomcat v9.0 Could not publish to the server. java.lang.IndexOutOfBoundsException
    Certbot让网站拥有免费https证书
    Nginx访问权限配置
    hexo博客pure主题解决不蒜子计数不显示的问题
    Mono.Cecil 修改目标.NET的IL代码保存时报异常的处理。
    [转载]斐讯K2 A2版免TTL刷BREED不死Bootloader
    各种UserAgent的列表
  • 原文地址:https://www.cnblogs.com/ljq1313/p/11454783.html
Copyright © 2020-2023  润新知