liulin
2024-08-05 ad56449d12346611f9cdf4e3c7d6f5112589bdd1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.lunhan.xxx.repository.mapper;
 
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.lunhan.xxx.entity.dto.search.SearchTestInfo;
import com.lunhan.xxx.repository.BasicMapper;
import com.lunhan.xxx.repository.po.TestInfoPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
@Mapper
public interface TestInfoMapper extends BasicMapper<TestInfoPO> {
    // #{param}:会进行预编译,而且进行类型匹配,最后进行变量替换,括号中可以添加映射类型如
//    @Select(
//        "<script>" +
//        "select * from student where id= #{param,javaType=int,jdbcType=NUMERIC}" +
//        "</script> "
//    )
    // ${param}:$只是只是简单的字符串拼接,要特别小心sql注入问题,对应非变量部分,只能用$。$方式一般用于传入数据库对象,比如这种group by 字段 ,order by 字段,表名,字段名等没法使用占位符的就需要使用${param}
 
    @Select("select * from test_info where id = #{id}")
    TestInfoPO testGet(Long id);
 
    @Select("select * from test_info where name = #{name}")
    TestInfoPO testGet2(String userName);
 
    @Select("select * from test_info where status = #{ew.status}")
    List<TestInfoPO> testList1(@Param(Constants.WRAPPER) SearchTestInfo search);
 
    @Select("select * from test_info where status = #{search.status}")
    List<TestInfoPO> testList2(@Param("search") SearchTestInfo search);
 
}