idea-java项目中的全部接口提取

方法类型一 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.<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值