-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
282 additions
and
109 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
clustermanage-server/src/main/java/cc/bitky/clustermanage/db/mongoops/RoutineTableOps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cc.bitky.clustermanage.db.mongoops; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.mongodb.core.MongoOperations; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class RoutineTableOps { | ||
private final MongoOperations operations; | ||
|
||
@Autowired | ||
public RoutineTableOps(MongoOperations operations) { | ||
this.operations = operations; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
clustermanage-server/src/main/java/cc/bitky/clustermanage/db/mongoops/SettingOps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cc.bitky.clustermanage.db.mongoops; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.mongodb.core.MongoOperations; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class SettingOps { | ||
private final MongoOperations operations; | ||
|
||
@Autowired | ||
public SettingOps(MongoOperations operations) { | ||
this.operations = operations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ermanage-server/src/main/java/cc/bitky/clustermanage/db/presenter/DbSettingPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cc.bitky.clustermanage.db.presenter; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import cc.bitky.clustermanage.db.bean.KySetting; | ||
import cc.bitky.clustermanage.db.repository.SettingRepository; | ||
import cc.bitky.clustermanage.server.bean.ServerWebMessageHandler.Card; | ||
|
||
@Repository | ||
public class DbSettingPresenter { | ||
private final SettingRepository settingRepository; | ||
|
||
@Autowired | ||
public DbSettingPresenter(SettingRepository settingRepository) { | ||
this.settingRepository = settingRepository; | ||
} | ||
|
||
/** | ||
* 将卡号集合保存在数据库的 Setting 文档中 | ||
* | ||
* @param cardArray 卡号集合 | ||
* @param card 卡号类型枚举 | ||
* @return 是否保存成功 | ||
*/ | ||
boolean saveCardArray(long[] cardArray, Card card) { | ||
KySetting kySetting = settingRepository.findOne("1"); | ||
if (kySetting == null) { | ||
kySetting = new KySetting(); | ||
kySetting.setId(1); | ||
} | ||
switch (card) { | ||
case FREE: | ||
kySetting.setFreeCardList(cardArray); | ||
break; | ||
case CONFIRM: | ||
kySetting.setConfirmCardList(cardArray); | ||
break; | ||
} | ||
settingRepository.save(kySetting); | ||
return true; | ||
} | ||
|
||
/** | ||
* 获取卡号的集合 | ||
* | ||
* @return 卡号的集合 | ||
*/ | ||
long[] getCardArray(Card card) { | ||
KySetting kyKySettings = settingRepository.findOne("1"); | ||
if (kyKySettings == null) return new long[0]; | ||
long[] longs; | ||
switch (card) { | ||
case FREE: | ||
longs = kyKySettings.getFreeCardList(); | ||
return longs == null ? new long[0] : longs; | ||
case CONFIRM: | ||
longs = kyKySettings.getConfirmCardList(); | ||
return longs == null ? new long[0] : longs; | ||
} | ||
return new long[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.