SpringBoot实现心理预约管理系统

SpringBoot实现心理预约管理系统
个人网站:http://xiaocaoshare.com
1.需求分析
用户角色:学生和教师
学生:注册、登录、个人资料查看、修改密码、在线预约、预约管理、心理大师、案例鉴赏、我要预约
教师:系统账号管理、教师信息管理、预约设置管理、学生信息管理、资讯案例管理、预约数据统计
2.技术架构
springboot+mybatis+mysql+html+css+js
开发工具:
IDEA或eclipse
3.部分代码展示:
package com.hyxm.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.hyxm.utils.MD5Util;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.hyxm.model.Userinfo;
import com.hyxm.service.UserinfoService;
import com.hyxm.utils.BaseCls;
import com.hyxm.utils.LgUserPack;

@Controller
@RequestMapping("/hymain")
public class HyMainController extends BaseCls {

@Autowired
private UserinfoService userinfoService;

@Autowired
private HttpSession httpSession;

@GetMapping("/login")
public String toALogin(Model model) {
	return "admin/login";
}

@PostMapping("/login")
public String doALogin(Model model, Userinfo nsfo, String ucode) {

	if (nsfo.getUlog() == null || nsfo.getUpwd() == null || ucode == null) {
		model.addAttribute("error", "请填写登录信息");
		return "admin/login";
	}

	String random = (String) httpSession
			.getAttribute("RANDOMVALIDATECODEKEY");
	if (random == null) {
		model.addAttribute("error", "验证码失效,请重新输入");
		return "admin/login";
	} else {
		if (ucode != null) {
			ucode = ucode.toLowerCase();
		}
		if (!random.toLowerCase().equals(ucode)) {
			model.addAttribute("error", "验证码错误");
			return "admin/login";
		}
	}

	nsfo.setQkeys("urole>1 and ulog='"+nsfo.getUlog()+"' and upwd='"+MD5Util.code(nsfo.getUpwd())+"'");

	List<Userinfo> list = userinfoService.GetListZDY(nsfo);
	if (list.size() > 0) {
		httpSession.setAttribute("auser", list.get(0));
		// return "redirect:/userinfo/main";
		return "redirect:main";
	} else {
		model.addAttribute("error", "账号或密码有误.");
		return "admin/login";
	}
}

@GetMapping("/main")
public String adMain(LgUserPack lgUr) {
	if (!validatepur(httpSession,lgUr)) { return "redirect:alogout"; }

	return "admin/main";
}

@RequestMapping("alogout")
public String alogout(Model model) {
	httpSession.setAttribute("auser", null);
	return "redirect:/hymain/login";
}

@GetMapping("audtpwd")
public String toAUdtpwd(LgUserPack lgUr) {
	if (!validatepur(httpSession,lgUr)) { return "redirect:alogout"; }

	return "admin/udpwd";
}

@PostMapping("audtpwd")
public String doAUdtpwd(Model model, LgUserPack lgUr, String password, String passwordnew,
		String passwordnew2) {

	if (!validatepur(httpSession,lgUr)) { model = setReModel404(model, "请先登录!", "/hymain/login");
	return "admin/udpwd"; }
	

	Userinfo entity = userinfoService.GetInfoById(lgUr.LgUser.getUid());
	if (!lgUr.LgUser.getUpwd().equals(password)) {
		model = setReModel404(model, "原密码不正确!", "/hymain/audtpwd");
		return "admin/udpwd";
	}

	entity.setUpwd(MD5Util.code(passwordnew2));
	userinfoService.Update(entity);
	model = setReModel201(model, "修改成功!", "/hymain/audtpwd");

	return "admin/udpwd";
}

@GetMapping("audtinfo")
public String toAudtinfo(Model model,LgUserPack lgUr) {
	model.addAttribute("entity", new Userinfo());

	if (!validatepur(httpSession,lgUr)) { model = setReModel404(model, "请先登录!", "/hymain/login");
	return "admin/udinfo"; }

	Userinfo entity = userinfoService.GetInfoById(lgUr.LgUser.getUid());
	model.addAttribute("entity", entity);
	return "admin/udinfo";
}

@PostMapping("audtinfo")
public String doAudtinfo(Model model,
		@RequestParam("hIMG") MultipartFile hIMG, LgUserPack lgUr,Userinfo nsfo)
		throws IllegalStateException, IOException {
	model.addAttribute("entity", new Userinfo());

	if (!validatepur(httpSession,lgUr)) { model = setReModel404(model, "请先登录!", "/hymain/login");
	return "admin/udinfo"; }
	Userinfo entity = userinfoService.GetInfoById(lgUr.LgUser.getUid());

	entity.setUname(nsfo.getUname());
	entity.setUsex(nsfo.getUsex());
	entity.setUidentid(nsfo.getUidentid());
	entity.setUtel(nsfo.getUtel());
	entity.setUemail(nsfo.getUemail());
	entity.setUaddress(nsfo.getUaddress());
	entity.setUdesc(nsfo.getUdesc());
	if (hIMG.getSize() > 0) {
		String ext = FilenameUtils.getExtension(hIMG.getOriginalFilename()); // 获取文件的后缀
		if (!ext.endsWith("jpg") && !ext.endsWith("png")) {
			System.out.println("图片格式有误!" + " 看看吧");
			model = setReModel404(model, "图片格式有误!", "");
			return "admin/udinfo";
		}
		/*
		 * String url =
		 * request.getSession().getServletContext().getRealPath("/upfile");
		 * //获取地址加后边的静态资源文件夹的地址 url="classpath:/upfile";
		 */
		String rndName = UUID.randomUUID().toString().replaceAll("-", "");
		String nFileName = rndName + "." + ext;
		// String urlAll = url +"/" + nFileName; //得到整个文件的url

		String urlAll = null;
		File path2 = new File(ResourceUtils.getURL("classpath:").getPath()
				.replace("%20", " ").replace('/', '\\'));
		if (!path2.exists())
			path2 = new File("");
		// 如果上传目录为/static/images/upload/,则可以如下获取:
		File upload2 = new File(path2.getAbsolutePath(), "static/upfile/");
		if (!upload2.exists())
			upload2.mkdirs();
		String path = upload2.getAbsolutePath() + "";

		System.out.println("上传路径:" + path);
		urlAll = path + "\\" + nFileName;

		hIMG.transferTo(new File(urlAll)); // 将hIMG图片存放到urlAll的路径当中
		entity.setUimg(nFileName); // 将图片的路径存入数据库中
	}

	userinfoService.Update(entity);

	model.addAttribute("entity", entity);
	model = setReModel201(model, "修改成功!", "/hymain/audtinfo");
	return "admin/udinfo";
}

@RequestMapping("/toaregis")
public String toaregis(Model model) {

	return "admin/regis";
}

}
4.系统演示视频:
链接:https://pan.baidu.com/s/1pf7EG9ixTsgz-lM7Lmvy0Q
提取码:85hs

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值