package com.moral.controller; import com.moral.common.bean.ResultBean; import com.moral.entity.Profession; import com.moral.service.ProfessionService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; import java.util.Optional; @RestController @RequestMapping("profession") public class ProfessionController { @Resource ProfessionService professionService; @GetMapping(value = "getall") public ResultBean> getALL(Optional name){ String queryName = name.isPresent()?name.get():null; return new ResultBean<>(professionService.queryByName(queryName)); } }