package com.demo.comp;
import com.demo.Service.bookmainService;
import com.demo.mapper.bookmainmapper;
import com.demo.pojo.bookmain;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
@Data
@Component
public class bookdate {
private String name;
private HttpServletRequest request;
private static bookmainmapper bookmainmapper;
private static bookmainService bookmainService;
@Autowired
public void setBookmainmapper(bookmainmapper bookmainmapper){
bookdate.bookmainmapper=bookmainmapper;
}
@Autowired
public void setBookmainService(bookmainService bookmainService){
bookdate.bookmainService=bookmainService;
}
public bookdate() {
}
public boolean pollinguser(String name,HttpServletRequest request){
System.out.println("sdsdjsd");
bookmain bookmain=new bookmain();
Date date=new Date();
if(bookmainmapper!=null && name!=null){
bookmain=bookmainmapper.getById(name);
if(bookmain!=null){
if(bookmain.getBookclass()!="NO"){
Long loin = bookmain.getLoin();
date =new Date();
long xz=date.getTime();
int x= (int) ((xz-loin)/1000);
float ok=x/(60);
System.out.println("已使用"+ok+"分钟");
float show=bookmain.getShowTime();
if(ok>show){
bookmain.setShowTime(0);
bookmainService.updateById(bookmain);
return false;
}else {
return true;
}
}
}
}
return true;
}
}
这个bookmainmapper 和 bookmainService就是我们需要的
主要是这里
@Autowired
public void setBookmainmapper(bookmainmapper bookmainmapper){
bookdate.bookmainmapper=bookmainmapper;
}
@Autowired
public void setBookmainService(bookmainService bookmainService){
bookdate.bookmainService=bookmainService;
}
注册时会产生3个session,不知道那个才是登录之后的那个,这里我前端在线,但是有两个session后端