Commit 6d311759 by wangming

Merge branch 'wangming' into '105'

banner

See merge request !5
2 parents 0828de1a 7bb7d7fe
package com.server.utils; 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.QiniuKey;
import com.server.utils.key.UploadUrlKey; import com.server.utils.key.UploadUrlKey;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -11,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -11,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
/** /**
* 本地文件存储 * 本地文件存储
...@@ -24,8 +30,22 @@ public class FileStore { ...@@ -24,8 +30,22 @@ public class FileStore {
@Autowired @Autowired
QiniuKey qiniuKey; QiniuKey qiniuKey;
public String storeImage(String path, MultipartFile file) { public String storeImage(String path, MultipartFile file) throws IOException {
return store(path, file); 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) { public String getRealPath(String path) {
......
...@@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper; ...@@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.server.shiro.persistent.bean.SysUser; import com.server.shiro.persistent.bean.SysUser;
import com.server.utils.DateUtils; 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.PageModel;
import com.server.web.common.model.TKzyCourse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -20,121 +22,126 @@ import java.util.Map; ...@@ -20,121 +22,126 @@ import java.util.Map;
@RequestMapping(BaseController.OSS_NAMESPACE + "/course") @RequestMapping(BaseController.OSS_NAMESPACE + "/course")
public class CourseController extends BaseController { public class CourseController extends BaseController {
// @Autowired @Autowired
// TSjCourseMapper courseMapper; private TKzyCourseMapper courseMapper;
//
// @Autowired
// CourseService courseService; /**
// * 直播列表
// /** * @param courseName
// * 直播列表 * @param pageNo
// * @param courseName * @param pageSize
// * @param pageNo * @return
// * @param pageSize */
// * @return @ResponseBody
// */ @RequestMapping(path = "/zbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// @ResponseBody public Map zbList(@RequestParam(defaultValue = "") String courseName
// @RequestMapping(path = "/zbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") ,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
// public Map zbList(@RequestParam(defaultValue = "") String courseName try {
// ,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) { Map paramMap = new HashMap<>();
// try { if(!("").equals(courseName)){
// Map paramMap = new HashMap<>(); paramMap.put("courseName","%"+courseName+"%");
// if(!("").equals(courseName)){ }
// paramMap.put("courseName","%"+courseName+"%"); PageHelper.startPage(pageNo,pageSize,true,false);
// } List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseZb",paramMap);
// PageHelper.startPage(pageNo,pageSize,true,false); PageInfo pageInfo = new PageInfo(list);
// List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseZb",paramMap); PageModel model = new PageModel();
// PageInfo pageInfo = new PageInfo(list); model.setTotal(pageInfo.getTotal());
// PageModel model = new PageModel(); model.setList(list);
// model.setTotal(pageInfo.getTotal()); return success(model);
// model.setList(list); } catch (Exception e) {
// return success(model); e.printStackTrace();
// } catch (Exception e) { return error("0","系统异常",null);
// e.printStackTrace(); }
// return error("0","系统异常",null); }
// }
// }
//
// /** /**
// * 录播列表 * 录播列表
// * @param courseName * @param courseName
// * @param pageNo * @param pageNo
// * @param pageSize * @param pageSize
// * @return * @return
// */ */
// @ResponseBody @ResponseBody
// @RequestMapping(path = "/lbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") @RequestMapping(path = "/lbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// public Map lbList(@RequestParam(defaultValue = "") String courseName public Map lbList(@RequestParam(defaultValue = "") String courseName
// ,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) { ,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
// try { try {
// Map paramMap = new HashMap<>(); Map paramMap = new HashMap<>();
// if(!("").equals(courseName)){ if(!("").equals(courseName)){
// paramMap.put("courseName","%"+courseName+"%"); paramMap.put("courseName","%"+courseName+"%");
// } }
// PageHelper.startPage(pageNo,pageSize,true,false); PageHelper.startPage(pageNo,pageSize,true,false);
// List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseLb",paramMap); List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseLb",paramMap);
// PageInfo pageInfo = new PageInfo(list); PageInfo pageInfo = new PageInfo(list);
// PageModel model = new PageModel(); PageModel model = new PageModel();
// model.setTotal(pageInfo.getTotal()); model.setTotal(pageInfo.getTotal());
// model.setList(list); model.setList(list);
// return success(model); return success(model);
// } catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); e.printStackTrace();
// return error("0","系统异常",null); return error("0","系统异常",null);
// } }
// } }
//
// /**
// * 上下架录播课
// * @param id /**
// * @param status * 上下架课程
// * @return * @param id
// */ * @param status 上下架状态 1 上架 2 下架
// @ResponseBody * @return
// @RequestMapping(path = "/courseStatus", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") */
// public Map courseStatus(@RequestParam long id,@RequestParam int status) { @ResponseBody
// try { @RequestMapping(path = "/courseStatus", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// SysUser user =getSysUser(); public Map courseStatus(@RequestParam long id,@RequestParam int status) {
// TSjCourse course = new TSjCourse(); try {
// course.setId(id); SysUser user =getSysUser();
// course.setIsUp(status); TKzyCourse course = new TKzyCourse();
// course.setUpdateDt(new Date()); course.setId(id);
// course.setEditorId(user.getId()); course.setIsUp(status);
// course.setEditorName(user.getRealname()); course.setUpdateDt(new Date());
// courseMapper.updateByPrimaryKeySelective(course); course.setEditorId(user.getId());
// return success("操作成功"); course.setEditorName(user.getRealname());
// } catch (Exception e) { courseMapper.updateByPrimaryKeySelective(course);
// e.printStackTrace(); return success("操作成功");
// return error("0","系统异常",null); } catch (Exception e) {
// } e.printStackTrace();
// } return error("0","系统异常",null);
// }
// /** }
// * 删除直播课
// * @param id
// * @return /**
// */ * 删除课程
// @ResponseBody * @param id
// @RequestMapping(path = "/deleteCourse", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") * @return
// public Map deleteCourse(@RequestParam long id) { */
// try { @ResponseBody
// SysUser user =getSysUser(); @RequestMapping(path = "/deleteCourse", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
// TSjCourse course = new TSjCourse(); public Map deleteCourse(@RequestParam long id) {
// course.setId(id); try {
// course.setIsDelete(1); SysUser user =getSysUser();
// course.setUpdateDt(new Date()); TKzyCourse course = new TKzyCourse();
// course.setEditorId(user.getId()); course.setId(id);
// course.setEditorName(user.getRealname()); course.setIsDelete(1);
// courseMapper.updateByPrimaryKeySelective(course); course.setUpdateDt(new Date());
// return success("操作成功"); course.setEditorId(user.getId());
// } catch (Exception e) { course.setEditorName(user.getRealname());
// e.printStackTrace(); courseMapper.updateByPrimaryKeySelective(course);
// return error("0","系统异常",null); return success("操作成功");
// } } catch (Exception e) {
// } e.printStackTrace();
// return error("0","系统异常",null);
// }
// /** }
// /**
// * 添加修改直播课 // * 添加修改直播课
// * @param id // * @param id
// * @param courseName // * @param courseName
...@@ -151,7 +158,7 @@ public class CourseController extends BaseController { ...@@ -151,7 +158,7 @@ public class CourseController extends BaseController {
// @RequestParam String startDt,@RequestParam String endDt) { // @RequestParam String startDt,@RequestParam String endDt) {
// try { // try {
// SysUser user =getSysUser(); // SysUser user =getSysUser();
// TSjCourse course = new TSjCourse(); // TKzyCourse course = new TKzyCourse();
// course.setCourseName(courseName); // course.setCourseName(courseName);
// course.setPicUrl(picUrl); // course.setPicUrl(picUrl);
// course.setCourseIntroduce(courseIntroduce); // course.setCourseIntroduce(courseIntroduce);
...@@ -179,6 +186,19 @@ public class CourseController extends BaseController { ...@@ -179,6 +186,19 @@ public class CourseController extends BaseController {
// return error("0","系统异常",null); // return error("0","系统异常",null);
// } // }
// } // }
//
// @Autowired
// CourseService courseService;
//
//
//
// //
// //
// /** // /**
...@@ -264,25 +284,5 @@ public class CourseController extends BaseController { ...@@ -264,25 +284,5 @@ public class CourseController extends BaseController {
// return error("0","系统异常",null); // 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 @@ ...@@ -124,4 +124,40 @@
ORDER BY t.id DESC ORDER BY t.id DESC
</select> </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> </mapper>
\ No newline at end of file
...@@ -48,7 +48,7 @@ rest.api.charset=utf-8 ...@@ -48,7 +48,7 @@ rest.api.charset=utf-8
#加密secret_key #加密secret_key
rest.api.secretkey=FoK28EsYrxuiM3ohnAurFGm2uGAHyijL rest.api.secretkey=FoK28EsYrxuiM3ohnAurFGm2uGAHyijL
#上传图片 #上传图片
upload.image.dir=/data/tempImages upload.image.dir=/alidata/server/kzy_oss/tempImages
upload.image.base.path=tempImages/ upload.image.base.path=tempImages/
#七牛云 #七牛云
qiniu.accessKey=tOdsZIdcGZB4A6B4X6XnhRj9PALEPIY4QRT7RduW qiniu.accessKey=tOdsZIdcGZB4A6B4X6XnhRj9PALEPIY4QRT7RduW
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!