-- ----------------------------
-- Table structure for fs_web_mail
-- ----------------------------
DROP TABLE IF EXISTS `fs_web_mail`;
CREATE TABLE `fs_web_mail` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user_id` int(10) NOT NULL COMMENT '用户',
`info` varchar(250) NOT NULL COMMENT '内容',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
`create_time` int(10) NOT NULL COMMENT '添加时间',
`update_time` int(10) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7317 DEFAULT CHARSET=utf8 COMMENT='站内信';
-- ----------------------------
-- Table structure for `fs_feedback`
-- ----------------------------
DROP TABLE IF EXISTS `fs_feedback`;
CREATE TABLE `fs_feedback` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`user_id` int(10) NOT NULL COMMENT '用户',
`content` varchar(250) NOT NULL COMMENT '内容',
`create_time` int(10) NOT NULL COMMENT '提交时间',
`update_time` int(10) NOT NULL COMMENT '更新时间',
`reply` varchar(250) DEFAULT NULL COMMENT '回复内容',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COMMENT='意见反馈';
<?php
/**
* Created by PhpStorm.
* User: lcz
* Date: 2018/6/5
* Time: 11:17
* 反馈意见
*/
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\WebMail;
use think\Db;
class Feedback extends Api {
protected $noNeedRight = ['*'];
/**
* 添加反馈
* @param token
* @param content 反馈意见
*/
public function add(){
$userId = $this->auth->id;
$content = input('post.content');
!$content && $this->error('请填写反馈意见');
$model = new \app\common\model\Feedback();
$res = $model->isUpdate(false)->save([
'user_id' => $userId,
'content' => $content,
]);
if($res) {
$this->success('提交成功');
} else {
$this->error('添加出错,请稍候再试');
}
}
/**
* 我的反馈记录
* @param token
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index(){
$userId = $this->auth->id;
$model = new \app\common\model\Feedback();
$rows = Db::name('feedback')->where(['user_id' => $userId])
->field('id, content, from_unixtime(create_time) as create_time, reply')
->order(['create_time' => 'DESC'])
->select();
$this->success('查询成功', $rows);
}
/**
* 站内信
*/
public function webmail(){
$rows = Db::name('webMail')
->where(['user_id' => $this->auth->id])
->field('id, info, from_unixtime(create_time) as create_time')
->order(['create_time' => 'desc'])
->page(input('post.page', 1, 'intval'))
->select();
Db::name('webMail')->where(['user_id' => $this->auth->id])
->setField('status', WebMail::STATUS_Y);
$this->success('查询成功', $rows);
}
}