当前位置: 首页> 游戏> 手游 > 我想看b站直播有哪些软件_广州网站优化推广公司_微信营销推广的方式有哪些_抖音关键词推广

我想看b站直播有哪些软件_广州网站优化推广公司_微信营销推广的方式有哪些_抖音关键词推广

时间:2025/8/11 9:21:45来源:https://blog.csdn.net/cq_run/article/details/142871267 浏览次数:0次
我想看b站直播有哪些软件_广州网站优化推广公司_微信营销推广的方式有哪些_抖音关键词推广

一、导入依赖

         <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>5.3.0</version></dependency>

二、实体类

package com.guide.entity;import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;/*** @author cxy* @create 2024-10-11 09:41:43*/@Data
@TableName("workpiece")
public class Workpiece {@TableId(value = "id", type = IdType.AUTO)@Schema(description = "id")private Integer id;@TableField(value = "vehicleModel")@Schema(description = "车型")private String vehicleModel;@TableField(value = "twoNum")@Schema(description = "轴二起始Num")private Integer twoNum;@TableField(value = "threeNum")@Schema(description = "轴三起始Num")private Integer threeNum;@TableField(value = "imgUrl")@Schema(description = "图片路径")private String imgUrl;
}

三、上传的模板

四、controller层 

package com.guide.controller;import cn.hutool.core.collection.CollUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.guide.entity.Workpiece;
import com.guide.result.Result;
import com.guide.service.WorkpieceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;/*** @author cxy* @create 2024-10-12 10:12:02*/@Tag(name = "excel")
@RequestMapping("/excel")
@RestController
@CrossOrigin(origins = "*")
@Slf4j
@RequiredArgsConstructor
public class ExcelController {private final WorkpieceService service;@PostMapping("/upLoad")@Operation(summary = "上传Excel")public Result upLoad(MultipartFile file) throws IOException {InputStream inputStream = file.getInputStream();ExcelReader reader = ExcelUtil.getReader(inputStream);List<List<Object>> list = reader.read(1);ArrayList<Workpiece> users = CollUtil.newArrayList();for (List<Object> row : list) {Workpiece user = new Workpiece();//excel表格结构数据要对应user.setVehicleModel(row.get(0).toString());user.setTwoNum(Integer.valueOf(row.get(1).toString()));user.setThreeNum(Integer.valueOf(row.get(2).toString()));user.setImgUrl(row.get(3).toString());users.add(user);//已经把excel数据赋值到users上 此时就可以插入数据库service.save(user);}return Result.success(true);}}

关键字:我想看b站直播有哪些软件_广州网站优化推广公司_微信营销推广的方式有哪些_抖音关键词推广

版权声明:

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

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

责任编辑: