Commit 7011f116 authored by chenchao.deng's avatar chenchao.deng

新增shop secret

parent 11d1c127
......@@ -100,4 +100,43 @@ public class ConfigController {
return ResponseUtil.error(e.getMessage());
}
}
/**
* @author Chen
* @description 获取店铺secret
* @date 2024/10/13 8:04
*/
@RequestMapping(value = "/getShopSecret", method = RequestMethod.GET)
public ResultDto getShopSecret(String shopId) {
String logs = "【getShopSecret】 ";
try {
return ResponseUtil.success(ipResourceService.getShop32Secret(shopId));
} catch (ClientRequestException e) {
log.warn("{}, ClientRequestException : {}", logs, e.getErrorCode().getReason());
return ResponseUtil.error(e.getErrorCode());
} catch (Exception e) {
log.error("{}, Exception : {}", logs, e.getMessage(), e);
return ResponseUtil.error(e.getMessage());
}
}
/**
* @author Chen
* @description 保存或者更新 店铺secret
* @date 2024/10/13 8:13
*/
@RequestMapping(value = "/saveShopSecret", method = RequestMethod.GET)
public ResultDto saveShopSecret(String shopId, String baseSecret) {
String logs = "【getShopSecret】 ";
try {
ipResourceService.saveShopSecret(shopId, baseSecret);
return ResponseUtil.success();
} catch (ClientRequestException e) {
log.warn("{}, ClientRequestException : {}", logs, e.getErrorCode().getReason());
return ResponseUtil.error(e.getErrorCode());
} catch (Exception e) {
log.error("{}, Exception : {}", logs, e.getMessage(), e);
return ResponseUtil.error(e.getMessage());
}
}
}
package com.edgec.browserbackend.browser.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* XXXX
*
* @Author: Chen
* @Date: 2024/10/13
*/
@Getter
@Setter
@Document(collection = "shopSecret")
public class ShopSecret {
@Id
private String id;
/**
* 商铺 id
*/
private String shopId;
/**
* 商铺 secret
*/
private String secret;
}
package com.edgec.browserbackend.browser.repository;
import com.edgec.browserbackend.browser.domain.Shop;
import com.edgec.browserbackend.browser.domain.ShopSecret;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
public interface ShopSecretRepository extends MongoRepository<ShopSecret, String> {
ShopSecret findByShopId(String shopId);
}
......@@ -10,6 +10,7 @@ import com.edgec.browserbackend.account.controller.LimitedUsers;
import com.edgec.browserbackend.account.domain.Account;
import com.edgec.browserbackend.account.domain.IpChargeRequestDto;
import com.edgec.browserbackend.account.domain.IpChargeResultDto;
import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.account.exception.AccountErrorCode;
import com.edgec.browserbackend.account.repository.AccountRepository;
import com.edgec.browserbackend.account.service.AccountService;
......@@ -160,6 +161,9 @@ public class IpResourceServiceImpl implements IpResourceService {
@Resource
private CloudPlatformConfigRepository cloudPlatformConfigRepository;
@Resource
private ShopSecretRepository shopSecretRepository;
public HttpHeaders buildPostHeader() {
HttpHeaders header = new HttpHeaders();
header.setContentType(MediaType.APPLICATION_JSON);
......@@ -969,6 +973,30 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
@Override
public String getShop32Secret(String shopId) {
ShopSecret shopSecret = shopSecretRepository.findByShopId(shopId);
ResultDto resultDto = new ResultDto();
resultDto.setStatus(0);
if(Objects.nonNull(shopSecret)){
return shopSecret.getSecret();
}
return null;
}
@Override
public void saveShopSecret(String shopId, String secret) {
ShopSecret shopSecret = shopSecretRepository.findByShopId(shopId);
if(Objects.nonNull(shopSecret)){
shopSecret.setSecret(secret);
}else {
shopSecret = new ShopSecret();
shopSecret.setShopId(shopId);
shopSecret.setSecret(secret);
}
shopSecretRepository.save(shopSecret);
}
private IpChargeRequestDto buildIpChargeRequestDto(IpResourceRequestDto request, int chargeType, int payMethod) {
IpChargeRequestDto ipChargeRequestDto = new IpChargeRequestDto();
......
package com.edgec.browserbackend.browser.service;
import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.browser.domain.IpOptions;
import com.edgec.browserbackend.browser.domain.IpSummary;
import com.edgec.browserbackend.browser.domain.PlatformOptions;
......@@ -54,4 +55,7 @@ public interface IpResourceService {
List<ReceptionPlatformOptions> getReceptionPlatformOptions();
String getShop32Secret(String shopId);
void saveShopSecret(String shopId, String sercret);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment