#I66JJR 列表模块的搜索功能有BUG

This commit is contained in:
hdm 2022-12-18 10:14:52 +08:00
parent 6c601a672b
commit 81a2152c89
7 changed files with 12 additions and 12 deletions

View File

@ -36,7 +36,7 @@ class Article extends BaseController
$param = get_params(); $param = get_params();
$where = []; $where = [];
if (!empty($param['keywords'])) { if (!empty($param['keywords'])) {
$where[] = ['a.id|a.title|a.keywords|a.desc|a.content|c.title', 'like', '%' . $param['keywords'] . '%']; $where[] = ['a.id|a.title|a.desc|a.content|c.title', 'like', '%' . $param['keywords'] . '%'];
} }
if (!empty($param['cate_id'])) { if (!empty($param['cate_id'])) {
$where[] = ['a.cate_id', '=', $param['cate_id']]; $where[] = ['a.cate_id', '=', $param['cate_id']];

View File

@ -36,7 +36,7 @@ class Gallery extends BaseController
$param = get_params(); $param = get_params();
$where = []; $where = [];
if (!empty($param['keywords'])) { if (!empty($param['keywords'])) {
$where[] = ['a.id|a.title|a.keywords|a.desc|c.title', 'like', '%' . $param['keywords'] . '%']; $where[] = ['a.id|a.title|a.desc|c.title', 'like', '%' . $param['keywords'] . '%'];
} }
if (!empty($param['cate_id'])) { if (!empty($param['cate_id'])) {
$where[] = ['a.cate_id', '=', $param['cate_id']]; $where[] = ['a.cate_id', '=', $param['cate_id']];

View File

@ -36,7 +36,7 @@ class Goods extends BaseController
$param = get_params(); $param = get_params();
$where = []; $where = [];
if (!empty($param['keywords'])) { if (!empty($param['keywords'])) {
$where[] = ['a.id|a.title|a.keywords|a.desc|a.content|c.title', 'like', '%' . $param['keywords'] . '%']; $where[] = ['a.id|a.title|a.desc|a.content|c.title', 'like', '%' . $param['keywords'] . '%'];
} }
if (!empty($param['cate_id'])) { if (!empty($param['cate_id'])) {
$where[] = ['a.cate_id', '=', $param['cate_id']]; $where[] = ['a.cate_id', '=', $param['cate_id']];

View File

@ -39,7 +39,7 @@ class Article extends Model
{ {
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$order = empty($param['order']) ? 'a.id desc' : $param['order']; $order = empty($param['order']) ? 'a.id desc' : $param['order'];
$list = $this->where($where) $list = self::where($where)
->field('a.*,c.id as cate_id,c.title as cate_title,u.nickname as admin_name') ->field('a.*,c.id as cate_id,c.title as cate_title,u.nickname as admin_name')
->alias('a') ->alias('a')
->join('ArticleCate c', 'a.cate_id = c.id') ->join('ArticleCate c', 'a.cate_id = c.id')

View File

@ -38,7 +38,7 @@ class Gallery extends Model
{ {
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$order = empty($param['order']) ? 'a.id desc' : $param['order']; $order = empty($param['order']) ? 'a.id desc' : $param['order'];
$list = $this->where($where) $list = self::where($where)
->field('a.*,c.title as cate_title,u.nickname as admin_name') ->field('a.*,c.title as cate_title,u.nickname as admin_name')
->alias('a') ->alias('a')
->join('ArticleCate c', 'a.cate_id = c.id') ->join('ArticleCate c', 'a.cate_id = c.id')

View File

@ -37,7 +37,7 @@ class Goods extends Model
{ {
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$order = empty($param['order']) ? 'a.id desc' : $param['order']; $order = empty($param['order']) ? 'a.id desc' : $param['order'];
$list = $this->where($where) $list = self::where($where)
->field('a.*,c.title as cate_title,u.nickname as admin_name') ->field('a.*,c.title as cate_title,u.nickname as admin_name')
->alias('a') ->alias('a')
->join('GoodsCate c', 'a.cate_id = c.id') ->join('GoodsCate c', 'a.cate_id = c.id')

View File

@ -17,7 +17,7 @@ class <model> extends Model
{ {
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit']; $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
$order = empty($param['order']) ? '<pk> desc' : $param['order']; $order = empty($param['order']) ? '<pk> desc' : $param['order'];
$list = $this->where($where)->field('<fieldlist>')->order($order)->paginate($rows, false, ['query' => $param]); $list = self::where($where)->field('<fieldlist>')->order($order)->paginate($rows, false, ['query' => $param]);
return $list; return $list;
} }
@ -30,7 +30,7 @@ class <model> extends Model
$insertId = 0; $insertId = 0;
try { try {
$param['create_time'] = time(); $param['create_time'] = time();
$insertId = $this->strict(false)->field(true)->insertGetId($param); $insertId = self::strict(false)->field(true)->insertGetId($param);
add_log('add', $insertId, $param); add_log('add', $insertId, $param);
} catch(\Exception $e) { } catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage()); return to_assign(1, '操作失败,原因:'.$e->getMessage());
@ -46,7 +46,7 @@ class <model> extends Model
{ {
try { try {
$param['update_time'] = time(); $param['update_time'] = time();
$this->where('<pk>', $param['<pk>'])->strict(false)->field(true)->update($param); self::where('<pk>', $param['<pk>'])->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param); add_log('edit', $param['id'], $param);
} catch(\Exception $e) { } catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage()); return to_assign(1, '操作失败,原因:'.$e->getMessage());
@ -61,7 +61,7 @@ class <model> extends Model
*/ */
public function get<model>ById($id) public function get<model>ById($id)
{ {
$info = $this->where('<pk>', $id)->find(); $info = self::where('<pk>', $id)->find();
return $info; return $info;
} }
@ -76,7 +76,7 @@ class <model> extends Model
//逻辑删除 //逻辑删除
try { try {
$param['delete_time'] = time(); $param['delete_time'] = time();
$this->where('<pk>', $id)->update(['delete_time'=>time()]); self::where('<pk>', $id)->update(['delete_time'=>time()]);
add_log('delete', $id); add_log('delete', $id);
} catch(\Exception $e) { } catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage()); return to_assign(1, '操作失败,原因:'.$e->getMessage());
@ -85,7 +85,7 @@ class <model> extends Model
else{ else{
//物理删除 //物理删除
try { try {
$this->where('<pk>', $id)->delete(); self::where('<pk>', $id)->delete();
add_log('delete', $id); add_log('delete', $id);
} catch(\Exception $e) { } catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage()); return to_assign(1, '操作失败,原因:'.$e->getMessage());