Commit 825d21a5 authored by hujun's avatar hujun

公告

parent 85e94731
......@@ -12,6 +12,7 @@ namespace app\index\controller;
use app\api_broker\service\PushMessageService;
use app\index\extend\Basic;
use app\model\PushFeed;
use app\model\SFile;
use think\Request;
class Notice extends Basic
......@@ -90,8 +91,22 @@ class Notice extends Basic
$data['steel_phone'] = 0;
$data['type'] = 1;
$data['annex_file_name'] = $this->params['annex_file_name'];
$num = $this->m_push->editData($data);
if ($num < 1) {
$id = $this->m_push->addData($data);
if ($id < 1) {
if ($this->params['annex_file_name']) {
$s_file = new SFile();
$annex_file_name = explode(',', $this->params['annex_file_name']);
foreach ($annex_file_name as $k=>$v) {
$file_data['file_name'] = $v;
$file_data['new_id'] = $id;
$file_data['type'] = 2;
$file_data['status'] = 0;
$s_file->insertData($file_data);
}
}
return $this->response(101, '新增公告失败!');
}
......
......@@ -21,9 +21,10 @@ class PushFeed extends BaseModel
* @return int|true
* @throws \think\Exception
*/
public function editNum($id, $field, $way = 1, $step = 1) {
public function editNum($id, $field, $way = 1, $step = 1)
{
$this->where('id',$id);
$this->where('id', $id);
if ($way == 1) {
$result = $this->setInc($field, $step);
} else {
......@@ -43,7 +44,8 @@ class PushFeed extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getFeedInfo($field = '', $params = '', $order = 'id ASC') {
public function getFeedInfo($field = '', $params = '', $order = 'id ASC')
{
return $this->field($field)
->where($params)
->order($order)
......@@ -61,7 +63,8 @@ class PushFeed extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListAgent($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
public function getListAgent($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
{
return $this->field($field)
->alias('a')
->join('a_agents b', 'a.publisher_id = b.id', 'left')
......@@ -76,10 +79,35 @@ class PushFeed extends BaseModel
* @param $params
* @return int|string
*/
public function getListAgentTotal($params) {
public function getListAgentTotal($params)
{
return $this->alias('a')
->join('a_agents b', 'a.publisher_id = b.id', 'left')
->where($params)
->count();
}
/**
* @param $data
* @param bool $kv
* @param string $key
* @param bool $confirm
* @return PushFeed|int|string
*/
public function addData($data, $kv = false, $key = 'id', $confirm = false)
{
$this->allowField(true);
if ($confirm) {//是否验证
$this->validate($confirm);
}
if ($kv) {//编辑
$res = $this->where("$key", $kv)->update($data);
} else {
$res = $this->insertGetId($data);
}
return $res;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment