package com.example.demo11.Controller;
import com.example.demo11.Service.MaterialService;
import com.example.demo11.entity.Material;
import com.example.demo11.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/material")
public class MaterialController{
@Autowired
private MaterialService materialService;
@RequestMapping("/{id}")
public Result<Material> getMaterial(@PathVariable("id") Integer id){
return Result.success(materialService.getById(id));
}
}
package com.example.demo11.Controller;标签:,springframework,demo11,org,import,com,annotation From: https://www.cnblogs.com/luoqingci/p/18556208
import com.example.demo11.Service.QualityService;
import com.example.demo11.entity.Quality;
import com.example.demo11.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//质量检测
@RestController
@RequestMapping("/quality")
public class QualityController {
@Autowired
private QualityService qualityService;
@PostMapping("/add")
public Result<String> addQuality(@RequestBody Quality quality) {
qualityService.save(quality);
return Result.success("添加成功");
}
}