Older/WebApplication/model/User.cpp
amass b6e0681489
All checks were successful
Deploy / PullDocker (push) Successful in 4s
Deploy / Build (push) Successful in 2m8s
Deploy Docker Images / Docusaurus build and Server deploy (push) Successful in 13s
add code.
2024-11-02 00:30:14 +08:00

24 lines
677 B
C++

#include "User.h"
#include <Wt/Dbo/Impl.h>
DBO_INSTANTIATE_TEMPLATES(User)
Wt::Dbo::dbo_traits<User>::IdType User::stringToId(const std::string &s) {
std::size_t pos = std::string::npos;
auto result = std::stoll(s, &pos);
if (pos != s.size())
return Wt::Dbo::dbo_traits<User>::invalidId();
else
return result;
}
Posts User::latestPosts(int count) const {
return posts.find().where("state = ?").bind(Post::Published).orderBy("date desc").limit(count);
}
Posts User::allPosts(Post::State state) const {
return posts.find().where("state = ?").bind(state).orderBy("date desc");
}
User::User() : role(Visitor), failedLoginAttempts(0) {
}