个人作业DailySummary后端

DailySummaryController

package com.example.demo.controller;

import com.example.demo.entity.CodingRecord;
import com.example.demo.service.CodingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/codingRecord")
public class CodingRecordController {
    @Autowired
    private CodingRecordService codingRecordService;

    @PostMapping("/create")
    public Map<String, Object> createRecord(@RequestBody CodingRecord record) {
        Map<String, Object> result = new HashMap<>();
        CodingRecord created = codingRecordService.createRecord(record);
        result.put("success", true);
        result.put("data", created);
        return result;
    }

    @GetMapping("/list/{studentId}")
    public Map<String, Object> getRecordList(@PathVariable String studentId) {
        Map<String, Object> result = new HashMap<>();
        List<CodingRecord> records = codingRecordService.getRecordsByStudentId(studentId);
        result.put("success", true);
        result.put("data", records);
        return result;
    }

    @GetMapping("/detail/{recordId}")
    public Map<String, Object> getRecordDetail(@PathVariable Integer recordId) {
        Map<String, Object> result = new HashMap<>();
        CodingRecord record = codingRecordService.getRecordById(recordId);
        result.put("success", true);
        result.put("data", record);
        return result;
    }

    @PutMapping("/update")
    public Map<String, Object> updateRecord(@RequestBody CodingRecord record) {
        Map<String, Object> result = new HashMap<>();
        boolean success = codingRecordService.updateRecord(record);
        result.put("success", success);
        return result;
    }

    @DeleteMapping("/delete/{recordId}")
    public Map<String, Object> deleteRecord(@PathVariable Integer recordId) {
        Map<String, Object> result = new HashMap<>();
        boolean success = codingRecordService.deleteRecord(recordId);
        result.put("success", success);
        return result;
    }
}

DailySummary

package com.example.demo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.time.LocalDate;

@Data
public class DailySummary {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    
    private String studentId;      // 学号
    private String summaryContent; // 总结内容
    private String blogUrl;        // 博客链接
    private LocalDate summaryDate; // 总结日期

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getSummaryContent() {
        return summaryContent;
    }

    public void setSummaryContent(String summaryContent) {
        this.summaryContent = summaryContent;
    }

    public String getBlogUrl() {
        return blogUrl;
    }

    public void setBlogUrl(String blogUrl) {
        this.blogUrl = blogUrl;
    }

    public LocalDate getSummaryDate() {
        return summaryDate;
    }

    public void setSummaryDate(LocalDate summaryDate) {
        this.summaryDate = summaryDate;
    }
}

DailySummaryService

package com.example.demo.service;

import com.example.demo.entity.DailySummary;
import java.time.LocalDate;
import java.util.List;

public interface DailySummaryService {
    DailySummary createSummary(DailySummary summary);
    List<DailySummary> getSummariesByDateRange(String studentId, LocalDate startDate, LocalDate endDate);
    DailySummary getTodaySummary(String studentId);
    boolean updateSummary(DailySummary summary);
    boolean deleteSummary(Integer summaryId);
}
posted @ 2025-03-28 00:23  QixunQiu  阅读(15)  评论(0)    收藏  举报