Merge pull request 'update' (#170) from zhangwei into dev

Reviewed-on: #170
This commit is contained in:
weiz 2024-01-15 09:31:22 +08:00
commit de6058aaa5
2 changed files with 10 additions and 11 deletions

View File

@ -15,7 +15,7 @@
namespace app\adminapi\lists\cost;
use app\adminapi\lists\BaseAdminDataLists;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\cost\CostSubject;
use app\common\lists\ListsSearchInterface;
@ -38,7 +38,7 @@ class CostSubjectLists extends BaseAdminDataLists implements ListsSearchInterfac
public function setSearch(): array
{
return [
'=' => ['sn', 'subject1'],
'%like%' => ['sn', 'subject1', 'subject12'],
];
}

View File

@ -41,11 +41,10 @@ class CostSubjectLogic extends BaseLogic
Db::startTrans();
try {
CostSubject::create([
'sn' => $params['sn'],
'subject1' => $params['subject1'],
'subject2' => $params['subject2'],
'sn' => $params['sn'],
'subject1' => $params['subject1'],
'subject2' => $params['subject2'] ?? '',
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -68,11 +67,11 @@ class CostSubjectLogic extends BaseLogic
Db::startTrans();
try {
CostSubject::where('id', $params['id'])->update([
'sn' => $params['sn'],
'subject1' => $params['subject1'],
'subject2' => $params['subject2'],
'sn' => $params['sn'],
'subject1' => $params['subject1'],
'subject2' => $params['subject2'] ?? '',
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -105,6 +104,6 @@ class CostSubjectLogic extends BaseLogic
*/
public static function detail($params): array
{
return CostSubject::findOrEmpty($params['id'])->toArray();
return CostSubject::field('id,sn,subject1,subject2')->findOrEmpty($params['id'])->toArray();
}
}