JavaCRUD模板参考

Mapper层

@Mapper
public interface ExCategoryMapper extends BaseMapper<ExCategory> {
}

Service层

package co.yixiang.exam.service;

import co.yixiang.exam.common.R;
import co.yixiang.exam.entity.ExStudent;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * @author Mtz
 * @version 1.0
 * @2024/5/138:55
 * @function
 * @comment
 */

public interface ExStudentService {
    /***
     * 学生模块分页查询
     * @param exStudent
     * @param pageable
     * @return
     */
    R<IPage<ExStudent>> selectInfo(ExStudent exStudent, Pageable pageable);

    /***
     * 学生模块添加
     * @param exStudent
     * @return R<Void>
     */
    R<Void> insertInfo(ExStudent exStudent);

    /***
     * 学生模块根据id修改
     * @param exStudent
     * @return
     */
    R<Void> saveInfo(ExStudent exStudent);

    /***
     * 学生模块根据id获取数据
     * @param exStudent
     * @return
     */
    R<ExStudent> getByIdInfo(ExStudent exStudent);

    /***
     * 学生模块根据集合id 批量删除数据
     * @param ids
     * @return   R<Void>
     */
    R<Void> removeIdsInfo(List<Integer> ids);
}

Controller层

package co.yixiang.exam.controller;

import co.yixiang.exam.common.R;
import co.yixiang.exam.entity.ExStudent;
import co.yixiang.exam.service.ExStudentService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Mtz
 * @version 1.0
 * @2024/5/139:35
 * @function
 * @comment 学生模块
 */
@RestController
@RequestMapping("/ex/student")
public class ExStudentController {
    @Autowired
    private ExStudentService exStudentService;


    /***
     * 学生模块分页查询
     * @param exStudent
     * @param pageable
     * @return R<IPage < ExStudent>>
     */
    @GetMapping("/selectInfo")
    public R<IPage<ExStudent>> selectInfo(ExStudent exStudent, Pageable pageable) {
        return exStudentService.selectInfo(exStudent, pageable);
    }

    /***
     * 学生模块添加
     * @param exStudent
     * @return R<Void>
     */
    @PostMapping("/insertInfo")
    public R<Void> insertInfo(@RequestBody ExStudent exStudent) {
        return exStudentService.insertInfo(exStudent);
    }

    /***
     * 学生模块根据id修改数据
     * @param exStudent
     * @return
     */
    @PostMapping("/saveInfo")
    public R<Void> saveInfo(@Validated @RequestBody ExStudent exStudent) {
        return exStudentService.saveInfo(exStudent);
    }

    /***
     * 学生模块根据id获取数据
     * @param exStudent
     * @return
     */
    @GetMapping("/getByIdInfo")
    public R<ExStudent> getByIdInfo(@Validated ExStudent exStudent) {
        return exStudentService.getByIdInfo(exStudent);
    }


    /***
     * 学生模块根据集合id 批量删除数据
     * @param ids
     * @return R<Void>
     */
    @PostMapping("/removeIdsInfo")
    public R<Void> removeIdsInfo(@RequestBody List<Integer> ids) {
        return exStudentService.removeIdsInfo(ids);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值