diff --git a/pom.xml b/pom.xml index e9f3ec5b54535f420e49f862781f47925f5db214..78aa7d7b1a30afbe7e804eceb51408f9c64504e4 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ 2.8.5 1.2.72 4.1.1 - 1.18.4 + 1.18.20 /work/renren @@ -75,6 +75,8 @@ aliyun-sdk-oss 3.10.2 + + @@ -93,6 +95,9 @@ + + + javax.xml.bind jaxb-api @@ -306,6 +311,7 @@ org.springframework.boot spring-boot-maven-plugin + 2.2.6.RELEASE true @@ -314,6 +320,7 @@ org.apache.maven.plugins maven-surefire-plugin + 2.12.4 true diff --git a/src/main/java/io/renren/common/utils/OssUtils.java b/src/main/java/io/renren/common/utils/OssUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..8cec693e0222e88ac1863bed8b407d5068030c9c --- /dev/null +++ b/src/main/java/io/renren/common/utils/OssUtils.java @@ -0,0 +1,31 @@ +package io.renren.common.utils; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; + +public class OssUtils { + private final static String endpoint = "http://oss-cn-beijing.aliyuncs.com"; + private final static String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; + private final static String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; + private final static String path = "ckedu2.oss-cn-beijing.aliyuncs.com"; + + public static OSS getOssClient() { + return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + } + + public static String getEndpoint() { + return endpoint; + } + + public static String getAccessKeyId() { + return accessKeyId; + } + + public static String getAccessKeySecret() { + return accessKeySecret; + } + + public static String getPath() { + return path; + } +} diff --git a/src/main/java/io/renren/components/TokenManager.java b/src/main/java/io/renren/components/TokenManager.java new file mode 100644 index 0000000000000000000000000000000000000000..50bbb27381cabe35ca2a482cd6b411b769d4ad1f --- /dev/null +++ b/src/main/java/io/renren/components/TokenManager.java @@ -0,0 +1,34 @@ +package io.renren.components; + +import io.jsonwebtoken.*; +import org.springframework.stereotype.Component; + +import java.util.Date; + +@Component +public class TokenManager { + //token有效时长 + private static long tokenEcpiration = 24 * 60 * 60 * 1000; + //编码秘钥 + private static String tokenSignKey = "ckedu_student_"; + + //1 使用jwt根据用户名生成token + public String createToken(String username) { + String token = Jwts.builder().setSubject(username) + .setExpiration(new Date(System.currentTimeMillis() + tokenEcpiration)) + .signWith(SignatureAlgorithm.HS512, tokenSignKey).compressWith(CompressionCodecs.GZIP).compact(); + return token; + } + + //2 根据token字符串得到用户信息 + public String getUserInfoFromToken(String token) { + token = token.substring(1, token.length() - 1); + Claims claims; + try { + claims = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token).getBody(); + } catch (ExpiredJwtException e) { + claims = e.getClaims(); + } + return claims.getSubject(); + } +} diff --git a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java index d1237bb7b578a74388db477e88540d9357f8d250..d303a0e51fa022dd586f12b22da3c2fddd115198 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java @@ -1,10 +1,11 @@ package io.renren.modules.generator.controller; +import java.io.IOException; import java.util.*; -import io.renren.modules.generator.entity.ActionmodelEntity; -import io.renren.modules.generator.entity.QuestionEntity; -import io.renren.modules.generator.service.ActionmodelService; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.convert.MapToPropertiesConverter; @@ -14,11 +15,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.ActivemodelEntity; -import io.renren.modules.generator.service.ActivemodelService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -33,81 +34,536 @@ import io.renren.common.utils.R; public class ActivemodelController { @Autowired private ActivemodelService activemodelService; + @Autowired private ActionmodelService actionmodelService; + @Autowired + private ClassesService classesService; + + @Autowired + private StudentService studentService; + + @Autowired + private QuestionService questionService; + + @Autowired + private AnswerService answerService; + + @Autowired + private FeetbackService feetbackService; + + @Autowired + private PictureService pictureService; + //2021 11/20 接口类型: "读" 测试人:ZhangShiYu //根据单元的id获取该单元所有的活动 @RequestMapping("/getAllActive") - public R getAllActive(@RequestParam Map params){ + public R getAllActive(@RequestParam Map params) { Object unit_id = params.get("unit_id"); - if (unit_id==null) + if (unit_id == null) return R.error("传递字段缺少"); List allActiveModel = activemodelService.getAllActiveModel(unit_id.toString()); - if (allActiveModel==null) + if (allActiveModel == null) return R.error("没有这个单元"); - return R.ok().put("active_list",allActiveModel); + return R.ok().put("active_list", allActiveModel); } //2021 11/21 接口类型: "读" 测试人:ZhangShiYu //根据活动的id获取该活动下的所有的板块以及板块的题目 @RequestMapping("/getAll") - public R getAllActionAndQuestion(@RequestParam Map params){ + public R getAllActionAndQuestion(@RequestParam Map params) { //获取活动id Object a_id = params.get("a_id"); - if (a_id==null) + if (a_id == null) return R.error("传递字段缺少"); //根据活动id查询该活动下的所有的板块实体 List allActionByAId = actionmodelService.getAllActionByAId(a_id.toString()); //创建一个Map数组 - ArrayList> arrayList=new ArrayList<>(); + ArrayList> arrayList = new ArrayList<>(); //遍历板块实体 for (ActionmodelEntity actionmodelEntity : allActionByAId) { //创建一个小Map - Map map1=new HashMap<>(); + Map map1 = new HashMap<>(); //首先把板块实体放入小Map里面 - map1.put("act",actionmodelEntity); + map1.put("act", actionmodelEntity); //根据板块实体去查该板块所有的题目 List allQuestionByActId = actionmodelService.getAllQuestionByActId(actionmodelEntity.getActionId()); - List> maps=new ArrayList<>(); + List> maps = new ArrayList<>(); for (QuestionEntity questionEntity : allQuestionByActId) { - Map map=new HashMap<>(); - map.put("qtitle",questionEntity.getQTitle());//问题标题 - map.put("qid",questionEntity.getQId());//问题id - map.put("qtype",questionEntity.getQType());//问题类型 - map.put("qpictureid",questionEntity.getQPicnumbers());//问题图片id - map.put("qnumber",questionEntity.getQNumber());//问题题号 - map.put("needbackexplore",questionEntity.getQIsallowreturnexplore());//是否需要回到探究 - map.put("multiple",questionEntity.getQIsmutiplecommit());//是否可以重复提交 - map.put("ischeckanswer",questionEntity.getQIscheckanswer());//是否可以查看答案正误 - if (questionEntity.getQType().equals("2")||questionEntity.getQType().equals("3")) - map.put("choice",questionEntity.getQOption().split(",,"));//分割开选项变成数组 - else{ + Map map = new HashMap<>(); + map.put("qtitle", questionEntity.getQTitle());//问题标题 + map.put("qid", questionEntity.getQId());//问题id + map.put("qtype", questionEntity.getQType());//问题类型 + map.put("qpictureid", questionEntity.getQPicnumbers());//问题图片id + map.put("qnumber", questionEntity.getQNumber());//问题题号 + map.put("needbackexplore", questionEntity.getQIsallowreturnexplore());//是否需要回到探究 + map.put("multiple", questionEntity.getQIsmutiplecommit());//是否可以重复提交 + map.put("ischeckanswer", questionEntity.getQIscheckanswer());//是否可以查看答案正误 + if (questionEntity.getQType().equals("2") || questionEntity.getQType().equals("3")) + map.put("choice", questionEntity.getQOption().split(",,"));//分割开选项变成数组 + else { ArrayList arrayList1 = new ArrayList<>(); arrayList1.add(questionEntity.getQOption()); - map.put("choice",arrayList1); + map.put("choice", arrayList1); } maps.add(map);//放入 } //把题目放入小Map里面 - map1.put("question_list",maps); + map1.put("question_list", maps); //把小map放入Map数组里面 arrayList.add(map1); } //返回Map数组 - return R.ok().put("info",arrayList); + return R.ok().put("info", arrayList); + + } + + /** + * 2021.11.24 + * zhaomr + * 新建活动 + * + * @param params 请求参数 + * @param request HttpServletRequest + * @return R + */ + @RequestMapping("/insertActive") + public R insertActive(@RequestParam Map params, HttpServletRequest request) { + String act_name = (String) params.get("act_name"); + String act_introduce = (String) params.get("act_introduce"); + String act_picNumber = (String) params.get("act_picNumber"); + + //此值应该通过token来获得还是通过参数获得 + String act_uid = (String) params.get("act_uid"); + + if (act_name == null || act_uid == null) return R.error("缺少参数!"); + + if(activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); + + String uuid = UUID.randomUUID().toString().replace("-", "").trim(); + + if (StringUtils.isEmpty(uuid)) return R.error("uuid生成失败"); + + ActivemodelEntity activemodelEntity = new ActivemodelEntity(); + + activemodelEntity.setActId(uuid); + activemodelEntity.setActName(act_name); + activemodelEntity.setActIntroduce(act_introduce); + //如果未传入picNumber 应该给一个默认值 + //可以在这里加一个判断,也可以前端通过ajax请求来获得一个默认值 直接传给picNumber + activemodelEntity.setActPicnumber(act_picNumber); + + activemodelEntity.setActUid(act_uid); + + int result = activemodelService.insertActive(activemodelEntity); + + if (result <= 0) return R.error("导入数据库失败!"); + else { + return R.ok("新建成功!"); + } + } + + /** + * 2021.11.24 + * zhaomr + * 根据id删除活动 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/deleteById") + public R deleteById(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + + if (act_id == null) return R.error("缺少参数!"); + + int result = activemodelService.deleteById(act_id); + + if (result == 0) return R.error("删除失败!该活动不存在或操作数据库失败失败!"); + else { + return R.ok("删除成功"); + } } + + /** + * 2021.11.21 + * zhaomr + * 更新活动的信息 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/updateActiveModel") + public R updateActiveModel(@RequestParam Map params) { + String act_name = (String) params.get("act_name"); + String act_introduce = (String) params.get("act_introduce"); + String act_picNumber = (String) params.get("act_picNumber"); + String act_id = (String) params.get("act_id"); + + if (act_name == null || act_id == null) return R.error("缺少参数!"); + + ActivemodelEntity activemodelEntity = activemodelService.getById(act_id); + + if(activemodelEntity == null) return R.error("修改失败!该活动不存在"); + + if(activemodelService.getByName(act_name) != null) return R.error("修改失败!该活动名已存在"); + + activemodelEntity.setActName(act_name); + activemodelEntity.setActPicnumber(act_picNumber); + activemodelEntity.setActIntroduce(act_introduce); + + int result = activemodelService.update(activemodelEntity); + + if (result == 0) return R.error("修改失败!导入数据库失败!"); + + return R.ok("修改成功!"); + } + + /** + * 2021.11.24 + * zhaomr + * 更改班级的开放状态 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/updateClassesOpen") + public R updateClassesOpen(@RequestParam Map params) { + String c_number = (String) params.get("c_number"); + String act_id = (String) params.get("act_id"); + + if (c_number == null || act_id == null) return R.error("缺少参数!"); + + ClassesEntity classesEntity = classesService.getByNumber(c_number); + + if(classesEntity == null) return R.error("更改失败!该班级未创建"); + + classesEntity.setCAid(act_id); + + int result = classesService.update(classesEntity); + + if(result == 0) return R.error("更改失败!导入数据库异常"); + + return R.ok("更改成功!"); + } + + /** + * 2021.11.24 + * zhaomr + * 评价作业 + * + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/evaluateHomework") + public R evaluateHomework(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + //当前页数 + String pn = (String) params.get("pn"); + //每页记录数 + String ps = (String) params.get("ps"); + + String classNumber = (String) params.get("c_number"); + + if (act_id == null) return R.error("缺少参数!"); + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + List studentEntityList = new ArrayList<>(); + + if (classNumber == null) { + List classesEntityList = classesService.getByCAid(act_id); + + if (classesEntityList == null) return R.error("当前活动没有班级!"); + + for (ClassesEntity classesEntity : classesEntityList) { + List nowList = studentService.getBySTclass(classesEntity.getCId()); + + if(nowList != null) + studentEntityList.addAll(nowList); + } + } else { + ClassesEntity classesEntity = classesService.getByNumber(classNumber); + studentEntityList = studentService.getBySTclass(classesEntity.getCId()); + } + + if (studentEntityList.size() == 0) return R.error("该班级没有学生!"); + + ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, "5"); + + if(actionmodelEntity == null) return R.error("该动作未创建!"); + + String actionId = actionmodelEntity.getActionId(); + + //解释模块所有问题 + List questionEntityList = questionService.getByActionId(actionId); + + if(questionEntityList == null) return R.error("该动作内还未添加题目"); + + QuestionEntity questionEntity = questionEntityList.get(1); + + List> mapList = new ArrayList<>(); + + for (StudentEntity studentEntity : studentEntityList) { + Map map = new HashMap<>(); + + map.put("id", studentEntity.getSId()); + map.put("action_id", actionId); + map.put("username", studentEntity.getSUsername()); + map.put("class", studentEntity.getSTclassnumber()); + map.put("sid", studentEntity.getSSid()); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(studentEntity.getSId(), questionEntity.getQId()); + + if (answerEntity == null) { + map.put("state", "false"); + map.put("submitTime", "none"); + map.put("feetTime", "none"); + map.put("score", "none"); + } else { + map.put("state", "true"); + map.put("submitTime", answerEntity.getASubtime()); + + FeetbackEntity feetbackEntity = feetbackService.getByActionIdAndSId(actionId, studentEntity.getSId()); + + if (feetbackEntity == null) { + map.put("feetTime", "none"); + map.put("score", "none"); + } else { + map.put("feetTime", feetbackEntity.getFeetTime()); + + String level = feetbackEntity.getFeetLevel(); + int score = Integer.parseInt(level); + + map.put("score", score > 5 ? score : score * 20); + } + } + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + + /** + * 2021.11.25 + * zhaomr + * 批阅题目 + * + * @param params 传入参数 + * @return R + */ + @RequestMapping("/remark") + public R remark(@RequestParam Map params) { + String s_id = (String) params.get("s_id"); + String action_id = (String) params.get("action_id"); + + if (s_id == null || action_id == null) return R.error("缺少参数!"); + + //不用再判断这个是否为空,因为只有在进入批阅题目的裂变之后才能进入这个方法,所以一定已经创建 + List questionEntityList = questionService.getByActionId(action_id); + + List> mapList = new ArrayList<>(); + + for (QuestionEntity questionEntity : questionEntityList) { + Map map = new HashMap<>(); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(s_id, questionEntity.getQId()); + map.put("title", questionEntity.getQTitle()); + map.put("type", questionEntity.getQType()); + map.put("option", questionEntity.getQOption()); + map.put("standardAnserwer", questionEntity.getQStandardanserwer()); + + if (answerEntity == null) map.put("context", "none"); + else { + map.put("context", answerEntity.getAContext()); + + FeetbackEntity feetbackEntity = feetbackService.getByActionIdAndSId(action_id, s_id); + + if(feetbackEntity != null) { + map.put("score", feetbackEntity.getFeetLevel()); + map.put("feetContext", feetbackEntity.getFeetContent()); + } + } + + if (questionEntity.getQPicnumbers() != null) { + String link = ""; + + String picnumbers = questionEntity.getQPicnumbers(); + + int i = picnumbers.indexOf(",,"); + + if (i == -1) { + PictureEntity pictureEntity = pictureService.getByNumber(picnumbers); + + link = pictureEntity.getPLink(); + } else { + String picnumber = picnumbers.substring(0, i); + + PictureEntity pictureEntity = pictureService.getByNumber(picnumber); + + link += pictureEntity.getPLink(); + + while (i != -1) { + int k = i; + i = picnumbers.indexOf(",,", i + 1); + + if (i == -1) picnumber = picnumbers.substring(k + 2); + else picnumber = picnumbers.substring(k + 2, i); + + pictureEntity = pictureService.getByNumber(picnumber); + link += ",," + pictureEntity.getPLink(); + } + } + + map.put("link", link); + } + + mapList.add(map); + } + + return R.ok("加载成功").put("data", mapList); + } + + /** + * 2021.11.25 + * zhaomr + * 查询不同动作的问题的回答情况 + * + * @param params 参数列表 + * @return R + */ + //可不可以在调用这个请求的时候将之后可能用到的信息一起传给前端 + //之后可能会查看正确人员和错误人员的列表,能不能在这个方法中统一传出 + //反思模块要查的东西不一样 不确定 !!! + @RequestMapping("/selectCompletion") + private R selectCompletion(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + String action_number = (String) params.get("action_number"); + //当前是第几页 + String pn = (String) params.get("pn"); + //每页记录数 + String ps = (String) params.get("ps"); + + if (act_id == null) return R.error("缺少参数!"); + + if (action_number == null) action_number = "1"; + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + System.out.println("act_id:" + act_id + "action_number:" + action_number); + + //actionmodelService为空 + ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, action_number); + + List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); + + List> mapList = new ArrayList<>(); + + for (QuestionEntity questionEntity : questionEntityList) { + Map map = new HashMap<>(); + + map.put("title", questionEntity.getQTitle()); + + List answerEntityList = answerService.getByQId(questionEntity.getQId()); + + int num = 0; + + for (AnswerEntity answerEntity : answerEntityList) + if("true".equals(answerEntity.getAIstrue())) num++; + + map.put("successPeople", num); + map.put("failPeople", answerEntityList.size() - num); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + + /** + * 2021.11.25 + * zhaomr + * 查询所有学生的答题情况 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/selectAllCompletion") + public R selectAllCompletion(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + //当前页数 + String pn = (String) params.get("pn"); + //每页记录数 + String ps = (String) params.get("ps"); + + String classNumber = (String) params.get("c_number"); + + if (act_id == null) return R.error("缺少参数!"); + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + List studentEntityList = new ArrayList<>(); + + if (classNumber == null) { + List classesEntityList = classesService.getByCAid(act_id); + + if (classesEntityList == null) return R.error("当前活动没有班级!"); + + for (ClassesEntity classesEntity : classesEntityList) { + List nowList = studentService.getBySTclass(classesEntity.getCId()); + + if(nowList != null) + studentEntityList.addAll(nowList); + } + } else { + ClassesEntity classesEntity = classesService.getByNumber(classNumber); + studentEntityList = studentService.getBySTclass(classesEntity.getCId()); + } + + if (studentEntityList.size() == 0) return R.error("该班级没有学生!"); + + List> mapList = new ArrayList<>(); + + for (StudentEntity studentEntity : studentEntityList) { + Map map = new HashMap<>(); + + map.put("id", studentEntity.getSId()); + map.put("name", studentEntity.getSName()); + map.put("class", studentEntity.getSTclassnumber()); + map.put("sid", studentEntity.getSSid()); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + /** * 列表 */ @RequestMapping("/list") @RequiresPermissions("generator:activemodel:list") - public R list(@RequestParam Map params){ + public R list(@RequestParam Map params) { PageUtils page = activemodelService.queryPage(params); return R.ok().put("page", page); @@ -119,8 +575,8 @@ public class ActivemodelController { */ @RequestMapping("/info/{actId}") @RequiresPermissions("generator:activemodel:info") - public R info(@PathVariable("actId") String actId){ - ActivemodelEntity activemodel = activemodelService.getById(actId); + public R info(@PathVariable("actId") String actId) { + ActivemodelEntity activemodel = activemodelService.getById(actId); return R.ok().put("activemodel", activemodel); } @@ -130,8 +586,8 @@ public class ActivemodelController { */ @RequestMapping("/save") @RequiresPermissions("generator:activemodel:save") - public R save(@RequestBody ActivemodelEntity activemodel){ - activemodelService.save(activemodel); + public R save(@RequestBody ActivemodelEntity activemodel) { + activemodelService.save(activemodel); return R.ok(); } @@ -141,8 +597,8 @@ public class ActivemodelController { */ @RequestMapping("/update") @RequiresPermissions("generator:activemodel:update") - public R update(@RequestBody ActivemodelEntity activemodel){ - activemodelService.updateById(activemodel); + public R update(@RequestBody ActivemodelEntity activemodel) { + activemodelService.updateById(activemodel); return R.ok(); } @@ -152,8 +608,8 @@ public class ActivemodelController { */ @RequestMapping("/delete") @RequiresPermissions("generator:activemodel:delete") - public R delete(@RequestBody String[] actIds){ - activemodelService.removeByIds(Arrays.asList(actIds)); + public R delete(@RequestBody String[] actIds) { + activemodelService.removeByIds(Arrays.asList(actIds)); return R.ok(); } diff --git a/src/main/java/io/renren/modules/generator/controller/AnswerController.java b/src/main/java/io/renren/modules/generator/controller/AnswerController.java index db0c79b1af0683412f9592747a412532161f3bac..77e9396267b2068e378c74cb1b382adaec91e334 100644 --- a/src/main/java/io/renren/modules/generator/controller/AnswerController.java +++ b/src/main/java/io/renren/modules/generator/controller/AnswerController.java @@ -1,8 +1,11 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; +import java.util.*; +import io.renren.modules.generator.entity.ActionmodelEntity; +import io.renren.modules.generator.entity.QuestionEntity; +import io.renren.modules.generator.service.ActionmodelService; +import io.renren.modules.generator.service.QuestionService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -32,6 +35,12 @@ public class AnswerController { @Autowired private AnswerService answerService; + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private QuestionService questionService; + //根据问题id和学生id和回答内容插入学生的答案(多选题需要在前端以,,分割) @RequestMapping("/insertAnswer") public R insertAnswer(@RequestParam Map params){ @@ -47,6 +56,75 @@ public class AnswerController { return R.error("插入失败,问题id不存在"); } + + /** + * 2021.11.25 + * zhaomr + * 获得某个学生这个活动中的全部答题情况 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/selectOneStudentQuestions") + public R selectOneStudentQuestions(@RequestParam Map params) { + String sId = (String) params.get("s_id"); + String actId = (String) params.get("act_id"); + + if(sId == null || actId == null) return R.error("缺少参数"); + + List actionmodelEntityList = actionmodelService.getByActId(actId); + + List>> arrayList = new ArrayList<>(); + + for (ActionmodelEntity actionmodelEntity : actionmodelEntityList) { + List> mapList = new ArrayList<>(); + + List questionEntities = questionService.getByActionId(actionmodelEntity.getActionId()); + + if(questionEntities.size() == 0) continue; + + //如果是解释板块的话 只展示客观题 + if("5".equals(actionmodelEntity.getActionNumber())) { + Map map = new HashMap<>(); + + QuestionEntity questionEntity = questionEntities.get(0); + map.put("title", questionEntity.getQTitle()); + map.put("option", questionEntity.getQOption()); + map.put("standardAnserwer", questionEntity.getQStandardanserwer()); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(sId, questionEntity.getQId()); + + if(answerEntity == null) map.put("status", "该学生还未回答该题"); + else { + map.put("context", answerEntity.getAContext()); + map.put("istrue", answerEntity.getAIstrue()); + } + + mapList.add(map); + }else { + for (QuestionEntity questionEntity : questionEntities) { + Map map = new HashMap<>(); + + map.put("title", questionEntity.getQTitle()); + map.put("option", questionEntity.getQOption()); + map.put("standardAnserwer", questionEntity.getQStandardanserwer()); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(sId, questionEntity.getQId()); + + if(answerEntity == null) map.put("status", "该学生还未回答该题"); + else { + map.put("context", answerEntity.getAContext()); + map.put("istrue", answerEntity.getAIstrue()); + } + mapList.add(map); + } + } + + arrayList.add(mapList); + } + + return R.ok("查询成功!").put("data", arrayList); + } /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/PictureController.java b/src/main/java/io/renren/modules/generator/controller/PictureController.java index 1029b30e396fa6085fe1527af5d495ecbd2abb11..c7ce73d3eef38ee6f4bfc1aadb82847da073dbee 100644 --- a/src/main/java/io/renren/modules/generator/controller/PictureController.java +++ b/src/main/java/io/renren/modules/generator/controller/PictureController.java @@ -1,8 +1,20 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; - +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.OSSClientBuilder; +import io.renren.common.utils.OssUtils; +import io.renren.components.TokenManager; +import io.renren.modules.generator.entity.TeacherEntity; +import io.renren.modules.generator.service.StudentService; +import io.renren.modules.generator.service.TeacherService; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +27,9 @@ import io.renren.modules.generator.entity.PictureEntity; import io.renren.modules.generator.service.PictureService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +45,97 @@ public class PictureController { @Autowired private PictureService pictureService; + @Autowired + private TokenManager tokenManager; + + @Autowired + private TeacherService teacherService; + + private static long num = 0; + + /** + * time: 2021.11.23 + * zhaomr + * 上传图片 + * + * @param file + * @param params + * @param request + * @return + * @throws IOException + */ + @RequestMapping("/insertPicture") + public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + +// 测试 +// String t_id = "123123123123"; + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "picture/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String p_number = t_id.substring(0, 3) + type + num++; + fileName += p_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + PictureEntity pictureEntity = new PictureEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + pictureEntity.setPId(uid); + pictureEntity.setPName(file.getOriginalFilename()); + + if(params.get("p_introduce") != null) + pictureEntity.setPIntroduce((String) params.get("p_introduce")); + + pictureEntity.setPNumber(p_number); + pictureEntity.setPLink(OssUtils.getPath() + fileName); + + int result = pictureService.insertPicture(pictureEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + List> maplist =new ArrayList<>(); + Map map = new HashMap<>(); + map.put("p_number", p_number); + map.put("p_link", pictureEntity.getPLink()); + maplist.add(map); + + return R.ok("导入成功!").put("data", maplist); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/PptController.java b/src/main/java/io/renren/modules/generator/controller/PptController.java index 17d92737ce73b895bb55e740c3869878fa32d246..560b0f53e1f675bda4fed49d29ab406123ec25e1 100644 --- a/src/main/java/io/renren/modules/generator/controller/PptController.java +++ b/src/main/java/io/renren/modules/generator/controller/PptController.java @@ -1,8 +1,16 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; - +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import io.renren.components.TokenManager; +import io.renren.modules.generator.entity.PictureEntity; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +23,9 @@ import io.renren.modules.generator.entity.PptEntity; import io.renren.modules.generator.service.PptService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +41,92 @@ public class PptController { @Autowired private PptService pptService; + @Autowired + private TokenManager tokenManager; + + private static long num = 0; + + /** + * time: 2021.11.23 + * zhaomr + * 上传ppt + * + * @param file + * @param params + * @param request + * @return + * @throws IOException + */ + @RequestMapping("/insertPpt") + public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "ppt/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + + String pt_number = t_id.substring(0, 3) + type + num++; + fileName += pt_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + PptEntity pptEntity = new PptEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + pptEntity.setPtId(uid); + pptEntity.setPtName(file.getOriginalFilename()); + + if(params.get("pt_introduce") != null) + pptEntity.setPtIntroduce((String) params.get("pt_introduce")); + + pptEntity.setPtNumber(pt_number); + pptEntity.setPtLink(OssUtils.getPath() + fileName); + + int result = pptService.insertPpt(pptEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + List> maplist =new ArrayList<>(); + Map map = new HashMap<>(); + map.put("pt_number", pt_number); + map.put("p_link", pptEntity.getPtLink()); + maplist.add(map); + + return R.ok("导入成功!").put("data", maplist); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/VideoController.java b/src/main/java/io/renren/modules/generator/controller/VideoController.java index 510ddaf071207706f085d2052c8057edac245754..78f3810494d1d6a810c2ae4444f232d8755d0a4f 100644 --- a/src/main/java/io/renren/modules/generator/controller/VideoController.java +++ b/src/main/java/io/renren/modules/generator/controller/VideoController.java @@ -1,8 +1,16 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; - +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import io.renren.components.TokenManager; +import io.renren.modules.generator.entity.PptEntity; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +23,9 @@ import io.renren.modules.generator.entity.VideoEntity; import io.renren.modules.generator.service.VideoService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +41,91 @@ public class VideoController { @Autowired private VideoService videoService; + @Autowired + private TokenManager tokenManager; + + private static int num = 0; + + /** + * time: 2021.11.23 + * zhaomr + * 上传视频 + * + * @param file + * @param params + * @param request + * @return + * @throws IOException + */ + @RequestMapping("/insertVideo") + public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "video/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String v_number = t_id.substring(0, 3) + type + num++; + fileName += v_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + VideoEntity videoEntity = new VideoEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + videoEntity.setVId(uid); + videoEntity.setVName(file.getOriginalFilename()); + + if(params.get("v_introduce") != null) + videoEntity.setVIntroduce((String) params.get("v_introduce")); + + videoEntity.setVNumber(v_number); + videoEntity.setVLink(OssUtils.getPath() + fileName); + + int result = videoService.insertVideo(videoEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + List> maplist =new ArrayList<>(); + Map map = new HashMap<>(); + map.put("v_number", v_number); + map.put("p_link", videoEntity.getVLink()); + maplist.add(map); + + return R.ok("导入成功!").put("data", maplist); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java b/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java index 05e06638fa5a7c8e506067bd37389bbcd0c92295..3250da1f952f6514f95c06e256507b8e288b5ac1 100644 --- a/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java @@ -55,7 +55,7 @@ public class ActivemodelEntity implements Serializable { /** * 活动开放的班级组 */ - private String actClassList; +// private String actClassList; /** * 活动开放的班级组 diff --git a/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java b/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java index ef59bb84c6f39ce2eb4e18839eab624bd030bd71..7afce570c54b8312593fad5f004d6d49ca41bf15 100644 --- a/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java @@ -40,5 +40,9 @@ public class ClassesEntity implements Serializable { * 课程id */ private String cMid; + /** + * 活动id + */ + private String cAid; } diff --git a/src/main/java/io/renren/modules/generator/service/ActionmodelService.java b/src/main/java/io/renren/modules/generator/service/ActionmodelService.java index a73f0c6455e5805388a5cfc196e3c3e1eb393567..0443b894e7627fae5d7feff71b602477aeb198a0 100644 --- a/src/main/java/io/renren/modules/generator/service/ActionmodelService.java +++ b/src/main/java/io/renren/modules/generator/service/ActionmodelService.java @@ -62,5 +62,26 @@ public interface ActionmodelService extends IService { PageUtils queryPage(Map params); + + /** + * 2021.11.24 + * zhaomr + * 根据活动id和动作号来查找 + * + * @param action_actid 活动id + * @param action_number 动作号 + * @return ActionmodelEntity + */ + ActionmodelEntity getByActIdAndNumber(String action_actid, String action_number); + + /** + * 2021.11.25 + * zhaomr + * 根据活动id查找其下所有动作 + * + * @param actId 活动id + * @return List + */ + List getByActId(String actId); } diff --git a/src/main/java/io/renren/modules/generator/service/ActivemodelService.java b/src/main/java/io/renren/modules/generator/service/ActivemodelService.java index e4ebeafd2abd2534781785e68872c18cbbe19d2f..4810e60b39e0188907b125745b96ae202f25721f 100644 --- a/src/main/java/io/renren/modules/generator/service/ActivemodelService.java +++ b/src/main/java/io/renren/modules/generator/service/ActivemodelService.java @@ -22,5 +22,44 @@ public interface ActivemodelService extends IService { //根据单元id获得所有的活动实体对象 List getAllActiveModel(String unitId); + /** + * 2021.11.24 + * zhaomr + * 插入活动 + * + * @param activemodelEntity 活动实体 + * @return 影响行数 + */ + int insertActive(ActivemodelEntity activemodelEntity); + + /** + * 2021.11.24 + * zhaomr + * 根据id删除 + * + * @param act_id 活动id + * @return 影响行数 + */ + int deleteById(String act_id); + + /** + * 2021.11.24 + * zhaomr + * 更新活动 + * + * @param activemodelEntity 活动实体 + * @return 影响行数 + */ + int update(ActivemodelEntity activemodelEntity); + + /** + * 2021.11.25 + * zhaomr + * 根据name查找 + * + * @param act_name + * @return + */ + ActivemodelEntity getByName(String act_name); } diff --git a/src/main/java/io/renren/modules/generator/service/AnswerService.java b/src/main/java/io/renren/modules/generator/service/AnswerService.java index 0388eaa20b5963bf8ae3cb0721f8d8ff0be1c18b..92996820a667767e6002f0cbb07e7e3e5384fdc5 100644 --- a/src/main/java/io/renren/modules/generator/service/AnswerService.java +++ b/src/main/java/io/renren/modules/generator/service/AnswerService.java @@ -27,5 +27,26 @@ public interface AnswerService extends IService { Boolean insertAnswer(String qId,String sId,String context); PageUtils queryPage(Map params); + + /** + * 2021.11.24 + * zhaomr + * 根据学生id和问题id查找回答 + * + * @param sId 学生id + * @param qId 问题id + * @return AnswerEntity + */ + AnswerEntity getBySIdAndQId(String sId, String qId); + + /** + * 2021.11.25 + * zhaomr + * 根据问题id查找回答 + * + * @param qId 问题id + * @return List + */ + List getByQId(String qId); } diff --git a/src/main/java/io/renren/modules/generator/service/ClassesService.java b/src/main/java/io/renren/modules/generator/service/ClassesService.java index b33239e66eac0d07c2464cbe3abd3a41b6f2c6b8..b62a73859ae8990c473e1d96d598c41a608a4968 100644 --- a/src/main/java/io/renren/modules/generator/service/ClassesService.java +++ b/src/main/java/io/renren/modules/generator/service/ClassesService.java @@ -57,5 +57,34 @@ public interface ClassesService extends IService { //根据班级id获得所有的课程实体对象 List getAllClassModel(String classId); + /** + * 2021.11.24 + * zhaomr + * 根据班号查询班级 + * + * @param c_number 班号 + * @return ClassesEntity + */ + ClassesEntity getByNumber(String c_number); + + /** + * 2021.11.24 + * zhaomr + * 查询这个活动下所有班级 + * + * @param cAid 活动id + * @return List + */ + List getByCAid(String cAid); + + /** + * 2021.11.24 + * zhaomr + * 修改班级信息 + * + * @param classesEntity 班级实体 + * @return int 影响行数 + */ + int update(ClassesEntity classesEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/FeetbackService.java b/src/main/java/io/renren/modules/generator/service/FeetbackService.java index c99dc95c150547d1129fd2ff519dfb865aaeaa02..713ac88e0f371b505d9b1733e78f60be69d5dafe 100644 --- a/src/main/java/io/renren/modules/generator/service/FeetbackService.java +++ b/src/main/java/io/renren/modules/generator/service/FeetbackService.java @@ -33,5 +33,16 @@ public interface FeetbackService extends IService { //根据反馈id和学生id将此反馈标志为学生已经查看 Boolean changeStateOfFeet(String fId,String sId); + + /** + * 2021.11.24 + * zhaomr + * 根据动作id和学生id查找 + * + * @param actionId 动作id + * @param sId 学生id + * @return FeetbackEntity + */ + FeetbackEntity getByActionIdAndSId(String actionId, String sId); } diff --git a/src/main/java/io/renren/modules/generator/service/PictureService.java b/src/main/java/io/renren/modules/generator/service/PictureService.java index 45c9d345c2120f638fdd6bbc7a1d32e8da12fb34..e681fd087c9e7e7661a257df30f4274df4f8a50e 100644 --- a/src/main/java/io/renren/modules/generator/service/PictureService.java +++ b/src/main/java/io/renren/modules/generator/service/PictureService.java @@ -16,5 +16,9 @@ import java.util.Map; public interface PictureService extends IService { PageUtils queryPage(Map params); + + int insertPicture(PictureEntity pictureEntity); + + PictureEntity getByNumber(String pNumber); } diff --git a/src/main/java/io/renren/modules/generator/service/PptService.java b/src/main/java/io/renren/modules/generator/service/PptService.java index 7cdb77750e3479b20ec4a900bcbbf825a93d4e58..f1e3f893a6b87a1ba2d2407049c97479f39901d1 100644 --- a/src/main/java/io/renren/modules/generator/service/PptService.java +++ b/src/main/java/io/renren/modules/generator/service/PptService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface PptService extends IService { PageUtils queryPage(Map params); + + int insertPpt(PptEntity pptEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/QuestionService.java b/src/main/java/io/renren/modules/generator/service/QuestionService.java index 0534e193968cd2be46da9aabe15b305edda8d663..5b3df37b2c52e3cb17ee4c2c51e6f322111ead7a 100644 --- a/src/main/java/io/renren/modules/generator/service/QuestionService.java +++ b/src/main/java/io/renren/modules/generator/service/QuestionService.java @@ -20,5 +20,15 @@ public interface QuestionService extends IService { //根据板块id获取该板块所有的问题 List getAllQuestion(String act_id); + + /** + * 2021.11.24 + * zhaomr + * 根据动作id获得该动作下所有问题 + * + * @param actionId 动作id + * @return List + */ + List getByActionId(String actionId); } diff --git a/src/main/java/io/renren/modules/generator/service/StudentService.java b/src/main/java/io/renren/modules/generator/service/StudentService.java index a16a7de72134a83e1673f7af1a24eeb0d2bcef47..bb717cf42f0be0c3dd0e47d6d09510f4fca00690 100644 --- a/src/main/java/io/renren/modules/generator/service/StudentService.java +++ b/src/main/java/io/renren/modules/generator/service/StudentService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.generator.entity.StudentEntity; +import java.util.List; import java.util.Map; /** @@ -32,5 +33,15 @@ public interface StudentService extends IService { * @return */ boolean deleteStudentById(String s_id); + + /** + * 2021.11.24 + * zhaomr + * 通过班级id查找所有学生 + * + * @param cTclass 班级id + * @return List + */ + List getBySTclass(String cTclass); } diff --git a/src/main/java/io/renren/modules/generator/service/TeacherService.java b/src/main/java/io/renren/modules/generator/service/TeacherService.java index b6ed29068dd09e1054bce0758fde1007007187a0..218941d54c694270b9286502f62a1b5b6d6aa51f 100644 --- a/src/main/java/io/renren/modules/generator/service/TeacherService.java +++ b/src/main/java/io/renren/modules/generator/service/TeacherService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface TeacherService extends IService { PageUtils queryPage(Map params); + + TeacherEntity getByUN(String username); } diff --git a/src/main/java/io/renren/modules/generator/service/VideoService.java b/src/main/java/io/renren/modules/generator/service/VideoService.java index 4379166a48fcd892c2bafb3c5e984e95f7be3a0e..ed40fae040c823631ed11e69835e3ba37f245e62 100644 --- a/src/main/java/io/renren/modules/generator/service/VideoService.java +++ b/src/main/java/io/renren/modules/generator/service/VideoService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface VideoService extends IService { PageUtils queryPage(Map params); + + int insertVideo(VideoEntity videoEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java index 224e06ed423ec8b54862eaf62d6739079f6adbe6..55dc1ece8e341b8a10c41252fc0fb557a71d73d1 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java @@ -1,5 +1,8 @@ package io.renren.modules.generator.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import io.renren.modules.generator.dao.QuestionDao; +import io.renren.modules.generator.entity.QuestionEntity; import ch.qos.logback.core.net.SyslogOutputStream; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import io.renren.modules.generator.dao.*; @@ -398,4 +401,20 @@ public class ActionmodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("action_actid", action_actid); + queryWrapper.eq("action_number", action_number); + + return actionmodelDao.selectOne(queryWrapper); + } + + @Override + public List getByActId(String actId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("action_actid", actId); + + return actionmodelDao.selectList(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java index 1e641faf04d5859f844c4e1f5a6d41a710911503..a5f62a83587da869ccfb1e55a16911731b37df8c 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java @@ -19,7 +19,6 @@ import io.renren.modules.generator.service.ActivemodelService; @Service("activemodelService") public class ActivemodelServiceImpl extends ServiceImpl implements ActivemodelService { - @Autowired ActivemodelDao activemodelDao; @@ -44,6 +43,50 @@ public class ActivemodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("act_name", act_name); + + return activemodelDao.selectOne(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java index 34ddc3f08a48a7d0b6fd1c03d5b69c4ec16a3bf3..3f70234999e1d72fafe56b00818e30c6a227e143 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java @@ -174,4 +174,20 @@ public class AnswerServiceImpl extends ServiceImpl impl return new PageUtils(page); } + @Override + public AnswerEntity getBySIdAndQId(String sId, String qId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("a_sid", sId); + queryWrapper.eq("a_qid", qId); + + return answerDao.selectOne(queryWrapper); + } + + @Override + public List getByQId(String qId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("a_qid", qId); + + return answerDao.selectList(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java index 3ad8b86a6577da95dd97d7bc5388b2e226e2e3ff..ad5eaf6bed99b470326f3f5e83891baa2d04d34b 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java @@ -28,10 +28,10 @@ public class ClassesServiceImpl extends ServiceImpl i @Autowired private ClassesDao classesDao; - ClassesDao classesDao; @Autowired ClassmodelDao classmodelDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -48,7 +48,7 @@ public class ClassesServiceImpl extends ServiceImpl i * @param cMid 课程id * @param cNumber 班号(班级名称) * @param cIntroduce 班级简介 - * int x 判断班级名称(班号)是否唯一,若班级名称不唯一(int x==1)返回false + * int x 判断班级名称(班号)是否唯一,若班级名称不唯一(int x==1)返回false * @return */ @Override @@ -57,8 +57,8 @@ public class ClassesServiceImpl extends ServiceImpl i QueryWrapper queryWrapper = new QueryWrapper<>(); QueryWrapper c_number = queryWrapper.eq("c_number", cNumber); ClassesEntity classes1 = classesDao.selectOne(c_number); - x = classes1==null?0:1; - if(x==0){ + x = classes1 == null ? 0 : 1; + if (x == 0) { ClassesEntity classes = new ClassesEntity(); UUID.randomUUID().toString(); classes.setCId(UUID.randomUUID().toString()); @@ -66,7 +66,7 @@ public class ClassesServiceImpl extends ServiceImpl i classes.setCIntroduce(cIntroduce); classes.setCMid(cMid); int insert = classesDao.insert(classes); - return insert>0?true:false; + return insert > 0 ? true : false; } return false; } @@ -93,43 +93,42 @@ public class ClassesServiceImpl extends ServiceImpl i * @return */ @Override - public boolean updateClassNumberById(String cid,String cNumber) { + public boolean updateClassNumberById(String cid, String cNumber) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); UpdateWrapper set = updateWrapper.eq("c_id", cid).set("c_number", cNumber); int update = classesDao.update(null, updateWrapper); - return update>0?true:false; + return update > 0 ? true : false; } /** - * 通过班级表里的班级id去修改班级简介 + * 通过班级表里的班级id去删除班级 * * @param cid - * @param cIntroduce * @return */ @Override - public boolean updateClassIntroduceById(String cid, String cIntroduce) { + public boolean deleteClassById(String cid) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - UpdateWrapper set = updateWrapper.eq("c_id", cid).set("c_introduce", cIntroduce); - int update = classesDao.update(null, updateWrapper); - return update>0?true:false; + UpdateWrapper c_id = updateWrapper.eq("c_id", cid); + int delete = classesDao.delete(c_id); + return delete > 0 ? true : false; } /** - * 通过班级表里的班级id去删除班级 + * 通过班级表里的班级id去修改班级简介 * * @param cid + * @param cIntroduce * @return */ @Override - public boolean deleteClassById(String cid) { + public boolean updateClassIntroduceById(String cid, String cIntroduce) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - UpdateWrapper c_id = updateWrapper.eq("c_id", cid); - int delete = classesDao.delete(c_id); - return delete>0?true:false; + UpdateWrapper set = updateWrapper.eq("c_id", cid).set("c_introduce", cIntroduce); + int update = classesDao.update(null, updateWrapper); + return update > 0 ? true : false; } -} //根据班级id获取所有的课程对象 如果班级不存在返回null @Override public List getAllClassModel(String classId) { @@ -151,4 +150,30 @@ public class ClassesServiceImpl extends ServiceImpl i return arrayList; } + /** + * 通过班号查找班级 + * + * @param c_number + * @return + */ + @Override + public ClassesEntity getByNumber(String c_number) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("c_number", c_number); + + return classesDao.selectOne(queryWrapper); + } + + @Override + public List getByCAid(String cAid) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("c_aid", cAid); + + return classesDao.selectList(queryWrapper); + } + + @Override + public int update(ClassesEntity classesEntity) { + return classesDao.updateById(classesEntity); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java index 9ad6cda69d0a732c17e1e0bb6f9fef4da4cca2bb..c56ea941e30ee61438cbddef1c1b96c41874ec48 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java @@ -96,7 +96,12 @@ public class FeetbackServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("feet_actionid", actionId); + queryWrapper.eq("feet_sid", sId); - - + return feetbackDao.selectOne(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java index 5615cdd8f16b3c7dbf03955b6d3888f637b04f24..0aef48dc44ef7f5f746e7182efd1113091a92ff1 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java @@ -1,5 +1,7 @@ package io.renren.modules.generator.service.impl; +import io.renren.common.exception.RRException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +18,9 @@ import io.renren.modules.generator.service.PictureService; @Service("pictureService") public class PictureServiceImpl extends ServiceImpl implements PictureService { + @Autowired + private PictureDao pictureDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +31,32 @@ public class PictureServiceImpl extends ServiceImpl i return new PageUtils(page); } + /** + * 2021.11.23 + * zhaomr + * 上传图片 + * + * @param pictureEntity 图片实体 + * @return 影响行数 + */ + @Override + public int insertPicture(PictureEntity pictureEntity) { + return pictureDao.insert(pictureEntity); + } + + /** + * 2021.11.25 + * zhaomr + * 根据图片号找照片 + * + * @param pNumber 图片号 + * @return 图片实体 + */ + @Override + public PictureEntity getByNumber(String pNumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("p_number", pNumber); + + return pictureDao.selectOne(queryWrapper); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java index 3f2d478bc1c3e1439a9dde1d8f951694f4ff61fb..9df2059c78c5e48c14523acabbb13733f9a15ac8 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +17,9 @@ import io.renren.modules.generator.service.PptService; @Service("pptService") public class PptServiceImpl extends ServiceImpl implements PptService { + @Autowired + private PptDao pptDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +30,8 @@ public class PptServiceImpl extends ServiceImpl implements Pp return new PageUtils(page); } + @Override + public int insertPpt(PptEntity pptEntity) { + return pptDao.insert(pptEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java index 84918b72d485638675a33ab76bb0486c2b7460bb..fe4da6eda1e19a8fa94001c6e167e7b808250515 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java @@ -40,4 +40,11 @@ public class QuestionServiceImpl extends ServiceImpl getByActionId(String actionId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("q_actionId", actionId); + + return questionDao.selectList(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java index c988563db76f3d9bfba422d6af97f4994a468bcf..cc2a23bbb887b2ed4f9a1baa06684c54b8dab33f 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java @@ -3,6 +3,8 @@ package io.renren.modules.generator.service.impl; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.List; import java.util.Map; import java.util.UUID; @@ -72,4 +74,11 @@ public class StudentServiceImpl extends ServiceImpl i return i>0?true:false; } + @Override + public List getBySTclass(String cTclass) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("s_tclass", cTclass); + + return studentDao.selectList(queryWrapper); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java index 38d6a7d71201a54fc78c6a1595e19285d5d18732..db87fcb699353dcb62bc5d23ddea5ddd45c14636 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +17,9 @@ import io.renren.modules.generator.service.TeacherService; @Service("teacherService") public class TeacherServiceImpl extends ServiceImpl implements TeacherService { + @Autowired + private TeacherDao teacherDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +30,11 @@ public class TeacherServiceImpl extends ServiceImpl i return new PageUtils(page); } + @Override + public TeacherEntity getByUN(String username) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("s_username",username); + TeacherEntity entity = teacherDao.selectOne(wrapper); + return entity; + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java index 6edfbf8023dcd0d066fec041932949706d944a4f..123bc422d03ef5ccb0f8feeb4ae1bc6d84609222 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +17,9 @@ import io.renren.modules.generator.service.VideoService; @Service("videoService") public class VideoServiceImpl extends ServiceImpl implements VideoService { + @Autowired + private VideoDao videoDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +30,8 @@ public class VideoServiceImpl extends ServiceImpl impleme return new PageUtils(page); } + @Override + public int insertVideo(VideoEntity videoEntity) { + return videoDao.insert(videoEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/util/OssUploadService.java b/src/main/java/io/renren/modules/generator/util/OssUploadService.java deleted file mode 100644 index 28caa151896c22122f97d524a649ac596f1dfe75..0000000000000000000000000000000000000000 --- a/src/main/java/io/renren/modules/generator/util/OssUploadService.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.renren.modules.generator.util; - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClient; -import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.model.PutObjectRequest; -import io.renren.modules.oss.entity.SysOssEntity; -import org.springframework.web.multipart.MultipartFile; - -import java.io.*; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.UUID; - -//阿里云文件上传工具类 -public class OssUploadService { - - //测试 - public static void main(String[] args) { - String uploadFile= uploadFileByFile(new File("C:\\Users\\张世宇\\Desktop\\开发需求.txt")); - System.out.println(uploadFile); - } - - public static String uploadFileByFile(File multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= new FileInputStream(multipartFile); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getName(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } - - public static String uploadFileByMultipartFile(MultipartFile multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= multipartFile.getInputStream(); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getOriginalFilename(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } -} diff --git a/src/main/java/io/renren/modules/generator/utils/OssUploadService.java b/src/main/java/io/renren/modules/generator/utils/OssUploadService.java deleted file mode 100644 index 9cece6cb8c730aa773f710c42de8c6f018bb5307..0000000000000000000000000000000000000000 --- a/src/main/java/io/renren/modules/generator/utils/OssUploadService.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.renren.modules.generator.utils; - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClient; -import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.model.PutObjectRequest; -import io.renren.modules.oss.entity.SysOssEntity; -import org.springframework.web.multipart.MultipartFile; - -import java.io.*; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.UUID; - -//阿里云文件上传工具类 -public class OssUploadService { - - //测试 - public static void main(String[] args) { - String uploadFile= uploadFileByFile(new File("C:\\Users\\张世宇\\Desktop\\开发需求.txt")); - System.out.println(uploadFile); - } - - public static String uploadFileByFile(File multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= new FileInputStream(multipartFile); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getName(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } - - public static String uploadFileByMultipartFile(MultipartFile multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= multipartFile.getInputStream(); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getOriginalFilename(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } -} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index c8a6571e85c5ce6a2b61136749b55b5f853fb6b6..ed756c17288dadd005c44c12ac9730d414f2b5f8 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a374b009355956e5a45f9cb22fa872aa1d7de91e..922bd525374a8c3c26667aa40cb3e9abbb69173f 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index a374b009355956e5a45f9cb22fa872aa1d7de91e..922bd525374a8c3c26667aa40cb3e9abbb69173f 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 diff --git a/src/main/resources/mapper/generator/ActivemodelDao.xml b/src/main/resources/mapper/generator/ActivemodelDao.xml index 77dd9f2d208b8be2a35e97621e4449f56d154f19..09f3f6c827b0cb9072284db2f3ccd286556e471e 100644 --- a/src/main/resources/mapper/generator/ActivemodelDao.xml +++ b/src/main/resources/mapper/generator/ActivemodelDao.xml @@ -13,6 +13,6 @@ - + diff --git a/src/main/resources/mapper/generator/ClassesDao.xml b/src/main/resources/mapper/generator/ClassesDao.xml index e6c08ca0b13694e380fb40c0fd209ed10d603c5f..396999c5f25c2c8ef909a220384e33aec6b75c82 100644 --- a/src/main/resources/mapper/generator/ClassesDao.xml +++ b/src/main/resources/mapper/generator/ClassesDao.xml @@ -10,6 +10,7 @@ +