方法类型一 value和method
涉及
@RequestMapping({“/api/rest”})
@RequestMapping(
value = {“/internal/v1/machine/delete”},
method = {RequestMethod.DELETE}
)
这种提取
示例代码如下:
@RestController
@RequestMapping({
"/api/rest"})
public class ModelManageApi {
@Autowired
private ModelMachineService modelMachineService;
private Logger logger = LoggerFactory.getLogger(this.getClass());
@RequestMapping(
value = {
"/internal/v1/machine/addModel"},
method = {
RequestMethod.POST}
)
@ResponseBody
public void addModelMachine(HttpServletRequest request, @RequestBody ModelMachineDto modelMachineDto) throws Exception {
List<ModelMachinePO> modelMachines = new ArrayList();
if (StringUtils.isEmpty(modelMachineDto.getCreateTime())) {
throw new RuntimeException("Request createDate can not be null");
} else if (null != modelMachineDto.getSns() && modelMachineDto.getSns().size() != 0) {
List<String> sns = modelMachineDto.getSns();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date createtime = format.parse(modelMachineDto.getCreateTime().trim());
for(int i = 0; i < sns.size(); ++i) {
if (StringUtils.isEmpty((CharSequence)sns.get(i))) {
throw new RuntimeException("Request SN can not be null");
}
ModelMachinePO modelMachinePO = new ModelMachinePO();
modelMachinePO.setCreateTime(createtime);
modelMachinePO.setSn((String)sns.get(i));
modelMachinePO.setMachineType(MachineType.PROTOTYPE.getValue());
modelMachines.add(modelMachinePO);
}
this.modelMachineService.addModelMachine(modelMachines);
} else {
throw new RuntimeException("Request SN can not be null");
}
}
@RequestMapping(
value = {
"/internal/v1/machine/delete"},
method = {
RequestMethod.DELETE}
)
@ResponseBody
public void removeModelMachine(@RequestBody ModelMachineDto modelMachineDto) throws Exception {
if (null != modelMachineDto.getSns() && modelMachineDto.<