コード例 #1
0
  /**
   * 新規追加、更新
   *
   * @param form
   * @param userInfo
   * @return
   */
  @Transactional
  public boolean update(SupportForm form, UserInfo userInfo) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}
    try {
      SpSupportTbl entity = new SpSupportTbl();

      // 更新の場合
      if (CommonConst.PAGE_MODE_EDIT.equals(form.getPageMode())) {
        entity = findOne(form.getSupportKey(), form.getUpdDate());
        if (entity == null) {
          throw new Exception();
        }
      }
      //
      entity.setSupportSpkikiKbn(form.getSupportSpkikiKbn());
      entity.setSupportHirakuKbn(form.getSupportHirakuKbn());
      entity.setSupportSybCode(form.getSupportSybCode());
      entity.setSupportAreaKbn(form.getSupportAreaKbn());
      entity.setSupportKeyword(form.getSupportKeyword());
      entity.setSupportStartDate(
          DateUtil.formatTimestampStart(
              DateUtil.getTimestamp(form.getSupportStartDate(), CommonConst.DEFAULT_YYYYMMDD)));
      entity.setSupportEndDate(
          DateUtil.formatTimestampEnd(
              DateUtil.getTimestamp(form.getSupportEndDate(), CommonConst.DEFAULT_YYYYMMDD)));
      entity.setSupportTitle(form.getSupportTitle());
      entity.setSupportContent(form.getSupportContent());
      entity.setUrl(form.getUrl());
      entity.setPartyCode(userInfo.getTargetPartyCode());

      // 更新以外の場合(新規、コピー)
      if (!CommonConst.PAGE_MODE_EDIT.equals(form.getPageMode())) {
        entity.setSupportInsDate(DateUtil.getNowTimestamp());
      }
      entity.setPublicFlag(form.getPublicFlag());
      //
      entity.setUpdUserKey(userInfo.getLoginUserKey());
      entity.setUpdDate(DateUtil.getNowTimestamp());
      //
      entity = spSupportTblRepository.saveAndFlush(entity);

      if (entity != null) {
        logger.infoCode("I0002"); // I0002=メソッド終了:{0}
        return true;
      }

    } catch (Exception e) {
      logger.errorCode("E1007", e); // E1007=登録に失敗しました。{0}
    }
    return false;
  }
コード例 #2
0
  /**
   * 削除
   *
   * @param form
   * @return
   */
  @Transactional
  public boolean delete(SupportForm form) {
    logger.infoCode("I0001"); // I0001=メソッド開始:{0}
    try {

      int c = spSupportTblRepository.delete(form.getSupportKey(), form.getUpdDate());

      if (c > 0) {
        spSupportTblRepository.flush();
        logger.infoCode("I0002"); // I0002=メソッド終了:{0}
        return true;
      }
    } catch (Exception e) {
      logger.errorCode("E1009", e); // E1009=削除に失敗しました。{0}
    }
    return false;
  }