标签:void turn extends ide private bsp control tsp rgs
@Entity public class Grade { @Id @GeneratedValue(strategy= GenerationType.AUTO) private Integer grade_id; private String grade_name; public Integer getGrade_id() { return grade_id; } public void setGrade_id(Integer grade_id) { this.grade_id = grade_id; } public String getGrade_name() { return grade_name; } public void setGrade_name(String grade_name) { this.grade_name = grade_name; } }
@Repository public interface IGradeMapper extends CrudRepository<Grade,Integer> { }
@RestController @RequestMappng("/IGradeController") public class IGradeController { @Resource private IGradeService iGradeService; //新增数据 @RequestMapping("/insertGrade") public Grade insertGrade(){ Grade grade=new Grade(); grade.setGrade_name("S1"); return iGradeService.insertGrade(grade); } @RequestMapping("/updateGrade") public Grade updateGrade(){ Grade grade=new Grade(); grade.setGrade_id(1); grade.setGrade_name("S2"); return iGradeService.updateGrade(grade); } @RequestMapping("/deleteGrade") public void deleteGrade(){ iGradeService.deleteGrade(1); } @RequestMapping("/getAllGrade") public Iterable<Grade> getAllGrade(){ return iGradeService.getAll(); } }
public interface IGradeService { public Grade insertGrade(Grade grade); public Grade updateGrade(Grade grade); public void deleteGrade(Integer id); public Iterable<Grade> getAll(); }
@Service("iGradeService") public class IGradeServcieImpl implements IGradeService { @Resource private IGradeMapper iGradeMapper; @Override public Grade insertGrade(Grade grade) { return iGradeMapper.save(grade); } @Override public Grade updateGrade(Grade grade) { return iGradeMapper.save(grade); } @Override public void deleteGrade(Integer id) { iGradeMapper.delete(id); } @Override public Iterable<Grade> getAll() { return iGradeMapper.findAll(); } }
@SpringBootApplication public class StartSpringBoot { public static void main(String[] args) { SpringApplication.run(StartSpringBoot.class,args); } }
标签:void turn extends ide private bsp control tsp rgs
原文地址:https://www.cnblogs.com/dabrk/p/12030592.html