|
|
|
@ -4,9 +4,7 @@ import com.community.pocket.entity.po.android.Token; |
|
|
|
|
import com.community.pocket.entity.vo.Result; |
|
|
|
|
import com.community.pocket.entity.vo.android.*; |
|
|
|
|
import com.community.pocket.repository.EmailDao; |
|
|
|
|
import com.community.pocket.repository.android.TokenDao; |
|
|
|
|
import com.community.pocket.repository.android.UserDao; |
|
|
|
|
import com.community.pocket.repository.android.VisitorPeopleDao; |
|
|
|
|
import com.community.pocket.repository.android.*; |
|
|
|
|
import com.community.pocket.util.EmailService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
@ -30,6 +28,9 @@ public class UserController { |
|
|
|
|
@Autowired |
|
|
|
|
private EmailService emailService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private TokenService tokenService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private TokenDao tokenDao; |
|
|
|
|
|
|
|
|
@ -111,39 +112,63 @@ public class UserController { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/uploadHeadImg") |
|
|
|
|
public InfoResponse upload(UserHeadImg userHeadImg) { |
|
|
|
|
return tokenService.checkToken(userHeadImg, new DoCheck<InfoResponse, UserHeadImg>() { |
|
|
|
|
@Override |
|
|
|
|
public InfoResponse ok(UserHeadImg userHeadImg) { |
|
|
|
|
if (userDao.uploadImg(userHeadImg)) { |
|
|
|
|
return new InfoResponse(Result.OK, InfoResponse.Msg.ok); |
|
|
|
|
} else { |
|
|
|
|
return new InfoResponse(Result.FAIL, InfoResponse.Msg.fail); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public InfoResponse fail() { |
|
|
|
|
return new InfoResponse(Result.FAIL, InfoResponse.Msg.fail, InfoResponse.Msg.token); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用户登录 |
|
|
|
|
* |
|
|
|
|
* @param username 用户 |
|
|
|
|
* @param password 密码 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/login") |
|
|
|
|
public LoginResponse login(String username, String password) { |
|
|
|
|
if(userDao.login(username, password)){ |
|
|
|
|
Token token=tokenDao.save(username); |
|
|
|
|
if (userDao.login(username, password)) { |
|
|
|
|
Token token = tokenDao.save(username); |
|
|
|
|
LoginResponse response; |
|
|
|
|
if(token!=null) { |
|
|
|
|
response=new LoginResponse(Result.OK, LoginResponse.Msg.ok,username); |
|
|
|
|
if (token != null) { |
|
|
|
|
response = new LoginResponse(Result.OK, LoginResponse.Msg.ok, username); |
|
|
|
|
response.setToken(token); |
|
|
|
|
}else{ |
|
|
|
|
response=new LoginResponse(Result.FAIL,LoginResponse.Msg.fail); |
|
|
|
|
} else { |
|
|
|
|
response = new LoginResponse(Result.FAIL, LoginResponse.Msg.fail); |
|
|
|
|
} |
|
|
|
|
return response; |
|
|
|
|
}else{ |
|
|
|
|
return new LoginResponse(Result.FAIL,LoginResponse.Msg.fail); |
|
|
|
|
} else { |
|
|
|
|
return new LoginResponse(Result.FAIL, LoginResponse.Msg.fail); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/login/token") |
|
|
|
|
public LoginResponse check(String token){ |
|
|
|
|
if(tokenDao.checkToken(token)){ |
|
|
|
|
Token t=tokenDao.get(token); |
|
|
|
|
if(t!=null){ |
|
|
|
|
LoginResponse response= new LoginResponse(Result.OK, LoginResponse.Msg.ok,t.getUsername()); |
|
|
|
|
response.setToken(t); |
|
|
|
|
public LoginResponse check(Token token) { |
|
|
|
|
return tokenService.checkToken(token, new DoCheck<LoginResponse, Token>() { |
|
|
|
|
@Override |
|
|
|
|
public LoginResponse ok(Token token) { |
|
|
|
|
LoginResponse response = new LoginResponse(Result.OK, LoginResponse.Msg.ok, token.getUsername()); |
|
|
|
|
response.setToken(token); |
|
|
|
|
return response; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return new LoginResponse(Result.FAIL, LoginResponse.Msg.fail); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public LoginResponse fail() { |
|
|
|
|
return new LoginResponse(Result.FAIL, LoginResponse.Msg.fail); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//检索投诉人
|
|
|
|
@ -163,19 +188,25 @@ public class UserController { |
|
|
|
|
//修改密码
|
|
|
|
|
@PostMapping("/my/info/modifyPwd") |
|
|
|
|
public InfoResponse modifyPwd(ModifyPwdForm modifyPwdForm) { |
|
|
|
|
if(tokenDao.checkToken(modifyPwdForm.getToken())){ |
|
|
|
|
if(userDao.login(modifyPwdForm.getUsername(),modifyPwdForm.getOldPassword())){ |
|
|
|
|
if(userDao.modifyPwd(modifyPwdForm)){ |
|
|
|
|
return new InfoResponse(Result.OK,InfoResponse.Msg.modify_pwd_ok); |
|
|
|
|
}else{ |
|
|
|
|
return new InfoResponse(Result.FAIL,InfoResponse.Msg.modify_pwd_fail); |
|
|
|
|
return tokenService.checkToken(modifyPwdForm, new DoCheck<InfoResponse, ModifyPwdForm>() { |
|
|
|
|
@Override |
|
|
|
|
public InfoResponse ok(ModifyPwdForm modifyPwdForm) { |
|
|
|
|
if (userDao.login(modifyPwdForm.getUsername(), modifyPwdForm.getOldPassword())) { |
|
|
|
|
if (userDao.modifyPwd(modifyPwdForm)) { |
|
|
|
|
return new InfoResponse(Result.OK, InfoResponse.Msg.modify_pwd_ok); |
|
|
|
|
} else { |
|
|
|
|
return new InfoResponse(Result.FAIL, InfoResponse.Msg.modify_pwd_fail); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return new InfoResponse(Result.FAIL, InfoResponse.Msg.modify_oldpwd_fail); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
return new InfoResponse(Result.FAIL,InfoResponse.Msg.modify_oldpwd_fail); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
return new InfoResponse(Result.FAIL,InfoResponse.Msg.token); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public InfoResponse fail() { |
|
|
|
|
return new InfoResponse(Result.FAIL, InfoResponse.Msg.token); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|