您的位置:首页 > 编程语言 > Java开发

(程序人生)小白第一周工作总结。2018-3-17

2018-03-17 17:14 591 查看
        今天是自学转行做java工程师的第一周,非科班转这行确实不容易,工作也是不要工资找的一份实习,希望自己能坚持下去,不要白费了几个月的自学时间。以后每周写一篇工作总结,记录下自己工作的点滴,也祝福自己能越走越好!
        这周刚以实习生的身份进入公司,公司未分配实际项目,只是了解了下公司目前做的项目和框架,之后我要接触的项目是基于jeesite框架的,它是前辈结合了springboot、mybatis、shiro等开发出的快速开发平台。我是官网下了源码,是maven工程的,导入eclipse后启动项目就可以登录127.0.0.1:8080/的后台管理页面(端口我们自己一般都是设置的8080,具体教程官网查看)。我们可以在jeesite框架生成的jeesite数据库中导入自己的数据库,导入的数据表必须添加create_by update_by create_date update_date 字段。然后在后台管理页面的代码生成菜单中选中我们的数据表按步骤设置好字段等等信息,点保存并生成代码就可以了。它会在jeesite-web层给我们生成java层(放dao, entiy, service, controller),   resource(配置,映射文件,页面文件等),如果生成的路径自己设定的,生成完复制java resource到jeesite-web层。相应的增删改查都生成好了,具体的在修改。

        当给映射文件传入的parameterType是一个String类型的时候xmlsql语句要做修改,比如有句是
select *
from xx
<where>
<if test="id != null">
and id = #{id,jdbcType}
</if>
</where>这里的id不能写Id会报错,当传入的是一个String类型的时候,对应的要写成_parameter,如
select *
from xx
<where>
<if test="_parameter != null">
and id = #{_parameter,jdbcType}
</if>
</where>
!!!注意在mysql语句的拼接过程中我们<if>语句有写and的了,#{}不要写成#{},   多了一个逗号会报错。
如果想要SQL语句那里就想写成id可以在dao层的方法中添加@Param(value=“id”)注解就可以了 ,如public Item xxById(@Param(value="id") String id);另外在映射文件中关于表跟表关联<assosication>标签的用法(感谢同事指点)<resultMap id="BaseResultMap" type="com.jeesite.modules.gjp.entity.GjpLedger" >
<id column="lid" property="lid" jdbcType="INTEGER" />
<result column="parent" property="parent" jdbcType="VARCHAR" />
<result column="money" property="money" jdbcType="DOUBLE" />
<result column="account" property="account" jdbcType="VARCHAR" />
<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
<result column="ldesc" property="ldesc" jdbcType="VARCHAR" />
<result column="create_by" property="createBy" jdbcType="VARCHAR" />
<result column="update_by" property="updateBy" jdbcType="VARCHAR" />
<result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />

<association property="sid" javaType="com.jeesite.modules.gjp.entity.GjpSort">
<id column="sid" property="sid" />
<result column="sname" property="sname"/>
<result column="parent" property="parent"/>
<result column="sdesc" property="sdesc"/>
<result column="create_by" property="createBy"/>
<result column="create_date" property="createDate"/>
<result column="update_by" property="updateBy"/>
<result column="update_date" property="updateDate"/>
</association>
</resultMap>BaseresultMap的是主表,要关联另一张表,首先association后面的第一个property=里要写成主表里的一个关联字段,然后要修改这个字段的类型,比如我这里第一个property写的sid 原先在实体类中的类型是String, 这里因为我的主表的sid要关联副表,所以把类型改成副表的实体类,即GjpSort 类型,还要记得把BaseresultMap里的
<result column="sid" property="sid" jdbcType="VARCHAR" />这句删除了
这样两张表就关联好了!此时我这个主表的sid能接收的是副表(gjp_sort)实体类的所有属性,比如副表里有sid、sname字段 我们只要写sid.sid    sid.sname就能取到值了。
第一周没做什么实质性东西,用jeesite框架自己重新写了下增删改查的方法,做的也比较慢。好好学习,好好学习,好好学习!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java