diff --git a/pom.xml b/pom.xml
index 617b5bc..84adab8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -155,14 +155,7 @@
2.0.43
-
-
- com.baomidou
- dynamic-datasource-spring-boot3-starter
- 4.3.1
-
-
-
+
org.projectlombok
lombok
diff --git a/src/main/java/com/aida/buyer/config/BuyerDataSourceConfig.java b/src/main/java/com/aida/buyer/config/BuyerDataSourceConfig.java
new file mode 100644
index 0000000..a4e2265
--- /dev/null
+++ b/src/main/java/com/aida/buyer/config/BuyerDataSourceConfig.java
@@ -0,0 +1,62 @@
+package com.aida.buyer.config;
+
+import com.baomidou.mybatisplus.core.config.GlobalConfig;
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages = "com.aida.buyer.module.*.mapper", sqlSessionFactoryRef = "buyerSqlSessionFactory")
+public class BuyerDataSourceConfig {
+
+ @Autowired
+ private MybatisPlusInterceptor mybatisPlusInterceptor;
+
+ @Autowired
+ private MetaObjectHandler myMetaObjectHandler;
+
+ @Primary
+ @Bean(name = "buyerDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource.buyer")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+ @Primary
+ @Bean(name = "buyerSqlSessionFactory")
+ public SqlSessionFactory sqlSessionFactory(
+ @Qualifier("buyerDataSource") DataSource dataSource,
+ ApplicationContext applicationContext) throws Exception {
+ MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
+ bean.setDataSource(dataSource);
+ bean.setMapperLocations(applicationContext.getResources("classpath*:/mapper/**/*.xml"));
+
+ GlobalConfig globalConfig = new GlobalConfig();
+ globalConfig.setBanner(false);
+ globalConfig.setMetaObjectHandler(myMetaObjectHandler);
+ bean.setGlobalConfig(globalConfig);
+
+ bean.setPlugins(mybatisPlusInterceptor);
+ return bean.getObject();
+ }
+
+ @Primary
+ @Bean(name = "buyerSqlSessionTemplate")
+ public SqlSessionTemplate sqlSessionTemplate(
+ @Qualifier("buyerSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
+ return new SqlSessionTemplate(sqlSessionFactory);
+ }
+}
diff --git a/src/main/java/com/aida/buyer/module/account/controller/BuyerAccountController.java b/src/main/java/com/aida/buyer/module/account/controller/BuyerAccountController.java
index 6ea5003..7ecf54e 100644
--- a/src/main/java/com/aida/buyer/module/account/controller/BuyerAccountController.java
+++ b/src/main/java/com/aida/buyer/module/account/controller/BuyerAccountController.java
@@ -20,7 +20,7 @@ public class BuyerAccountController {
private final IBuyerAccountService buyerAccountService;
@PostMapping("/sendCode")
- @Operation(summary = "忘记密码:发送邮箱验证码")
+ @Operation(summary = "注册||忘记密码:发送邮箱验证码")
public Boolean sendCode(@Valid @RequestBody SendCodeDTO dto) {
return buyerAccountService.sendCode(dto);
}
diff --git a/src/main/java/com/aida/buyer/module/account/dto/RegisterDTO.java b/src/main/java/com/aida/buyer/module/account/dto/RegisterDTO.java
index a15a7ba..16fafe0 100644
--- a/src/main/java/com/aida/buyer/module/account/dto/RegisterDTO.java
+++ b/src/main/java/com/aida/buyer/module/account/dto/RegisterDTO.java
@@ -24,7 +24,6 @@ public class RegisterDTO {
@Schema(description = "用户名")
private String username;
- @NotBlank(message = "emailVerifyCode is required")
@Schema(description = "邮箱验证码")
private String emailVerifyCode;
}
diff --git a/src/main/java/com/aida/buyer/module/account/dto/SendCodeDTO.java b/src/main/java/com/aida/buyer/module/account/dto/SendCodeDTO.java
index ab74bb7..f6f0aad 100644
--- a/src/main/java/com/aida/buyer/module/account/dto/SendCodeDTO.java
+++ b/src/main/java/com/aida/buyer/module/account/dto/SendCodeDTO.java
@@ -11,4 +11,8 @@ public class SendCodeDTO {
@NotBlank(message = "email is required")
@Schema(description = "邮箱")
private String email;
+
+ @NotBlank(message = "operationType is required")
+ @Schema(description = "操作类型:FORGET_PWD, REGISTER")
+ private String operationType;
}
diff --git a/src/main/java/com/aida/buyer/module/account/mapper/BuyerAccountMapper.java b/src/main/java/com/aida/buyer/module/account/mapper/BuyerAccountMapper.java
index 78f4fb4..2ea5fc0 100644
--- a/src/main/java/com/aida/buyer/module/account/mapper/BuyerAccountMapper.java
+++ b/src/main/java/com/aida/buyer/module/account/mapper/BuyerAccountMapper.java
@@ -1,11 +1,9 @@
package com.aida.buyer.module.account.mapper;
import com.aida.buyer.module.account.entity.BuyerAccount;
-import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
-@DS("buyer")
public interface BuyerAccountMapper extends BaseMapper {
}
diff --git a/src/main/java/com/aida/buyer/module/account/service/impl/BuyerAccountServiceImpl.java b/src/main/java/com/aida/buyer/module/account/service/impl/BuyerAccountServiceImpl.java
index 79990ed..406383b 100644
--- a/src/main/java/com/aida/buyer/module/account/service/impl/BuyerAccountServiceImpl.java
+++ b/src/main/java/com/aida/buyer/module/account/service/impl/BuyerAccountServiceImpl.java
@@ -30,12 +30,13 @@ public class BuyerAccountServiceImpl implements IBuyerAccountService {
public Boolean sendCode(SendCodeDTO dto) {
String email = dto.getEmail();
+ String operationType = dto.getOperationType();
String code = RandomsUtil.generateVerifyCode(100000L, 999999L);
- String cacheKey = "FORGET_PWD_" + email;
+ String cacheKey = operationType + "_" + email;
LoginCacheUtil.setVerifyCodeCache(cacheKey, code);
SendEmailUtil.sendVerifyCode(email, code);
- log.info("Email verification code sent to: {}", email);
+ log.info("Email verification code sent to: {},code:{}", email, code);
return Boolean.TRUE;
}
@@ -85,7 +86,7 @@ public class BuyerAccountServiceImpl implements IBuyerAccountService {
LoginCacheUtil.setVerifyCodeCache(cacheKey, code);
SendEmailUtil.sendVerifyCode(email, code);
- log.info("PreLogin verification code sent to: {}", email);
+ log.info("PreLogin verification code sent to: {},code:{}", email, code);
PreLoginVO vo = new PreLoginVO();
vo.setUserId(account.getId());
diff --git a/src/main/java/com/aida/buyer/module/order/controller/BuyerOrderController.java b/src/main/java/com/aida/buyer/module/order/controller/BuyerOrderController.java
index 2567e71..a2c3adc 100644
--- a/src/main/java/com/aida/buyer/module/order/controller/BuyerOrderController.java
+++ b/src/main/java/com/aida/buyer/module/order/controller/BuyerOrderController.java
@@ -2,8 +2,10 @@ package com.aida.buyer.module.order.controller;
import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
+import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.service.IBuyerOrderService;
+import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -43,4 +45,10 @@ public class BuyerOrderController {
public Response createOrder(@RequestBody List listingIds) {
return buyerOrderService.createOrder(listingIds);
}
+
+ @PostMapping("/assets/page")
+ @Operation(summary = "我的资产分页查询")
+ public Response> getMyAssets(@RequestBody AssetsDTO dto) {
+ return buyerOrderService.getMyAssets(dto);
+ }
}
diff --git a/src/main/java/com/aida/buyer/module/order/dto/AssetsDTO.java b/src/main/java/com/aida/buyer/module/order/dto/AssetsDTO.java
new file mode 100644
index 0000000..374718c
--- /dev/null
+++ b/src/main/java/com/aida/buyer/module/order/dto/AssetsDTO.java
@@ -0,0 +1,29 @@
+package com.aida.buyer.module.order.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@Schema(description = "我的资产分页查询请求参数")
+public class AssetsDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Schema(description = "买家ID(自动填充,无需传入)")
+ private Long buyerId;
+
+ @Schema(description = "商品分类列表,支持多选")
+ private List categories;
+
+ @Schema(description = "适用性别 female/male/all,不传表示全部")
+ private String designFor;
+
+ @Schema(description = "页码,默认1")
+ private long page = 1;
+
+ @Schema(description = "每页数量,默认10")
+ private long size = 10;
+}
diff --git a/src/main/java/com/aida/buyer/module/order/feign/OrderFeignClient.java b/src/main/java/com/aida/buyer/module/order/feign/OrderFeignClient.java
index 755e106..e9b618d 100644
--- a/src/main/java/com/aida/buyer/module/order/feign/OrderFeignClient.java
+++ b/src/main/java/com/aida/buyer/module/order/feign/OrderFeignClient.java
@@ -3,16 +3,16 @@ package com.aida.buyer.module.order.feign;
import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
import com.aida.buyer.module.feign.annotation.InternalCall;
+import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.dto.CreateOrderDTO;
+import com.aida.buyer.module.order.dto.UpdateOrderStatusDTO;
+import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import com.aida.buyer.module.order.vo.CreateOrderResultVO;
-import com.aida.buyer.module.order.dto.UpdateOrderStatusDTO;
-
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -23,13 +23,19 @@ import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "aida-seller", contextId = "order", path = "/order")
public interface OrderFeignClient {
+ @InternalCall
@PostMapping("/buyer/orders")
Response> getOrdersByBuyerId(@RequestBody BuyerOrdersDTO dto);
+ @InternalCall
@PostMapping("/create")
Response createOrder(@RequestBody CreateOrderDTO dto);
@InternalCall
@PutMapping("/status/batch")
Response updateOrderStatus(@RequestBody UpdateOrderStatusDTO dto);
+
+ @InternalCall
+ @PostMapping("/assets/page")
+ Response> getAssetsPage(@RequestBody AssetsDTO dto);
}
diff --git a/src/main/java/com/aida/buyer/module/order/service/IBuyerOrderService.java b/src/main/java/com/aida/buyer/module/order/service/IBuyerOrderService.java
index 0fafa41..d806cb4 100644
--- a/src/main/java/com/aida/buyer/module/order/service/IBuyerOrderService.java
+++ b/src/main/java/com/aida/buyer/module/order/service/IBuyerOrderService.java
@@ -2,7 +2,9 @@ package com.aida.buyer.module.order.service;
import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
+import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
+import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import java.util.List;
@@ -12,4 +14,6 @@ public interface IBuyerOrderService {
Response> getMyOrders(BuyerOrdersDTO dto);
Response createOrder(List listingIds);
+
+ Response> getMyAssets(AssetsDTO dto);
}
diff --git a/src/main/java/com/aida/buyer/module/order/service/impl/BuyerOrderServiceImpl.java b/src/main/java/com/aida/buyer/module/order/service/impl/BuyerOrderServiceImpl.java
index 81966aa..cb190af 100644
--- a/src/main/java/com/aida/buyer/module/order/service/impl/BuyerOrderServiceImpl.java
+++ b/src/main/java/com/aida/buyer/module/order/service/impl/BuyerOrderServiceImpl.java
@@ -6,10 +6,12 @@ import com.aida.buyer.common.result.PageResponse;
import com.aida.buyer.common.result.Response;
import com.aida.buyer.module.account.entity.BuyerAccount;
import com.aida.buyer.module.account.mapper.BuyerAccountMapper;
+import com.aida.buyer.module.order.dto.AssetsDTO;
import com.aida.buyer.module.order.dto.BuyerOrdersDTO;
import com.aida.buyer.module.order.dto.CreateOrderDTO;
import com.aida.buyer.module.order.feign.OrderFeignClient;
import com.aida.buyer.module.order.service.IBuyerOrderService;
+import com.aida.buyer.module.order.vo.AssetsVO;
import com.aida.buyer.module.order.vo.BuyerOrderVO;
import com.aida.buyer.module.order.vo.CreateOrderResultVO;
import lombok.RequiredArgsConstructor;
@@ -48,4 +50,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
// TODO:调用支付模块,传入buyerId,result.getOrderIds(),result.getTotalAmount()
return Response.success();
}
+
+ @Override
+ public Response> getMyAssets(AssetsDTO dto) {
+ dto.setBuyerId(UserContext.getBuyerId());
+ return orderFeignClient.getAssetsPage(dto);
+ }
}
diff --git a/src/main/java/com/aida/buyer/module/order/vo/AssetsVO.java b/src/main/java/com/aida/buyer/module/order/vo/AssetsVO.java
new file mode 100644
index 0000000..1f47399
--- /dev/null
+++ b/src/main/java/com/aida/buyer/module/order/vo/AssetsVO.java
@@ -0,0 +1,33 @@
+package com.aida.buyer.module.order.vo;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+@Schema(description = "我的资产商品明细")
+public class AssetsVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Schema(description = "商品ID")
+ @JsonSerialize(using = ToStringSerializer.class)
+ private Long listingId;
+
+ @Schema(description = "商品名称")
+ private String listingName;
+
+ @Schema(description = "商品缩略图URL")
+ private String thumbnailUrl;
+
+ @Schema(description = "成交单价(HK$)")
+ private BigDecimal price;
+
+ @Schema(description = "购买时间")
+ private LocalDateTime createTime;
+}