4.30-团队项目-每日任务
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、明日任务
完善各个身份人愿信息填写时的输入限制
__EOF__

本文链接:https://www.cnblogs.com/lx06/p/14761037.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类