分布式锁的实现方式改为Redisson,并优化抽象接口

This commit is contained in:
zlt2000
2020-05-05 21:38:10 +08:00
parent d828520b1d
commit 479e69e12e
18 changed files with 231 additions and 258 deletions
@@ -18,6 +18,9 @@ import java.util.Map;
* 应用相关接口
*
* @author zlt
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Api(tags = "应用")
@RestController
@@ -53,7 +56,7 @@ public class ClientController {
@PostMapping("/saveOrUpdate")
@ApiOperation(value = "保存或者修改应用")
public Result saveOrUpdate(@RequestBody ClientDto clientDto) {
public Result saveOrUpdate(@RequestBody ClientDto clientDto) throws Exception {
return clientService.saveClient(clientDto);
}
}
@@ -9,9 +9,12 @@ import java.util.Map;
/**
* @author zlt
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
public interface IClientService extends ISuperService<Client> {
Result saveClient(Client clientDto);
Result saveClient(Client clientDto) throws Exception;
/**
* 查询应用列表
@@ -23,11 +23,14 @@ import java.util.Map;
/**
* @author zlt
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Slf4j
@Service
public class ClientServiceImpl extends SuperServiceImpl<ClientMapper, Client> implements IClientService {
private final static String LOCK_KEY_CLIENTID = CommonConstant.LOCK_KEY_PREFIX+"clientId:";
private final static String LOCK_KEY_CLIENTID = "clientId:";
@Autowired
private RedisRepository redisRepository;
@@ -39,7 +42,7 @@ public class ClientServiceImpl extends SuperServiceImpl<ClientMapper, Client> im
private DistributedLock lock;
@Override
public Result saveClient(Client client) {
public Result saveClient(Client client) throws Exception {
client.setClientSecret(passwordEncoder.encode(client.getClientSecretStr()));
String clientId = client.getClientId();
super.saveOrUpdateIdempotency(client, lock