update
parent
dbec1c0470
commit
1592ec4188
@ -0,0 +1,45 @@
|
|||||||
|
package com.jingcheng.cms.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jingcheng.cms.model.Professional;
|
||||||
|
import com.jingcheng.cms.service.ProfessionalService;
|
||||||
|
import com.jingcheng.cms.util.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/professional")
|
||||||
|
public class ProfessionalController {
|
||||||
|
@Autowired
|
||||||
|
private ProfessionalService professionalService;
|
||||||
|
|
||||||
|
@RequestMapping("/all-professional")
|
||||||
|
public AjaxResult getAllProfessional() {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
List<Professional> professionalList = professionalService.getAllProfessional();
|
||||||
|
if (null == professionalList || 0 == professionalList.size()){
|
||||||
|
ajaxResult.setRetmsg("专业列表为空");
|
||||||
|
}else {
|
||||||
|
ajaxResult.setData(professionalList);
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getProfessionalById")
|
||||||
|
public AjaxResult getProfessionalById(@RequestBody JSONObject jsonObject) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
Long professionalId = jsonObject.getLong("professionalId");
|
||||||
|
Professional professionalList = professionalService.getProfessionalById(professionalId);
|
||||||
|
if (null == professionalList){
|
||||||
|
ajaxResult.setRetmsg("专业为空");
|
||||||
|
}else {
|
||||||
|
ajaxResult.setData(professionalList);
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.jingcheng.cms.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jingcheng.cms.model.Professional;
|
||||||
|
import com.jingcheng.cms.service.ProfessionalService;
|
||||||
|
import com.jingcheng.cms.service.QuestionService;
|
||||||
|
import com.jingcheng.cms.util.AjaxResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/question")
|
||||||
|
public class QuestionController {
|
||||||
|
@Autowired
|
||||||
|
private QuestionService questionService;
|
||||||
|
|
||||||
|
@RequestMapping("/getQuestionsByProfessionalId")
|
||||||
|
public AjaxResult getQuestionsByProfessionalId(@RequestBody JSONObject jsonObject) {
|
||||||
|
String professionalId = jsonObject.getString("professionalId");
|
||||||
|
return questionService.getQuestionsByProfessionalId(professionalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.jingcheng.cms.mapper;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.model.Answer;
|
||||||
|
import com.jingcheng.cms.util.CommonMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface AnswerMapper extends CommonMapper<Answer> {
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.jingcheng.cms.mapper;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.model.Option;
|
||||||
|
import com.jingcheng.cms.util.CommonMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface OptionMapper extends CommonMapper<Option> {
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.jingcheng.cms.mapper;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.model.Professional;
|
||||||
|
import com.jingcheng.cms.util.CommonMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ProfessionalMapper extends CommonMapper<Professional> {
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.jingcheng.cms.mapper;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.model.Question;
|
||||||
|
import com.jingcheng.cms.util.CommonMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface QuestionMapper extends CommonMapper<Question> {
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.jingcheng.cms.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("answer")
|
||||||
|
public class Answer extends BaseEntity{
|
||||||
|
|
||||||
|
private Integer questionId;
|
||||||
|
private Integer answerIndex;
|
||||||
|
private String questionAnswer;
|
||||||
|
private String parse;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.jingcheng.cms.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("option")
|
||||||
|
public class Option extends BaseEntity{
|
||||||
|
|
||||||
|
private Integer questionId;
|
||||||
|
private Integer optionIndex;
|
||||||
|
private String questionOption;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.jingcheng.cms.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("professional")
|
||||||
|
public class Professional extends BaseEntity{
|
||||||
|
|
||||||
|
private String professionalName;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.jingcheng.cms.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("question")
|
||||||
|
public class Question extends BaseEntity{
|
||||||
|
|
||||||
|
private Integer professionalId;
|
||||||
|
private Integer questionType;
|
||||||
|
private String questionContent;
|
||||||
|
private String questionImage;
|
||||||
|
private Integer score;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package com.jingcheng.cms.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jingcheng.cms.model.Category;
|
||||||
|
import com.jingcheng.cms.model.CategoryType;
|
||||||
|
import com.jingcheng.cms.model.Professional;
|
||||||
|
import com.jingcheng.cms.util.AjaxResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProfessionalService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有专业
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Professional> getAllProfessional();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id获取专业
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Professional getProfessionalById(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.jingcheng.cms.service;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.model.Professional;
|
||||||
|
import com.jingcheng.cms.util.AjaxResult;
|
||||||
|
import com.jingcheng.cms.vo.QuestionVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface QuestionService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过专业id获取试题
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getQuestionsByProfessionalId(String professionalId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.jingcheng.cms.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jingcheng.cms.constants.Constants;
|
||||||
|
import com.jingcheng.cms.mapper.CategoryMapper;
|
||||||
|
import com.jingcheng.cms.mapper.CategoryTypeMapper;
|
||||||
|
import com.jingcheng.cms.mapper.ProfessionalMapper;
|
||||||
|
import com.jingcheng.cms.model.Category;
|
||||||
|
import com.jingcheng.cms.model.CategoryType;
|
||||||
|
import com.jingcheng.cms.model.Professional;
|
||||||
|
import com.jingcheng.cms.service.CategoryService;
|
||||||
|
import com.jingcheng.cms.service.ProfessionalService;
|
||||||
|
import com.jingcheng.cms.util.AjaxResult;
|
||||||
|
import com.jingcheng.cms.util.PageUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import tk.mybatis.mapper.entity.Example;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class ProfessionalImpl implements ProfessionalService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProfessionalMapper professionalMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Professional> getAllProfessional() {
|
||||||
|
List<Professional> professionals = professionalMapper.selectAll();
|
||||||
|
return professionals;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Professional getProfessionalById(Long id) {
|
||||||
|
Professional professional = new Professional();
|
||||||
|
professional.setId(id);
|
||||||
|
return professionalMapper.selectByPrimaryKey(professional);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.jingcheng.cms.vo;
|
||||||
|
|
||||||
|
import com.jingcheng.cms.model.Answer;
|
||||||
|
import com.jingcheng.cms.model.Option;
|
||||||
|
import com.jingcheng.cms.model.Question;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QuestionVO extends Question {
|
||||||
|
|
||||||
|
private List<Option> questionOptions;
|
||||||
|
private List<Answer> questionAnswers;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue