筛选查询

This commit is contained in:
tortoise 2024-09-01 13:11:50 +08:00
parent e48adf67c3
commit 2b3f5ccbd7
3 changed files with 14 additions and 0 deletions

View File

@ -77,6 +77,10 @@ RecordController {
@PutMapping("/admin/record/{id}")
public Result<CommonResponse> adminUpdateRecord(@PathVariable Integer id, @RequestBody RecordDto recordDto) {
Record record = modelMapper.map(recordDto, Record.class);
Integer i = recordService.IsRecord(id);
if(i==null) {
throw new RuntimeException("该记录不存在");
}
recordService.updateRecord(record, id);
return Result.msg("修改成功");
}
@ -85,6 +89,10 @@ RecordController {
@Operation(summary = "删除单个奖惩记录")
@DeleteMapping("/admin/record/{id}")
public Result<CommonResponse> adminDeleteRecord(@PathVariable Integer id) {
Integer i = recordService.IsRecord(id);
if(i==null) {
throw new RuntimeException("该记录不存在");
}
recordService.deleteRecord(id);
return Result.msg("删除成功");
}

View File

@ -79,4 +79,6 @@ public interface RecordMapper {
Integer getSidByCategoryId(Integer i);
@Select("SELECT * FROM record WHERE student_id = #{sid} LIMIT #{page},#{size}")
List<Record> getRecordsById(int page, int size, Integer sid);
@Select("SELECT id FROM record WHERE id = #{id}")
Integer IsRecord(Integer id);
}

View File

@ -80,4 +80,8 @@ public class RecordService {
public List<Record> getRecordsById(int page, int size, Integer sid) {
return recordMapper.getRecordsById(page, size, sid);
}
public Integer IsRecord(Integer id) {
return recordMapper.IsRecord(id);
}
}