12.学生列表中的添加学生
14.题目难度导入
17.建议时长
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.file.Files; |
| | | import java.util.HashMap; |
| | | import java.util.UUID; |
| | |
| | | |
| | | // 读取文件内容 |
| | | byte[] fileContent = Files.readAllBytes(file.toPath()); |
| | | |
| | | String downloadfile = URLEncoder.encode(fileName,"UTF-8"); |
| | | // 设置响应头 |
| | | response.setHeader("Content-Disposition", "attachment; filename=" + fileName); |
| | | response.setHeader("Content-Disposition", "attachment; filename=" + downloadfile); |
| | | response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
| | | |
| | | // 将文件内容写入响应输出流 |
| | |
| | | |
| | | @NotBlank(message = "请填写学员登录账号", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("登录账号") |
| | | private String account; |
| | | private String userName; |
| | | |
| | | @ApiModelProperty("登录密码") |
| | | private String password; |
| | | |
| | | private String birthDay; |
| | | |
| | | public static ClassesUser getEntityByForm(@NonNull EditClassesUserForm form, ClassesUser entity) { |
| | | if(entity == null) { |
| | | entity = new ClassesUser(); |
| | |
| | | package com.ycl.jxkg.domain.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ycl.jxkg.domain.base.AbsVo; |
| | | import com.ycl.jxkg.domain.entity.ClassesUser; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | @Data |
| | | public class ClassesUserVO extends AbsVo { |
| | | |
| | | /** 班级ID */ |
| | | /** |
| | | * 班级ID |
| | | */ |
| | | private Integer classesId; |
| | | |
| | | /** 用户ID */ |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private Integer userId; |
| | | |
| | | /** 真实姓名 */ |
| | | /** |
| | | * 真实姓名 |
| | | */ |
| | | private String realName; |
| | | |
| | | /** 年龄 */ |
| | | /** |
| | | * 年龄 |
| | | */ |
| | | private Integer sex; |
| | | |
| | | /** 电话 */ |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String phone; |
| | | |
| | | /** 加入时间 */ |
| | | /** |
| | | * 加入时间 |
| | | */ |
| | | private Date createTime; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String userName; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String age; |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date birthDay; |
| | | private Integer status; |
| | | |
| | | public static ClassesUserVO getVoByEntity(@NonNull ClassesUser entity, ClassesUserVO vo) { |
| | | if(vo == null) { |
| | | if (vo == null) { |
| | | vo = new ClassesUserVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnore; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.format.NumberFormat; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentStyle; |
| | | import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; |
| | |
| | | /** |
| | | * 选项下拉数据 |
| | | */ |
| | | private String[] optionList = {"A","B","C","D","E","F","G","H"}; |
| | | private String[] optionList = {"A", "B", "C", "D", "E", "F", "G", "H"}; |
| | | |
| | | public SelectExcel(List subjectNameList) { |
| | | this.subjectNameList = subjectNameList; |
| | |
| | | // 添加题目下拉 |
| | | DataValidationConstraint questionConstraint = dataValidationHelper.createExplicitListConstraint(questionTypeList); |
| | | DataValidation questionValidation = dataValidationHelper.createValidation(questionConstraint, questionTypeRange); |
| | | |
| | | setValidation(questionValidation); |
| | | sheet.addValidationData(questionValidation); |
| | | |
| | | |
| | |
| | | // 添加课目下拉 |
| | | DataValidationConstraint subjectConstraint = dataValidationHelper.createExplicitListConstraint(subjectNameList.toArray((new String[0]))); |
| | | DataValidation subjectValidation = dataValidationHelper.createValidation(subjectConstraint, subjectTypeRange); |
| | | |
| | | setValidation(subjectValidation); |
| | | sheet.addValidationData(subjectValidation); |
| | | |
| | | // 设置选项下拉范围,第4列,1500行内 |
| | |
| | | // 添加选项下拉 |
| | | DataValidationConstraint optionConstraint = dataValidationHelper.createExplicitListConstraint(optionList); |
| | | DataValidation optionValidation = dataValidationHelper.createValidation(optionConstraint, optionRange); |
| | | |
| | | setValidation(optionValidation); |
| | | sheet.addValidationData(optionValidation); |
| | | |
| | | // 设置选项下拉范围,第4列,1500行内 |
| | |
| | | // 添加选项下拉 |
| | | DataValidationConstraint answerConstraint = dataValidationHelper.createExplicitListConstraint(optionList); |
| | | DataValidation answerValidation = dataValidationHelper.createValidation(answerConstraint, answerRange); |
| | | setValidation(answerValidation); |
| | | sheet.addValidationData(answerValidation); |
| | | |
| | | // 难道1-5 |
| | | String[] difficultList = new String[]{"1", "2", "3", "4", "5"}; |
| | | CellRangeAddressList difficultRange = new CellRangeAddressList(2, 1500, 8, 8); |
| | | // 添加选项下拉 |
| | | DataValidationConstraint difficultConstraint = dataValidationHelper.createExplicitListConstraint(difficultList); |
| | | DataValidation difficultValidation = dataValidationHelper.createValidation(difficultConstraint, difficultRange); |
| | | setValidation(difficultValidation); |
| | | sheet.addValidationData(difficultValidation); |
| | | } |
| | | private DataValidation setValidation(DataValidation dataValidation){ |
| | | dataValidation.setEmptyCellAllowed(false); |
| | | dataValidation.setSuppressDropDownArrow(true); |
| | | dataValidation.setShowErrorBox(true); |
| | | //设置输入错误提示信息 |
| | | dataValidation.createErrorBox("选择错误提示", "你输入的值未在备选列表中,请下拉选择合适的值!"); |
| | | return dataValidation; |
| | | } |
| | | } |
| | |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result add(EditClassesUserForm form) { |
| | | public Result add(EditClassesUserForm form) { |
| | | Long count = new LambdaQueryChainWrapper<>(userMapper) |
| | | .eq(User::getUserName, form.getAccount()) |
| | | .eq(User::getUserName, form.getUserName()) |
| | | .count(); |
| | | if (count > 0) { |
| | | throw new RuntimeException("该登录账号已被使用"); |
| | | } |
| | | User user = new User(); |
| | | user.setUserName(form.getPhone()); |
| | | user.setUserName(form.getUserName()); |
| | | String password = StringUtils.hasText(form.getPassword()) ? form.getPassword() : DEFAULT_PASSWORD; |
| | | user.setPassword(authenticationService.pwdEncode(password)); |
| | | user.setStatus(UserStatusEnum.Enable.getCode()); |
| | |
| | | user.setPhone(form.getPhone()); |
| | | user.setRealName(form.getRealName()); |
| | | user.setSex(form.getSex()); |
| | | DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd"); |
| | | try { |
| | | user.setBirthDay(fmt.parse(form.getBirthDay())); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | user.setLastUpdatePasswordTime(new Date()); |
| | | userMapper.insert(user); |
| | | |
| | |
| | | throw new RuntimeException("学员数据不存在"); |
| | | } |
| | | Long count = new LambdaQueryChainWrapper<>(userMapper) |
| | | .eq(User::getUserName, form.getAccount()) |
| | | .eq(User::getUserName, form.getUserName()) |
| | | .ne(User::getId, classesUser.getUserId()) |
| | | .count(); |
| | | if (count > 0) { |
| | |
| | | |
| | | // BeanUtils.copyProperties(classesUser, user); |
| | | // userMapper.updateById(user); |
| | | user.setUserName(form.getAccount()); |
| | | user.setUserName(form.getUserName()); |
| | | user.setPassword(form.getPassword()); |
| | | user.setPhone(form.getPhone()); |
| | | user.setRealName(form.getRealName()); |
| | | user.setSex(form.getSex()); |
| | | user.setAge(form.getAge()); |
| | | DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd"); |
| | | try { |
| | | user.setBirthDay(fmt.parse(form.getBirthDay())); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | userMapper.updateById(user); |
| | | return Result.ok("修改成功"); |
| | | } |
| | |
| | | public List<ExamPaper> myExamPaper(Integer paperType) { |
| | | Integer userId = webContext.getCurrentUser().getId(); |
| | | List<ExamPaper> list = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .select(ExamPaper::getId, ExamPaper::getName, ExamPaper::getVisibility) |
| | | .select(ExamPaper::getId, ExamPaper::getName, ExamPaper::getVisibility,ExamPaper::getSuggestTime) |
| | | .eq(ExamPaper::getCreateUser, userId) |
| | | .eq(Objects.nonNull(paperType), ExamPaper::getPaperType, paperType) |
| | | .or() |
| | | .eq(ExamPaper::getVisibility, VisibilityEnum.Public.getName()) |
| | | .eq(Objects.nonNull(paperType), ExamPaper::getPaperType, paperType) |
| | | .orderByDesc(ExamPaper::getId) |
| | | .list(); |
| | | list.stream().forEach(item -> { |
| | | if (VisibilityEnum.Public.getName().equals(item.getVisibility())) { |
| | |
| | | // 查出所有的课目(excel下拉数据) |
| | | List<Subject> subjects = subjectService.list(); |
| | | List<String> subjectNameList = subjects.stream().map(Subject::getName).collect(Collectors.toList()); |
| | | |
| | | EasyExcel.write(response.getOutputStream(), ExamPaperImportVO.class) |
| | | .sheet("模板") |
| | | .registerWriteHandler(new PaperSelectExcel(subjectNameList)) |
| | |
| | | <result column="sex" property="sex"/> |
| | | <result column="phone" property="phone"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="user_name" property="userName"/> |
| | | <result column="age" property="age"/> |
| | | <result column="birth_day" property="birthDay"/> |
| | | <result column="status" property="status"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="ResultMap" type="com.ycl.jxkg.domain.vo.StudentExamInfoVO"> |
| | |
| | | TCU.id, |
| | | TU.real_name, |
| | | TU.sex, |
| | | TU.phone |
| | | TU.phone, |
| | | TU.user_name, |
| | | TU.age, |
| | | TU.birth_day, |
| | | TU.status |
| | | FROM t_classes_user TCU |
| | | LEFT JOIN t_user TU ON TU.id = TCU.user_id and TU.deleted = 0 |
| | | WHERE TCU.deleted = 0 AND TCU.classes_id = #{query.classesId} |
| | | <if test="query.studentName != null and query.studentName != ''">AND TU.real_name like concat('%', |
| | | #{query.studentName}, '%') |
| | | </if> |
| | | order by TU.id desc |
| | | </select> |
| | | |
| | | |