package com.yanzhen.service; // 定义包名 import com.yanzhen.mapper.SelectionJoinerMapper; // 导入SelectionJoinerMapper接口 import com.yanzhen.entity.SelectionJoiner; // 导入SelectionJoiner实体类 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 SelectionJoinerService { // 定义SelectionJoinerService类 @Autowired // 自动装配SelectionJoinerMapper对象 private SelectionJoinerMapper selectionJoinerMapper; public int create(SelectionJoiner selectionJoiner) { // 创建SelectionJoiner记录的方法 return selectionJoinerMapper.create(selectionJoiner); // 调用Mapper层的create方法 } public int delete(String ids) { // 根据ID字符串批量删除SelectionJoiner记录的方法 String[] arr = ids.split(","); // 将ID字符串按逗号分割成数组 int row = 0; // 初始化受影响行数为0 for (String s : arr) { // 遍历ID数组 if(!StringUtils.isEmpty(s)){ // 如果ID不为空 selectionJoinerMapper.delete(Integer.parseInt(s)); // 调用Mapper层的delete方法删除记录 row++; // 受影响行数加1 } } return row; // 返回受影响行数 } public int delete(Integer id) { // 根据ID删除SelectionJoiner记录的方法 return selectionJoinerMapper.delete(id); // 调用Mapper层的delete方法 } public int update(SelectionJoiner selectionJoiner) { // 更新SelectionJoiner记录的方法 return selectionJoinerMapper.update(selectionJoiner); // 调用Mapper层的update方法 } public int updateSelective(SelectionJoiner selectionJoiner) { // 选择性更新SelectionJoiner记录的方法 return selectionJoinerMapper.updateSelective(selectionJoiner); // 调用Mapper层的updateSelective方法 } public PageInfo query(SelectionJoiner selectionJoiner) { // 查询SelectionJoiner记录列表的方法 if(selectionJoiner != null && selectionJoiner.getPage() != null){ // 如果查询条件和分页信息不为空 PageHelper.startPage(selectionJoiner.getPage(),selectionJoiner.getLimit()); // 启动分页并设置分页参数 } return new PageInfo(selectionJoinerMapper.query(selectionJoiner)); // 调用Mapper层的query方法并封装成PageInfo对象返回 } public SelectionJoiner detail(Integer id) { // 根据ID获取SelectionJoiner详情的方法 return selectionJoinerMapper.detail(id); // 调用Mapper层的detail方法 } public int count(SelectionJoiner selectionJoiner) { // 统计SelectionJoiner记录数量的方法 return selectionJoinerMapper.count(selectionJoiner); // 调用Mapper层的count方法 } }