You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ssgl/zsq/GradeService年级管理.java

59 lines
2.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.yanzhen.service; // 定义包名
import com.yanzhen.mapper.GradeMapper; // 导入GradeMapper接口
import com.yanzhen.entity.Grade; // 导入Grade实体类
import com.github.pagehelper.PageHelper; // 导入PageHelper分页工具类
import com.github.pagehelper.PageInfo; // 导入PageInfo分页信息类
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring的自动装配注解
import org.springframework.stereotype.Service; // 导入Spring的服务层注解
import org.springframework.util.StringUtils; // 导入Spring的工具类用于字符串操作
@Service // 标注该类为服务层组件
public class GradeService { // 定义GradeService类 “年级管理----管理员”
@Autowired // 自动装配GradeMapper对象
private GradeMapper gradeMapper;
public int create(Grade grade) { // 创建Grade记录的方法
return gradeMapper.create(grade); // 调用GradeMapper的create方法并返回结果
}
public int delete(String ids) { // 根据ID字符串批量删除Grade记录的方法
String[] arr = ids.split(","); // 将ID字符串按逗号分割成数组
int row = 0; // 初始化受影响行数为0
for (String s : arr) { // 遍历ID数组
if(!StringUtils.isEmpty(s)){ // 如果ID不为空
gradeMapper.delete(Integer.parseInt(s)); // 调用GradeMapper的delete方法删除记录
row++; // 受影响行数加1
}
}
return row; // 返回受影响行数
}
public int delete(Integer id) { // 根据ID删除单个Grade记录的方法
return gradeMapper.delete(id); // 调用GradeMapper的delete方法并返回结果
}
public int update(Grade grade) { // 更新Grade记录的方法
return gradeMapper.update(grade); // 调用GradeMapper的update方法并返回结果
}
public int updateSelective(Grade grade) { // 选择性更新Grade记录的方法
return gradeMapper.updateSelective(grade); // 调用GradeMapper的updateSelective方法并返回结果
}
public PageInfo<Grade> query(Grade grade) { // 查询Grade记录列表的方法
if(grade != null && grade.getPage() != null){ // 如果Grade对象和分页参数不为空
PageHelper.startPage(grade.getPage(),grade.getLimit()); // 启动分页并设置分页参数
}
return new PageInfo<Grade>(gradeMapper.query(grade)); // 调用GradeMapper的query方法并返回分页信息
}
public Grade detail(Integer id) { // 根据ID获取Grade详情的方法
return gradeMapper.detail(id); // 调用GradeMapper的detail方法并返回结果
}
public int count(Grade grade) { // 统计Grade记录数量的方法
return gradeMapper.count(grade); // 调用GradeMapper的count方法并返回结果
}
}