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