基于javaweb+mysql的springboot宠物医院预约挂号系统(java+spring+springboot+mybatis+thymeleaf+html+layui+maven+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot宠物医院预约挂号系统(java+spring+springboot+mybatis+thymeleaf+html+layui+maven+mysql)
一、项目简述功能包括: 用户分为宠物,医生,管理员,宠物主人可进行注册选择医生挂号,选择日期,选择号源,医生可进行宠物接诊,管理员可对宠物,医生信息的维护等等功能。
二、项目运行 环境配置:
Jdk1.8 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
System.out.println(substring);
}*/
/**
* 医生图片上传
* @param mufile
* @param id
* @return
* @throws IOException
*/
@RequestMapping(value ="/zixunAdd")
@ResponseBody
public Map<String, Object> zixunAdd(@RequestParam("mf")MultipartFile mufile,@RequestParam("id")Integer id) throws IOException{
Map<String, Object> map = new HashMap<String, Object>();
String random = StringRandom.getRandom();
String filename = mufile.getOriginalFilename();
//随机字符+原图片名用作新的图片名
filename = random+".jpg";
try {
//文件保存路径 D:/xxxx/xxxx/
File file = new File(filePath+filename);
//判断父级文件是否存在
if (!file.getParentFile().exists()) {
file.getParentFile().mkdir();
}
mufile.transferTo(file);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
Doctor doctor = new Doctor();
if(id != -1){
doctor.setId(id);
doctor.setImg("/files/"+filename);
doctorService.updateByPrimaryKeySelective(doctor);
}else {
//添加图片路径
doctor.setImg("/files/"+filename);
doctorService.insertSelective(doctor);
System.out.println("id:"+doctor.getId());
map.put("id",doctor.getId());
}
return map;
}
/**
* 判断管理员账号
*/
@RequestMapping("/sectionxList")
@ResponseBody
public List<Section> sectionxList(Model model, Integer id) {
List<Section> selectByExample = null;
if(id != null) {
Section section = new Section();
if(pa.getPid() != null) {
criteria.andPidEqualTo(pa.getPid());
}
}
List<Patient> selectByExample = patientService.selectByExample(se);
if(selectByExample.size() >0 ) {
List<Messages> lmlist = messagesService.selectByExample(null);
int j = 0 ;
for (Messages me : lmlist) {
if(me.getUid() == id) {
return j;
}
j++;
}
}
return -1;
}
/**
*查询科室
*/
@RequestMapping(value = "/sectioNameList")
@ResponseBody
public List<Section> sectioNameList(String name) {
Section se = new Section();
se.setName(name);
se.setType(2);
List<Section> sectionlist = sectionService.selectByExample(se);
if(sectionlist.size() > 0) {
//查询全部科室
se.setName(null);
se.setPid(sectionlist.get(0).getPid());
se.setType(2);
sectionlist = sectionService.selectByExample(se);
}
return sectionlist;
}
/**
* 坐诊时间yuyue
*/
@RequestMapping("/doctorTimePage")
public String doctorTimePage(Integer id,Model model) {
if(id != null) {
Doctor doctor = doctorService.selectByPrimaryKey(id);
model.addAttribute("doctor",doctor);
}
public Map<String,String> panzhanghao(Model model, String zhanghao) {
Map<String, String> map = new HashMap<String, String>();
DoctorExample se = new DoctorExample();
DoctorExample.Criteria criteria = se.createCriteria();
criteria.andUsernameEqualTo(zhanghao);
List<Doctor> selectByExample = doctorService.selectByExample(se);
if(selectByExample.size() > 0){
map.put("pan","err");
}else{
map.put("pan","ok");
}
return map;
}
/**
* 医生添加
* @param model
* @param zixun
* @return
*/
@RequestMapping("/zixunInsert")
public String zixunInsert(Model model,Doctor doctor){
if(doctor.getId() != null){
if(doctor.getSid() != null) {
Section selectByPrimaryKey = sectionService.selectByPrimaryKey(doctor.getSid());
doctor.setSname(selectByPrimaryKey.getName());
}
doctorService.updateByPrimaryKeySelective(doctor);
}
model.addAttribute("type",1);
return "login";
}
/**
* 管理员注册界面
*/
@RequestMapping("/mimaPageUptate")
public String mimaPageUptate(Integer type,Model model) {
//1医生 2 管理员
if(type == 1 ) {
return "doctorRegister";
}
return "adminRegister";
}
/**
* 医生注册界面
*/
@RequestMapping("/doctorRegisterPage")
}
model.addAttribute("sectionList",list2);
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("section",section);
return "admin/sectionList";
}
/**
* 科室详情下级列表
*/
@RequestMapping("/sectionBelowList")
public String sectionBelowList(Model model, Section section, Integer id) {
if(section == null) {
section = new Section();
}
section.setType(2);// 2 科室详情
section.setPid(id);
Section se = sectionService.selectByPrimaryKey(id);
List<Section> list = sectionService.selectByExample(section);
model.addAttribute("sectionList",list);
model.addAttribute("section",section);
model.addAttribute("se",se);
return "admin/sectionBelow";
}
/**
* 跳转添加科室界面
*/
@RequestMapping("/sectionAddPage")
public String zuopinList() {
return "admin/sectionAdd";
}
/**
* 跳转添加科室下级界面
*/
@RequestMapping("/sectionAddBelowPage")
public String zuopinList(Model model,Integer id) {
if(id != null) {
Section se = sectionService.selectByPrimaryKey(id);
model.addAttribute("se",se);
}
return "admin/sectionAddBelow";
}
}
if(banners.getImg() != null && !"".equals(banners.getImg())){
imgnames = banners.getImg().split(",");
}
model.addAttribute("imgnames",imgnames);
model.addAttribute("banners",banners);
return "admin/bannersUpdate";
}
/**
*轮播图片删除
*/
@RequestMapping(value ="/bannersDel")
@ResponseBody
public Map<String, Object> bannersDel(Integer id,String src) throws IOException{
Map<String, Object> map = new HashMap<String, Object>();
StringBuffer sb = new StringBuffer();
if(id != null && src != null){
Banners banner = bannersService.selectByPrimaryKey(id);
if(banner.getImg() != null){
String[] split = banner.getImg().split(",");
for(int i = 0; i<split.length;i++){
if(src.equals(split[i])){
//String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真实路径
String path = src.substring(src.indexOf("s") + 2); //获取文件名
File file = new File(filePath +path);
if(file.exists()){
//file.delete();
map.put("massage","删除成功");
}else{
map.put("massage","删除失败");
}
}else{
sb.append(split[i]+",");
}
}
}
}
Banners banners = new Banners();
banners.setId(id);
banners.setImg(sb.toString());
bannersService.updateByPrimaryKeySelective(banners);
return map;
}
/**
*banner图片上传
*/
return "doctor/messageList";
}
@RequestMapping("/index")
public String index(Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt == null) {
return "redirect:/login/index";
}
int doctor = doctorService.countByExample(null); //医生总数
int section = sectionService.count(); //科室总数
//患者总数
int patient = 0;
List<Patient> selectByExample = patientService.selectByExample(null);
Messages mess = new Messages();
for (Patient pa : selectByExample) {
if(pa.getName() != null) {
mess.setDid(dt.getId());
mess.setUsername(pa.getName());
List<Messages> selectMessages = messagesService.selectMessages(mess);
if(selectMessages.size() > 0 )
{
patient++;
}
}
}
//预约总数
MessagesExample me = new MessagesExample();
MessagesExample.Criteria mecriteria = me.createCriteria();
mecriteria.andDidEqualTo(dt.getId());
int messages = messagesService.countByExample(me);
model.addAttribute("doctor",doctor);
model.addAttribute("section",section);
model.addAttribute("patient",patient);
model.addAttribute("messages",messages);
PageInfo<Doctor> pageInfo = doctorService.selectDoctorList(null,1,4);
if(pageInfo.getList() != null && pageInfo.getList().size() >0 ) {
List<Doctor> list = pageInfo.getList();
StringBuffer sb = new StringBuffer();
StringBuffer shu = new StringBuffer();
int v = list.size()-1;
for(int i=0;i<list.size();i++) {
if(v==i) {
sb.append(list.get(i).getName());
shu.append(list.get(i).getYipeoples());
}else {
/**
* 退号
*/
@RequestMapping("/messagesTui")
public String messagesTui(Integer id) {
if(id != null) {
Messages messages = new Messages();
messages.setId(id);
messages.setType(4); //4退号失败
messagesService.updateByPrimaryKeySelective(messages);
}
return "redirect:/doctor/messageList?type=3";
}
}
/**
* 自定义拦截器
*/
public class Interceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
HttpSession session = request.getSession();
Doctor doctor = (Doctor) session.getAttribute("DOCTOR");
Admin admin = (Admin) session.getAttribute("ADMIN");
Patient patient = (Patient) session.getAttribute("PATIENT");
if (doctor != null || admin != null|| patient != null ) {
/**
* 后端管理员控制层
*/
@Controller
@RequestMapping("/admin")
public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
private SectionService sectionService;
@Autowired
private BannersService bannersService;
@Autowired
private DoctorService doctorService;
@Autowired
private PatientService patientService;
@Autowired
private MessagesService messagesService;
private Integer size = 6;//每页显示数量
@Value("${fileUrl}") //在配置文件中获取文件的保存路径
private String filePath;
public String messageTime(String name,Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(name != null) {
Messages mess = new Messages();
mess.setDid(dt.getId());
mess.setUsername(name);
List<Messages> selectMessages = messagesService.selectMessagesTWO(mess);
model.addAttribute("messagesList", selectMessages);
}
return "doctor/messageTime";
}
/**
* 修改医生信息
*/
@RequestMapping("/admindoctorUptate")
public String adminUptatePassword(Doctor doctor,Model model) {
if(doctor != null && doctor.getId() != null) {
if(doctor.getSid() != null) {
Section section = sectionService.selectByPrimaryKey(doctor.getSid());
doctor.setSid(section.getId());
doctor.setSname(section.getName());
}
doctorService.updateByPrimaryKeySelective(doctor);
}
return "redirect:/doctor/index";
}
/**
* 预约信息列表
*/
@RequestMapping("/messageList")
public String doctorList(Model model, Messages messages, @RequestParam(value="page",defaultValue="1")Integer page,Integer type,HttpServletRequest request) {
if(messages == null) {
messages = new Messages();
}
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt != null){
messages.setDid(dt.getId());
}else{
return "redirect:/login/index";
}
messages.setType(type);
/**
* 登录控制层
*/
@Controller
@RequestMapping("/login")
public class LoginController {
@Autowired
private AdminService adminService;
@Autowired
private DoctorService doctorService;
@Autowired
private SectionService sectionService;
if(type == 3){
model.addAttribute("type",type);
session.invalidate(); //session销毁
return "loginByPatient";
}
model.addAttribute("type",type);
session.invalidate(); //session销毁
return "login";
}
/*
*//**
* 跳转忘记密码界面
*//*
@RequestMapping("/mimaPageUptate")
public String passwordUpate() {
return "behind/merchant/mibaoUptate";
}
*//**
* 修改密码
*//*
@RequestMapping("/mimaUpate")
@ResponseBody
public Map<String,String> passwordUpate(Model model, String mima, String mibao, String zhanghao) {
Map<String, String> map = new HashMap<String, String>();
Merchant me = new Merchant();
me.setZhanghao(zhanghao);
me.setMibao(mibao);
List<Merchant> list = merchantService.selectMerchant(me);
if(list.size() > 0){
Merchant me2 = new Merchant();
me2.setId(list.get(0).getId());
me2.setMima(mima);
merchantService.updateByPrimaryKeySelective(me2);
map.put("pan","ok");
}else{
map.put("pan","err");
}
return map;
}
/**
*患者信息列表
*/
@RequestMapping("/patientList")
public String messageList(Model model, Patient patient, @RequestParam(value="page",defaultValue="1")Integer page,HttpServletRequest request) {
if(patient == null) {
patient = new Patient();
}
HttpSession session = request.getSession();
Doctor dt = (Doctor) session.getAttribute("DOCTOR");
if(dt == null){
return "redirect:/login/index";
}
/*
* PageInfo<Patient> pageInfo =
* patientService.selectPatientList(patient,1,size); List<Patient> list =
* pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
* messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
* null && pa.getPid() != 0){ messages.setDid(dt.getId());
* messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
* List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
* 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
* pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
*
* } } if(list2.size() <= 8) { pageInfo.setPages(1); }
*/
Messages messages = new Messages();
// messages.setTime(new Date());
messages.setType(1);
messages.setDid(dt.getId());
PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
model.addAttribute("doctorList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("patient",patient);
return "doctor/patientList";
}
/**
*预约信息列表
* @throws ParseException
*/
@RequestMapping(value = "/tiaozhuanList")
@ResponseBody
public String messagesList(@RequestParam("xiao")Integer xiao,@RequestParam("da")Integer da) {
Messages message = new Messages();
if(xiao != null & da != null) {
Messages mexiao = messagesService.selectByPrimaryKey(xiao);
Integer px = mexiao.getPai();
Messages meda = messagesService.selectByPrimaryKey(da);
mexiao.setPai(meda.getPai());
meda.setPai(px);
public String adminUptatePassword(Model model,Admin admin,HttpServletRequest request) {
HttpSession session = request.getSession();
Admin ad = (Admin) session.getAttribute("ADMIN");
if(ad != null && admin.getPassword() != null){
admin.setId(ad.getId());
adminService.updateByPrimaryKeySelective(admin);
}
return "redirect:/admin/index";
}
*/
}
/**
*医生列表查询
*/
@RequestMapping(value = "/doctorLike")
@ResponseBody
public List<Doctor> doctorLike(String name) {
Doctor doctor = new Doctor();
doctor.setName(name);
List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
return selectDoctor;
}
/**
*科室查询
*/
@RequestMapping(value = "/doctorIdList")
@ResponseBody
public Section doctorIdList(Integer sid) {
Section selectByPrimaryKey = sectionService.selectByPrimaryKey(sid);
return selectByPrimaryKey;
}
/**
*医生列表查询
* @throws ParseException
*/
@RequestMapping(value = "/doctortimeSelect")
@ResponseBody
public List<Doctor> doctortimeSelect(@RequestParam("datetimei")String datetimei,@RequestParam("id")Integer id) throws ParseException {
Doctor doctor = new Doctor();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
doctor.setSid(id);
doctor.setBegindate(simpleDateFormat.parse(datetimei));
List<Doctor> selectDoctor = doctorService.selectTime(doctor);
return selectDoctor;
}
/**
*医生列表查询
* @throws ParseException
*/
/**
* 登录控制层
*/
@Controller
@RequestMapping("/login")
public class LoginController {
@Autowired
private AdminService adminService;
@Autowired
private DoctorService doctorService;
@Autowired
private SectionService sectionService;
@Autowired
private PatientService patientService;
@Value("${fileUrl}") //在配置文件中获取文件的保存路径
private String filePath;
/**
* 后台登陆界面
}
model.addAttribute("sou",sou);
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("person",person);
return "behind/admin/feiyi_personList";
}
*//**
* 人物删除
* @param model
* @return
*//*
@RequestMapping("/personDelete")
public String personDelete(Model model,Integer id) {
if(id != null){
Person person = personService.selectByPrimaryKey(id);
//删除人物的图片
//String fp= filePath.substring(filePath.indexOf("/")+1);//文件的真实路径
String name = person.getImg().substring(person.getImg().indexOf("s") + 2); //获取文件名
File file = new File(filePath +name);
if(file.exists()){
file.delete();
}
personService.deleteByPrimaryKey(id);
}
return "redirect:/admin/personList";
}
*//**
* 管理员
*//*
@RequestMapping("/feiyisList")
public String zuopinList(Model model,Feiyis feiyis,@RequestParam(value="page",defaultValue="1")Integer page,String sou) {
feiyis.setState(0);//0为正常 1是管理员下架的
PageInfo<Feiyis> pageInfo = feiyisService.selectFeiyis(feiyis,page,size);
model.addAttribute("feiyiList",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
model.addAttribute("feiyis",feiyis);
return "behind/admin/feiyisList";
}
*//**
* 非遗视界删除
* @param model
* @return
*//*
@RequestMapping("/feiyisDelete")
public String feiyisDelete(Model model,Integer id,Integer type) {
if (id != null) {
File file = new File(filePath +name);
if(file.exists()){
file.delete();
}
videoService.deleteByPrimaryKey(id);
}
return "redirect:/admin/feiyi_videoList";
}
*//**
* 管理员-人物列表
*//*
@RequestMapping("/personList")
public String personList(Model model,Person person,@RequestParam(value="page",defaultValue="1")Integer page,String sou) {
PageInfo<Person> pageInfo = personService.selectPageList(person,page,size);
List<Person> list = pageInfo.getList();
List<Person> list2 = new ArrayList<Person>();
//默认显示第一张图片
for(int i =0; i<list.size();i++){
Person sh = list.get(i);
String[] img = sh.getImg().split(",");
if(img.length > 0){
sh.setImg(img[0]);
list.set(i,sh);
}
}
if(sou != null && !"".equals(sou)){
char sz = sou.charAt(0);
//判断是否是大写
if(Character.isUpperCase(sz)){
sz = StringRandom.toLower(sz); //大写转小写
}
for(int i =0; i<list.size();i++){
Person sh = list.get(i);
if(sh.getName() != null){
char names = StringRandom.getPinYinHeadChar(sh.getName()); //名字的首字母
if(names == sz){
list2.add(sh);
}
}
}
model.addAttribute("personList",list2);
}else{
model.addAttribute("personList",list);