|
|
@ -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.Result; |
|
|
|
import com.community.pocket.entity.vo.android.*; |
|
|
|
import com.community.pocket.entity.vo.android.*; |
|
|
|
import com.community.pocket.repository.EmailDao; |
|
|
|
import com.community.pocket.repository.EmailDao; |
|
|
|
import com.community.pocket.repository.android.TokenDao; |
|
|
|
import com.community.pocket.repository.android.*; |
|
|
|
import com.community.pocket.repository.android.UserDao; |
|
|
|
|
|
|
|
import com.community.pocket.repository.android.VisitorPeopleDao; |
|
|
|
|
|
|
|
import com.community.pocket.util.EmailService; |
|
|
|
import com.community.pocket.util.EmailService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
@ -30,6 +28,9 @@ public class UserController { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private EmailService emailService; |
|
|
|
private EmailService emailService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private TokenService tokenService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private TokenDao tokenDao; |
|
|
|
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 username 用户 |
|
|
|
* @param password 密码 |
|
|
|
* @param password 密码 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@PostMapping("/login") |
|
|
|
@PostMapping("/login") |
|
|
|
public LoginResponse login(String username, String password) { |
|
|
|
public LoginResponse login(String username, String password) { |
|
|
|
if(userDao.login(username, password)){ |
|
|
|
if (userDao.login(username, password)) { |
|
|
|
Token token=tokenDao.save(username); |
|
|
|
Token token = tokenDao.save(username); |
|
|
|
LoginResponse response; |
|
|
|
LoginResponse response; |
|
|
|
if(token!=null) { |
|
|
|
if (token != null) { |
|
|
|
response=new LoginResponse(Result.OK, LoginResponse.Msg.ok,username); |
|
|
|
response = new LoginResponse(Result.OK, LoginResponse.Msg.ok, username); |
|
|
|
response.setToken(token); |
|
|
|
response.setToken(token); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
response=new LoginResponse(Result.FAIL,LoginResponse.Msg.fail); |
|
|
|
response = new LoginResponse(Result.FAIL, LoginResponse.Msg.fail); |
|
|
|
} |
|
|
|
} |
|
|
|
return response; |
|
|
|
return response; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return new LoginResponse(Result.FAIL,LoginResponse.Msg.fail); |
|
|
|
return new LoginResponse(Result.FAIL, LoginResponse.Msg.fail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/login/token") |
|
|
|
@PostMapping("/login/token") |
|
|
|
public LoginResponse check(String token){ |
|
|
|
public LoginResponse check(Token token) { |
|
|
|
if(tokenDao.checkToken(token)){ |
|
|
|
return tokenService.checkToken(token, new DoCheck<LoginResponse, Token>() { |
|
|
|
Token t=tokenDao.get(token); |
|
|
|
@Override |
|
|
|
if(t!=null){ |
|
|
|
public LoginResponse ok(Token token) { |
|
|
|
LoginResponse response= new LoginResponse(Result.OK, LoginResponse.Msg.ok,t.getUsername()); |
|
|
|
LoginResponse response = new LoginResponse(Result.OK, LoginResponse.Msg.ok, token.getUsername()); |
|
|
|
response.setToken(t); |
|
|
|
response.setToken(token); |
|
|
|
return response; |
|
|
|
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") |
|
|
|
@PostMapping("/my/info/modifyPwd") |
|
|
|
public InfoResponse modifyPwd(ModifyPwdForm modifyPwdForm) { |
|
|
|
public InfoResponse modifyPwd(ModifyPwdForm modifyPwdForm) { |
|
|
|
if(tokenDao.checkToken(modifyPwdForm.getToken())){ |
|
|
|
return tokenService.checkToken(modifyPwdForm, new DoCheck<InfoResponse, ModifyPwdForm>() { |
|
|
|
if(userDao.login(modifyPwdForm.getUsername(),modifyPwdForm.getOldPassword())){ |
|
|
|
@Override |
|
|
|
if(userDao.modifyPwd(modifyPwdForm)){ |
|
|
|
public InfoResponse ok(ModifyPwdForm modifyPwdForm) { |
|
|
|
return new InfoResponse(Result.OK,InfoResponse.Msg.modify_pwd_ok); |
|
|
|
if (userDao.login(modifyPwdForm.getUsername(), modifyPwdForm.getOldPassword())) { |
|
|
|
}else{ |
|
|
|
if (userDao.modifyPwd(modifyPwdForm)) { |
|
|
|
return new InfoResponse(Result.FAIL,InfoResponse.Msg.modify_pwd_fail); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|