source: ProjectBuilder/devel/pb-server/lib/ProjectBuilder/Model/Confs.pm@ 2077

Last change on this file since 2077 was 2077, checked in by Bruno Cornec, 8 years ago

First attempt to add a Mojolicious web app with swagger providing a RESTful API for pb

File size: 968 bytes
Line 
1package ProjectBuilder::Model::Confs;
2use Mojo::Base -base;
3use ProjectBuilder::Conf;
4use Data::Dumper;
5
6sub add {
7 my ($self, $conf) = @_;
8 my $sql = 'insert into confs (title, body) values (?, ?) returning id';
9 #return $self->pg->db->query($sql, $conf->{title}, $conf->{body})->hash->{id};
10}
11
12sub all { #shift->pg->db->query('select * from confs')->hashes->to_array
13 my @confs;
14 my $i = 0;
15 foreach my $k (pb_conf_get_all()) {
16 my ($v) = pb_conf_get($k);
17 $confs[$i] = { id => $k,
18 body => $v->{"pb"},
19 };
20 $i++;
21 }
22 #print "PARAMS: ".Dumper(@confs)."\n";
23 return(\@confs);
24}
25
26sub find {
27 my ($self, $id) = @_;
28 #return $self->pg->db->query('select * from confs where id = ?', $id)->hash;
29}
30
31sub remove { #shift->pg->db->query('delete from confs where id = ?', shift)
32}
33
34sub save {
35 my ($self, $id, $conf) = @_;
36 my $sql = 'update confs set title = ?, body = ? where id = ?';
37 #$self->pg->db->query($sql, $conf->{title}, $conf->{body}, $id);
38}
39
401;
Note: See TracBrowser for help on using the repository browser.