// Path: el-bombillo-account-service/src/main/java/org/bitionaire/elbombillo/account/model/Account.java
// @ToString @EqualsAndHashCode
// public class Account implements Serializable {
// 
//     private static final long serialVersionUID = 1L;
// 
//     @JsonView({ AccountRepresentation.Abbreviated.class, AccountRepresentation.Complete.class })
//     @Getter private final Long id;
// 
//     @JsonView({ AccountRepresentation.Abbreviated.class, AccountRepresentation.Complete.class })
//     @Getter private final String username;
// 
//     @JsonView({ AccountRepresentation.Complete.class })
//     @Getter private final String firstName;
// 
//     @JsonView({ AccountRepresentation.Complete.class })
//     @Getter private final String lastName;
// 
//     @JsonView({ AccountRepresentation.Complete.class })
//     @Getter private final String email;
// 
//     @JsonView({ AccountRepresentation.Abbreviated.class, AccountRepresentation.Complete.class })
//     @InjectLink(
//             resource = AccountResource.class,
//             style = InjectLink.Style.ABSOLUTE,
//             method = "get",
//             bindings = @Binding(name = "username", value = "${instance.username}"),
//             rel = "self"
//     )
//     @Getter private URI self;
// 
//     @JsonCreator
//     public Account(@JsonProperty("id") final Long id,
//                    @JsonProperty("username") final String username,
//                    @JsonProperty("firstName") final String firstName,
//                    @JsonProperty("lastName") final String lastName,
//                    @JsonProperty("email") final String email) {
//         this.id = id;
//         this.username = username;
//         this.firstName = firstName;
//         this.lastName = lastName;
//         this.email = email;
//     }
// 
// }
// 
// Path: el-bombillo-account-service/src/main/java/org/bitionaire/elbombillo/account/persistence/orm/AccountMapper.java
// public class AccountMapper implements ResultSetMapper<Account> {
// 
//     @Override
//     public Account map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException {
//         return new Account(r.getLong("id"), r.getString("username"), r.getString("firstname"), r.getString("lastname"), r.getString("email"));
//     }
// }


import org.bitionaire.elbombillo.account.model.Account;
import org.bitionaire.elbombillo.account.persistence.orm.AccountMapper;
import org.skife.jdbi.v2.sqlobject.*;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
import java.util.List;
package org.bitionaire.elbombillo.account.persistence.dao;



@RegisterMapper(AccountMapper.class)
public interface AccountDAO {

    @SqlQuery("select id, username, firstname, lastname, email from account where id = :id")
    Account findAccount(@Bind("id") final long id);

    @SqlQuery("select id, username, firstname, lastname, email from account where username = :username")
    Account findAccount(@Bind("username") final String username);

    @SqlQuery("select id, username, firstname, lastname, email from account limit :limit offset :offset")
    List<Account> allAccounts(@Bind("limit") final int limit, @Bind("offset") final int offset);

    @GetGeneratedKeys
    @SqlUpdate("insert into account (username, firstname, lastname, email) values (:username, :firstName, :lastName, :email)")
    long insertAccount(@BindBean final Account account);

    @SqlQuery("select count(id) from account")
    long countAccounts();

    @SqlUpdate("update account set username=:username, firstname=:firstname, lastname=:lastname, email=:email whree id=:id")
    void updateAccount(@BindBean final Account account);

// Path: el-bombillo-account-service/src/main/java/org/bitionaire/elbombillo/account/model/Account.java
// @ToString @EqualsAndHashCode
// public class Account implements Serializable {
// 
//     private static final long serialVersionUID = 1L;
// 
//     @JsonView({ AccountRepresentation.Abbreviated.class, AccountRepresentation.Complete.class })
//     @Getter private final Long id;
// 
//     @JsonView({ AccountRepresentation.Abbreviated.class, AccountRepresentation.Complete.class })
//     @Getter private final String username;
// 
//     @JsonView({ AccountRepresentation.Complete.class })
//     @Getter private final String firstName;
// 
//     @JsonView({ AccountRepresentation.Complete.class })
//     @Getter private final String lastName;
// 
//     @JsonView({ AccountRepresentation.Complete.class })
//     @Getter private final String email;
// 
//     @JsonView({ AccountRepresentation.Abbreviated.class, AccountRepresentation.Complete.class })
//     @InjectLink(
//             resource = AccountResource.class,
//             style = InjectLink.Style.ABSOLUTE,
//             method = "get",
//             bindings = @Binding(name = "username", value = "${instance.username}"),
//             rel = "self"
//     )
//     @Getter private URI self;
// 
//     @JsonCreator
//     public Account(@JsonProperty("id") final Long id,
//                    @JsonProperty("username") final String username,
//                    @JsonProperty("firstName") final String firstName,
//                    @JsonProperty("lastName") final String lastName,
//                    @JsonProperty("email") final String email) {
//         this.id = id;
//         this.username = username;
//         this.firstName = firstName;
//         this.lastName = lastName;
//         this.email = email;
//     }
// 
// }
// 
// Path: el-bombillo-account-service/src/main/java/org/bitionaire/elbombillo/account/persistence/orm/AccountMapper.java
// public class AccountMapper implements ResultSetMapper<Account> {
// 
//     @Override
//     public Account map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException {
//         return new Account(r.getLong("id"), r.getString("username"), r.getString("firstname"), r.getString("lastname"), r.getString("email"));
//     }
// }


// Path: el-bombillo-account-service/src/main/java/org/bitionaire/elbombillo/account/persistence/dao/AccountDAO.java
import org.bitionaire.elbombillo.account.model.Account;
import org.bitionaire.elbombillo.account.persistence.orm.AccountMapper;
import org.skife.jdbi.v2.sqlobject.*;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
import java.util.List;

package org.bitionaire.elbombillo.account.persistence.dao;



@RegisterMapper(AccountMapper.class)
public interface AccountDAO {

    @SqlQuery("select id, username, firstname, lastname, email from account where id = :id")
    Account findAccount(@Bind("id") final long id);

    @SqlQuery("select id, username, firstname, lastname, email from account where username = :username")
    Account findAccount(@Bind("username") final String username);

    @SqlQuery("select id, username, firstname, lastname, email from account limit :limit offset :offset")
    List<Account> allAccounts(@Bind("limit") final int limit, @Bind("offset") final int offset);

    @GetGeneratedKeys
    @SqlUpdate("insert into account (username, firstname, lastname, email) values (:username, :firstName, :lastName, :email)")
    long insertAccount(@BindBean final Account account);

    @SqlQuery("select count(id) from account")
    long countAccounts();

    @SqlUpdate("update account set username=:username, firstname=:firstname, lastname=:lastname, email=:email whree id=:id")
    void updateAccount(@BindBean final Account account);

    @SqlUpdate("delete from account where id=:id")