Commit 3d3f63c5 by 翁国栋

上传模板

parent a6e13fa8
package cn.timer.api.controller.insure;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -10,6 +12,7 @@ import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.dto.insure.ProductDto;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import cn.timer.api.utils.aliyun.OSSUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
......@@ -18,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
......@@ -34,6 +38,8 @@ import org.springframework.web.bind.annotation.*;
public class InsureProductController {
@Autowired
private InsureProductMapper insureProductMapper;
@Autowired
private OSSUtil oss;
@GetMapping(value = "/productList")
@ApiOperation(value = "12.产品列表", httpMethod = "GET", notes = "产品列表")
......@@ -51,5 +57,26 @@ public class InsureProductController {
}
return ResultUtil.error("添加产品失败");
}
@PostMapping(value = "/importTmp")
@ApiOperation(value = "导入模板", httpMethod = "POST", notes = "保存产品")
public Result<Object> saveProduct( @RequestParam("productId") Integer productId, @RequestParam("file") MultipartFile file) {
InsureProduct insureProduct=InsureProduct.builder().id(productId).build().selectById();
if(insureProduct==null){
return ResultUtil.error("导入模板失败");
}
String path = "8timer2.0/" + productId+ "/Temp/"+ file.getOriginalFilename();
if (file == null || file.getSize() <= 0) {
return ResultUtil.error("上传的文件为空,请重新选择!");
} else {
try {
String url= oss.uploadFile(new File(path), file.getInputStream());
insureProduct.setTmpUrl(url);
insureProduct.updateById();
} catch (IOException e) {
e.printStackTrace();
}
return ResultUtil.data(path, "上传成功!");
}
}
}
......@@ -50,4 +50,5 @@ public class PolicyDto {
private boolean isAll = false;
private Integer productPlanId;
private String planName;
private String tmpUrl;
}
......@@ -354,7 +354,8 @@
(select count(org_code) from insure_policy WHERE product_id=ip.id) as totalCompany,
count( iu.id ) AS totalUser,
sum( iu.price ) AS totalPremium,
ipp.update_time AS updateTime
ipp.update_time AS updateTime,
ip.tmp_url as tmpUrl
FROM
insure_product ip
LEFT JOIN insure_policy ipp ON ipp.product_id = ip.id and ipp.`status`=1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment