1.用户注册和登陆微信小程序
2.用户查看美食美食资讯信息
3.用户查看美食食谱推荐信息,在线搜索美食信息
4.用户查看美食食谱分类,根据分类选择美食
5.用户查看美食食谱详情,收藏美食食谱,点赞和在线评论
6.用户在线论坛交流,可以发布帖子,查看帖子,回复帖子信息
7.用户个人中心修改个人资料,修改密码
7.用户个人中心查看我的收藏美食食谱信息
8.用户个人中心查看我的发帖信息
9.退出登陆
1.管理员输入账户登陆后台
2.个人中心:管理员修改密码和账户信息
3.菜系管理:对菜系分类进行添加,删除,修改,查询
4.美食分类管理:对美食的分类信息进行添加,修改,删除,查询
5.口味管理:对美食的口味信息进行查询,删除,添加,修改
6.用户管理:对注册的用户信息进行添加,修改,删除,查询
7.美食食谱管理:对小程序的美食食谱信息进行添加,修改,删除,查询
8.美食论坛管理:对用户发布的交流论坛信息进行添加,修改,删除,查询
9.美食资讯:对美食的资讯信息进行添加,修改,查询,删除
10.轮播图管理:对网站轮播图进行添加,修改,查询,删除
11.退出系统
请联系我获取更详细的演示视频
每推荐一位同学,推荐费一位100!
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UsersEntity user = userService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
}
@Override
public String generateToken(Long userid,String username, String tableName, String role) {
TokenEntity tokenEntity = this.selectOne(new EntityWrapper<TokenEntity>().eq("userid", userid).eq("role", role));
String token = CommonUtil.getRandomString(32);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.HOUR_OF_DAY, 1);
if(tokenEntity!=null) {
tokenEntity.setToken(token);
tokenEntity.setExpiratedtime(cal.getTime());
this.updateById(tokenEntity);
} else {
this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime()));
}
return token;
}
/**
* 权限(Token)验证
*/
@Component
public class AuthorizationInterceptor implements HandlerInterceptor {
public static final String LOGIN_TOKEN_KEY = "Token";
@Autowired
private TokenService tokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//支持跨域请求
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization");
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
// 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态
if (request.getMethod().equals(RequestMethod.OPTIONS.name())) {
response.setStatus(HttpStatus.OK.value());
return false;
}
IgnoreAuth annotation;
if (handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(IgnoreAuth.class);
} else {
return true;
}
//从header中获取token
String token = request.getHeader(LOGIN_TOKEN_KEY);
/**
* 不需要验证权限的方法直接放过
*/
if(annotation!=null) {
return true;
}
TokenEntity tokenEntity = null;
if(StringUtils.isNotBlank(token)) {
tokenEntity = tokenService.getTokenEntity(token);
}
if(tokenEntity != null) {
request.getSession().setAttribute("userId", tokenEntity.getUserid());
request.getSession().setAttribute("role", tokenEntity.getRole());
request.getSession().setAttribute("tableName", tokenEntity.getTablename());
request.getSession().setAttribute("username", tokenEntity.getUsername());
return true;
}
PrintWriter writer = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
try {
writer = response.getWriter();
writer.print(JSONObject.toJSONString(R.error(401, "请先登录")));
} finally {
if(writer != null){
writer.close();
}
}
// throw new EIException("请先登录", 401);
return false;
}
}
文章下方名片联系我即可~
大家点赞、收藏、关注、评论啦 、查看??获取联系方式??
精彩专栏推荐订阅:在下方专栏??