Commit d237f380 authored by licc's avatar licc

新增方案下载接口

parent 1d039083
......@@ -2,6 +2,7 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.SchemeInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -21,5 +22,16 @@ public interface SchemeMapper extends BaseMapper<SchemeInfo> {
*/
int edit(SchemeInfo schemeInfo);
/**
* 统计
* @return 数量
*/
int count();
/**
* 获取方案信息
* @param id 方案id
* @return 方案信息
*/
SchemeInfo getById(@Param("id") Integer id);
}
......@@ -6,6 +6,7 @@
<id column="id" property="id"/>
<result column="scheme_name" property="schemeName"/>
<result column="upload_time" property="uploadTime"/>
<result column="file_url" property="fileUrl"/>
<result column="type" property="type"/>
<result column="is_delete" property="isDelete"/>
<result column="create_time" property="createTime"/>
......@@ -22,16 +23,17 @@
</sql>
<sql id="cols_exclude_id">
scheme_name,upload_time, type,is_delete,create_time,update_time
scheme_name,upload_time,file_url, type,is_delete,create_time,update_time
</sql>
<sql id="vals">
#{schemeName},#{uploadTime},#{type},#{isDelete},now(),now()
#{schemeName},#{uploadTime},#{fileUrl},#{type},#{isDelete},now(),now()
</sql>
<sql id="updateCondition">
<if test="schemeName != null">scheme_name = #{schemeName},</if>
<if test="uploadTime != null">upload_time =#{uploadTime},</if>
<if test="fileUrl != null">file_url =#{fileUrl},</if>
<if test="type != null">type =#{type},</if>
<if test="isDelete != null">is_delete =#{isDelete},</if>
update_time =now()
......@@ -41,6 +43,7 @@
<if test="id != null">id = #{id}</if>
<if test="schemeName != null">and scheme_name = #{schemeName}</if>
<if test="uploadTime != null">and upload_time =#{uploadTime}</if>
<if test="fileUrl != null">and file_url =#{fileUrl}</if>
<if test="type != null">and type =#{type}</if>
<if test="isDelete != null">and is_delete =#{isDelete}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
......@@ -90,4 +93,14 @@
</where>
</select>
<select id="getById" resultType="cn.wisenergy.model.app.SchemeInfo">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
id=#{id}
</where>
</select>
</mapper>
......@@ -34,6 +34,12 @@ public class SchemeInfo implements Serializable {
@ApiModelProperty(value = "上传时间", name = "uploadTime")
private Date uploadTime;
/**
* 上传url
*/
@ApiModelProperty(value = "上传时间", name = "uploadTime")
private String fileUrl;
/**
* 1:本科文化一批 2:本科美术一批 3:艺术本科批文学编导
* 4:本科体育 5:专科专业分类6:专科美术一批 7:专科文学编导一批 8:专科体育一批
......
......@@ -9,21 +9,23 @@ import com.github.pagehelper.PageInfo;
/**
*@ Description: 方案接口定义
*@ Author : 86187
*@ Date : 2021/1/13 14:50
*/
* @ Description: 方案接口定义
* @ Author : 86187
* @ Date : 2021/1/13 14:50
*/
public interface SchemeService {
/**
* 方案查询
*
* @param schemeVo 查询参数
* @return 方案查询结果列表
* @return 方案查询结果列表
*/
R<VolunteerVo> getList(SchemeVo schemeVo);
/**
* 根据方案id,删除方案
*
* @param schemeId 方案id
* @return
*/
......@@ -31,8 +33,17 @@ public interface SchemeService {
/**
* 方案列表查询
*
* @param schemeVo 查询参数
* @return 方案查询结果列表
* @return 方案查询结果列表
*/
R<PageInfo<SchemeInfo>> getSchemeList(SchemeQueryVo schemeVo);
/**
* 获取方案下载路径
*
* @param schemeId 方案id
* @return 方案下载路径
*/
R<String> download(Integer schemeId);
}
......@@ -24,11 +24,13 @@ public interface VolunteerService extends IService<Volunteer> {
/**
* Excel批量添加方案志愿
* @param file 志愿文件
* @param type 方案类型
*
* @param file 志愿文件
* @param type 方案类型
* @param schemeName 方案名称
* @param response 相应数据
* @param fileUrl 方案url
* @param response 相应数据
* @throws IOException 异常
*/
void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException;
void excelAdd(MultipartFile file, Integer type, String schemeName, String fileUrl, HttpServletResponse response) throws IOException;
}
......@@ -303,6 +303,22 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
return R.ok(info);
}
@Override
public R<String> download(Integer schemeId) {
log.info("volunteer-service[]SchemeServiceImpl[]download[]input.param.schemeId:" + schemeId);
if (null == schemeId) {
return R.error("入参为空!");
}
//获取方案信息
SchemeInfo schemeInfo = schemeMapper.getById(schemeId);
if (null == schemeInfo || StringUtils.isBlank(schemeInfo.getFileUrl())) {
return R.error("未上传方案,无法下载!");
}
return R.ok(schemeInfo.getFileUrl());
}
/**
* 获取文化生志愿列表
......
......@@ -50,8 +50,9 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer
}
@Override
public void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName)) {
public void excelAdd(MultipartFile file, Integer type, String schemeName,String fileUrl, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName) ||
StringUtils.isBlank(fileUrl)) {
throw new BaseException("操作错误");
}
......@@ -70,6 +71,7 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer
SchemeInfo schemeInfo = new SchemeInfo();
schemeInfo.setSchemeName(schemeName);
schemeInfo.setType(type);
schemeInfo.setFileUrl(fileUrl);
schemeInfo.setUploadTime(new Date());
schemeInfo.setIsDelete(0);
......
......@@ -54,12 +54,14 @@ public class SchemeController {
@ApiOperation(value = "Excel批量添加方案志愿", notes = "Excel批量添加方案志愿")
@PostMapping("/excel/add")
public R excelAdd(@RequestParam("file") MultipartFile file, @RequestParam("type") Integer type,
@RequestParam("schemeName") String schemeName, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName)) {
@RequestParam("schemeName") String schemeName,
@RequestParam("fileUrl") String fileUrl, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName) ||
StringUtils.isBlank(fileUrl)) {
throw new BaseException("操作错误");
}
volunteerService.excelAdd(file, type, schemeName, response);
volunteerService.excelAdd(file, type, schemeName, fileUrl, response);
return R.ok("添加成功");
}
......@@ -87,4 +89,16 @@ public class SchemeController {
return schemeService.deleteById(schemeId);
}
@ApiOperation(value = "获取方案下载路径", notes = "获取方案下载路径", httpMethod = "GET")
@ApiImplicitParam(name = "schemeId", value = "方案id", dataType = "int")
@GetMapping("/download")
public R<String> download(Integer schemeId) {
log.info("volunteer-service[]SchemeController[]download[]input.param.schemeId:" + schemeId);
if (null == schemeId) {
return R.error("入参为空!");
}
return schemeService.download(schemeId);
}
}
......@@ -40,9 +40,9 @@ spring:
# 启用
enabled: true
# 上传文件单个限制
max-file-size: 5MB
max-file-size: 10MB
# 总限制
max-request-size: 10MB
max-request-size: 20MB
redis:
database: 0
......
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