TestService.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.example.fms.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4. import com.example.fms.domain.Test;
  5. import com.example.fms.mapper.TestMapper;
  6. import lombok.RequiredArgsConstructor;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.apache.poi.ss.formula.functions.T;
  9. import org.springframework.context.annotation.Lazy;
  10. import org.springframework.stereotype.Service;
  11. import java.util.List;
  12. /**
  13. * @Author xiexiang
  14. * @Date 2023/6/12
  15. */
  16. @Service
  17. @Slf4j
  18. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  19. public class TestService extends ServiceImpl<TestMapper, Test> {
  20. public void add(Test test){
  21. test.setName("Tse");
  22. test.setAddress("江苏省玉山镇");
  23. test.setPhone("18625069786");
  24. test.insert();
  25. }
  26. public void update(Test test){
  27. test.setName("Sxy");
  28. test.updateById();
  29. }
  30. public List<Test> query2(){
  31. List<Test> tests = this.list();
  32. System.out.println("tests = " + tests);
  33. return tests;
  34. }
  35. public Test query1(String name){
  36. LambdaQueryWrapper<Test> LW = new LambdaQueryWrapper<>();
  37. LW.eq(Test::getName, name);
  38. Test test = this.getOne(LW);
  39. System.out.println("test = " + test);
  40. return test;
  41. }
  42. public void delete(String name){
  43. Test test = this.query1(name);
  44. test.deleteById();
  45. }
  46. }