mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
2019-08-15更新
This commit is contained in:
@@ -45,6 +45,8 @@ public class UpdateImgController {
|
||||
private COSImageupload cosImageupload;
|
||||
@Autowired
|
||||
private FTPImageupload ftpImageupload;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
@RequestMapping({"/", "/index"})
|
||||
public String indexImg(Model model, HttpSession httpSession) {
|
||||
@@ -52,6 +54,7 @@ public class UpdateImgController {
|
||||
Print.Normal("当前项目路径:"+System.getProperty("user.dir"));
|
||||
Config config = configService.getSourceype();//查询当前系统使用的存储源类型。
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
Integer filesizetourists = 0;
|
||||
Integer filesizeuser = 0;
|
||||
Integer imgcounttourists = 0;
|
||||
@@ -117,6 +120,7 @@ public class UpdateImgController {
|
||||
if(uploadConfig.getIsupdate()!=1){
|
||||
isupdate = (u == null) ? 0: 1;//如果u等于null那么isupdate就等于0,否则等于1
|
||||
}
|
||||
model.addAttribute("sysconfig",sysConfig);
|
||||
model.addAttribute("ykxz", isupdate);
|
||||
return "index";
|
||||
|
||||
@@ -142,7 +146,7 @@ public class UpdateImgController {
|
||||
long stime = System.currentTimeMillis();
|
||||
String userpath = "tourist";
|
||||
if(uploadConfig.getUrltype()==2){
|
||||
java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd");
|
||||
java.text.DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
userpath = dateFormat.format(new Date());
|
||||
}else{
|
||||
if (u != null) {
|
||||
@@ -243,7 +247,7 @@ public class UpdateImgController {
|
||||
User u = (User) session.getAttribute("user");
|
||||
String userpath = "tourist";
|
||||
if(uploadConfig.getUrltype()==2){
|
||||
java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd");
|
||||
java.text.DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
userpath = dateFormat.format(new Date());
|
||||
}else{
|
||||
if (u != null) {
|
||||
|
||||
@@ -11,8 +11,10 @@ import javax.validation.Valid;
|
||||
|
||||
import cn.hellohao.pojo.Config;
|
||||
import cn.hellohao.pojo.EmailConfig;
|
||||
import cn.hellohao.pojo.SysConfig;
|
||||
import cn.hellohao.service.ConfigService;
|
||||
import cn.hellohao.service.EmailConfigService;
|
||||
import cn.hellohao.service.SysConfigService;
|
||||
import cn.hellohao.utils.SendEmail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -37,48 +39,55 @@ public class UserController {
|
||||
private EmailConfigService emailConfigService;
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
@RequestMapping("/register")
|
||||
@ResponseBody
|
||||
public String Register(@Valid User user) {
|
||||
//取当前时间
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
EmailConfig emailConfig = emailConfigService.getemail();
|
||||
Integer countusername = userService.countusername(user.getUsername());
|
||||
Integer countmail = userService.countmail(user.getEmail());
|
||||
if (countusername == 0 && countmail == 0) {
|
||||
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
||||
String birthder = df.format(new Date());// new Date()为获取当前系统时间
|
||||
user.setLevel(1);
|
||||
user.setUid(uid);
|
||||
user.setBirthder(birthder);
|
||||
//查询是否启用了邮箱验证。
|
||||
Config config = configService.getSourceype();
|
||||
System.err.println("是否启用了邮箱激活:"+emailConfig.getUsing());
|
||||
Integer type = 0;
|
||||
if(emailConfig.getUsing()==1){
|
||||
user.setIsok(0);
|
||||
//初始化邮箱
|
||||
MimeMessage message = SendEmail.Emails(emailConfig);
|
||||
//注册完发激活链接
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
Integer a = SendEmail.sendEmail(message, user.getUsername(), uid, user.getEmail(),emailConfig,config);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
type = 1;
|
||||
}else{
|
||||
//直接注册
|
||||
user.setIsok(1);
|
||||
type = 2;
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
if(sysConfig.getRegister()==1){
|
||||
//取当前时间
|
||||
EmailConfig emailConfig = emailConfigService.getemail();
|
||||
Integer countusername = userService.countusername(user.getUsername());
|
||||
Integer countmail = userService.countmail(user.getEmail());
|
||||
if (countusername == 0 && countmail == 0) {
|
||||
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
||||
String birthder = df.format(new Date());// new Date()为获取当前系统时间
|
||||
user.setLevel(1);
|
||||
user.setUid(uid);
|
||||
user.setBirthder(birthder);
|
||||
//查询是否启用了邮箱验证。
|
||||
Config config = configService.getSourceype();
|
||||
System.err.println("是否启用了邮箱激活:"+emailConfig.getUsing());
|
||||
Integer type = 0;
|
||||
if(emailConfig.getUsing()==1){
|
||||
user.setIsok(0);
|
||||
//初始化邮箱
|
||||
MimeMessage message = SendEmail.Emails(emailConfig);
|
||||
//注册完发激活链接
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
Integer a = SendEmail.sendEmail(message, user.getUsername(), uid, user.getEmail(),emailConfig,config);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
type = 1;
|
||||
}else{
|
||||
//直接注册
|
||||
user.setIsok(1);
|
||||
type = 2;
|
||||
}
|
||||
Integer ret = userService.register(user);
|
||||
jsonObject.put("ret",ret);
|
||||
jsonObject.put("zctype",type);
|
||||
} else {
|
||||
jsonObject.put("ret",-2);
|
||||
}
|
||||
Integer ret = userService.register(user);
|
||||
jsonObject.put("ret",ret);
|
||||
jsonObject.put("zctype",type);
|
||||
} else {
|
||||
jsonObject.put("ret",-2);
|
||||
}else{
|
||||
jsonObject.put("ret",-3);
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
@@ -87,23 +96,29 @@ public class UserController {
|
||||
@RequestMapping("/login.do")
|
||||
@ResponseBody
|
||||
public String login( HttpSession httpSession, String email, String password) {
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Integer ret = userService.login(email, password);
|
||||
if (ret > 0) {
|
||||
User user = userService.getUsers(email);
|
||||
if (user.getIsok() == 1) {
|
||||
httpSession.setAttribute("user", user);
|
||||
httpSession.setAttribute("email", user.getEmail());
|
||||
httpSession.setAttribute("pass", user.getPassword());
|
||||
jsonArray.add(1);
|
||||
} else if(ret==-1){
|
||||
jsonArray.add(-1);
|
||||
}else {
|
||||
jsonArray.add(-2);
|
||||
if(sysConfig.getRegister()==1){
|
||||
Integer ret = userService.login(email, password);
|
||||
if (ret > 0) {
|
||||
User user = userService.getUsers(email);
|
||||
if (user.getIsok() == 1) {
|
||||
httpSession.setAttribute("user", user);
|
||||
httpSession.setAttribute("email", user.getEmail());
|
||||
httpSession.setAttribute("pass", user.getPassword());
|
||||
jsonArray.add(1);
|
||||
} else if(ret==-1){
|
||||
jsonArray.add(-1);
|
||||
}else {
|
||||
jsonArray.add(-2);
|
||||
}
|
||||
} else {
|
||||
jsonArray.add(0);
|
||||
}
|
||||
} else {
|
||||
jsonArray.add(0);
|
||||
}else{
|
||||
jsonArray.add(-3);
|
||||
}
|
||||
|
||||
return jsonArray.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ package cn.hellohao.pojo;
|
||||
*/
|
||||
public class SysConfig {
|
||||
private Integer id;
|
||||
private String register;
|
||||
private Integer register;
|
||||
|
||||
public SysConfig() {
|
||||
}
|
||||
|
||||
public SysConfig(Integer id, String register) {
|
||||
public SysConfig(Integer id, Integer register) {
|
||||
this.id = id;
|
||||
this.register = register;
|
||||
}
|
||||
@@ -25,11 +25,11 @@ public class SysConfig {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRegister() {
|
||||
public Integer getRegister() {
|
||||
return register;
|
||||
}
|
||||
|
||||
public void setRegister(String register) {
|
||||
public void setRegister(Integer register) {
|
||||
this.register = register;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,6 +512,8 @@ Technology constantly updated, we will always move forward on the road ahead.
|
||||
,icon: 2 // icon
|
||||
});
|
||||
});
|
||||
}else if(data.ret ==-3){
|
||||
tanchuang('注册失败','本站禁止用户注册','error');
|
||||
} else {
|
||||
layui.use('layer', function(){
|
||||
var layer = layui.layer;
|
||||
@@ -554,6 +556,8 @@ Technology constantly updated, we will always move forward on the road ahead.
|
||||
toastr.error('您的账号是未激活状态,无法登陆。');
|
||||
} else if(data==-2){
|
||||
toastr.error('您的账号已被冻结。');
|
||||
}else if(data==-3){
|
||||
tanchuang('登录失败','本站禁止用户登录','error');
|
||||
}else {
|
||||
toastr.error('登录失败,请重试。');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user