当前位置: 首页> 汽车> 维修 > 温州移动网站建设服务商_首页关键词排名代发_搜索网站排行榜_网络营销策划方案范文

温州移动网站建设服务商_首页关键词排名代发_搜索网站排行榜_网络营销策划方案范文

时间:2025/8/9 15:49:15来源:https://blog.csdn.net/huangsu_123/article/details/147042510 浏览次数: 0次
温州移动网站建设服务商_首页关键词排名代发_搜索网站排行榜_网络营销策划方案范文

入参为json,然后根据需要对多张表进行操作:

入参格式:

[{"custstoreName":"swagger-测试经销商01","customerName":"swagger-测试客户01","propertyNo":"swaggertest01","propertyName":"swagger-测试资产01","proName":"四川省","cityName":"攀枝花市","propertyType":"1","deviceNumber":"swaggerdevice01","fileName":"swagger-测试资产01附件01","fileUrl":"https://www.baidu.com/?tn=25017023_17_dg"},{"custstoreName":"swagger-测试经销商02","customerName":"swagger-测试客户01","propertyNo":"swaggertest02","propertyName":"swagger-测试资产02","proName":"黑龙江省","cityName":"七台河市","propertyType":"1","deviceNumber":"swaggerdevice02","fileName":"swagger-测试资产02附件01","fileUrl":"https://www.baidu.com/?tn=25017023_17_dg"},{"custstoreName":"swagger-测试经销商03","customerName":"swagger-测试客户02","propertyNo":"swaggertest03","propertyName":"swagger-测试资产03","proName":"江苏省","cityName":"徐州市","propertyType":"1","deviceNumber":"swaggerdevice03","fileName":"swagger-测试资产03附件01","fileUrl":"https://www.baidu.com/?tn=25017023_17_dg"}]

其中tbPropertyService.addProperty的内容,参考:

java+postgresql+swagger-多表关联insert操作(六)

1、Service:

package com.example.springbootmybatisplus.service;import com.alibaba.fastjson.JSONObject;
import com.example.springbootmybatisplus.dto.PropertyDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class TbPropertyService2 {private static final Logger log = LoggerFactory.getLogger(TbDevicestatusService.class);@Autowiredprivate TbPropertyService tbPropertyService;public void addProperty2(String msg) {try {List<PropertyDto> jsonArray = JSONObject.parseArray(msg, PropertyDto.class);for (int i = 0; i < jsonArray.size(); i++) {PropertyDto propertyDto = jsonArray.get(i);tbPropertyService.addProperty(JSONObject.toJSONString(propertyDto));}} catch (Exception e) {log.error("异常信息:" + e.getMessage());}}}

2、Controller:

package com.example.springbootmybatisplus.contronller;import com.example.springbootmybatisplus.service.TbPropertyService;
import com.example.springbootmybatisplus.service.TbPropertyService2;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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("/tb-property")
@Api(tags = "资产管理")
public class TbPropertyController {@Autowiredprivate TbPropertyService tbPropertyService;@Autowiredprivate TbPropertyService2 tbPropertyService2;@PostMapping("/insert1")public ResponseEntity<String> insert1(@RequestBody String msg) {try {tbPropertyService.addProperty(msg);return ResponseEntity.status(HttpStatus.CREATED).body("Success");} catch (Exception e) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed");}}@PostMapping("/insert2")public ResponseEntity<String> insert2(@RequestBody String msg) {try {tbPropertyService2.addProperty2(msg);return ResponseEntity.status(HttpStatus.CREATED).body("Success");} catch (Exception e) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed");}}
}

3、调用接口打印的日志:

关键字:温州移动网站建设服务商_首页关键词排名代发_搜索网站排行榜_网络营销策划方案范文

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: