Explorar o código

用户端-订单和用户端-商品添加查询从库的注解

liu hai 8 meses
pai
achega
315ab44f23

+ 12 - 0
src/main/java/com/sqx/modules/goods/service/impl/GoodsServiceImpl.java

@@ -14,6 +14,7 @@ import com.sqx.common.exception.SqxException;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.RedisUtils;
 import com.sqx.common.utils.Result;
+import com.sqx.datasource.annotation.DataSource;
 import com.sqx.modules.activity.service.ActivityShopService;
 import com.sqx.modules.activity.vo.ShopActivityVO;
 import com.sqx.modules.common.entity.CommonInfo;
@@ -160,6 +161,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
 
 
     @Override
+    @DataSource("dynamic")
     public Result selectGoodsList(Long shopId, Double lng, Double lat) {
         GoodsShop goodsShop = goodsShopDao.selectGoodsList(shopId, lng, lat);
         //List<Goods> goodsList = goodsDao.selectGoodsClassifyList(shopId);
@@ -390,6 +392,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectShortShop(double lng, double lat, String shopName, Integer page, Integer limit, Long shopId) {
         Page<GoodsShop> pages = new Page<>(page, limit);
         IPage<GoodsShop> goodsShopIPage = goodsDao.selectShortShop(pages, lng, lat, shopName, shopId);
@@ -504,6 +507,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectShop(ShopQueryDTO queryDTO) {
         //如果没有经纬度,则默认为北京的经纬度
         Double lat = queryDTO.getLat();
@@ -733,6 +737,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
 //    }
 
     @Override
+    @DataSource("dynamic")
     public Result selectGoodsById(Long goodsId) {
         Goods goods = goodsDao.selectGoodsById(goodsId);
         if (goods != null) {
@@ -804,6 +809,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectSupplierShop(ShopQueryDTO queryDTO) {
         //如果没有经纬度,则默认为北京的经纬度
         Double lat = queryDTO.getLat();
@@ -863,6 +869,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectGoodShop(Long shopId) {
         GoodsShop goodsShop = goodsShopDao.selectById(shopId);
 
@@ -887,6 +894,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result goodsCoverList(Integer page,Integer limit,String name) {
         Page<Goods> pages = new Page<>(page, limit);
         Integer total=(page-1)*limit;
@@ -896,6 +904,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result goodsPictureList(Integer page, Integer limit, String name) {
         Page<Goods> pages = new Page<>(page, limit);
         Integer total=(page-1)*limit;
@@ -905,6 +914,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result goodsParticularsPictureList(Integer page, Integer limit, String name) {
         Page<Goods> pages = new Page<>(page, limit);
         Integer total=(page-1)*limit;
@@ -914,6 +924,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectGoodsClassifyList(Long shopId, Double lng, Double lat) {
         GoodsShop goodsShop = goodsShopDao.selectGoodsList(shopId, lng, lat);
         //List<Goods> goodsList = goodsDao.selectGoodsClassifyList(shopId);
@@ -936,6 +947,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectSupermarketGoodsList(Long shopId, Integer classifyId, Integer page, Integer limit) {
         Page<Goods> pages = new Page<>(page, limit);
         IPage<Goods> goodsIPage = goodsDao.selectSupermarketGoodsList(pages,shopId, classifyId);

+ 11 - 0
src/main/java/com/sqx/modules/order/service/impl/AppAppOrderServiceImpl.java

@@ -26,6 +26,7 @@ import com.sqx.common.utils.DistanceUtil;
 import com.sqx.common.utils.MyGlobalThreadPool;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
+import com.sqx.datasource.annotation.DataSource;
 import com.sqx.modules.activity.entity.ActivityPartRecord;
 import com.sqx.modules.activity.service.ActivityPartRecordService;
 import com.sqx.modules.activity.service.ActivityService;
@@ -394,6 +395,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectShareTheBill(Long userId, Long orderId) {
         HashMap hashMap = new HashMap();
         TbOrder tbOrder = appOrderDao.selectById(orderId);
@@ -432,6 +434,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public IPage<Evaluate> getEvaluateList(Evaluate evaluate, Integer page, Integer limit) {
         Page<Evaluate> pages;
         if (page != null && limit != null) {
@@ -1364,6 +1367,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result echoOrder(Long userId, Long shopId, Long goodsId) {
         TbOrder tbOrder = appOrderDao.selectOne(new QueryWrapper<TbOrder>().eq("user_id", userId).eq("shop_id", shopId).eq("status", 1));
         if (tbOrder == null) {
@@ -1587,6 +1591,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result waitTakeFood(Long userId, Integer orderType, Integer page, Integer limit, Integer status) {
         Page<TbOrder> pages = new Page<>(page, limit);
         IPage<TbOrder> tbOrderIPage = appOrderDao.waitTakeFood(pages, userId, orderType, status);
@@ -1612,6 +1617,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectOrderById(Long orderId) {
         TbOrder tbOrder = appOrderDao.selectByOrderId(orderId);
 
@@ -2351,6 +2357,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectShoppingTrolley(Long userId) {
         List<TbOrder> tbOrderIPage = appOrderDao.selectShoppingTrolley(userId);
         for (int i = 0; i < tbOrderIPage.size(); i++) {
@@ -2362,6 +2369,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectShoppingTrolleyByShopId(Long userId, Long shopId) {
         TbOrder tbOrders = appOrderDao.selectShoppingTrolleyByShopId(userId, shopId);
         List<OrderGoods> orderGoods = orderGoodsDao.selectList(new QueryWrapper<OrderGoods>().eq("order_id", tbOrders.getOrderId()));
@@ -2517,6 +2525,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectBuyGoods(Long userId, Long orderId) {
         TbOrder tbOrder = appOrderDao.selectBuyGoods(orderId, userId);
         List<OrderGoods> orderGoodsList = orderGoodsDao.selectList(new QueryWrapper<OrderGoods>().eq("order_id", tbOrder.getOrderId()));
@@ -2711,6 +2720,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public Result selectOrder(Long userId, Integer orderId, Integer page, Integer limit) {
         HashMap hashMap = new HashMap();
         Page<TbOrder> pages = new Page(page, limit);
@@ -2920,6 +2930,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     }
 
     @Override
+    @DataSource("dynamic")
     public PageUtils getGoodsSkuSalesCount(GoodsSkuQuery query) {
         Page<GoodsSkuSalesCountVO> pages = new Page<>(query.getPage(), query.getLimit());
 

+ 10 - 6
src/main/resources/application-dev.yml

@@ -3,9 +3,12 @@ spring:
         type: com.alibaba.druid.pool.DruidDataSource
         druid:
             driver-class-name: com.mysql.cj.jdbc.Driver
-            url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT&useAffectedRows=true
+#            url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT&useAffectedRows=true
+#            username: root
+#            password: chuanghai@2024
+            url: jdbc:mysql://172.22.45.21:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT&useAffectedRows=true
             username: root
-            password: chuanghai@2024
+            password: Chuanghai2024.
             initial-size: 100
             max-active: 500
             min-idle: 10
@@ -123,11 +126,12 @@ sftp:
 
 dynamic:
     driver-class-name: com.mysql.cj.jdbc.Driver
-#    url: jdbc:mysql://172.16.20.104:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
-    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+#    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+#    username: root
+#    password: chuanghai@2024
+    url: jdbc:mysql://172.22.45.21:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT&useAffectedRows=true
     username: root
-#    password: ch@2025.wm
-    password: chuanghai@2024
+    password: Chuanghai2024.
     initial-size: 15
     max-active: 100
     min-idle: 10