upgrade add shopify auth

master
ycfxx 3 years ago
parent f441fe9b5e
commit ad4f78e101

@ -15,4 +15,7 @@ public interface ShopifyStoreMapper {
@AutoSql(SqlType.SELECT)
ShopifyStore selectByShop(@Param("shopify_shop") String shop);
@AutoSql(SqlType.UPDATE)
void update(ShopifyStore shopifyStore);
}

@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class ShopifyMerchantAuthApplication {
@ -28,9 +30,6 @@ public class ShopifyMerchantAuthApplication {
@Autowired
private ShopifyStoreService shopifyStoreService;
@Autowired
private SignInAccountService signInAccountService;
@Autowired
private SignInStatusManager signInStatusManager;
@ -47,7 +46,19 @@ public class ShopifyMerchantAuthApplication {
String statusKey = signInStatusManager.partnerSignIn(loginInfo);
JSONObject client = signInStatusManager.getCurrentClient(statusKey);
shopifyStoreService.createShopifyStore(ShopifyStore.instanceOf(client, request.getShop()));
ShopifyStore shopifyShop = shopifyStoreService.getByShopifyShop(request.getShop());
if (shopifyShop == null) {
shopifyStoreService.createShopifyStore(ShopifyStore.instanceOf(client, request.getShop()));
return shopifyAuthService.shopifyPermission(request);
}
shopifyStoreService.modifyShopifyStore(shopifyShop
.setClientId(client.getInteger("client_id"))
.setClientMoniker(client.getString("client_moniker"))
.setModifyTime(new Date())
.setModifier(request.getShop()));
return shopifyAuthService.shopifyPermission(request);
}

@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.UUID;
@ -13,6 +14,7 @@ import java.util.UUID;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ShopifyStore {
private String id;

@ -18,4 +18,11 @@ public interface ShopifyStoreService {
* @return
*/
ShopifyStore getByShopifyShop(String shop);
/**
* shopify
*
* @param shopifyStore
*/
void modifyShopifyStore(ShopifyStore shopifyStore);
}

@ -21,4 +21,9 @@ public class ShopifyStoreServiceImpl implements ShopifyStoreService {
public ShopifyStore getByShopifyShop(String shop) {
return shopifyStoreMapper.selectByShop(shop);
}
@Override
public void modifyShopifyStore(ShopifyStore shopifyStore) {
shopifyStoreMapper.update(shopifyStore);
}
}

@ -1,11 +1,11 @@
package au.com.royalpay.payment.manage.shopify.store.web;
import au.com.royalpay.payment.manage.shopify.store.domain.service.PaymentAppMerchantService;
import au.com.royalpay.payment.manage.shopify.store.web.command.CreateShopifyMerchantCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* shopify
@ -26,4 +26,13 @@ public class ShopifyStoreController {
public Boolean validPaymentAppMerchant(@RequestParam("loginId") String loginId) {
return paymentAppMerchantService.existMerchant(loginId);
}
/**
* shopify
*
* @param command
*/
@PostMapping("/register")
public void createMerchantWithShopify(@RequestBody @Valid CreateShopifyMerchantCommand command) {
}
}

@ -0,0 +1,16 @@
package au.com.royalpay.payment.manage.shopify.store.web.command;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class CreateShopifyMerchantCommand {
private PaymentMerchantCommand paymentMerchant;
private PaymentAccountCommand paymentAccount;
@NotBlank(message = "Shop can not blank")
private String shopifyShop;
}

@ -0,0 +1,11 @@
package au.com.royalpay.payment.manage.shopify.store.web.command;
import lombok.Data;
@Data
public class PaymentAccountCommand {
private String loginId;
private String password;
}

@ -0,0 +1,25 @@
package au.com.royalpay.payment.manage.shopify.store.web.command;
import lombok.Data;
@Data
public class PaymentMerchantCommand {
private String companyName;
private String address;
private String suburb;
private String postcode;
private String state;
private String country;
private String contactPerson;
private String contactPhone;
private String contactEmail;
}

@ -41,4 +41,15 @@ class ShopifyStoreServiceTest {
log.info(JSON.toJSONString(shopifyStore));
}
@Test
public void modifyShopifyStore() {
ShopifyStore shopifyStore = shopifyStoreService.getByShopifyShop("geek-test-shop.myshopify.com");
shopifyStoreService.modifyShopifyStore(shopifyStore
.setClientId(123)
.setClientMoniker("hello")
.setModifyTime(new Date())
.setModifier("geek-test-shop.myshopify.com"));
}
}
Loading…
Cancel
Save