mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-16 21:33:21 +00:00
Module Core : ajout clss config serveur, update enum MessageType & AccountLevel
This commit is contained in:
parent
156d912aba
commit
0ceb0d72cd
@ -4,24 +4,33 @@ public enum MessageType {
|
||||
ERROR_QUERY,
|
||||
REFUSED_QUERY,
|
||||
|
||||
QUERY_CONNECT,
|
||||
ACK_CONNECT,
|
||||
|
||||
QUERY_SALE,
|
||||
ACK_SALE,
|
||||
|
||||
QUERY_REVERT_SALE,
|
||||
ACK_REVERT_SALE,
|
||||
|
||||
QUERY_LAST_SALES_LIST,
|
||||
MSG_LAST_SALES_LIST,
|
||||
|
||||
QUERY_STAT,
|
||||
MSG_STAT,
|
||||
|
||||
QUERY_STOCK,
|
||||
MSG_STOCK,
|
||||
|
||||
QUERY_LOGIN,
|
||||
ACK_LOGIN,
|
||||
QUERY_ACCOUNT_LIST,
|
||||
MSG_ACCOUNT_LIST,
|
||||
|
||||
QUERY_CONNECT_ACCOUNT,
|
||||
ACK_CONNECT_ACCOUNT,
|
||||
|
||||
QUERY_UPDATE,
|
||||
ACK_UPDATE
|
||||
ACK_UPDATE,
|
||||
|
||||
QUERY_PING,
|
||||
ACK_PING,
|
||||
|
||||
QUERY_CONFIG_LIST,
|
||||
MSG_CONFIG_LIST
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.pqt.core.entities.server_config;
|
||||
|
||||
public enum ConfigFields {
|
||||
ALLOW_SALE_COMMIT,
|
||||
ALLOW_SALE_REVERT,
|
||||
|
||||
ALLOW_STOCK_VIEW,
|
||||
ALLOW_STOCK_UPDATE,
|
||||
|
||||
ALLOW_ACCOUNT_CONNECT,
|
||||
ALLOW_ACCOUNT_MODIFICATION
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.pqt.core.entities.server_config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ServerConfig {
|
||||
|
||||
private Map<ConfigFields, Boolean> fields;
|
||||
|
||||
public ServerConfig() {
|
||||
}
|
||||
|
||||
public ServerConfig(Map<ConfigFields, Boolean> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public ServerConfig(ConfigFields... configFields) {
|
||||
fields = new HashMap<>();
|
||||
Arrays.stream(configFields).forEach(field->fields.put(field, true));
|
||||
|
||||
EnumSet.allOf(ConfigFields.class).stream().filter(field->!fields.containsKey(field)).forEach(field->fields.put(field, false));
|
||||
}
|
||||
|
||||
public Map<ConfigFields, Boolean> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(Map<ConfigFields, Boolean> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public boolean isSupported(ConfigFields field){
|
||||
return fields.containsKey(field) && fields.get(field);
|
||||
}
|
||||
|
||||
public void switchFieldValue(ConfigFields field){
|
||||
if(fields.containsKey(field)){
|
||||
fields.replace(field, !fields.get(field));
|
||||
}else{
|
||||
fields.put(field, true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(ConfigFields field, boolean value){
|
||||
if(!fields.containsKey(field)){
|
||||
fields.put(field, value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,8 +1,21 @@
|
||||
package com.pqt.core.entities.user_account;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by Notmoo on 18/07/2017.
|
||||
*/
|
||||
public enum AccountLevel {
|
||||
GUEST, STAFF, WAITER, MASTER
|
||||
LOWEST, GUEST, STAFF, WAITER, MASTER;
|
||||
|
||||
public static AccountLevel getLowest(){
|
||||
return Arrays.stream(AccountLevel.values()).sorted(Comparator.naturalOrder()).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static AccountLevel getHighest(){
|
||||
return Arrays.stream(AccountLevel.values()).sorted(Comparator.reverseOrder()).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user