All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.magic80.springBootCommon.controller.BaseController Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
package com.magic80.springBootCommon.controller;

import com.magic80.springBootCommon.helper.PagedHelper;
import com.magic80.springBootCommon.model.BaseEntity;
import com.magic80.springBootCommon.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

public class BaseController {

    @Autowired
    protected S service;

    @PostMapping("/insert")
    public void insert(@RequestBody E entity) {
        service.insert(entity);
    }

    @PostMapping("/update")
    public void updateById(@RequestBody E entity) {
        service.updateById(entity);
    }

    @GetMapping("/delete")
    public void deleteById(Integer id) {
        service.deleteById(id);
    }

    @GetMapping("/get")
    public E findById(Integer id) {
        return (E) service.findById(id);
    }

    @GetMapping("/all")
    public List findAll() {
        return service.findAll();
    }

    @GetMapping("/list")
    public Map findList(@RequestParam Map requestMap) {
        return PagedHelper.pagedList(requestMap, map -> findDefaultList(map));
    }

    protected List findDefaultList(Map requestMap) {
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy