当前位置:   article > 正文

Java项目:宠物医院与商城一体的系统(java+Springboot+Jsp+maven+Mysql)_spingboot+jsp+ma

spingboot+jsp+ma

源码获取:博客首页 "资源" 里下载!

项目运行


环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

Springboot+ SpringMVC + MyBatis + Jsp + Html+ JavaScript + JQuery + Ajax + maven等等
 

宠物医院与商城一体的系统

 

 

 

 

 

 

后端管理员控制层:

  1. /**
  2. * 后端管理员控制层
  3. */
  4. @Controller
  5. @RequestMapping("/api")
  6. public class PatientController {
  7. private Integer size = 6;//每页显示数量
  8. @Autowired
  9. private AdminService adminService;
  10. @Autowired
  11. private SectionService sectionService;
  12. @Autowired
  13. private BannersService bannersService;
  14. @Autowired
  15. private DoctorService doctorService;
  16. @Autowired
  17. private PatientService patientService;
  18. @Autowired
  19. private MessagesService messagesService;
  20. /**
  21. * 医生列表
  22. */
  23. @RequestMapping("/doctorList1")
  24. public String doctorList(Model model, Doctor doctor, @RequestParam(value="page",defaultValue="1")Integer page) {
  25. if(doctor == null) {
  26. doctor = new Doctor();
  27. }
  28. PageInfo<Doctor> pageInfo = doctorService.selectDoctorList(doctor,page,size);
  29. List<Doctor> list = pageInfo.getList();
  30. model.addAttribute("doctorList",pageInfo.getList());
  31. model.addAttribute("pageInfo",pageInfo);
  32. model.addAttribute("doctor",doctor);
  33. return "patient/doctorList";
  34. }
  35. /**
  36. *登录
  37. * @throws ParseException
  38. */
  39. @RequestMapping(value = "/userLogin")
  40. @ResponseBody
  41. public Patient userLogin(@RequestBody Patient patient) throws ParseException {
  42. List<Patient> list = patientService.selectPatient(patient);
  43. if(patient != null && patient.getUsername() != null && patient.getPassword() != null) {
  44. if(list.size() > 0) {
  45. return list.get(0);
  46. }
  47. }
  48. return patient;
  49. }
  50. /**
  51. *登录
  52. * @throws ParseException
  53. */
  54. @RequestMapping(value = "/passwordSave")
  55. @ResponseBody
  56. public String passwordSave(@RequestBody Patient patient ) throws ParseException {
  57. if(patient != null && patient.getUsername() != null && patient.getPassword() != null) {
  58. Patient pa = new Patient();
  59. pa.setUsername(patient.getUsername());
  60. List<Patient> list = patientService.selectPatient(pa);
  61. if(list.size() > 0) {
  62. return "err";
  63. }
  64. patientService.insertSelective(patient);
  65. return "ok";
  66. }
  67. return "err";
  68. }
  69. /**
  70. *登录验证
  71. * @throws ParseException
  72. */
  73. @RequestMapping(value = "/userLoginView")
  74. @ResponseBody
  75. public String userLoginView(HttpServletRequest request) throws ParseException {
  76. HttpSession session = request.getSession();
  77. Patient patient =(Patient) session.getAttribute("USER");
  78. System.out.println("*********登陆验证********");
  79. System.out.println(patient);
  80. if(patient != null) {
  81. return "ok";
  82. }
  83. return "err";
  84. }
  85. /**
  86. *banner图
  87. */
  88. @RequestMapping(value = "/bannerList")
  89. @ResponseBody
  90. public String[] formAdd() {
  91. Banners banners = bannersService.selectByPrimaryKey(1);
  92. String[] split = null;
  93. if(banners != null && banners.getImg() != null) {
  94. split = banners.getImg().split(",");
  95. }
  96. return split;
  97. }
  98. /**
  99. *科室查询
  100. */
  101. @RequestMapping(value = "/sectionList")
  102. @ResponseBody
  103. public Map<String,List<Section>> sectionList() {
  104. Map<String,List<Section>> map = new HashMap<String,List<Section>>();
  105. List<Section> sectionlist2 = null;
  106. Section se = new Section();
  107. se.setType(1);
  108. List<Section> sectionlist = sectionService.selectByExample(se);
  109. if(sectionlist.size() > 0 ) {
  110. //科室详情
  111. Section section = new Section();
  112. section.setPid(sectionlist.get(0).getId());
  113. section.setType(2);
  114. sectionlist2 = sectionService.selectByExample(section);
  115. }
  116. map.put("sectionlist",sectionlist);
  117. map.put("sectionlist2",sectionlist2);
  118. return map;
  119. }
  120. /**
  121. *科室下级查询
  122. */
  123. @RequestMapping(value = "/sectionXiaList")
  124. @ResponseBody
  125. public List<Section> sectionXiaList(Integer id) {
  126. Section se = new Section();
  127. se.setPid(id);
  128. se.setType(2);
  129. List<Section> sectionlist = sectionService.selectByExample(se);
  130. return sectionlist;
  131. }
  132. /**
  133. *科室下级查询
  134. */
  135. @RequestMapping(value = "/patientPai")
  136. @ResponseBody
  137. public Integer patientPai(Integer id) {
  138. Patient pa = new Patient();
  139. pa.setPid(id);
  140. PatientExample se = new PatientExample();
  141. PatientExample.Criteria criteria = se.createCriteria();
  142. if(pa != null){
  143. if(pa.getPid() != null) {
  144. criteria.andPidEqualTo(pa.getPid());
  145. }
  146. }
  147. List<Patient> selectByExample = patientService.selectByExample(se);
  148. if(selectByExample.size() >0 ) {
  149. List<Messages> lmlist = messagesService.selectByExample(null);
  150. int j = 0 ;
  151. for (Messages me : lmlist) {
  152. if(me.getUid() == id) {
  153. return j;
  154. }
  155. j++;
  156. }
  157. }
  158. return -1;
  159. }
  160. /**
  161. *查询科室
  162. */
  163. @RequestMapping(value = "/sectioNameList")
  164. @ResponseBody
  165. public List<Section> sectioNameList(String name) {
  166. Section se = new Section();
  167. se.setName(name);
  168. se.setType(2);
  169. List<Section> sectionlist = sectionService.selectByExample(se);
  170. if(sectionlist.size() > 0) {
  171. //查询全部科室
  172. se.setName(null);
  173. se.setPid(sectionlist.get(0).getPid());
  174. se.setType(2);
  175. sectionlist = sectionService.selectByExample(se);
  176. }
  177. return sectionlist;
  178. }
  179. /**
  180. * 坐诊时间yuyue
  181. */
  182. @RequestMapping("/doctorTimePage")
  183. public String doctorTimePage(Integer id,Model model) {
  184. if(id != null) {
  185. Doctor doctor = doctorService.selectByPrimaryKey(id);
  186. model.addAttribute("doctor",doctor);
  187. }
  188. return "patient/doctorTime";
  189. }
  190. /**
  191. *医生列表查询
  192. */
  193. @RequestMapping(value = "/doctorList")
  194. @ResponseBody
  195. public List<Doctor> doctorList(Integer sid) {
  196. Doctor doctor = new Doctor();
  197. doctor.setSid(sid);
  198. List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
  199. return selectDoctor;
  200. }
  201. /**
  202. *医生列表查询
  203. */
  204. @RequestMapping(value = "/doctorLike")
  205. @ResponseBody
  206. public List<Doctor> doctorLike(String name) {
  207. Doctor doctor = new Doctor();
  208. doctor.setName(name);
  209. List<Doctor> selectDoctor = doctorService.selectDoctor(doctor);
  210. return selectDoctor;
  211. }
  212. /**
  213. *科室查询
  214. */
  215. @RequestMapping(value = "/doctorIdList")
  216. @ResponseBody
  217. public Section doctorIdList(Integer sid) {
  218. Section selectByPrimaryKey = sectionService.selectByPrimaryKey(sid);
  219. return selectByPrimaryKey;
  220. }
  221. /**
  222. *医生列表查询
  223. * @throws ParseException
  224. */
  225. @RequestMapping(value = "/doctortimeSelect")
  226. @ResponseBody
  227. public List<Doctor> doctortimeSelect(@RequestParam("datetimei")String datetimei,@RequestParam("id")Integer id) throws ParseException {
  228. Doctor doctor = new Doctor();
  229. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  230. doctor.setSid(id);
  231. doctor.setBegindate(simpleDateFormat.parse(datetimei));
  232. List<Doctor> selectDoctor = doctorService.selectTime(doctor);
  233. return selectDoctor;
  234. }
  235. /**
  236. *医生列表查询
  237. * @throws ParseException
  238. */
  239. @RequestMapping(value = "/doctorGeRenList")
  240. @ResponseBody
  241. public Doctor doctorGeRenList(Integer id) throws ParseException {
  242. Doctor doctor = doctorService.selectByPrimaryKey(id);
  243. return doctor;
  244. }
  245. /**
  246. *时间格式转换
  247. */
  248. @RequestMapping(value = "/doctorYuyueTime")
  249. @ResponseBody
  250. public Map<String,String> doctorYuyueTime(Integer id) {
  251. Map<String,String> map = new HashMap<String,String>();
  252. SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  253. Doctor doctor = doctorService.selectByPrimaryKey(id);
  254. map.put("begin",sdf.format(doctor.getBegintime()));
  255. map.put("end",sdf.format(doctor.getEndtime()));
  256. return map;
  257. }
  258. /**
  259. *时间格式转换
  260. * @throws ParseException
  261. */
  262. @RequestMapping(value = "/timeZhuan")
  263. @ResponseBody
  264. public String timeZhuan(String time) throws ParseException {
  265. Date parse = new Date();
  266. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  267. if(time != null) {
  268. parse = sdf.parse(time);
  269. }
  270. return sdf.format(parse);
  271. }
  272. /**
  273. *添加患者信息
  274. */
  275. @RequestMapping(value = "/loginByPatient")
  276. public String loginByPatient(@RequestBody Patient patient) {
  277. return "loginByPatient";
  278. }
  279. /**
  280. *添加患者信息
  281. */
  282. @RequestMapping(value = "/patientSave")
  283. public String patientSave(Patient patient) {
  284. patientService.insertSelective(patient);
  285. return "loginByPatient";
  286. }
  287. /**
  288. * 判断患者账号
  289. */
  290. @RequestMapping("/panzhanghao")
  291. @ResponseBody
  292. public Map<String,String> panzhanghao(Model model, String zhanghao) {
  293. Map<String, String> map = new HashMap<String, String>();
  294. PatientExample se = new PatientExample();
  295. PatientExample.Criteria criteria = se.createCriteria();
  296. criteria.andUsernameEqualTo(zhanghao);
  297. List<Patient> selectByExample = patientService.selectByExample(se);
  298. if(selectByExample.size() > 0){
  299. map.put("pan","err");
  300. }else{
  301. map.put("pan","ok");
  302. }
  303. return map;
  304. }
  305. /**
  306. * 患者注册界面
  307. */
  308. @RequestMapping("/patientAddPage")
  309. public String patientAddPage(Model model) {
  310. return "patientRegister";
  311. }
  312. /**
  313. *患者信息列表
  314. */
  315. @RequestMapping(value = "/patientList")
  316. @ResponseBody
  317. public List<Patient> patientList(Integer pid,HttpServletRequest request) {
  318. Patient pa = new Patient();
  319. pa.setPid(pid);
  320. List<Patient> selectPatient = patientService.selectPatient(pa);
  321. return selectPatient;
  322. }
  323. /**
  324. *患者信息列表
  325. */
  326. @RequestMapping("/patientList2")
  327. public String messageList2(Model model, Patient patient, @RequestParam(value="page",defaultValue="1")Integer page,HttpServletRequest request) {
  328. if(patient == null) {
  329. patient = new Patient();
  330. }
  331. HttpSession session = request.getSession();
  332. Patient patient1 = (Patient) session.getAttribute("PATIENT");
  333. if(patient1 == null){
  334. return "redirect:/login/font/index";
  335. }
  336. /*
  337. * PageInfo<Patient> pageInfo =
  338. * patientService.selectPatientList(patient,1,size); List<Patient> list =
  339. * pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
  340. * messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
  341. * SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
  342. * null && pa.getPid() != 0){ messages.setDid(dt.getId());
  343. * messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
  344. * List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
  345. * 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
  346. * pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
  347. *
  348. * } } if(list2.size() <= 8) { pageInfo.setPages(1); }
  349. */
  350. Messages messages = new Messages();
  351. // messages.setTime(new Date());
  352. messages.setType(1);
  353. messages.setUid(patient1.getPid());
  354. PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
  355. model.addAttribute("doctorList",pageInfo.getList());
  356. model.addAttribute("pageInfo",pageInfo);
  357. model.addAttribute("patient",patient);
  358. return "patient/patientList";
  359. }
  360. /**
  361. *患者信息列表
  362. */
  363. @RequestMapping(value = "/patienDel")
  364. @ResponseBody
  365. public List<Patient> patienDel(Integer id) {
  366. if(id != null) {
  367. patientService.deleteByPrimaryKey(id);
  368. }
  369. List<Patient> selectByExample = patientService.selectByExample(null);
  370. return selectByExample;
  371. }
  372. /**
  373. *患者信息查看
  374. */
  375. @RequestMapping(value = "/patientUpatePage")
  376. @ResponseBody
  377. public Patient patientUpatePage(Integer id) {
  378. Patient patient = null;
  379. if(id != null) {
  380. patient = patientService.selectByPrimaryKey(id);
  381. }
  382. return patient;
  383. }
  384. /**
  385. *患者信息修改
  386. */
  387. @RequestMapping(value = "/patientUpdate")
  388. @ResponseBody
  389. public Patient patientUpdate(@RequestBody Patient patient) {
  390. patientService.updateByPrimaryKeySelective(patient);
  391. return null;
  392. }
  393. /**
  394. *预约信息
  395. * @throws ParseException
  396. */
  397. @RequestMapping(value = "/messagesSave")
  398. public String messagesSave(Messages patient,HttpServletRequest request) throws ParseException {
  399. HttpSession session = request.getSession();
  400. Patient patient1 = (Patient) session.getAttribute("PATIENT");
  401. Messages hui = null;
  402. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  403. Date shijian = simpleDateFormat.parse(patient.getSname());
  404. patient.setTime(shijian);
  405. patient.setType(1);//待预约
  406. Doctor doctor = doctorService.selectByPrimaryKey(patient.getDid());//医生
  407. if(doctor != null) {
  408. patient.setDname(doctor.getName());
  409. if(doctor.getYipeoples() == null) {
  410. doctor.setYipeoples(0);
  411. }
  412. doctor.setYipeoples(doctor.getYipeoples()+1);
  413. doctorService.updateByPrimaryKeySelective(doctor);
  414. }
  415. Section section = sectionService.selectByPrimaryKey(patient.getSid());//科室
  416. if(section != null) {
  417. patient.setSname(section.getName());
  418. }
  419. Patient pa = patientService.selectByPrimaryKey(patient1.getId()); //患者
  420. if(pa != null) {
  421. patient.setUid(pa.getPid());
  422. patient.setUserid(pa.getId());
  423. patient.setPhone(pa.getPhone());
  424. patient.setUsername(pa.getUsername());
  425. patient.setAge(pa.getAge());
  426. int countByExample = messagesService.countByExample(null);
  427. patient.setBianhao(countByExample+1);
  428. //排序
  429. Messages message = new Messages();
  430. // message.setUid(patient.getUid());
  431. message.setTime(patient.getTime());
  432. message.setDid(patient.getDid());
  433. message.setType(-1);
  434. List<Messages> list = messagesService.selectMessages(message);
  435. if(list.size() <= 0) {
  436. patient.setPai(1);
  437. }else {
  438. patient.setPai(list.size()+1);
  439. }
  440. }
  441. messagesService.insertSelective(patient);
  442. if(patient.getId() != null) {
  443. hui = messagesService.selectByPrimaryKey(patient.getId());
  444. Messages xin = new Messages();
  445. xin.setDid(hui.getDid());
  446. xin.setType(1);
  447. xin.setTime(shijian);
  448. List<Messages> selectMessagesPai = messagesService.selectMessagesPai(xin);
  449. hui.setAge(selectMessagesPai.size());
  450. }
  451. return "redirect:/api/doctorList1";
  452. }
  453. /**
  454. *取消预约
  455. * @throws ParseException
  456. */
  457. @RequestMapping(value = "/messagesQuXiao")
  458. public String messagesQuXiao(Integer id) throws ParseException {
  459. Messages ma = new Messages();
  460. ma.setId(id);
  461. ma.setType(2); //取消预约
  462. messagesService.updateByPrimaryKeySelective(ma);
  463. Messages mes = messagesService.selectByPrimaryKey(id);
  464. Messages messages = new Messages();
  465. messages.setType(1);
  466. messages.setUid(mes.getUid());
  467. messages.setTime(new Date());
  468. List<Messages> list = messagesService.selectMessages(messages);
  469. return "redirect:/api/patientList2";
  470. }
  471. /**
  472. *预约信息列表
  473. * @throws ParseException
  474. */
  475. @RequestMapping(value = "/messagesUidList")
  476. @ResponseBody
  477. public List<Messages> messagesUidList(@RequestBody Messages message) throws ParseException {
  478. List<Messages> list = null;
  479. if(message.getType() != null && message.getType() == 1) {
  480. message.setTime(new Date());
  481. list = messagesService.selectMessagesPai(message);
  482. }else {
  483. list = messagesService.selectMessagesTWO(message);
  484. }
  485. Messages me = new Messages();
  486. me.setType(1);
  487. me.setTime(new Date());
  488. for (int i = 0; i < list.size(); i++) {
  489. me.setDid(list.get(i).getDid());
  490. List<Messages> lin = messagesService.selectMessagesPai(me);
  491. list.get(i).setAge(lin.size());
  492. }
  493. return list;
  494. }
  495. /**
  496. *预约信息列表
  497. * @throws ParseException
  498. */
  499. @RequestMapping(value = "/messagesList")
  500. @ResponseBody
  501. public List<Messages> messagesList(@RequestParam("type")Integer type,@RequestParam("uid")Integer uid) throws ParseException {
  502. Messages message = new Messages();
  503. List<Messages> list = null;
  504. message.setType(type);
  505. message.setUid(uid);
  506. if(type != null && type == 1) {
  507. message.setTime(new Date());
  508. list = messagesService.selectMessagesPai(message);
  509. Messages me = new Messages();
  510. me.setType(1);
  511. me.setTime(new Date());
  512. for (int i = 0; i < list.size(); i++) {
  513. me.setDid(list.get(i).getDid());
  514. List<Messages> lin = messagesService.selectMessagesPai(me);
  515. list.get(i).setAge(lin.size());
  516. }
  517. }else {
  518. list = messagesService.selectMessagesTWO(message);
  519. }
  520. return list;
  521. }
  522. /**
  523. *预约信息列表
  524. * @throws ParseException
  525. */
  526. @RequestMapping(value = "/messagesLists")
  527. @ResponseBody
  528. public List<Messages> messagesLists(Integer uid) throws ParseException {
  529. Messages message = new Messages();
  530. message.setUid(uid);
  531. List<Messages> list = messagesService.selectMessagesTWO(message);
  532. Messages me = new Messages();
  533. me.setType(1);
  534. me.setTime(new Date());
  535. for (int i = 0; i < list.size(); i++) {
  536. if(list.get(i).getType() == 1) {
  537. me.setDid(list.get(i).getDid());
  538. List<Messages> lin = messagesService.selectMessagesPai(me);
  539. list.get(i).setAge(lin.size());
  540. }
  541. }
  542. return list;
  543. }
  544. /**
  545. * @throws ParseException
  546. */
  547. @RequestMapping(value = "/doctortouList")
  548. @ResponseBody
  549. public List<Doctor> doctortouList() {
  550. PageInfo<Doctor> pageInfo = doctorService.selectDoctorList(null,1,4);
  551. return pageInfo.getList();
  552. }
  553. /**
  554. * @throws ParseException
  555. */
  556. @RequestMapping(value = "/datatimeGua")
  557. @ResponseBody
  558. public Integer datatimeGua(@RequestParam("datetime")String datetime,@RequestParam("did")Integer did) throws ParseException {
  559. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  560. Date parse = sdf.parse(datetime);
  561. Messages message = new Messages();
  562. message.setTime(parse);
  563. message.setDid(did);
  564. message.setType(-1);
  565. List<Messages> list = messagesService.selectMessages(message);
  566. return list.size();
  567. }
  568. }

登录控制层:

  1. /**
  2. * 登录控制层
  3. */
  4. @Controller
  5. @RequestMapping("/login")
  6. public class LoginController {
  7. @Autowired
  8. private AdminService adminService;
  9. @Autowired
  10. private DoctorService doctorService;
  11. @Autowired
  12. private SectionService sectionService;
  13. @Autowired
  14. private PatientService patientService;
  15. @Value("${fileUrl}") //在配置文件中获取文件的保存路径
  16. private String filePath;
  17. /**
  18. * 后台登陆界面
  19. * @throws IOException
  20. */
  21. @RequestMapping("/afterView")
  22. public String afterLogin(Integer type,Model model) {
  23. if(type == null) {
  24. type = 1;
  25. }
  26. model.addAttribute("type",type);
  27. return "login";
  28. }
  29. /**
  30. * 后台登陆界面
  31. */
  32. @RequestMapping("/index")
  33. public String index(Integer type,Model model) {
  34. if(type == null){
  35. type = 1;
  36. }
  37. model.addAttribute("type",type);
  38. return "login";
  39. }
  40. /**
  41. * 后台登陆界面
  42. */
  43. @RequestMapping("/font/index")
  44. public String fontIndex(Integer type,Model model) {
  45. if(type == null){
  46. type = 3;
  47. }
  48. model.addAttribute("type",type);
  49. return "loginByPatient";
  50. }
  51. /* public static void main(String[] args) {
  52. String filename ="C:\\Users\\Administrator\\Pictures\\项目图片\\1156.jpg_wh1200.jpg";
  53. int indexOf = filename.indexOf(".");
  54. String substring = filename.substring(indexOf);
  55. System.out.println(substring);
  56. }*/
  57. /**
  58. * 医生图片上传
  59. * @param mufile
  60. * @param id
  61. * @return
  62. * @throws IOException
  63. */
  64. @RequestMapping(value ="/zixunAdd")
  65. @ResponseBody
  66. public Map<String, Object> zixunAdd(@RequestParam("mf")MultipartFile mufile,@RequestParam("id")Integer id) throws IOException{
  67. Map<String, Object> map = new HashMap<String, Object>();
  68. String random = StringRandom.getRandom();
  69. String filename = mufile.getOriginalFilename();
  70. //随机字符+原图片名用作新的图片名
  71. filename = random+".jpg";
  72. try {
  73. //文件保存路径 D:/xxxx/xxxx/
  74. File file = new File(filePath+filename);
  75. //判断父级文件是否存在
  76. if (!file.getParentFile().exists()) {
  77. file.getParentFile().mkdir();
  78. }
  79. mufile.transferTo(file);
  80. } catch (IllegalStateException | IOException e) {
  81. e.printStackTrace();
  82. }
  83. Doctor doctor = new Doctor();
  84. if(id != -1){
  85. doctor.setId(id);
  86. doctor.setImg("/files/"+filename);
  87. doctorService.updateByPrimaryKeySelective(doctor);
  88. }else {
  89. //添加图片路径
  90. doctor.setImg("/files/"+filename);
  91. doctorService.insertSelective(doctor);
  92. System.out.println("id:"+doctor.getId());
  93. map.put("id",doctor.getId());
  94. }
  95. return map;
  96. }
  97. /**
  98. * 判断管理员账号
  99. */
  100. @RequestMapping("/sectionxList")
  101. @ResponseBody
  102. public List<Section> sectionxList(Model model, Integer id) {
  103. List<Section> selectByExample = null;
  104. if(id != null) {
  105. Section section = new Section();
  106. section.setPid(id);
  107. selectByExample = sectionService.selectByExample(section);
  108. }
  109. return selectByExample;
  110. }
  111. /**
  112. * 判断管理员账号
  113. */
  114. @RequestMapping("/mimaUpate")
  115. @ResponseBody
  116. public Map<String,String> passwordUpate(Model model, String zhanghao) {
  117. Map<String, String> map = new HashMap<String, String>();
  118. Admin ad = new Admin();
  119. ad.setUsername(zhanghao);
  120. List<Admin> selectAdmin = adminService.selectAdmin(ad);
  121. if(selectAdmin.size() > 0){
  122. map.put("pan","err");
  123. }else{
  124. map.put("pan","ok");
  125. }
  126. return map;
  127. }
  128. /**
  129. * 判断医生账号
  130. */
  131. @RequestMapping("/panzhanghao")
  132. @ResponseBody
  133. public Map<String,String> panzhanghao(Model model, String zhanghao) {
  134. Map<String, String> map = new HashMap<String, String>();
  135. DoctorExample se = new DoctorExample();
  136. DoctorExample.Criteria criteria = se.createCriteria();
  137. criteria.andUsernameEqualTo(zhanghao);
  138. List<Doctor> selectByExample = doctorService.selectByExample(se);
  139. if(selectByExample.size() > 0){
  140. map.put("pan","err");
  141. }else{
  142. map.put("pan","ok");
  143. }
  144. return map;
  145. }
  146. /**
  147. * 医生添加
  148. * @param model
  149. * @param zixun
  150. * @return
  151. */
  152. @RequestMapping("/zixunInsert")
  153. public String zixunInsert(Model model,Doctor doctor){
  154. if(doctor.getId() != null){
  155. if(doctor.getSid() != null) {
  156. Section selectByPrimaryKey = sectionService.selectByPrimaryKey(doctor.getSid());
  157. doctor.setSname(selectByPrimaryKey.getName());
  158. }
  159. doctorService.updateByPrimaryKeySelective(doctor);
  160. }
  161. model.addAttribute("type",1);
  162. return "login";
  163. }
  164. /**
  165. * 管理员注册界面
  166. */
  167. @RequestMapping("/mimaPageUptate")
  168. public String mimaPageUptate(Integer type,Model model) {
  169. //1医生 2 管理员
  170. if(type == 1 ) {
  171. return "doctorRegister";
  172. }
  173. return "adminRegister";
  174. }
  175. /**
  176. * 医生注册界面
  177. */
  178. @RequestMapping("/doctorRegisterPage")
  179. public String doctorRegister(Model model) {
  180. List<Section> sectionlist2 = null;
  181. Section se = new Section();
  182. se.setType(1);
  183. List<Section> sectionlist = sectionService.selectByExample(se);
  184. if(sectionlist.size() > 0 ) {
  185. //科室详情
  186. Section section = new Section();
  187. section.setPid(sectionlist.get(0).getId());
  188. section.setType(2);
  189. sectionlist2 = sectionService.selectByExample(section);
  190. }
  191. model.addAttribute("sectionlist", sectionlist);
  192. model.addAttribute("sectionlist2", sectionlist2);
  193. return "doctorRegister";
  194. }
  195. /**
  196. * 管理员注册
  197. */
  198. @RequestMapping("/admin_Register")
  199. public String admin_Register(Admin admin,Model model) {
  200. int insertSelective = adminService.insertSelective(admin);
  201. model.addAttribute("type",2);
  202. return "login";
  203. }
  204. /**
  205. * 登陆验证
  206. * @return
  207. */
  208. @RequestMapping("/verificatio")
  209. public String verificatio(String username, String password, Integer type, HttpServletRequest request,Model model) {
  210. HttpSession session = request.getSession();
  211. session.setAttribute("type",type);
  212. //类型为1是医院 2是管理员
  213. if(type == 1){
  214. Doctor doctor = new Doctor();
  215. doctor.setUsername(username);
  216. doctor.setPasswoed(password);
  217. List<Doctor> doctorlist = doctorService.selectDoctor(doctor);
  218. if(doctorlist.size() <= 0){
  219. model.addAttribute("message","密码错误");
  220. model.addAttribute("type",type);
  221. return "login";
  222. }
  223. session.setAttribute("DOCTOR",doctorlist.get(0));
  224. return "redirect:/doctor/index";
  225. }
  226. if(type == 3){
  227. Patient patient = new Patient();
  228. patient.setUsername(username);
  229. patient.setPassword(password);
  230. List<Patient> list = patientService.selectPatient(patient);
  231. if(list.size() <= 0) {
  232. model.addAttribute("message","密码错误");
  233. model.addAttribute("type",type);
  234. return "loginByPatient";
  235. }
  236. session.setAttribute("PATIENT",list.get(0));
  237. return "redirect:/api/doctorList1";
  238. }
  239. Admin admin = new Admin();
  240. admin.setUsername(username);
  241. admin.setPassword(password);
  242. List<Admin> adminlist = adminService.selectAdmin(admin);
  243. if(adminlist.size() <= 0){
  244. model.addAttribute("message","密码错误");
  245. model.addAttribute("type",type);
  246. return "login";
  247. }
  248. session.setAttribute("ADMIN",adminlist.get(0));
  249. return "redirect:/admin/index";
  250. }
  251. /**
  252. * 退出登录
  253. * @param request
  254. * @return
  255. */
  256. @RequestMapping("/sessionInvalidate")
  257. public String boot(HttpServletRequest request,Model model) {
  258. HttpSession session = request.getSession();
  259. Integer type = (Integer) session.getAttribute("type");
  260. if(type == null){
  261. type=1;
  262. }
  263. if(type == 3){
  264. model.addAttribute("type",type);
  265. session.invalidate(); //session销毁
  266. return "loginByPatient";
  267. }
  268. model.addAttribute("type",type);
  269. session.invalidate(); //session销毁
  270. return "login";
  271. }
  272. /*
  273. *//**
  274. * 跳转忘记密码界面
  275. *//*
  276. @RequestMapping("/mimaPageUptate")
  277. public String passwordUpate() {
  278. return "behind/merchant/mibaoUptate";
  279. }
  280. *//**
  281. * 修改密码
  282. *//*
  283. @RequestMapping("/mimaUpate")
  284. @ResponseBody
  285. public Map<String,String> passwordUpate(Model model, String mima, String mibao, String zhanghao) {
  286. Map<String, String> map = new HashMap<String, String>();
  287. Merchant me = new Merchant();
  288. me.setZhanghao(zhanghao);
  289. me.setMibao(mibao);
  290. List<Merchant> list = merchantService.selectMerchant(me);
  291. if(list.size() > 0){
  292. Merchant me2 = new Merchant();
  293. me2.setId(list.get(0).getId());
  294. me2.setMima(mima);
  295. merchantService.updateByPrimaryKeySelective(me2);
  296. map.put("pan","ok");
  297. }else{
  298. map.put("pan","err");
  299. }
  300. return map;
  301. }
  302. *//**
  303. * 后台登陆界面
  304. * @return
  305. *//*
  306. @RequestMapping("/afterView")
  307. public String afterLogin(Integer type,Model model) {
  308. if(type == null){
  309. type = 1;
  310. }
  311. model.addAttribute("type",type);
  312. return "behind/login";
  313. }
  314. *//**
  315. * 登陆验证
  316. * @return
  317. *//*
  318. @RequestMapping("/verificatio")
  319. public String signin(String username, String password, Integer type, HttpServletRequest request,Model model) {
  320. HttpSession session = request.getSession();
  321. session.setAttribute("type",type);
  322. //类型为1是商户后台 2是管理员
  323. if(type == 1){
  324. Merchant merchant = new Merchant();
  325. merchant.setZhanghao(username);
  326. merchant.setMima(password);
  327. merchant.setState(1);
  328. List<Merchant> merchants = merchantService.selectMerchant(merchant);
  329. if(merchants.size() <= 0){
  330. model.addAttribute("message","密码错误");
  331. model.addAttribute("type",type);
  332. return "behind/login";
  333. }
  334. session.setAttribute("MERCHANT",merchants.get(0));
  335. return "redirect:/merchant/index";
  336. }
  337. Admin admin = new Admin();
  338. admin.setUsername(username);
  339. admin.setPassword(password);
  340. List<Admin> adminlist = adminService.selectAdmin(admin);
  341. if(adminlist.size() <= 0){
  342. model.addAttribute("message","密码错误");
  343. model.addAttribute("type",type);
  344. return "behind/login";
  345. }
  346. session.setAttribute("ADMIN",adminlist.get(0));
  347. return "redirect:/admin/index";
  348. }
  349. *//**
  350. * 退出登录
  351. * @param request
  352. * @return
  353. *//*
  354. @RequestMapping("/sessionInvalidate")
  355. public String boot(HttpServletRequest request,Model model) {
  356. HttpSession session = request.getSession();
  357. Integer type = (Integer) session.getAttribute("type");
  358. if(type == null){
  359. type=1;
  360. }
  361. model.addAttribute("type",type);
  362. session.invalidate(); //session销毁
  363. return "behind/login";
  364. }
  365. *//**
  366. * 管理员修改密码界面
  367. * @return
  368. *//*
  369. @RequestMapping("/adminUptatePage")
  370. public String adminUptatePage(Model model) {
  371. return "behind/admin/adminUptate";
  372. }
  373. *//**
  374. * 商户修改密码界面
  375. * @return
  376. *//*
  377. @RequestMapping("/merchantUptate")
  378. public String merchantUptate(Model model) {
  379. return "behind/merchant/merchantUptate";
  380. }
  381. */
  382. }

医生端:

  1. /**
  2. * 医生端
  3. */
  4. @Controller
  5. @RequestMapping("/doctor")
  6. public class DoctorController {
  7. @Autowired
  8. private AdminService adminService;
  9. @Autowired
  10. private DoctorService doctorService;
  11. @Autowired
  12. private SectionService sectionService;
  13. @Autowired
  14. private PatientService patientService;
  15. @Autowired
  16. private MessagesService messagesService;
  17. private Integer size = 8;//每页显示数量
  18. /**
  19. * 修改信息
  20. * @param model
  21. * @return
  22. */
  23. @RequestMapping("/tiaomessagelist")
  24. public String tiaomessagelist(@RequestBody List<Messages> mlist,Model model) {
  25. System.out.println(mlist.size());
  26. model.addAttribute("mlist",mlist);
  27. return "doctor/messageList";
  28. }
  29. @RequestMapping("/index")
  30. public String index(Model model,HttpServletRequest request) {
  31. HttpSession session = request.getSession();
  32. Doctor dt = (Doctor) session.getAttribute("DOCTOR");
  33. if(dt == null) {
  34. return "redirect:/login/index";
  35. }
  36. int doctor = doctorService.countByExample(null); //医生总数
  37. int section = sectionService.count(); //科室总数
  38. //患者总数
  39. int patient = 0;
  40. List<Patient> selectByExample = patientService.selectByExample(null);
  41. Messages mess = new Messages();
  42. for (Patient pa : selectByExample) {
  43. if(pa.getName() != null) {
  44. mess.setDid(dt.getId());
  45. mess.setUsername(pa.getName());
  46. List<Messages> selectMessages = messagesService.selectMessages(mess);
  47. if(selectMessages.size() > 0 )
  48. {
  49. patient++;
  50. }
  51. }
  52. }
  53. //预约总数
  54. MessagesExample me = new MessagesExample();
  55. MessagesExample.Criteria mecriteria = me.createCriteria();
  56. mecriteria.andDidEqualTo(dt.getId());
  57. int messages = messagesService.countByExample(me);
  58. model.addAttribute("doctor",doctor);
  59. model.addAttribute("section",section);
  60. model.addAttribute("patient",patient);
  61. model.addAttribute("messages",messages);
  62. PageInfo<Doctor> pageInfo = doctorService.selectDoctorList(null,1,4);
  63. if(pageInfo.getList() != null && pageInfo.getList().size() >0 ) {
  64. List<Doctor> list = pageInfo.getList();
  65. StringBuffer sb = new StringBuffer();
  66. StringBuffer shu = new StringBuffer();
  67. int v = list.size()-1;
  68. for(int i=0;i<list.size();i++) {
  69. if(v==i) {
  70. sb.append(list.get(i).getName());
  71. shu.append(list.get(i).getYipeoples());
  72. }else {
  73. sb.append(list.get(i).getName()+",");
  74. shu.append(list.get(i).getYipeoples()+",");
  75. }
  76. }
  77. model.addAttribute("name",sb.toString());
  78. model.addAttribute("nu",shu.toString());
  79. }
  80. return "doctor/index";
  81. }
  82. /**
  83. * 修改信息
  84. * @param model
  85. * @return
  86. */
  87. @RequestMapping("/doctorUptatePage")
  88. public String doctorUptatePage(Model model,HttpServletRequest request) {
  89. HttpSession session = request.getSession();
  90. Doctor dt = (Doctor) session.getAttribute("DOCTOR");
  91. if(dt != null) {
  92. Doctor doctor = doctorService.selectByPrimaryKey(dt.getId());
  93. List<Section> sectionlist2 = null;
  94. model.addAttribute("doctor",doctor);
  95. //科室
  96. Section se = new Section();
  97. se.setType(1);
  98. List<Section> sectionlist = sectionService.selectByExample(se);
  99. model.addAttribute("sectionlist", sectionlist);
  100. //科室详情
  101. Section se1 = sectionService.selectByPrimaryKey(doctor.getSid());
  102. if(se1 != null) {
  103. Section section = new Section();
  104. section.setPid(se1.getPid());
  105. section.setType(2);
  106. sectionlist2 = sectionService.selectByExample(section);
  107. model.addAttribute("sectionlist2", sectionlist2);
  108. model.addAttribute("se1", se1);
  109. }
  110. }
  111. return "doctor/doctorUptate";
  112. }
  113. /**
  114. * 修改医生信息
  115. */
  116. @RequestMapping("/messageTime")
  117. public String messageTime(String name,Model model,HttpServletRequest request) {
  118. HttpSession session = request.getSession();
  119. Doctor dt = (Doctor) session.getAttribute("DOCTOR");
  120. if(name != null) {
  121. Messages mess = new Messages();
  122. mess.setDid(dt.getId());
  123. mess.setUsername(name);
  124. List<Messages> selectMessages = messagesService.selectMessagesTWO(mess);
  125. model.addAttribute("messagesList", selectMessages);
  126. }
  127. return "doctor/messageTime";
  128. }
  129. /**
  130. * 修改医生信息
  131. */
  132. @RequestMapping("/admindoctorUptate")
  133. public String adminUptatePassword(Doctor doctor,Model model) {
  134. if(doctor != null && doctor.getId() != null) {
  135. if(doctor.getSid() != null) {
  136. Section section = sectionService.selectByPrimaryKey(doctor.getSid());
  137. doctor.setSid(section.getId());
  138. doctor.setSname(section.getName());
  139. }
  140. doctorService.updateByPrimaryKeySelective(doctor);
  141. }
  142. return "redirect:/doctor/index";
  143. }
  144. /**
  145. * 预约信息列表
  146. */
  147. @RequestMapping("/messageList")
  148. public String doctorList(Model model, Messages messages, @RequestParam(value="page",defaultValue="1")Integer page,Integer type,HttpServletRequest request) {
  149. if(messages == null) {
  150. messages = new Messages();
  151. }
  152. HttpSession session = request.getSession();
  153. Doctor dt = (Doctor) session.getAttribute("DOCTOR");
  154. if(dt != null){
  155. messages.setDid(dt.getId());
  156. }else{
  157. return "redirect:/login/index";
  158. }
  159. messages.setType(type);
  160. //底层数据
  161. PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages,page,size);
  162. //工作区数据
  163. messages.setTime(new Date());
  164. List<Messages> list = messagesService.selectMessagesPai(messages);
  165. model.addAttribute("mlist",list);
  166. model.addAttribute("messagesList",pageInfo.getList());
  167. model.addAttribute("pageInfo",pageInfo);
  168. model.addAttribute("messages",messages);
  169. model.addAttribute("type",type);
  170. return "doctor/messageList";
  171. }
  172. /**
  173. *医生列表查询
  174. */
  175. @RequestMapping(value = "/messageAjax")
  176. @ResponseBody
  177. public List<Messages> doctorList(HttpServletRequest request) {
  178. Messages messages = new Messages();
  179. HttpSession session = request.getSession();
  180. Doctor dt = (Doctor) session.getAttribute("DOCTOR");
  181. messages.setDid(dt.getId());
  182. messages.setType(1);
  183. messages.setTime(new Date());
  184. PageInfo<Messages> pageInfo2 = messagesService.selectMessagesListDemo(messages,1,99);
  185. return pageInfo2.getList();
  186. }
  187. /**
  188. *医生列表查询
  189. */
  190. @RequestMapping(value = "/messagesQundingUptate")
  191. @ResponseBody
  192. public String messagesQundingUptate(Integer id) {
  193. if(id != null) {
  194. Messages messages = new Messages();
  195. messages.setId(id);
  196. messages.setType(3); //3表示预约成功
  197. messagesService.updateByPrimaryKeySelective(messages);
  198. Messages selectByPrimaryKey = messagesService.selectByPrimaryKey(id);
  199. Messages mes = new Messages();
  200. mes.setType(1);
  201. mes.setTime(new Date());
  202. mes.setDid(selectByPrimaryKey.getDid());
  203. List<Messages> list = messagesService.selectMessagesPai(mes);
  204. for (int i = 0; i < list.size(); i++) {
  205. list.get(i).setPai(i+1);
  206. messagesService.updateByPrimaryKeySelective(list.get(i));
  207. }
  208. }
  209. return "ok";
  210. }
  211. /**
  212. *患者信息列表
  213. */
  214. @RequestMapping("/patientList")
  215. public String messageList(Model model, Patient patient, @RequestParam(value="page",defaultValue="1")Integer page,HttpServletRequest request) {
  216. if(patient == null) {
  217. patient = new Patient();
  218. }
  219. HttpSession session = request.getSession();
  220. Doctor dt = (Doctor) session.getAttribute("DOCTOR");
  221. if(dt == null){
  222. return "redirect:/login/index";
  223. }
  224. /*
  225. * PageInfo<Patient> pageInfo =
  226. * patientService.selectPatientList(patient,1,size); List<Patient> list =
  227. * pageInfo.getList(); List<Patient> list2 = new ArrayList<Patient>(); Messages
  228. * messages = new Messages(); boolean pan = false; SimpleDateFormat sdf = new
  229. * SimpleDateFormat("yyyy-MM-dd"); for (Patient pa : list) { if(pa.getPid() !=
  230. * null && pa.getPid() != 0){ messages.setDid(dt.getId());
  231. * messages.setUid(pa.getPid()); messages.setUsername(pa.getName());
  232. * List<Messages> ml = messagesService.selectMessages(messages); if(ml.size() >
  233. * 0 ){ Date time = ml.get(0).getTime(); pa.setUsername(sdf.format(time));
  234. * pa.setPhone(dt.getName()); pa.setIdentitys(dt.getSname()); list2.add(pa); }
  235. *
  236. * } } if(list2.size() <= 8) { pageInfo.setPages(1); }
  237. */
  238. Messages messages = new Messages();
  239. // messages.setTime(new Date());
  240. messages.setType(1);
  241. messages.setDid(dt.getId());
  242. PageInfo<Messages> pageInfo = messagesService.selectMessagesList(messages, 1, size);
  243. model.addAttribute("doctorList",pageInfo.getList());
  244. model.addAttribute("pageInfo",pageInfo);
  245. model.addAttribute("patient",patient);
  246. return "doctor/patientList";
  247. }
  248. /**
  249. *预约信息列表
  250. * @throws ParseException
  251. */
  252. @RequestMapping(value = "/tiaozhuanList")
  253. @ResponseBody
  254. public String messagesList(@RequestParam("xiao")Integer xiao,@RequestParam("da")Integer da) {
  255. Messages message = new Messages();
  256. if(xiao != null & da != null) {
  257. Messages mexiao = messagesService.selectByPrimaryKey(xiao);
  258. Integer px = mexiao.getPai();
  259. Messages meda = messagesService.selectByPrimaryKey(da);
  260. mexiao.setPai(meda.getPai());
  261. meda.setPai(px);
  262. messagesService.updateByPrimaryKeySelective(mexiao);
  263. messagesService.updateByPrimaryKeySelective(meda);
  264. }
  265. return null;
  266. }
  267. /**
  268. * 确定预约
  269. */
  270. @RequestMapping("/messagesUptate")
  271. public String messagesUptate(Integer id) {
  272. if(id != null) {
  273. Messages messages = new Messages();
  274. messages.setId(id);
  275. messages.setType(3); //3表示预约成功
  276. messagesService.updateByPrimaryKeySelective(messages);
  277. }
  278. return "redirect:/doctor/messageList?type=1";
  279. }
  280. /**
  281. * 取消
  282. */
  283. @RequestMapping("/messagesQuXiao")
  284. public String messagesQuXiao(Integer id) {
  285. if(id != null) {
  286. Messages messages = new Messages();
  287. messages.setId(id);
  288. messages.setType(2); //2取消预约
  289. messagesService.updateByPrimaryKeySelective(messages);
  290. }
  291. return "redirect:/doctor/messageList?type=1";
  292. }
  293. /**
  294. * 退号
  295. */
  296. @RequestMapping("/messagesTui")
  297. public String messagesTui(Integer id) {
  298. if(id != null) {
  299. Messages messages = new Messages();
  300. messages.setId(id);
  301. messages.setType(4); //4退号失败
  302. messagesService.updateByPrimaryKeySelective(messages);
  303. }
  304. return "redirect:/doctor/messageList?type=3";
  305. }
  306. }

 源码获取:博客首页 "资源" 里下载!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/566222
推荐阅读
相关标签
  

闽ICP备14008679号