提取常量
This commit is contained in:
parent
144ef52fca
commit
a01c480dc4
@ -0,0 +1,7 @@
|
|||||||
|
package com.xhpc.common;
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
|
||||||
|
public static final String PILE_WHITELIST = "PILE_WHITELIST";
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,7 +7,6 @@ import com.ruoyi.common.core.utils.HttpUtils;
|
|||||||
import com.xhpc.common.api.PowerPileService;
|
import com.xhpc.common.api.PowerPileService;
|
||||||
import com.xhpc.common.data.down.StartChargingData;
|
import com.xhpc.common.data.down.StartChargingData;
|
||||||
import com.xhpc.common.data.up.OrderData;
|
import com.xhpc.common.data.up.OrderData;
|
||||||
import com.xhpc.pp.logic.FieldLogic;
|
|
||||||
import com.xhpc.pp.server.ChargingPileServer;
|
import com.xhpc.pp.server.ChargingPileServer;
|
||||||
import com.xhpc.pp.tx.ServiceResult;
|
import com.xhpc.pp.tx.ServiceResult;
|
||||||
import com.xhpc.pp.utils.security.CRCCalculator;
|
import com.xhpc.pp.utils.security.CRCCalculator;
|
||||||
@ -38,8 +37,6 @@ public class ChargingController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PowerPileService powerPileService;
|
private PowerPileService powerPileService;
|
||||||
@Autowired
|
|
||||||
private FieldLogic fieldLogic;
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("test/pile/charging/order")
|
@PostMapping("test/pile/charging/order")
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.xhpc.common.Constants.PILE_WHITELIST;
|
||||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -13,18 +14,18 @@ public class PileController {
|
|||||||
@PostMapping("pile/whitelist")
|
@PostMapping("pile/whitelist")
|
||||||
public Object addWhitelist(@RequestBody Set<String> whitelist) {
|
public Object addWhitelist(@RequestBody Set<String> whitelist) {
|
||||||
|
|
||||||
Set<String> cacheWhitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
Set<String> cacheWhitelist = REDIS.getCacheSet(PILE_WHITELIST);
|
||||||
cacheWhitelist.addAll(whitelist);
|
cacheWhitelist.addAll(whitelist);
|
||||||
REDIS.setCacheSet("PILE_WHITELIST", cacheWhitelist);
|
REDIS.setCacheSet(PILE_WHITELIST, cacheWhitelist);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("pile/whitelist/{pileNo}")
|
@DeleteMapping("pile/whitelist/{pileNo}")
|
||||||
public Object deleteWhitelist(@PathVariable String pileNo) {
|
public Object deleteWhitelist(@PathVariable String pileNo) {
|
||||||
|
|
||||||
Set<String> cacheWhitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
Set<String> cacheWhitelist = REDIS.getCacheSet(PILE_WHITELIST);
|
||||||
cacheWhitelist.remove(pileNo);
|
cacheWhitelist.remove(pileNo);
|
||||||
REDIS.setCacheSet("PILE_WHITELIST", cacheWhitelist);
|
REDIS.setCacheSet(PILE_WHITELIST, cacheWhitelist);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.xhpc.common.Constants.PILE_WHITELIST;
|
||||||
import static com.xhpc.pp.config.EarlierBeanConf.getLocalIPAndPort;
|
import static com.xhpc.pp.config.EarlierBeanConf.getLocalIPAndPort;
|
||||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ public class RegisterLogic implements ServiceLogic {
|
|||||||
String resultCode = ServiceResult.OK;
|
String resultCode = ServiceResult.OK;
|
||||||
String hexCode = ServiceResult.HEX_OK;
|
String hexCode = ServiceResult.HEX_OK;
|
||||||
String pileNo = (String) req.get("pileNo");
|
String pileNo = (String) req.get("pileNo");
|
||||||
Set<String> whitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
Set<String> whitelist = REDIS.getCacheSet(PILE_WHITELIST);
|
||||||
if (!whitelist.contains(pileNo)) {
|
if (!whitelist.contains(pileNo)) {
|
||||||
hexCode = ServiceResult.HEX_FAIL;
|
hexCode = ServiceResult.HEX_FAIL;
|
||||||
resultCode = ServiceResult.FAIL;
|
resultCode = ServiceResult.FAIL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user