package world.xuewei.controller; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.stereotype.Controller; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.GetMapping; import world.xuewei.constant.MedicalConstants; import world.xuewei.entity.*; import world.xuewei.utils.Assert; import java.util.*; /** * 系统跳转控制器 *

* ========================================================================== * 郑重说明:本项目免费开源!原创作者为:薛伟同学,严禁私自出售。 * ========================================================================== * B站账号:薛伟同学 * 微信公众号:薛伟同学 * 作者博客:http://xuewei.world * ========================================================================== * 陆陆续续总会收到粉丝的提醒,总会有些人为了赚取利益倒卖我的开源项目。 * 不乏有粉丝朋友出现钱付过去,那边只把代码发给他就跑路的,最后还是根据线索找到我。。 * 希望各位朋友擦亮慧眼,谨防上当受骗! * ========================================================================== * * @author XUEW */ @Controller public class SystemController extends BaseController { /** * 首页 */ @GetMapping("/index.html") public String index(Map map) { return "index"; } /** * 智能医生 */ @GetMapping("/doctor") public String doctor(Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } return "doctor"; } /** * 退出登录 */ @GetMapping("/logout") public String logout() { session.invalidate(); return "redirect:/index.html"; } /** * 所有反馈 */ @GetMapping("/all-feedback") public String feedback(Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } List feedbackList = feedbackService.all(); map.put("feedbackList", feedbackList); return "all-feedback"; } /** * 我的资料 */ @GetMapping("/profile") public String profile(Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } return "profile"; } /** * 查询相关疾病 */ @GetMapping("findIllness") public String findIllness(Map map, Integer kind, String illnessName, Integer page) { // 处理page page = ObjectUtils.isEmpty(page) ? 1 : page; Map illness = illnessService.findIllness(kind, illnessName, page); if (Assert.notEmpty(kind)) { map.put("title", illnessKindService.get(kind).getName() + (illnessName == null ? "" : ('"' + illnessName + '"' + "的搜索结果"))); } else { map.put("title", illnessName == null ? "全部" : ('"' + illnessName + '"' + "的搜索结果")); } if (loginUser != null && kind != null) { historyService.insetOne(loginUser.getId(), MedicalConstants.TYPE_OPERATE, illnessKindService.get(kind).getId() + "," + (Assert.isEmpty(illnessName) ? "无" : illnessName)); } if (loginUser != null && Assert.notEmpty(illnessName)) { historyService.insetOne(loginUser.getId(), MedicalConstants.TYPE_ILLNESS, illnessName); } map.putAll(illness); map.put("page", page); map.put("kind", kind); map.put("illnessName", illnessName); map.put("kindList", illnessKindService.findList()); map.put("history", loginUser == null ? null : historyService.findList(loginUser.getId())); return "search-illness"; } /** * 查询相关疾病下的药 */ @GetMapping("findIllnessOne") public String findIllnessOne(Map map, Integer id) { Map illnessOne = illnessService.findIllnessOne(id); Illness illness = illnessService.get(id); if (loginUser != null) { historyService.insetOne(loginUser.getId(), MedicalConstants.TYPE_ILLNESS, illness.getIllnessName()); } map.putAll(illnessOne); return "illness-reviews"; } /** * 查询相关疾病下的药 */ @GetMapping("findMedicineOne") public String findMedicineOne(Map map, Integer id) { Medicine medicine = medicineService.get(id); // historyService.insetOne(loginUser.getId(),MedicalConstants.TYPE_MEDICINE,medicine.getMedicineName()); map.put("medicine", medicine); return "medicine"; } /** * 查询相关疾病下的药 */ @GetMapping("findMedicines") public String findMedicines(Map map, String nameValue, Integer page) { // 处理page page = ObjectUtils.isEmpty(page) ? 1 : page; if (loginUser != null && Assert.notEmpty(nameValue)) { historyService.insetOne(loginUser.getId(), MedicalConstants.TYPE_MEDICINE, nameValue); } map.putAll(medicineService.getMedicineList(nameValue, page)); map.put("history", loginUser == null ? null : historyService.findList(loginUser.getId())); map.put("title", nameValue); return "illness"; } /** * 查询相关疾病下的药 */ @GetMapping("globalSelect") public String globalSelect(Map map, String nameValue) { nameValue = nameValue.replace(",", ","); List idArr = Arrays.asList(nameValue.split(",")); //首先根据关键字去查询 Set illnessSet = new HashSet<>(); idArr.forEach(s -> { Illness one = illnessService.getOne(new QueryWrapper().like("illness_name", s)); if (ObjectUtil.isNotNull(one)) { illnessSet.add(one); } }); idArr.forEach(s -> { Illness one = illnessService.getOne(new QueryWrapper().like("special_symptom", s)); if (ObjectUtil.isNotNull(one)) { illnessSet.add(one); } }); idArr.forEach(s -> { Illness one = illnessService.getOne(new QueryWrapper().like("illness_symptom", s)); if (ObjectUtil.isNotNull(one)) { illnessSet.add(one); } }); map.put("illnessSet", illnessSet); return "index"; } /** * 添加疾病页面 */ @GetMapping("add-illness") public String addIllness(Integer id, Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } Illness illness = new Illness(); if (Assert.notEmpty(id)) { illness = illnessService.get(id); } List illnessKinds = illnessKindService.all(); map.put("illness", illness); map.put("kinds", illnessKinds); return "add-illness"; } /** * 添加药品页面 */ @GetMapping("add-medical") public String addMedical(Integer id, Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } List illnesses = illnessService.all(); Medicine medicine = new Medicine(); if (Assert.notEmpty(id)) { medicine = medicineService.get(id); for (Illness illness : illnesses) { List query = illnessMedicineService.query(IllnessMedicine.builder().medicineId(id).illnessId(illness.getId()).build()); if (Assert.notEmpty(query)) { illness.setIllnessMedicine(query.get(0)); } } } map.put("illnesses", illnesses); map.put("medicine", medicine); return "add-medical"; } /** * 疾病管理页面 */ @GetMapping("all-illness") public String allIllness(Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } List illnesses = illnessService.all(); for (Illness illness : illnesses) { illness.setKind(illnessKindService.get(illness.getKindId())); } map.put("illnesses", illnesses); return "all-illness"; } /** * 药品管理页面 */ @GetMapping("all-medical") public String allMedical(Map map) { if (Assert.isEmpty(loginUser)) { return "redirect:/index.html"; } List medicines = medicineService.all(); map.put("medicines", medicines); return "all-medical"; } }