123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace app\admin\controller\sys_manage;
- use app\admin\service\sys_manage\FieldService;
- use app\admin\validate\sys_manage\FieldValidate;
- use app\controller\Curd;
- use app\model\Content;
- use app\model\SysField;
- use Illuminate\Support\Facades\Schema;
- use support\Request;
- use support\Response;
- class FieldController extends Curd
- {
- public function __construct()
- {
- $this->model = new SysField();
- }
- /**
- * @Desc 字段列表
- * @Author Gorden
- * @Date 2024/2/22 14:49
- *
- * @param Request $request
- * @return \support\Response
- */
- public function fieldList(Request $request)
- {
- return FieldService::fieldList($request);
- }
- public function selectList(Request $request): Response
- {
- [$where, $format, $limit, $field, $order] = $this->selectInput($request);
- $query = $this->doSelect($where, $field, $order);
- return $this->doFormat($query, $format, 1000);
- }
- /**
- * @Desc 字段详情
- * @Author Gorden
- * @Date 2024/2/22 14:54
- *
- * @param $id
- * @return \support\Response
- */
- public function fieldInfo($id)
- {
- return FieldService::fieldInfo($id);
- }
- /**
- * @Desc 新建字段
- * @Author Gorden
- * @Date 2024/2/22 14:32
- *
- * @param Request $request
- * @return \support\Response
- */
- public function addField(Request $request)
- {
- // $validate = new FieldValidate();
- // if (!$validate->scene('add')->check($request->post())) {
- // return json_fail($validate->getError());
- // }
- // 验证数据表是否存在
- if (!FieldService::checkTableExist($request->post('field_table'))) {
- return json_fail('数据表不存在');
- }
- // 验证字段重复
- if (FieldService::checkFieldExist($request->post('field_table'), $request->post('field_column_key'))) {
- return json_fail('字段已存在,请勿重复添加');
- }
- return FieldService::addField($request->post());
- }
- /**
- * @Desc 修改字段
- * @Author Gorden
- * @Date 2024/2/22 14:41
- *
- * @param $id
- * @param Request $request
- * @return \support\Response
- */
- public function updateFields($id, Request $request)
- {
- // $validate = new FieldValidate();
- // if (!$validate->scene('update')->check($request->post())) {
- // return json_fail($validate->getError());
- // }
- // 验证数据表是否存在
- if (!FieldService::checkTableExist($request->post('field_table'))) {
- return json_fail('数据表不存在');
- }
- return FieldService::updateField($id, $request->post());
- }
- /**
- * @Desc 修改字段状态
- * @Author Gorden
- * @Date 2024/2/22 15:05
- *
- * @param $id
- * @param Request $request
- * @return \support\Response
- */
- public function updateStatus($id, Request $request)
- {
- $validate = new FieldValidate();
- if (!$validate->scene('update_status')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return FieldService::updateStatus($id, $request->post());
- }
- /**
- * @Desc 删除字段
- * @Author Gorden
- * @Date 2024/2/22 15:08
- *
- * @param $id
- * @return \support\Response
- */
- public function delField(Request $request)
- {
- $fieldId = $request->post('field_id');
- return FieldService::delField($fieldId);
- }
- }
|