您好,登錄后才能下訂單哦!
今天小編給大家分享一下醫療掛號系統web開發的方法的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
本文開發分布式醫療掛號系統,進入到醫院信息、科室、排版接口的開發,內容比較枯燥。
Controller層:
@PostMapping("hospital/show") public Result getHospital(HttpServletRequest request) { // 1.將從醫院管理表傳遞過來的醫院信息轉換為Object類型 Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String hoscode = (String) paramMap.get("hoscode"); String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } // 5.執行查詢操作 Hospital hospital = hospitalService.getByHoscode(hoscode); return Result.ok(hospital); }
Service接口:
Hospital getByHoscode(String hoscode);
Service實現類:
@Override public Hospital getByHoscode(String hoscode) { Hospital hospital = hospitalRepository.getHospitalByHoscode(hoscode); return hospital; }
Repository層:
@Repository public interface HospitalRepository extends MongoRepository<Hospital,String> { /** * 根據HosCode獲得記錄 * @param hoscode * @return */ Hospital getHospitalByHoscode(String hoscode); }
上傳科室Controller層:
@PostMapping("saveDepartment") public Result saveDepartment(HttpServletRequest request) { // 1.將傳遞過來的數組類型轉換為Object類型 Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String hoscode = (String) paramMap.get("hoscode"); String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } // 5.執行上傳科室操作 departmentService.save(paramMap); return Result.ok(); }
上傳科室Service接口:
void save(Map<String, Object> paramMap);
上傳科室Service實現類:
@Override public void save(Map<String, Object> paramMap) { // 1.把paramMap集合轉換為Department對象(借助JSONObject工具) String paramMapString = JSONObject.toJSONString(paramMap); Department department = JSONObject.parseObject(paramMapString, Department.class); // 2.根據醫院編號和科室編號查詢科室信息 Department departmentExist = departmentRepository .getDepartmentByHoscodeAndDepcode(department.getHoscode(), department.getDepcode()); // 3.如果有就執行更新,沒有就執行保存 if (null != departmentExist) {// 更新 departmentExist.setUpdateTime(new Date()); departmentExist.setIsDeleted(0); departmentRepository.save(departmentExist); } else {// 保存 department.setCreateTime(new Date()); department.setUpdateTime(new Date()); department.setIsDeleted(0); departmentRepository.save(department); } }
Repositroy層交由Spring Data
去自動完成。
查詢科室Controller層:
@PostMapping("department/list") public Result findDepartment(HttpServletRequest request) { // 1.將傳遞過來的科室轉換為Object類型 Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 3.獲取醫院編號 String hoscode = (String) paramMap.get("hoscode"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 當前頁和每頁記錄數 int page = StringUtils.isEmpty(paramMap.get("page")) ? 1 : Integer.parseInt((String) paramMap.get("page")); int limit = StringUtils.isEmpty(paramMap.get("limit")) ? 1 : Integer.parseInt((String) paramMap.get("limit")); String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } DepartmentQueryVo departmentQueryVo = new DepartmentQueryVo(); departmentQueryVo.setHoscode(hoscode); // 執行查詢科室操作 Page<Department> pageModel = departmentService.findPageDepartment(page, limit, departmentQueryVo); return Result.ok(pageModel); }
查詢科室Service接口:
Page<Department> findPageDepartment(int page, int limit, DepartmentQueryVo departmentQueryVo);
查詢科室Service實現類:
@Override public Page<Department> findPageDepartment(int page, int limit, DepartmentQueryVo departmentQueryVo) { // 創建Pageable對象,設置當前頁和每頁記錄數 PageRequest pageable = PageRequest.of(page - 1, limit); // 創建Example對象 Department department = new Department(); BeanUtils.copyProperties(departmentQueryVo, department); department.setIsDeleted(0); ExampleMatcher matcher = ExampleMatcher.matching() .withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING) .withIgnoreCase(true); Example<Department> example = Example.of(department, matcher); Page<Department> all = departmentRepository.findAll(example, pageable); return all; }
Repositroy層交由Spring Data
去自動完成。
刪除科室Controller層:
@PostMapping("department/remove") public Result removeDepartment(HttpServletRequest request) { // 1.將傳遞過來的科室轉換為Object類型 Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 獲取科室編號 和 醫院編號 String depcode = (String) paramMap.get("depcode"); String hoscode = (String) paramMap.get("hoscode"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } departmentService.remove(hoscode, depcode); return Result.ok(); }
刪除科室Service接口:
@PostMapping("department/remove") public Result removeDepartment(HttpServletRequest request) { // 1.將傳遞過來的科室轉換為Object類型 Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 獲取科室編號 和 醫院編號 String depcode = (String) paramMap.get("depcode"); String hoscode = (String) paramMap.get("hoscode"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } departmentService.remove(hoscode, depcode); return Result.ok(); }
刪除科室Service接口:
void remove(String hoscode, String depcode);
刪除科室Service實現類:
@Override public void remove(String hoscode, String depcode) { // 1.根據 醫院編號 和 科室編號 查詢科室信息 Department department = departmentRepository.getDepartmentByHoscodeAndDepcode(hoscode, depcode); if (null != department) { // 執行刪除方法 departmentRepository.deleteById(department.getId()); } }
Repositroy層交由Spring Data
去自動完成。
上傳排班Controller層:
@PostMapping("saveSchedule") public Result saveSchedule(HttpServletRequest request) { Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 獲取科室編號 和 醫院編號 String hoscode = (String) paramMap.get("hoscode"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } // 執行上傳操作 scheduleService.save(paramMap); return Result.ok(); }
上傳排班Service接口:
void save(Map<String, Object> paramMap);
上傳排班Service實現類:
@Override public void save(Map<String, Object> paramMap) { // 1.把paramMap集合轉換為Department對象(借助JSONObject工具) String paramMapString = JSONObject.toJSONString(paramMap); Schedule schedule = JSONObject.parseObject(paramMapString, Schedule.class); // 2.根據 醫院編號 和 排班編號 查詢科室信息 Schedule scheduleExist = scheduleRepository .getScheduleByHoscodeAndHosScheduleId(schedule.getHoscode(), schedule.getHosScheduleId()); // 3.如果有就執行更新,沒有就執行保存 if (null != scheduleExist) {// 更新 scheduleExist.setUpdateTime(new Date()); scheduleExist.setIsDeleted(0); scheduleExist.setStatus(1); scheduleRepository.save(scheduleExist); } else {// 保存 schedule.setCreateTime(new Date()); schedule.setUpdateTime(new Date()); schedule.setIsDeleted(0); schedule.setStatus(1); scheduleRepository.save(schedule); } }
Repositroy層交由Spring Data
去自動完成。
查詢排班Controller層:
@PostMapping("schedule/list") public Result findSchedule(HttpServletRequest request) { Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 3.獲取醫院編號,科室編號 String hoscode = (String) paramMap.get("hoscode"); String depcode = (String) paramMap.get("depcode"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 當前頁和每頁記錄數 int page = StringUtils.isEmpty(paramMap.get("page")) ? 1 : Integer.parseInt((String) paramMap.get("page")); int limit = StringUtils.isEmpty(paramMap.get("limit")) ? 1 : Integer.parseInt((String) paramMap.get("limit")); String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } ScheduleQueryVo scheduleQueryVo = new ScheduleQueryVo(); scheduleQueryVo.setHoscode(hoscode); scheduleQueryVo.setHoscode(depcode); // 執行查詢科室操作 Page<Schedule> pageModel = scheduleService.findPageSchedule(page, limit, scheduleQueryVo); return Result.ok(pageModel); }
查詢排班Service接口:
Page<Schedule> findPageSchedule(int page, int limit, ScheduleQueryVo scheduleQueryVo);
查詢排班Service實現類:
@Override public Page<Schedule> findPageSchedule(int page, int limit, ScheduleQueryVo scheduleQueryVo) { // 創建Pageable對象,設置當前頁和每頁記錄數 PageRequest pageable = PageRequest.of(page - 1, limit); // 創建Example對象 Schedule schedule = new Schedule(); BeanUtils.copyProperties(scheduleQueryVo, schedule); schedule.setIsDeleted(0); schedule.setStatus(1); ExampleMatcher matcher = ExampleMatcher.matching() .withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING) .withIgnoreCase(true); Example<Schedule> example = Example.of(schedule, matcher); Page<Schedule> all = scheduleRepository.findAll(example, pageable); return all; }
Repositroy層交由Spring Data
去自動完成。
刪除排班Controller層:
@PostMapping("schedule/remove") public Result removeSchedule(HttpServletRequest request){ Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 獲取醫院編號和排班編號 String hoscode = (String) paramMap.get("hoscode"); String hosScheduleId = (String) paramMap.get("hosScheduleId"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } scheduleService.removeSchedule(hoscode, hosScheduleId); return Result.ok(); }
刪除排班Service接口:
void removeSchedule(String hoscode, String hosScheduleId);
刪除排班Service實現類:
@PostMapping("schedule/remove") public Result removeSchedule(HttpServletRequest request){ Map<String, String[]> requestMap = request.getParameterMap(); Map<String, Object> paramMap = HttpRequestHelper.switchMap(requestMap); // 獲取醫院編號和排班編號 String hoscode = (String) paramMap.get("hoscode"); String hosScheduleId = (String) paramMap.get("hosScheduleId"); // 2.獲取醫院管理表中的密鑰(已經使用MD5加密好了) String hospSign = (String) paramMap.get("sign"); // 3.獲取醫院設置表中的密鑰并進行MD5加密 String signKey = hospitalSetService.getSignKey(hoscode); String signKeyMd5 = MD5.encrypt(signKey); // 4.密鑰不匹配就拋出錯誤 if (!hospSign.equals(signKeyMd5)) { throw new YyghException(ResultCodeEnum.SIGN_ERROR); } scheduleService.removeSchedule(hoscode, hosScheduleId); return Result.ok(); }
Repositroy層交由Spring Data
去自動完成。
以上就是“醫療掛號系統web開發的方法”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。