Ver código fonte

lp联合查询

skyfffire 2 anos atrás
pai
commit
38c4b7a41d

+ 13 - 4
src/main/java/modules/address/address.sqlt

@@ -2,8 +2,8 @@
 #sql("findByChainIdAndHash")
 select a.name as addressName, a.comment as addressComment, a.type as addressType, a.other as addressOther, 
        b.*
-from #(_PARA_ARRAY_[0]) b inner join t_address a
-on a.chainId=b.chainId and a.hash=b.hash
+from #(_PARA_ARRAY_[0]) b 
+inner join t_address a on a.chainId=b.chainId and a.hash=b.hash
 where a.chainId=#para(1) and a.hash=#para(2)
 #end
 
@@ -11,11 +11,20 @@ where a.chainId=#para(1) and a.hash=#para(2)
 #sql("findByChainId")
 select a.name as addressName, a.comment as addressComment, a.type as addressType, a.other as addressOther, 
        b.*
-from #(_PARA_ARRAY_[0]) b inner join t_address a
-on a.chainId=b.chainId and a.hash=b.hash
+from #(_PARA_ARRAY_[0]) b 
+inner join t_address a on a.chainId=b.chainId and a.hash=b.hash
 where a.chainId=#para(1)
 #end
 
+#查询lp
+#sql("findLpByChainId")
+select l.*, t0.decimals as decimals0, t1.decimals as decimals1
+from #(_PARA_ARRAY_[0]) l
+left join t_token t0 on t0.chainId=l.chainId and t0.hash=l.token0
+left join t_token t1 on t1.chainId=l.chainId and t1.hash=l.token1
+where not isnull(l.token0) and not isnull(l.token1)
+#end
+
 #查询满足条件的address大类的name
 #sql("findNameByChainIdAndHash")
 select t.name as name

+ 14 - 0
src/main/java/modules/address/lp/LpService.java

@@ -0,0 +1,14 @@
+package modules.address.lp;
+
+import com.jfinal.plugin.activerecord.Db;
+import com.jfinal.plugin.activerecord.Record;
+import common.utils.http.MyPaginate;
+
+import java.util.List;
+
+public class LpService {
+	public List<Record> findLpByChainId(String tableName, int chainId, MyPaginate p) {
+		return Db.template("address.findLpByChainId", tableName, chainId)
+				.paginate(p.getPageNumber(), p.getPageSize()).getList();
+	}
+}

+ 9 - 0
src/main/java/modules/address/lp/bal/BalLpService.java

@@ -5,13 +5,18 @@ import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import common.model.Address;
 import common.model.BalLp;
+import common.utils.http.MyPaginate;
+import common.utils.model.TableUtil;
 import modules.address.AddressService;
+import modules.address.lp.LpService;
 
 import java.util.List;
 
 public class BalLpService {
 	@Inject
 	private AddressService addressService;
+	@Inject
+	private LpService lpService;
 
 	public boolean append(BalLp balLp, Address address) {
 		boolean isAddressExist = addressService.isAddressExist(address);
@@ -38,4 +43,8 @@ public class BalLpService {
 	public List<Record> findByChainId(int chainId, int pageNumber, int pageSize) {
 		return Db.template("address.findByChainId", "t_bal_lp", chainId).paginate(pageNumber, pageSize).getList();
 	}
+
+	public List<Record> findByChainId(int chainId, MyPaginate p) {
+		return lpService.findLpByChainId(TableUtil.getTableName(BalLp.class), chainId, p);
+	}
 }

+ 1 - 1
src/main/java/modules/address/lp/v2/V2LpController.java

@@ -51,7 +51,7 @@ public class V2LpController extends MyController {
 		V2Lp v2Lp = getJsonModel(V2Lp.class);
 		MyPaginate p = getJsonModel(MyPaginate.class);
 
-		List<Record> rstList = service.findByChainId(v2Lp.getChainId(), p.getPageNumber(), p.getPageSize());
+		List<Record> rstList = service.findByChainId(v2Lp.getChainId(), p);
 		renderJson(MyRet.ok("V2Lps is found.").setData(rstList));
 	}
 }

+ 7 - 2
src/main/java/modules/address/lp/v2/V2LpService.java

@@ -5,13 +5,18 @@ import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import common.model.Address;
 import common.model.V2Lp;
+import common.utils.http.MyPaginate;
+import common.utils.model.TableUtil;
 import modules.address.AddressService;
+import modules.address.lp.LpService;
 
 import java.util.List;
 
 public class V2LpService {
 	@Inject
 	private AddressService addressService;
+	@Inject
+	private LpService lpService;
 
 	public boolean append(V2Lp v2Lp, Address address) {
 		boolean isAddressExist = addressService.isAddressExist(address);
@@ -35,7 +40,7 @@ public class V2LpService {
 		return Db.template("address.findByChainIdAndHash", "t_v2_lp", chainId, hash).findFirst();
 	}
 
-	public List<Record> findByChainId(int chainId, int pageNumber, int pageSize) {
-		return Db.template("address.findByChainId", "t_v2_lp", chainId).paginate(pageNumber, pageSize).getList();
+	public List<Record> findByChainId(int chainId, MyPaginate p) {
+		return lpService.findLpByChainId(TableUtil.getTableName(V2Lp.class), chainId, p);
 	}
 }

+ 1 - 1
src/main/java/modules/address/lp/v3/V3LpController.java

@@ -51,7 +51,7 @@ public class V3LpController extends MyController {
 		V3Lp v3Lp = getJsonModel(V3Lp.class);
 		MyPaginate p = getJsonModel(MyPaginate.class);
 
-		List<Record> rstList = service.findByChainId(v3Lp.getChainId(), p.getPageNumber(), p.getPageSize());
+		List<Record> rstList = service.findByChainId(v3Lp.getChainId(), p);
 		renderJson(MyRet.ok("V3Lps is found.").setData(rstList));
 	}
 }

+ 7 - 2
src/main/java/modules/address/lp/v3/V3LpService.java

@@ -5,13 +5,18 @@ import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import common.model.Address;
 import common.model.V3Lp;
+import common.utils.http.MyPaginate;
+import common.utils.model.TableUtil;
 import modules.address.AddressService;
+import modules.address.lp.LpService;
 
 import java.util.List;
 
 public class V3LpService {
 	@Inject
 	private AddressService addressService;
+	@Inject
+	private LpService lpService;
 
 	public boolean append(V3Lp v3Lp, Address address) {
 		boolean isAddressExist = addressService.isAddressExist(address);
@@ -35,7 +40,7 @@ public class V3LpService {
 		return Db.template("address.findByChainIdAndHash", "t_v3_lp", chainId, hash).findFirst();
 	}
 
-	public List<Record> findByChainId(int chainId, int pageNumber, int pageSize) {
-		return Db.template("address.findByChainId", "t_v3_lp", chainId).paginate(pageNumber, pageSize).getList();
+	public List<Record> findByChainId(int chainId, MyPaginate p) {
+		return lpService.findLpByChainId(TableUtil.getTableName(V3Lp.class), chainId, p);
 	}
 }

+ 5 - 1
src/test/http/address/V2LpTest.http

@@ -36,5 +36,9 @@ Content-Type: application/json
 {
   "chainId": 1,
   "pageNumber": 1,
-  "pageSize": 200
+  "pageSize": 200,
+  "auth": {
+    "auth": "9d8b7074bf189dcad17189c8f264c0cb",
+    "timestamp": "123123"
+  }
 }