Oracle中进行对含有Blob的数据进行Update操作

Controller

    /**
     * 新增知情同意书模板
     *
     * @param
     * @return
     */
    @ResponseBody
    @PostMapping("/insertOrUpdateConsent")
    @ApiOperation(value = "新增知情同意书模板信息")
    @LoginRequired
    @RequiredPermission("/insertOrUpdateConsent") // 权限注解
    public ResponseMessage insertOrUpdateConsent(@RequestBody InformedConsentTemplet informedConsentTempLet) {
        try {
            if (informedConsentTempLet == null) {
                return ResponseMessage.createErrResponseMessage("没有知情同意书模板信息");
            }
            //记录用户操作
            OperationLog operationLog = OperationLogUtil.setParam(request, "新增知情同意书模板信息", JSON.toJSONString(informedConsentTempLet, SerializerFeature.WriteMapNullValue));
            operationLog.setOperation(this.getClass().getSimpleName() + "-" + Thread.currentThread().getStackTrace()[1].getMethodName());

            this.informedConsentTemletService.insert(informedConsentTempLet);

            operationLogMapper.insert(operationLog);
            return ResponseMessage.createSucResponseMessage();
        } catch (Exception e) {
            log.error("新增知情同意书模板异常", e);
            return ResponseMessage.createErrResponseMessage("新增知情同意书模板失败");
        }
    }

Service

    /**
     * 新增知情同意书模板新增修改
     *
     * @param informedConsent
     * @throws Exception
     */
    public void insert(InformedConsentTemplet informedConsent) throws Exception {
        try {
            //没有id进行创建,有id进行修改
            String consentId = informedConsent.getConsentId();
            if (StringUtils.isBlank(consentId)) {
                informedConsent.setConsentId(UUID.randomUUID().toString().replace("-", ""));
                informedConsent.setCreateDate(new Date());
                int i = this.informedConsentTempletMapper.insert(informedConsent);
                if (i > 0) {
                    log.info("【知情同意书模板新增方法成功】");
                }
            } else {
                List<InformedConsentTemplet> selectAll = this.informedConsentTempletMapper.selectAll(consentId, null);
                if (selectAll.size() < 0) {
                    throw new BusinessException("数据库中不存在该条数据");
                }
                informedConsent.setUpdateDate(new Date());
                int i = this.informedConsentTempletMapper.updateByPrimaryKey(informedConsent);
                if (i > 0) {
                    log.info("【知情同意书模板修改方法成功】");
                }
            }
        } catch (Exception e) {
            log.error("【新增同意书模板方法异常】异常信息为:" + e.getMessage());
            throw new Exception(e.getMessage());
        }
    }

XML

<update id="updateByPrimaryKey" parameterType="com.sinosoft.ie.model.InformedConsentTemplet">
    update INFORMED_CONSENT_TEMPLET
    set CONSENT_NAME = #{consentName,jdbcType=VARCHAR},
      CONSENT_DESC = #{consentDesc,jdbcType=VARCHAR},
      CONSENT_VERSION = #{consentVersion,jdbcType=VARCHAR},
      USEFLAG = #{useflag,jdbcType=VARCHAR},
      CREATE_DATE = #{createDate,jdbcType=DATE},
      UPDATE_DATE = #{updateDate,jdbcType=DATE},
      CREATOR_ID = #{creatorId,jdbcType=NUMERIC},
      UPDATOR_ID = #{updatorId,jdbcType=NUMERIC},
      CONTENT = utl_raw.cast_to_raw(#{content,jdbcType=BLOB})
    where CONSENT_ID = #{consentId,jdbcType=VARCHAR}
 </update>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值