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 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; } }