/** * 新增 * 作者: yangzhu * 日期: 2018-08-03 */ public Result addJobDetail(Context context) { JobDetail jobDetail = ContextUtils.getBean(JobDetail.class, context); //判断是否为空 Boolean isExistJob = jobDetailService.isExistJob(jobDetail); if (isExistJob) { return Result.fail("存在重复的数据!"); } ContextUtils.setCreateMsg(jobDetail, context); jobDetail.setId(idGenerator.nextIdStr()); jobDetailService.insertSelective(jobDetail); return Result.success("新增成功!"); }
//判断是否为空(选择性的代码) Boolean isExistJob = jobDetailService.isExistJob(jobDetail); if (isExistJob) { return Result.fail("存在重复的数据!"); }
int insertSelective(JobDetail jobDetail);
@Override public int insertSelective(JobDetail record) { return jobDetailMapper.insertSelective(record); }
int insertSelective(JobDetail record);
<insert id="insertSelective" parameterType="com.csii.loan.common.model.batch.JobDetail"> INSERT INTO batch_job_detail <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="jobName != null"> job_name, </if> <if test="jobType != null"> job_type, </if> <if test="trandateType != null"> trandate_type, </if> <if test="executePeriod != null"> execute_period, </if> <if test="remark != null"> remark, </if> <if test="createUser != null"> create_user, </if> <if test="createOrg != null"> create_org, </if> <if test="createTime != null"> create_time, </if> <if test="updateUser != null"> update_user, </if> <if test="updateOrg != null"> update_org, </if> <if test="updateTime != null"> update_time, </if> <if test="curVers != null"> cur_vers, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=VARCHAR}, </if> <if test="jobName != null"> #{jobName,jdbcType=VARCHAR}, </if> <if test="jobType != null"> #{jobType,jdbcType=CHAR}, </if> <if test="trandateType != null"> #{trandateType,jdbcType=VARCHAR}, </if> <if test="executePeriod != null"> #{executePeriod,jdbcType=CHAR}, </if> <if test="remark != null"> #{remark,jdbcType=VARCHAR}, </if> <if test="createUser != null"> #{createUser,jdbcType=VARCHAR}, </if> <if test="createOrg != null"> #{createOrg,jdbcType=VARCHAR}, </if> <if test="createTime != null"> #{createTime,jdbcType=VARCHAR}, </if> <if test="updateUser != null"> #{updateUser,jdbcType=VARCHAR}, </if> <if test="updateOrg != null"> #{updateOrg,jdbcType=VARCHAR}, </if> <if test="updateTime != null"> #{updateTime,jdbcType=VARCHAR}, </if> <if test="curVers != null"> #{curVers,jdbcType=INTEGER}, </if> </trim> </insert>