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/NoticeReceiveController.java

60 lines
2.9 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.controller; // 定义包名
import com.github.pagehelper.PageInfo; // 导入分页插件
import com.yanzhen.entity.NoticeReceive; // 导入公告接收实体类
import com.yanzhen.service.NoticeReceiveService; // 导入公告接收服务接口
import com.yanzhen.utils.Result; // 导入结果工具类
import org.springframework.beans.factory.annotation.Autowired; // 导入自动装配注解
import org.springframework.web.bind.annotation.*; // 导入Spring MVC相关注解
import java.util.Map; // 导入Map接口
@RestController // 声明这是一个控制器并且返回的数据直接写入HTTP响应体中
@RequestMapping("/noticeReceive") // 设置请求路径前缀为/noticeReceive
public class NoticeReceiveController { // 定义控制器类
@Autowired // 自动注入NoticeReceiveService实例
private NoticeReceiveService noticeReceiveService;
@PostMapping("create") // 映射POST请求到create方法
public Result create(@RequestBody NoticeReceive noticeReceive){ // 接收JSON格式的公告接收数据
int flag = noticeReceiveService.create(noticeReceive); // 调用服务层创建公告接收
if(flag>0){ // 如果创建成功
return Result.ok(); // 返回成功结果
}else{ // 如果创建失败
return Result.fail(); // 返回失败结果
}
}
@GetMapping("delete") // 映射GET请求到delete方法
public Result delete(String ids){ // 接收要删除的公告接收ID字符串
int flag = noticeReceiveService.delete(ids); // 调用服务层删除公告接收
if(flag>0){ // 如果删除成功
return Result.ok(); // 返回成功结果
}else{ // 如果删除失败
return Result.fail(); // 返回失败结果
}
}
@PostMapping("update") // 映射POST请求到update方法
public Result update(@RequestBody NoticeReceive noticeReceive){ // 接收JSON格式的公告接收数据
int flag = noticeReceiveService.update(noticeReceive); // 调用服务层更新公告接收
if(flag>0){ // 如果更新成功
return Result.ok(); // 返回成功结果
}else{ // 如果更新失败
return Result.fail(); // 返回失败结果
}
}
@GetMapping("detail") // 映射GET请求到detail方法
public NoticeReceive detail(Integer id){ // 接收公告接收ID
return noticeReceiveService.detail(id); // 调用服务层获取公告接收详情并返回
}
@PostMapping("query") // 映射POST请求到query方法
public Map<String,Object> query(@RequestBody NoticeReceive noticeReceive){ // 接收JSON格式的查询条件
PageInfo<NoticeReceive> pageInfo = noticeReceiveService.query(noticeReceive); // 调用服务层进行分页查询
return Result.ok(pageInfo); // 返回包含分页信息的查询结果
}
}