|
@@ -24,15 +24,23 @@ class Api
|
|
|
|
|
|
public function get($name, $key, $set, $update = false, $num = 1)
|
|
|
{
|
|
|
- $where['key'] = $key;
|
|
|
- $template = Dever::db('poster/template')->state($where);
|
|
|
- if (!$update) {
|
|
|
- $update = $template['update'];
|
|
|
+ if (strstr($key, ',') || is_numeric($key)) {
|
|
|
+ $where['ids'] = $key;
|
|
|
+ } else {
|
|
|
+ $where['key'] = $key;
|
|
|
}
|
|
|
+
|
|
|
+ $template = Dever::db('poster/template')->getAll($where);
|
|
|
+
|
|
|
$key = array_rand($template, 1);
|
|
|
$template = $template[$key];
|
|
|
|
|
|
if ($template) {
|
|
|
+
|
|
|
+ if (!$update) {
|
|
|
+ $update = $template['update'];
|
|
|
+ }
|
|
|
+
|
|
|
$where = array();
|
|
|
$where['template_id'] = $template['id'];
|
|
|
$model = Dever::db('poster/model')->state($where);
|
|
@@ -53,6 +61,8 @@ class Api
|
|
|
|
|
|
return Dever::pic($result);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ return Dever::pic($template['background']);
|
|
|
}
|
|
|
}
|
|
|
|