介紹
Service接口
接口基礎了接口 IService,實現類實現就需要實現IService里的方法,但是MyBatisplus已經幫我們寫好了實現類,給我們的實現類繼承即可。
public interface IEmpService extends IService<Emp> {
//其他業務方法....
}
Service實現類
這樣Service業務層就有了 Mybaitsplus里的方法
@Service
public class EmpServiceImpl extends ServiceImpl<EmpMapper, Emp> implements IEmpService {
}
Controller
@GetMapping("/list")public Result getEmpList(@RequestParam List<Integer> ids){List<Emp> list =empService.listByIds(ids);//根據ID批量查詢return Result.success("獲取成功",list);}