Commit 7bb7d7fe by wangming

banner

1 parent 848ad47b
package com.server.utils;
import com.qiniu.common.QiniuException;
import com.qiniu.common.Zone;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import com.server.utils.key.QiniuKey;
import com.server.utils.key.UploadUrlKey;
import org.slf4j.Logger;
......@@ -11,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* 本地文件存储
......@@ -24,8 +30,22 @@ public class FileStore {
@Autowired
QiniuKey qiniuKey;
public String storeImage(String path, MultipartFile file) {
return store(path, file);
public String storeImage(String path, MultipartFile file) throws IOException {
String accessKey = qiniuKey.getAccessKey();
String secretKey = qiniuKey.getSecretKey();
String bucket = qiniuKey.getBucket();
String fileName = file.getOriginalFilename();
Auth auth = Auth.create(accessKey, secretKey);
String upToken = auth.uploadToken(bucket);
String imageUrl = "";
InputStream input = file.getInputStream();
imageUrl = uploadUrlKey.getBasePath()+String.valueOf(System.currentTimeMillis())+"."+fileName.substring(fileName.lastIndexOf(".") + 1);
//构造一个带指定Zone对象的配置类
Configuration cfg = new Configuration(Zone.zone1());
//...其他参数参考类注释
UploadManager uploadManager = new UploadManager(cfg);
uploadManager.put(input,imageUrl,upToken,null, null);
return imageUrl;
}
public String getRealPath(String path) {
......
......@@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.server.shiro.persistent.bean.SysUser;
import com.server.utils.DateUtils;
import com.server.web.common.mapper.TKzyCourseMapper;
import com.server.web.common.model.PageModel;
import com.server.web.common.model.TKzyCourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -20,121 +22,126 @@ import java.util.Map;
@RequestMapping(BaseController.OSS_NAMESPACE + "/course")
public class CourseController extends BaseController {
// @Autowired
// TSjCourseMapper courseMapper;
//
// @Autowired
// CourseService courseService;
//
// /**
// * 直播列表
// * @param courseName
// * @param pageNo
// * @param pageSize
// * @return
// */
// @ResponseBody
// @RequestMapping(path = "/zbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// public Map zbList(@RequestParam(defaultValue = "") String courseName
// ,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
// try {
// Map paramMap = new HashMap<>();
// if(!("").equals(courseName)){
// paramMap.put("courseName","%"+courseName+"%");
// }
// PageHelper.startPage(pageNo,pageSize,true,false);
// List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseZb",paramMap);
// PageInfo pageInfo = new PageInfo(list);
// PageModel model = new PageModel();
// model.setTotal(pageInfo.getTotal());
// model.setList(list);
// return success(model);
// } catch (Exception e) {
// e.printStackTrace();
// return error("0","系统异常",null);
// }
// }
//
// /**
// * 录播列表
// * @param courseName
// * @param pageNo
// * @param pageSize
// * @return
// */
// @ResponseBody
// @RequestMapping(path = "/lbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// public Map lbList(@RequestParam(defaultValue = "") String courseName
// ,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
// try {
// Map paramMap = new HashMap<>();
// if(!("").equals(courseName)){
// paramMap.put("courseName","%"+courseName+"%");
// }
// PageHelper.startPage(pageNo,pageSize,true,false);
// List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseLb",paramMap);
// PageInfo pageInfo = new PageInfo(list);
// PageModel model = new PageModel();
// model.setTotal(pageInfo.getTotal());
// model.setList(list);
// return success(model);
// } catch (Exception e) {
// e.printStackTrace();
// return error("0","系统异常",null);
// }
// }
//
// /**
// * 上下架录播课
// * @param id
// * @param status
// * @return
// */
// @ResponseBody
// @RequestMapping(path = "/courseStatus", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// public Map courseStatus(@RequestParam long id,@RequestParam int status) {
// try {
// SysUser user =getSysUser();
// TSjCourse course = new TSjCourse();
// course.setId(id);
// course.setIsUp(status);
// course.setUpdateDt(new Date());
// course.setEditorId(user.getId());
// course.setEditorName(user.getRealname());
// courseMapper.updateByPrimaryKeySelective(course);
// return success("操作成功");
// } catch (Exception e) {
// e.printStackTrace();
// return error("0","系统异常",null);
// }
// }
//
// /**
// * 删除直播课
// * @param id
// * @return
// */
// @ResponseBody
// @RequestMapping(path = "/deleteCourse", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// public Map deleteCourse(@RequestParam long id) {
// try {
// SysUser user =getSysUser();
// TSjCourse course = new TSjCourse();
// course.setId(id);
// course.setIsDelete(1);
// course.setUpdateDt(new Date());
// course.setEditorId(user.getId());
// course.setEditorName(user.getRealname());
// courseMapper.updateByPrimaryKeySelective(course);
// return success("操作成功");
// } catch (Exception e) {
// e.printStackTrace();
// return error("0","系统异常",null);
// }
// }
//
//
// /**
@Autowired
private TKzyCourseMapper courseMapper;
/**
* 直播列表
* @param courseName
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping(path = "/zbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map zbList(@RequestParam(defaultValue = "") String courseName
,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
try {
Map paramMap = new HashMap<>();
if(!("").equals(courseName)){
paramMap.put("courseName","%"+courseName+"%");
}
PageHelper.startPage(pageNo,pageSize,true,false);
List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseZb",paramMap);
PageInfo pageInfo = new PageInfo(list);
PageModel model = new PageModel();
model.setTotal(pageInfo.getTotal());
model.setList(list);
return success(model);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 录播列表
* @param courseName
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping(path = "/lbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map lbList(@RequestParam(defaultValue = "") String courseName
,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
try {
Map paramMap = new HashMap<>();
if(!("").equals(courseName)){
paramMap.put("courseName","%"+courseName+"%");
}
PageHelper.startPage(pageNo,pageSize,true,false);
List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseLb",paramMap);
PageInfo pageInfo = new PageInfo(list);
PageModel model = new PageModel();
model.setTotal(pageInfo.getTotal());
model.setList(list);
return success(model);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 上下架课程
* @param id
* @param status 上下架状态 1 上架 2 下架
* @return
*/
@ResponseBody
@RequestMapping(path = "/courseStatus", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map courseStatus(@RequestParam long id,@RequestParam int status) {
try {
SysUser user =getSysUser();
TKzyCourse course = new TKzyCourse();
course.setId(id);
course.setIsUp(status);
course.setUpdateDt(new Date());
course.setEditorId(user.getId());
course.setEditorName(user.getRealname());
courseMapper.updateByPrimaryKeySelective(course);
return success("操作成功");
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 删除课程
* @param id
* @return
*/
@ResponseBody
@RequestMapping(path = "/deleteCourse", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map deleteCourse(@RequestParam long id) {
try {
SysUser user =getSysUser();
TKzyCourse course = new TKzyCourse();
course.setId(id);
course.setIsDelete(1);
course.setUpdateDt(new Date());
course.setEditorId(user.getId());
course.setEditorName(user.getRealname());
courseMapper.updateByPrimaryKeySelective(course);
return success("操作成功");
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
// /**
// * 添加修改直播课
// * @param id
// * @param courseName
......@@ -151,7 +158,7 @@ public class CourseController extends BaseController {
// @RequestParam String startDt,@RequestParam String endDt) {
// try {
// SysUser user =getSysUser();
// TSjCourse course = new TSjCourse();
// TKzyCourse course = new TKzyCourse();
// course.setCourseName(courseName);
// course.setPicUrl(picUrl);
// course.setCourseIntroduce(courseIntroduce);
......@@ -179,6 +186,19 @@ public class CourseController extends BaseController {
// return error("0","系统异常",null);
// }
// }
//
// @Autowired
// CourseService courseService;
//
//
//
//
//
// /**
......@@ -264,25 +284,5 @@ public class CourseController extends BaseController {
// return error("0","系统异常",null);
// }
// }
//
// /**
// * 获取类目集合
// * @param className
// * @return
// */
// @ResponseBody
// @RequestMapping(path = "/queryClassList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// public Map queryClassList(@RequestParam(defaultValue = "") String className) {
// try {
// Map paramMap = new HashMap<>();
// if(!("").equals(className)){
// paramMap.put("className","%"+className+"%");
// }
// List classList = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryClassList",paramMap);
// return success(classList);
// } catch (Exception e) {
// e.printStackTrace();
// return error("0","系统异常",null);
// }
// }
}
......@@ -124,4 +124,40 @@
ORDER BY t.id DESC
</select>
<select id="queryCourseZb" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
c.id,
c.course_name AS courseName,
c.is_up as isUp,
date_format(c.start_dt,'%Y-%m-%d %H:%i:%S') startDt,
date_format(c.end_dt,'%Y-%m-%d %H:%i:%S') endDt,
if(date_format(NOW(),'%Y-%m-%d %H:%i:%S') &lt; date_format(c.start_dt,'%Y-%m-%d %H:%i:%S'),0,if(date_format(NOW(),'%Y-%m-%d %H:%i:%S')&gt; date_format(c.end_dt,'%Y-%m-%d %H:%i:%S'),2,1)) status
FROM
t_kzy_course c
WHERE c.course_type=1
AND c.is_delete = 0
<if test="courseName != null">
AND c.course_name LIKE #{courseName}
</if>
ORDER BY c.create_dt DESC
</select>
<select id="queryCourseLb" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
c.id,
c.course_name AS courseName,
date_format(c.create_dt,'%Y-%m-%d %H:%i:%S') createDt,
if(c.live_url is not null,1,2) liveStatus,
c.is_up AS isUp
FROM
t_kzy_course c
WHERE c.course_type=2
AND c.is_delete = 0
<if test="courseName != null">
AND c.course_name LIKE #{courseName}
</if>
ORDER BY c.create_dt DESC
</select>
</mapper>
\ No newline at end of file
......@@ -48,7 +48,7 @@ rest.api.charset=utf-8
#加密secret_key
rest.api.secretkey=FoK28EsYrxuiM3ohnAurFGm2uGAHyijL
#上传图片
upload.image.dir=/data/tempImages
upload.image.dir=/alidata/server/kzy_oss/tempImages
upload.image.base.path=tempImages/
#七牛云
qiniu.accessKey=tOdsZIdcGZB4A6B4X6XnhRj9PALEPIY4QRT7RduW
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!