You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB
Java

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