Commit e15790f1 authored by 张永's avatar 张永

增加后台单独上传服务更新接口

parent 816a6767
package com.egolm.film.api.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_film_upload;
public interface OtherUploadService {
public void batchSave(List<Fc_film_upload> fc_film_upload);
public void save(Fc_film_upload fc_film_upload);
public int checkExists(Integer film_id,Integer number);
public List<Map<String,Object>> getWaitUploadList(Page page);
public void updateBegin(Integer film_id, Integer number,String videoId,String taskName);
public void updateProgress(String videoId,String progress);
public void updateSuccess(String videoId);
public void updateFail(String videoId,String errorMessage);
public void updateFail(Integer film_id,Integer number,String errorMessage);
}
package com.egolm.film.api.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.OtherUploadService;
import com.egolm.film.bean.Fc_film_upload;
import com.egolm.film.util.FilmContrants;
@Service
public class OtherUploadServiceImpl implements OtherUploadService {
@Autowired
private JdbcTemplate jdbcTemplate;
public void save(Fc_film_upload fc_film_upload) {
jdbcTemplate.saveOrUpdate(fc_film_upload);
}
public void batchSave(List<Fc_film_upload> fc_film_upload) {
jdbcTemplate.batchSave(fc_film_upload);
}
public int checkExists(Integer film_id,Integer number) {
String sql = "SELECT count(1) from fc_film_upload where film_id = ? and number = ?";
return jdbcTemplate.queryForInt(sql, film_id,number);
}
//开始上传
public void updateBegin(Integer film_id, Integer number,String videoId,String taskName) {
if(StringUtil.isNotEmpty(taskName)) {
String sql = "update fc_film_upload set id = ? ,upload_state = ? ,upload_progress = '0%' ,taskName=? where film_id = ? and number = ? ";
jdbcTemplate.executeUpdate(sql,videoId,FilmContrants.UPLOAD_STATUS_ING,taskName,film_id,number);
}else {
String sql = "update fc_film_upload set id = ? ,upload_state = ? ,upload_progress = '0%' where film_id = ? and number = ? ";
jdbcTemplate.executeUpdate(sql,videoId,FilmContrants.UPLOAD_STATUS_ING,film_id,number);
}
}
//修改进度
public void updateProgress(String videoId,String progress) {
String sql = "update fc_film_upload set upload_progress = ? where id = ? ";
jdbcTemplate.executeUpdate(sql,progress,videoId);
}
//上传成功
public void updateSuccess(String videoId) {
String sql = "update fc_film_upload set upload_time = now() ,file_local_path = '' ,upload_state = ? where id = ? ";
jdbcTemplate.executeUpdate(sql,FilmContrants.UPLOAD_STATUS_COMPLETED,videoId);
}
//上传失败
public void updateFail(String videoId,String errorMessage) {
String sql = "update fc_film_upload set upload__error_message =? ,upload_state = ? where id = ? ";
jdbcTemplate.executeUpdate(sql, errorMessage,FilmContrants.UPLOAD_STATUS_FILE,videoId);
}
public void updateFail(Integer film_id,Integer number,String errorMessage) {
String sql = "update fc_film_upload set upload__error_message =? ,upload_state = ? where film_id = ? and number = ? ";
jdbcTemplate.executeUpdate(sql, errorMessage,FilmContrants.UPLOAD_STATUS_FILE,film_id,number);
}
/**
* 获取待上传的视频 一次1条
* @Title: getList
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public List<Map<String,Object>> getWaitUploadList(Page page){
String sql = "SELECT * from fc_film_upload where upload_state = 0";
return jdbcTemplate.limit(sql, page);
}
}
package com.egolm.film.bean;
import javax.persistence.Entity;
import javax.persistence.Column;
import java.util.Date;
@Entity(name="fc_film_upload")
public class Fc_film_upload implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Column(columnDefinition="varchar(255) COMMENT '阿里云视频ID'")
private String id;
@Column(columnDefinition="int(11) COMMENT '影片ID'")
private Integer film_id;
@Column(columnDefinition="int(11) COMMENT '集数'")
private Integer number;
@Column(columnDefinition="int(11) COMMENT '上传状态 0未上传, 1上传中, 2已上传'")
private Integer upload_state;
@Column(columnDefinition="varchar(255) COMMENT '剧集名'")
private String unit_name;
@Column(columnDefinition="varchar(255) COMMENT '文件名'")
private String file_name;
@Column(columnDefinition="datetime COMMENT '开始上传时间'")
private Date create_time;
@Column(columnDefinition="datetime COMMENT '完成上传时间'")
private Date upload_time;
@Column(columnDefinition="varchar(36) COMMENT '上传进度'")
private String upload_progress;
@Column(columnDefinition="varchar(255) COMMENT '后台服务上传路径'")
private String file_local_path;
@Column(columnDefinition="varchar(255) COMMENT '后台服务上传失败原因'")
private String upload__error_message;
@Column(columnDefinition="varchar(255) COMMENT '分配的任务名称'")
private String taskName;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setFilm_id(Integer film_id) {
this.film_id = film_id;
}
public Integer getFilm_id() {
return film_id;
}
public void setNumber(Integer number) {
this.number = number;
}
public Integer getNumber() {
return number;
}
public void setUpload_state(Integer upload_state) {
this.upload_state = upload_state;
}
public Integer getUpload_state() {
return upload_state;
}
public void setUnit_name(String unit_name) {
this.unit_name = unit_name;
}
public String getUnit_name() {
return unit_name;
}
public void setFile_name(String file_name) {
this.file_name = file_name;
}
public String getFile_name() {
return file_name;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Date getCreate_time() {
return create_time;
}
public void setUpload_time(Date upload_time) {
this.upload_time = upload_time;
}
public Date getUpload_time() {
return upload_time;
}
public void setUpload_progress(String upload_progress) {
this.upload_progress = upload_progress;
}
public String getUpload_progress() {
return upload_progress;
}
public void setFile_local_path(String file_local_path) {
this.file_local_path = file_local_path;
}
public String getFile_local_path() {
return file_local_path;
}
public void setUpload__error_message(String upload__error_message) {
this.upload__error_message = upload__error_message;
}
public String getUpload__error_message() {
return upload__error_message;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public String getTaskName() {
return taskName;
}
}
package com.egolm.film.util;
public class FilmContrants {
public static int UPLOAD_STATUS_INIT=0; //待上传
public static int UPLOAD_STATUS_ING=1; //上传中
public static int UPLOAD_STATUS_COMPLETED=2; //上传完成
public static int UPLOAD_STATUS_FILE=3; //上传失败
}
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