|
@@ -0,0 +1,64 @@
|
|
|
+/*
|
|
|
+ * ioGame
|
|
|
+ * Copyright (C) 2021 - 2023 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
|
|
|
+ * # iohao.com . 渔民小镇
|
|
|
+ *
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU Affero General Public License as
|
|
|
+ * published by the Free Software Foundation, either version 3 of the
|
|
|
+ * License, or (at your option) any later version.
|
|
|
+ *
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU Affero General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU Affero General Public License
|
|
|
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
+ */
|
|
|
+package com.iohao.mmo.equip.service;
|
|
|
+
|
|
|
+import com.iohao.mmo.equip.entity.BasicEquipProperty;
|
|
|
+import com.iohao.mmo.equip.entity.Dictionary;
|
|
|
+import com.iohao.mmo.equip.entity.Equip;
|
|
|
+import com.iohao.mmo.equip.repository.EquipRepository;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
+import org.springframework.data.mongodb.core.query.Update;
|
|
|
+import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 唐斌
|
|
|
+ * @date 2023-07-30
|
|
|
+ * @description: 装备属性实现类
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class DictionaryService {
|
|
|
+ final MongoTemplate mongoTemplate;
|
|
|
+ final EquipRepository equipRepository;
|
|
|
+
|
|
|
+ public Equip ofEquip(String id) {
|
|
|
+
|
|
|
+ return mongoTemplate.findById(id, Equip.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void upsert(Dictionary dictionary) {
|
|
|
+
|
|
|
+ // 查询条件,如果数据存在更新
|
|
|
+ Query query = new Query();
|
|
|
+ query.addCriteria(Criteria.where("dictType").is(dictionary.getDictType()));
|
|
|
+
|
|
|
+ // 更新的字段
|
|
|
+ Update update = new Update();
|
|
|
+ update.set("dictName", dictionary.getDictName());
|
|
|
+ update.set("dictDataList", dictionary.getDictDataList());
|
|
|
+ mongoTemplate.upsert(query,update,Dictionary.class);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|