chat controller/service: add boss to pb

This commit is contained in:
Adam
2019-02-01 22:29:45 -05:00
parent bcdcad2895
commit 22963c72b1
2 changed files with 8 additions and 8 deletions

View File

@@ -135,20 +135,20 @@ public class ChatController
} }
@PostMapping("/pb") @PostMapping("/pb")
public void submitPb(@RequestParam String name, @RequestParam int pb) public void submitPb(@RequestParam String name, @RequestParam String boss, @RequestParam int pb)
{ {
if (pb < 0) if (pb < 0)
{ {
return; return;
} }
chatService.setPb(name, pb); chatService.setPb(name, boss, pb);
} }
@GetMapping("/pb") @GetMapping("/pb")
public int getPb(@RequestParam String name) public int getPb(@RequestParam String name, @RequestParam String boss)
{ {
Integer pb = chatService.getPb(name); Integer pb = chatService.getPb(name, boss);
if (pb == null) if (pb == null)
{ {
throw new NotFoundException(); throw new NotFoundException();

View File

@@ -122,21 +122,21 @@ public class ChatService
} }
} }
public Integer getPb(String name) public Integer getPb(String name, String boss)
{ {
String value; String value;
try (Jedis jedis = jedisPool.getResource()) try (Jedis jedis = jedisPool.getResource())
{ {
value = jedis.get("pb." + name); value = jedis.get("pb." + boss + "." + name);
} }
return value == null ? null : Integer.parseInt(value); return value == null ? null : Integer.parseInt(value);
} }
public void setPb(String name, int pb) public void setPb(String name, String boss, int pb)
{ {
try (Jedis jedis = jedisPool.getResource()) try (Jedis jedis = jedisPool.getResource())
{ {
jedis.setex("pb." + name, (int) EXPIRE.getSeconds(), Integer.toString(pb)); jedis.setex("pb." + boss + "." + name, (int) EXPIRE.getSeconds(), Integer.toString(pb));
} }
} }
} }