作业01

1. 根据ID查询所有学生信息

在这里插入图片描述
在这里插入图片描述

2. 实现对学生成绩的增删改查以及分页

  • 模糊查询
  • 分页
package com.example.ewspace.mapper;

import com.example.ewspace.enty.Student;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper {

    // 新增
    @Insert("insert into student(name,classes,subject,score) values(#{name},#{classes},#{subject},#{score})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    boolean addStudent(Student s);

    // 修改
    @Update("update student set name=#{name},classes=#{classes},subject=#{subject},score=#{score} where id=#{id}")
    boolean updateStudent(Student s);

    // 删除
    @Delete("delete from student where id = #{id}")
    boolean delStudentById(int id);

    // 查
    @Select("select * from student where #{id}")
    List<Student> selectStudentById(int id);

    /**
     * 分页查询
     * 动态查询  type:指定一个类
     * method:使用这个类中的selectWhitParamSql方法返回的sql字符串
     * 作为查询的语句
     */
    @Select("select * from student")
    List<Student> selectStudentList();

}

package com.example.ewspace.controller;

import com.example.ewspace.enty.Student;
import com.example.ewspace.service.StudentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/testStudent")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("selectStudent/{id}")
    public List<Student> SelectStudent(@PathVariable int id) {
        return studentService.SelectStudent(id);
    }

    public boolean addStudent(@PathVariable Student s) {
        return studentService.addStudent(s);
    }

    @RequestMapping("/fy")
    public PageInfo<Student> selectStudentListByName(@RequestParam(value="pageNum",defaultValue="1") int pageNum,
                                                     @RequestParam(value="pageSize",defaultValue="5") int pageSize) {
        PageInfo<Student> pageInfo = studentService.selectStudentList(pageNum,pageSize);
        return pageInfo;
    }
}

package com.example.ewspace.service;

import com.example.ewspace.enty.Student;
import com.example.ewspace.mapper.StudentMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {

    @Autowired
    StudentMapper studentMapper;

    public List<Student> SelectStudent(int id) {
        return studentMapper.selectStudentById(id);
    }

    public boolean addStudent(Student s) {
        return studentMapper.addStudent(s);
    }

    public PageInfo<Student> selectStudentList(int pageNum, int pageSize) {
        //1.startPage--start,设置当前页和每页显示条数
        PageHelper.startPage(pageNum,pageSize);
        //2.填充自己的sql查询逻辑
        List<Student> list = studentMapper.selectStudentList();
        //3.pageHelper收尾,将返回结果信息进行分页处理
        PageInfo<Student> pageResult = new PageInfo<Student>(list);
        return pageResult;
    }
}

package test;

import com.example.ewspace.EwspaceApplication;
import com.example.ewspace.enty.Student;
import com.example.ewspace.mapper.StudentMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@SpringBootTest(classes = EwspaceApplication.class)
@RunWith(SpringRunner.class)
public class StudentTest {

    @Autowired
    private StudentMapper studentMapper;

    @Test
    public void testSelectStudentById() {
        List<Student> list = studentMapper.selectStudentById(1);
        list.forEach(System.out::println);
    }

    @Test
    public void testaddStudent() {
        Student s = new Student();
        s.setName("zhangshan");
        s.setClasses("3");
        s.setSubject("s2");
        s.setScore("88");
        boolean i = studentMapper.addStudent(s);
        System.out.println(i ? "添加成功":"添加失败");
    }

    @Test
    public void updateStudent() {
        Student s = new Student();
        s.setId(2);
        s.setName("nanjing");
        s.setClasses("2");
        s.setSubject("s2");
        s.setScore("78");
        boolean i = studentMapper.updateStudent(s);
        System.out.println(i ? "修改成功":"修改失败");
    }

    @Test
    public void delStudent() {
        boolean i = studentMapper.delStudentById(13);
        System.out.println(i ? "删除成功":"删除失败");
    }

    @Test
    public void selectStudentListById() {
        int pageNum = 1;
        int pageSize = 5;
        PageHelper.startPage(pageNum,pageSize);
        List<Student> list = studentMapper.selectStudentList();
        PageInfo<Student> pageResult = new PageInfo<Student>(list);
        System.out.println(pageResult);
    }
}

自己举一反三吧:

访问网址:http://localhost:8081/testStudent/fy/
在这里插入图片描述

2. 实现对学生成绩的增删改查以及分页(在上一题基础上使用动态SQL批量判断)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
图像识别技术在病虫害检测的应用是一个快速发展的领域,它结合了计算机视觉和机器学习算法来自动识别和分类植物上的病虫害。以下是这一技术的一些关键步骤和组成部分: 1. **数据收集**:首先需要收集大量的植物图像数据,这些数据包括健康植物的图像以及受不同病虫害影响的植物图像。 2. **图像预处理**:对收集到的图像进行处理,以提高后续分析的准确性。这可能包括调整亮度、对比度、去噪、裁剪、缩放等。 3. **特征提取**:从图像提取有助于识别病虫害的特征。这些特征可能包括颜色、纹理、形状、边缘等。 4. **模型训练**:使用机器学习算法(如支持向量机、随机森林、卷积神经网络等)来训练模型。训练过程,算法会学习如何根据提取的特征来识别不同的病虫害。 5. **模型验证和测试**:在独立的测试集上验证模型的性能,以确保其准确性和泛化能力。 6. **部署和应用**:将训练好的模型部署到实际的病虫害检测系统,可以是移动应用、网页服务或集成到智能农业设备。 7. **实时监测**:在实际应用,系统可以实时接收植物图像,并快速给出病虫害的检测结果。 8. **持续学习**:随着时间的推移,系统可以不断学习新的病虫害样本,以提高其识别能力。 9. **用户界面**:为了方便用户使用,通常会有一个用户友好的界面,显示检测结果,并提供进一步的指导或建议。 这项技术的优势在于它可以快速、准确地识别出病虫害,甚至在早期阶段就能发现问题,从而及时采取措施。此外,它还可以减少对化学农药的依赖,支持可持续农业发展。随着技术的不断进步,图像识别在病虫害检测的应用将越来越广泛。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值