12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace app\controller\sys;
- use think\facade\View;
- use app\model\GuestBook as GuestBookModel;
- use app\utils\ReUtils;
- class GuestBook extends Base
- {
- protected $modelName = "GuestBook";
- /**
- * 显示资源列表
- *
- * @return \think\Response
- */
- public function index()
- {
- $list = GuestBookModel::order('id desc')->paginate();
- View::assign('list', $list);
- return View::fetch();
- }
- /**
- * 标记状态修改 1,正常; 0,非正常
- */
- public function status(int $id)
- {
- try {
- $info = GuestBookModel::find($id);
- $info->mark = 1 - $info['mark'];
- $info->save();
- return ReUtils::success();
- } catch (\Exception $e) {
- return ReUtils::error($e->getMessage());
- }
- }
- /**
- * 保存备注
- * @param int $id
- * @param string $remark
- * @return \think\Response\Json
- *
- */
- public function remark($id = 0, $remark = '')
- {
- try {
- $info = GuestBookModel::find($id);
- $info->remark = $remark;
- $info->save();
- return json(['code' => 0, 'msg' => '修改成功!']);
- } catch (\Exception $e) {
- return json(['code' => 1, 'msg' => $e->getMessage()]);
- }
- }
- }
|