记录一下,mysql默认值起作用了,只是insert 的时候字段没有判断null或者空,导致默认值被覆盖,改为如下添加
<insert id="save" parameterType="com.bootdo.stock.domain.GoodsManageDO" useGeneratedKeys="true" keyProperty="goodsManageId"> insert into stock_goods_manage <trim prefix="(" suffix=")" suffixOverrides=","> <if test="deptId != null and deptId != '' ">dept_id,</if> <if test="semesterId != null and semesterId != '' ">semester_id,</if> <if test="inTotalNum != null and inTotalNum != '' ">in_total_num,</if> <if test="outTotalNum != null and outTotalNum != '' ">out_total_num,</if> <if test="planInNum != null and planInNum != '' ">plan_in_num,</if> <if test="planOutNum != null and planOutNum != '' ">plan_out_num,</if> <if test="temporaryInNum != null and temporaryInNum != '' ">temporary_in_num,</if> <if test="temporaryOutNum != null and temporaryOutNum != '' ">temporary_out_num,</if> <if test="checkTotalNum != null and checkTotalNum != '' ">check_total_num,</if> <if test="totalNum != null and totalNum != '' ">total_num,</if> <if test="startSemesterNum != null and startSemesterNum != '' ">start_semester_num,</if> <if test="endSemesterNum != null and endSemesterNum != '' ">end_semester_num,</if> <if test="goodsId != null and goodsId != '' ">goods_id,</if> <if test="goodsCode != null and goodsCode != '' ">goods_code,</if> <if test="goodsName != null and goodsName != '' ">goods_name,</if> <if test="goodsAbb != null and goodsAbb != '' ">goods_abb,</if> <if test="model != null and model != '' ">model,</if> <if test="unit != null and unit != '' ">unit,</if> <if test="kind != null and kind != '' ">kind,</if> <if test="price != null and price != '' ">price,</if> <if test="remark != null and remark != '' ">remark</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="deptId != null and deptId != '' ">#{deptId},</if> <if test="semesterId != null and semesterId != '' ">#{semesterId},</if> <if test="inTotalNum != null and inTotalNum != '' ">#{inTotalNum},</if> <if test="outTotalNum != null and outTotalNum != '' ">#{outTotalNum},</if> <if test="planInNum != null and planInNum != '' ">#{planInNum},</if> <if test="planOutNum != null and planOutNum != '' ">#{planOutNum},</if> <if test="temporaryInNum != null and temporaryInNum != '' ">#{temporaryInNum},</if> <if test="temporaryOutNum != null and temporaryOutNum != '' ">#{temporaryOutNum},</if> <if test="checkTotalNum != null and checkTotalNum != '' ">#{checkTotalNum},</if> <if test="totalNum != null and totalNum != '' ">#{totalNum},</if> <if test="startSemesterNum != null and startSemesterNum != '' ">#{startSemesterNum},</if> <if test="endSemesterNum != null and endSemesterNum != '' ">#{endSemesterNum},</if> <if test="goodsId != null and goodsId != '' ">#{goodsId},</if> <if test="goodsCode != null and goodsCode != '' ">#{goodsCode},</if> <if test="goodsName != null and goodsName != '' ">#{goodsName},</if> <if test="goodsAbb != null and goodsAbb != '' ">#{goodsAbb},</if> <if test="model != null and model != '' ">#{model},</if> <if test="unit != null and unit != '' ">#{unit},</if> <if test="kind != null and kind != '' ">#{kind},</if> <if test="price != null and price != '' ">#{price},</if> <if test="remark != null and remark != '' ">#{remark}</if> </trim> </insert>