1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      如何用mongodb和springboot修改深層嵌套對象

      如何用MongoDB和spring boot修改深層嵌套對象?這篇文章運用了實例代碼展示,代碼非常詳細,可供感興趣的小伙伴們參考借鑒,希望對大家有所幫助。

      創(chuàng)新互聯(lián)公司于2013年開始,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目網(wǎng)站制作、成都做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元富裕做網(wǎng)站,已為上家服務,為富裕各地企業(yè)和個人服務,聯(lián)系電話:18982081108

      1.開發(fā)環(huán)境:mongodb+spring boot項目,使用mongoTemplate進行修改
      2.數(shù)據(jù)為三層嵌套TopicModel——>TopicTableModel——>TopicColumnModel
      3.修改代碼展示
      (1)修改第二級TopicTableModel對象

      @Override
          public boolean updateTableModel(TopicTableModel tableModel) {
              Query query = new Query();
              query.addCriteria(Criteria.where("tableList.tableId").is(tableModel.getTableId()));
              Update update = new Update().set("tableList.$.tableName", tableModel.getTableName())
                      .set("tableList.$.tableComment", tableModel.getTableComment())
                      .set("tableList.$.status", Integer.valueOf(tableModel.getStatus()));
              // .set("tableList.$.topicCode", tableModel.getTopicCode());
              UpdateResult tableUr = this.mongoTemplate.upsert(query, update, TopicModel.class);
              if ((tableUr.getMatchedCount() > 0L) || (tableUr.getUpsertedId() != null)) {
      
                  return true;
              }
              return false;
          }

      (3)修改第三級(TopicColumnModel),需要先遍歷定位到修改的第三級對像的索引

      @Override
          public boolean updateColumnModel(TopicColumnModel topicColumnModel, String tmId, String tbId) {
              Query query = new Query();
              query.addCriteria(Criteria.where("tableList.tableId").is(tbId));
              Update update = new Update();
              List topicModels = mongoTemplate.find(query, TopicModel.class);
              for (int i = 0; i < topicModels.size(); i++) {
                  if (topicModels.get(i).getId().equals(tmId)) {
                      List topicTableModels = topicModels.get(i).getTableList();
                      for (int j = 0; j < topicTableModels.size(); j++) {
                          if (topicTableModels.get(j).getTableId().equals(tbId)) {
                              List topicColumnModels = topicTableModels.get(j).getColList();
                              for (int k = 0; k < topicColumnModels.size(); k++) {
                                  if (topicColumnModels.get(k).getColId().equals(topicColumnModel.getColId())) {
                                      update.set("tableList.$.colList." + k + ".colName",topicColumnModel.getColName())
                                              .set("tableList.$.colList."+ k +".desc1", topicColumnModel.getDesc1())
                                              .set("tableList.$.colList." + k +".desc2", topicColumnModel.getDesc2())
                                              .set("tableList.$.colList." + k +".internalMark", topicColumnModel.getInternalMark())
                                              .set("tableList.$.colList." + k +".qualifierMark", topicColumnModel.getQualifierMark())
                                              .set("tableList.$.colList." + k +".chineseName", topicColumnModel.getChineseName())
                                              .set("tableList.$.colList." + k +".dataSource", topicColumnModel.getDataSource())
                                              .set("tableList.$.colList." + k +".getRules", topicColumnModel.getGetRules())
                                              .set("tableList.$.colList." + k +".dataType", topicColumnModel.getDataType())
                                              .set("tableList.$.colList." + k +".dataLength", topicColumnModel.getDataLength())
                                              .set("tableList.$.colList." + k +".pkey", topicColumnModel.isPkey())
                                              .set("tableList.$.colList." + k +".index", topicColumnModel.isIndex())
                                              .set("tableList.$.colList." + k +".nullAble", topicColumnModel.isNullAble())
                                              .set("tableList.$.colList." + k +".unique", topicColumnModel.isUnique())
                                              .set("tableList.$.colList." + k +".colComment", topicColumnModel.getColComment())
                                              .set("tableList.$.colList." + k +".defaultValue", topicColumnModel.getDefaultValue())
                                              .set("tableList.$.colList." + k +".check", topicColumnModel.getCheck())
                                              .set("tableList.$.colList." + k +".attributeType", topicColumnModel.getAttributeType());
                                  }
                              }
                          }
                      }
                  }
      
              }
              UpdateResult tableUr = this.mongoTemplate.updateFirst(query, update, TopicModel.class);
              if ((tableUr.getMatchedCount() > 0L) || (tableUr.getUpsertedId() != null)) {
                  return true;
              }
              return false;
          }

      看完這篇文章,你們學會用mongodb和spring boot修改深層嵌套對象了嗎?如果還想學到更多技能或想了解更多相關內(nèi)容,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀。


      名稱欄目:如何用mongodb和springboot修改深層嵌套對象
      當前網(wǎng)址:http://www.ef60e0e.cn/article/jdoshs.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        廊坊市| 体育| 博爱县| 丹江口市| 丽水市| 华亭县| 家居| 定兴县| 永靖县| 贡嘎县| 通江县| 冷水江市| 寿光市| 商都县| 定日县| 临沂市| 阿拉善右旗| 西藏| 乳源| 古田县| 观塘区| 安丘市| 正阳县| 安宁市| 泽州县| 漳浦县| 榆中县| 疏勒县| 汽车| 田东县| 广州市| 永丰县| 牡丹江市| 威宁| 石泉县| 庆阳市| 桃源县| 定襄县| 腾冲县| 同江市| 团风县|