Merge remote-tracking branch 'origin/master'
New file |
| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.ycl.jxkg.group.Update; |
| | | import com.ycl.jxkg.group.Add; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import lombok.RequiredArgsConstructor; |
| | | import java.util.List; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import com.ycl.jxkg.service.MeetService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.form.MeetForm; |
| | | import com.ycl.jxkg.domain.query.MeetQuery; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 会议表 前端控制器 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "会议表", tags = "会议表管理") |
| | | @RestController |
| | | @RequestMapping("api/admin/meet") |
| | | public class MeetController { |
| | | |
| | | private final MeetService meetService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | public Result add(@RequestBody @Validated(Add.class) MeetForm form) { |
| | | return meetService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result update(@RequestBody @Validated(Update.class) MeetForm form) { |
| | | return meetService.update(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return meetService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return meetService.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | public Result page(MeetQuery query) { |
| | | return meetService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | public Result detail(@PathVariable("id") Integer id) { |
| | | return meetService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public Result list() { |
| | | return meetService.all(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.controller.student; |
| | | |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.form.MeetForm; |
| | | import com.ycl.jxkg.domain.query.MeetQuery; |
| | | import com.ycl.jxkg.group.Add; |
| | | import com.ycl.jxkg.group.Update; |
| | | import com.ycl.jxkg.service.MeetService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 会议表 前端控制器 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "会议表", tags = "会议表管理") |
| | | @RestController |
| | | @RequestMapping("api/student/meet") |
| | | public class MeetController { |
| | | |
| | | private final MeetService meetService; |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | public Result page(MeetQuery query) { |
| | | return meetService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | public Result detail(@PathVariable("id") Integer id) { |
| | | return meetService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public Result list() { |
| | | return meetService.all(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ycl.jxkg.domain.base.AbsEntity; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 会议表 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Data |
| | | @TableName("t_meet") |
| | | public class Meet extends AbsEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("meet_name") |
| | | /** 会议名 */ |
| | | private String meetName; |
| | | |
| | | @TableField("meet_cover") |
| | | /** 会议封面 */ |
| | | private String meetCover; |
| | | |
| | | @TableField("student_ids") |
| | | /** 学生id */ |
| | | private String studentIds; |
| | | |
| | | @TableField("create_user") |
| | | /** 创建人 */ |
| | | private Integer createUser; |
| | | |
| | | @TableField("start_time") |
| | | /** 开始时间 */ |
| | | private Date startTime; |
| | | |
| | | @TableField("end_time") |
| | | /** 结束时间 */ |
| | | private Date endTime; |
| | | |
| | | @TableField("status") |
| | | /** 状态 0/1/2 未开始/进行中/已结束 */ |
| | | private Integer status; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.form; |
| | | |
| | | import com.ycl.jxkg.group.Update; |
| | | import com.ycl.jxkg.group.Add; |
| | | import com.ycl.jxkg.domain.base.AbsForm; |
| | | import com.ycl.jxkg.domain.entity.Meet; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 会议表表单 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "Meet表单", description = "会议表表单") |
| | | public class MeetForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "会议名不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("会议名") |
| | | private String meetName; |
| | | |
| | | @NotBlank(message = "会议封面不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("会议封面") |
| | | private String meetCover; |
| | | |
| | | @NotBlank(message = "学生id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("学生id") |
| | | private List<Integer> studentIds; |
| | | |
| | | @NotNull(message = "创建人不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("创建人") |
| | | private Integer createUser; |
| | | |
| | | @NotNull(message = "开始时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("开始时间") |
| | | private Date startTime; |
| | | |
| | | @NotNull(message = "结束时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("结束时间") |
| | | private Date endTime; |
| | | |
| | | @NotNull(message = "状态 0/1/2 未开始/进行中/已结束不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("状态 0/1/2 未开始/进行中/已结束") |
| | | private Integer status; |
| | | |
| | | public static Meet getEntityByForm(@NonNull MeetForm form, Meet entity) { |
| | | if(entity == null) { |
| | | entity = new Meet(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.domain.query; |
| | | |
| | | import com.ycl.jxkg.domain.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 会议表查询 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "Meet查询", description = "会议表查询") |
| | | public class MeetQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package com.ycl.jxkg.domain.vo; |
| | | |
| | | import com.ycl.jxkg.domain.base.AbsVo; |
| | | import com.ycl.jxkg.domain.entity.Meet; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 会议表展示 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Data |
| | | public class MeetVO extends AbsVo { |
| | | |
| | | /** 会议名 */ |
| | | private String meetName; |
| | | |
| | | /** 会议封面 */ |
| | | private String meetCover; |
| | | |
| | | /** 学生id */ |
| | | private List<Integer> studentIds; |
| | | |
| | | /** 创建人 */ |
| | | private Integer createUser; |
| | | |
| | | /** 开始时间 */ |
| | | private Date startTime; |
| | | |
| | | /** 结束时间 */ |
| | | private Date endTime; |
| | | |
| | | /** 状态 0/1/2 未开始/进行中/已结束 */ |
| | | private Integer status; |
| | | |
| | | public static MeetVO getVoByEntity(@NonNull Meet entity, MeetVO vo) { |
| | | if(vo == null) { |
| | | vo = new MeetVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.enums; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public enum MeetStatusEnum { |
| | | |
| | | Wait(0, "未开始"), |
| | | Starting(1, "进行中"), |
| | | End(2, "已结束"); |
| | | |
| | | |
| | | Integer code; |
| | | String name; |
| | | |
| | | MeetStatusEnum(Integer code, String name) { |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | |
| | | private static Map<Integer, MeetStatusEnum> keyMap = new HashMap<>(); |
| | | |
| | | static { |
| | | for (MeetStatusEnum item : MeetStatusEnum.values()) { |
| | | keyMap.put(item.getCode(), item); |
| | | } |
| | | } |
| | | |
| | | public static MeetStatusEnum fromCode(Integer code) { |
| | | return keyMap.get(code); |
| | | } |
| | | |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.mapper; |
| | | |
| | | import com.ycl.jxkg.domain.entity.Meet; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ycl.jxkg.domain.query.MeetQuery; |
| | | import com.ycl.jxkg.domain.vo.MeetVO; |
| | | import com.ycl.jxkg.domain.form.MeetForm; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 会议表 Mapper 接口 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Mapper |
| | | public interface MeetMapper extends BaseMapper<Meet> { |
| | | |
| | | /** |
| | | * id查找会议表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | MeetVO getById(Integer id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") MeetQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.jxkg.service; |
| | | |
| | | import com.ycl.jxkg.domain.entity.Meet; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.form.MeetForm; |
| | | import com.ycl.jxkg.domain.query.MeetQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 会议表 服务类 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | public interface MeetService extends IService<Meet> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(MeetForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(MeetForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(MeetQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(Integer id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
| | |
| | | if (InnerError4 != null) return InnerError4; |
| | | Result InnerError5 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.ShortAnswer.getCode()); |
| | | if (InnerError5 != null) return InnerError5; |
| | | Result InnerError6 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Calculate.getCode()); |
| | | Result InnerError6 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Audio.getCode()); |
| | | if (InnerError6 != null) return InnerError6; |
| | | Result InnerError7 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Calculate.getCode()); |
| | | if (InnerError7 != null) return InnerError7; |
| | | Result InnerError8 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Analysis.getCode()); |
| | | if (InnerError8 != null) return InnerError8; |
| | | } |
| | | examPaper.setContent(JSON.toJSONString(questionTitleList)); |
| | | baseMapper.insert(examPaper); |
New file |
| | |
| | | package com.ycl.jxkg.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.jxkg.domain.entity.Meet; |
| | | import com.ycl.jxkg.mapper.MeetMapper; |
| | | import com.ycl.jxkg.service.MeetService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.jxkg.domain.form.MeetForm; |
| | | import com.ycl.jxkg.domain.vo.MeetVO; |
| | | import com.ycl.jxkg.domain.query.MeetQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.ycl.jxkg.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 会议表 服务实现类 |
| | | * |
| | | * @author flq |
| | | * @since 2024-06-17 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MeetServiceImpl extends ServiceImpl<MeetMapper, Meet> implements MeetService { |
| | | |
| | | private final MeetMapper meetMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(MeetForm form) { |
| | | Meet entity = MeetForm.getEntityByForm(form, null); |
| | | entity.setStudentIds(JSONArray.toJSONString(form.getStudentIds())); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(MeetForm form) { |
| | | Meet entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | entity.setStudentIds(JSONArray.toJSONString(form.getStudentIds())); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(MeetQuery query) { |
| | | |
| | | IPage<Meet> page = PageUtil.getPage(query, Meet.class); |
| | | baseMapper.getPage(page, query); |
| | | List<Meet> records = page.getRecords(); |
| | | List<MeetVO> vos = new ArrayList<>(); |
| | | for (Meet record : records) { |
| | | MeetVO meetVO = new MeetVO(); |
| | | BeanUtils.copyProperties(record,meetVO); |
| | | meetVO.setStudentIds(JSONArray.parseArray(record.getStudentIds(),Integer.class)); |
| | | vos.add(meetVO); |
| | | } |
| | | return Result.ok().data(vos).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(Integer id) { |
| | | MeetVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<Meet> entities = baseMapper.selectList(null); |
| | | List<MeetVO> vos = entities.stream() |
| | | .map(entity -> MeetVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ycl.jxkg.mapper.MeetMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.Meet"> |
| | | <result column="meet_name" property="meetName" /> |
| | | <result column="meet_cover" property="meetCover" /> |
| | | <result column="student_ids" property="studentIds" /> |
| | | <result column="create_user" property="createUser" /> |
| | | <result column="start_time" property="startTime" /> |
| | | <result column="end_time" property="endTime" /> |
| | | <result column="status" property="status" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | TM.meet_name, |
| | | TM.meet_cover, |
| | | TM.student_ids, |
| | | TM.create_user, |
| | | TM.start_time, |
| | | TM.end_time, |
| | | TM.status, |
| | | TM.id |
| | | FROM |
| | | t_meet TM |
| | | WHERE |
| | | TM.id = #{id} AND TM.deleted = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | TM.meet_name, |
| | | TM.meet_cover, |
| | | TM.student_ids, |
| | | TM.create_user, |
| | | TM.start_time, |
| | | TM.end_time, |
| | | TM.status, |
| | | TM.id |
| | | FROM |
| | | t_meet TM |
| | | <where> |
| | | TM.deleted = 0 |
| | | <if test="studentId!=null"> |
| | | and |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |