把这段sql代码转换mybatisplus代码:SELECT p.id, p.identifier,c.company_order,p.business_source,p.salesmen,p.charge,p.contract_sign_date,p.total_money,IFNULL(pa.invoice_money,0.00) invoice_money,IF(pa.invoice_money IS NULL,p.total_money,p.total_money-pa.invoice_money) invoice_money_notready,IFNULL(pa.invoice_money_rate,0.00) invoice_money_rate FROM `ly_project` p LEFT JOIN `ly_project_amount` pa ON pa.project_id = p.id LEFT JOIN `ly_contract` c ON c.id = p.contract_id WHERE p.identifier LIKE '%2305106%' AND c.company_order LIKE '%海量%' ORDER BY p.contract_sign_date
时间: 2024-03-16 19:41:31 浏览: 588
以下是将 SQL 代码转换为 MyBatis Plus 代码的示例:
```java
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
queryWrapper.select("p.id", "p.identifier", "c.company_order", "p.business_source", "p.salesmen", "p.charge", "p.contract_sign_date", "p.total_money", "IFNULL(pa.invoice_money,0.00) invoice_money", "IF(pa.invoice_money IS NULL,p.total_money,p.total_money-pa.invoice_money) invoice_money_notready", "IFNULL(pa.invoice_money_rate,0.00) invoice_money_rate")
.eq("p.identifier", "%2305106%")
.like("c.company_order", "海量")
.orderByAsc("p.contract_sign_date")
.leftJoin(ProjectAmount.class, "pa", "pa.project_id = p.id")
.leftJoin(Contract.class, "c", "c.id = p.contract_id");
List<Project> projectList = projectMapper.selectList(queryWrapper);
```
这段代码中,我们使用了 MyBatis Plus 提供的 `QueryWrapper` 类来构造查询条件,使用 `select` 方法来指定需要查询的字段,使用 `eq` 和 `like` 方法来添加查询条件,使用 `orderByAsc` 方法来指定排序方式,使用 `leftJoin` 方法来添加左连接的表和连接条件。最后,我们调用 `selectList` 方法来执行查询,并将结果保存在 `projectList` 变量中。
阅读全文