diff --git a/server/like-front/src/main/java/com/mdd/front/controller/MajorController.java b/server/like-front/src/main/java/com/mdd/front/controller/MajorController.java index ac5d1a7f..3fa642e5 100644 --- a/server/like-front/src/main/java/com/mdd/front/controller/MajorController.java +++ b/server/like-front/src/main/java/com/mdd/front/controller/MajorController.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @RestController -@RequestMapping("adminapi/major") +@RequestMapping("frontapi/major") @Api(tags = "专业管理") public class MajorController { diff --git a/server/like-front/src/main/java/com/mdd/front/controller/StudentInfoController.java b/server/like-front/src/main/java/com/mdd/front/controller/StudentInfoController.java new file mode 100644 index 00000000..ec54fb10 --- /dev/null +++ b/server/like-front/src/main/java/com/mdd/front/controller/StudentInfoController.java @@ -0,0 +1,26 @@ +package com.mdd.front.controller; + +import com.mdd.common.core.AjaxResult; +import com.mdd.front.service.IStudentInfoService; +import com.mdd.front.validate.student.PreRegistrationStudentInfoValidate; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("frontapi/student") +@Api(tags = "学生信息") +public class StudentInfoController { + + @Resource + private IStudentInfoService IStudentInfoService; + + @PostMapping("/add") + @ApiOperation(value = "新增预报名学生信息") + public AjaxResult addPreRegistrationStudentInfo(@Validated @RequestBody PreRegistrationStudentInfoValidate studentInfoValidate) { + return IStudentInfoService.add(studentInfoValidate); + } +} diff --git a/server/like-front/src/main/java/com/mdd/front/service/IStudentInfoService.java b/server/like-front/src/main/java/com/mdd/front/service/IStudentInfoService.java new file mode 100644 index 00000000..7ef09d93 --- /dev/null +++ b/server/like-front/src/main/java/com/mdd/front/service/IStudentInfoService.java @@ -0,0 +1,10 @@ +package com.mdd.front.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mdd.common.core.AjaxResult; +import com.mdd.common.entity.StudentInfo; +import com.mdd.front.validate.student.PreRegistrationStudentInfoValidate; + +public interface IStudentInfoService extends IService { + AjaxResult add(PreRegistrationStudentInfoValidate studentInfoValidate); +} diff --git a/server/like-front/src/main/java/com/mdd/front/service/impl/StudentServiceImpl.java b/server/like-front/src/main/java/com/mdd/front/service/impl/StudentServiceImpl.java new file mode 100644 index 00000000..3cb4d1cf --- /dev/null +++ b/server/like-front/src/main/java/com/mdd/front/service/impl/StudentServiceImpl.java @@ -0,0 +1,60 @@ +package com.mdd.front.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mdd.common.core.AjaxResult; +import com.mdd.common.entity.StudentBaseInfo; +import com.mdd.common.entity.StudentInfo; +import com.mdd.common.mapper.StudentBaseInfoMapper; +import com.mdd.common.mapper.StudentInfoMapper; +import com.mdd.front.service.IStudentInfoService; +import com.mdd.front.validate.student.PreRegistrationStudentInfoValidate; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class StudentServiceImpl extends ServiceImpl implements IStudentInfoService { + + @Resource + private StudentBaseInfoMapper studentBaseInfoMapper; + @Resource + private StudentInfoMapper studentInfoMapper; + + @Override + public AjaxResult add(PreRegistrationStudentInfoValidate studentInfoValidate) { + StudentInfo studentInfo = new StudentInfo(); + BeanUtils.copyProperties(studentInfoValidate, studentInfo); + + StudentBaseInfo studentBaseInfo = new StudentBaseInfo(); + BeanUtils.copyProperties(studentInfoValidate, studentBaseInfo); + + // 根据身份证号查询该学生是否已经提交过信息 + String idCard = studentInfoValidate.getIdCard(); + StudentBaseInfo baseInfo = studentBaseInfoMapper.selectOne(new QueryWrapper().eq("id_card", idCard)); + // 编辑 + if (null != baseInfo) { + Long studentId = baseInfo.getStudentId(); + Long studentBaseId = baseInfo.getStudentBaseId(); + + studentInfo.setStudentId(studentId); + studentBaseInfo.setStudentBaseId(studentBaseId); + + studentInfoMapper.updateById(studentInfo); + studentBaseInfoMapper.updateById(studentBaseInfo); + } + // 新增 + else { + // 学生学业信息入库 + BeanUtils.copyProperties(studentInfoValidate, studentInfo); + studentInfoMapper.insert(studentInfo); + + // 学生基本信息入库 + BeanUtils.copyProperties(studentInfoValidate, studentBaseInfo); + studentBaseInfo.setStudentId(studentInfo.getStudentId()); + studentBaseInfoMapper.insert(studentBaseInfo); + } + return AjaxResult.success(); + } +} diff --git a/server/like-front/src/main/java/com/mdd/front/validate/student/PreRegistrationStudentInfoValidate.java b/server/like-front/src/main/java/com/mdd/front/validate/student/PreRegistrationStudentInfoValidate.java new file mode 100644 index 00000000..e4622873 --- /dev/null +++ b/server/like-front/src/main/java/com/mdd/front/validate/student/PreRegistrationStudentInfoValidate.java @@ -0,0 +1,52 @@ +package com.mdd.front.validate.student; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@ApiModel("预报名学生信息参数") +public class PreRegistrationStudentInfoValidate implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "姓名") + private String name; + + @ApiModelProperty(value = "性别") + private Integer gender; + + @ApiModelProperty(value = "身份证号") + private String idCard; + + @ApiModelProperty(value = "毕业院校") + private String previousSchool; + + @ApiModelProperty(value = "中考成绩") + private BigDecimal highSchoolScore; + + @ApiModelProperty(value = "身高") + private BigDecimal height; + + @ApiModelProperty(value = "体重") + private BigDecimal weight; + + @ApiModelProperty(value = "鞋码") + private BigDecimal shoeSize; + + @ApiModelProperty(value = "专业id") + private Integer majorId; + + @ApiModelProperty(value = "招生老师") + private Integer recruitmentTeacherId; + + @ApiModelProperty(value = "接待老师") + private Integer receptionTeacherId; + + @ApiModelProperty(value = "预报名金额") + private BigDecimal preRegistrationAmount; +}