mybatisplus使用@Select

在自己的mapper文件里面 比如我这个是ckDao.java文件,写个方法,然后就可以用 @Autowired 注册这个mapper,就会去执行sql语句

    @Select("SELECT DISTINCT  name FROM `ck` where company = '顺网' and deleted = 1")
    List<CkEntity> listCompany();

    @Select("SELECT count(*) FROM `ck` where company = '顺网' and deleted = 1" + " and name like '%${name}%'")
    String countCompanyData(@Param("name") String name);

实现方法

    @Override
    public XXX listCompanyData() {
        List<CkEntity> ckEntities = ckDao.listCompany();
       
        return XXX;
    }

你可能感兴趣的:(mybatisplus,java)