1、社团信息以及进行用户信息分类
2、完成情况
社团信息录入存储功能完成,用户信息分类社长社员完成社长信息修改。
package com.atguigu.crud.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.atguigu.crud.bean.Club;
import com.atguigu.crud.bean.User;
import com.atguigu.crud.service.ClubService;
import com.atguigu.crud.service.UserService;
import com.atguigu.crud.utils.ValidateCodeExpiredException;
import java.util.List;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@Controller
public class MainController {
@Autowired
UserService userService;
@Autowired
ClubService club;
@RequestMapping(value = { "/register" })
public String doregister(User user, HttpServletRequest request) {
// 获取请求的ip地址
user.setRegister_ip(request.getRemoteAddr());
boolean result = false;
try {
result = userService.register(user);
request.setAttribute("msg", "注册成功");
} catch (MessagingException e) {
e.printStackTrace();
request.setAttribute("msg", "注册失败");
}
return "forward:/register.jsp";
}
@RequestMapping("/login")
public String dologin(String login_mail, String pwd, Model model, HttpSession session) {
User user = userService.login(login_mail, pwd);
if (user == null) {
model.addAttribute("msg", "用户名或密码错误");
} else {
if (user.getStatus() == 0) {
model.addAttribute("msg", "需激活|" + user.getId());
} else {
session.setAttribute("user", user);
List<Club> list = club.list(user.getId());
session.setAttribute("clublist", list);
if (user.getNick_name() == null) {
return "redirect:/user/edit?action=xiu";
}
return "forward:/index.jsp";
}
}
return "forward:/login.jsp";
}
@GetMapping(value = "/active", produces = { "application/json;charset=UTF-8" })
@ResponseBody
public String active(Long userId, String code) {
try {
boolean result = userService.active(userId, code);
if (result) {
return "激活成功!";
} else {
return "验证码错误,请重新去邮箱确认";
}
} catch (ValidateCodeExpiredException e) {
return e.getMessage();
}
}
@GetMapping("/logout.html")
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/login.jsp";
}
}
3、明日任务
完善各个身份人愿信息填写时的输入限制