123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- /**
- * ============================================================================
- *
- * ============================================================================
- * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
- * 网站地址: https://www.valimart.net/
- * ----------------------------------------------------------------------------
- *
- * ============================================================================
- * 数据层模型
- */
- class Appadv extends BaseModel
- {
- /**
- * 获取APP广告位列表
- * @author csdeshang
- * @param array $condition 查询条件
- * @param int $pagesize 分页页数
- * @param str $orderby 排序
- * @return array 二维数组
- */
- public function getAppadvpositionList($condition = array(), $pagesize = '', $orderby = 'ap_id desc') {
- if ($pagesize) {
- $result = Db::name('appadvposition')->where($condition)->order($orderby)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
- $this->page_info = $result;
- return $result->items();
- } else {
- return Db::name('appadvposition')->where($condition)->order($orderby)->select()->toArray();
- }
- }
- /**
- * 根据条件查询多条记录
- * @author csdeshang
- * @param array $condition 查询条件
- * @param int $pagesize 分页页数
- * @param int $limit 数量限制
- * @param str $orderby 排序
- * @return array 二维数组
- */
- public function getAppadvList($condition = array(), $pagesize = '', $limit = 0, $orderby = 'adv_sort asc') {
- if ($pagesize) {
- $result = Db::name('appadv')->where($condition)->order($orderby)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
- $this->page_info = $result;
- return $result->items();
- } else {
- return Db::name('appadv')->where($condition)->order($orderby)->select()->toArray();
- }
- }
- /**
- * 新增广告位
- * @author csdeshang
- * @param array $data 参数内容
- * @return bool 布尔类型的返回结果
- */
- public function addAppadvposition($data) {
- return Db::name('appadvposition')->insertGetId($data);
- }
- /**
- * 新增广告
- * @author csdeshang
- * @param array $data 参数内容
- * @return bool 布尔类型的返回结果
- */
- public function addAppadv($data) {
- $result = Db::name('appadv')->insertGetId($data);
- $apId = (int) $data['ap_id'];
- dkcache("appadv/{$apId}");
- return $result;
- }
- /**
- * 更新广告位记录
- * @author csdeshang
- * @param array $data 更新内容
- * @return bool
- */
- public function editAppadvposition($ap_id,$data) {
- dkcache("appadv/{$ap_id}");
- return Db::name('appadvposition')->where('ap_id', $ap_id)->update($data);
- }
-
- /**
- * 获取一个app广告位
- * @author csdeshang
- * @param array $condition 查询条件
- * @return array
- */
- public function getOneAppadvposition($condition = array()) {
- return Db::name('appadvposition')->where($condition)->find();
- }
- /**
- * 删除一个广告位
- * @author csdeshang
- * @param array $ap_id 参数内容
- * @return bool 布尔类型的返回结果
- */
- public function delAppadvposition($ap_id) {
- $apId = (int) $ap_id;
- dkcache("appadv/{$apId}");
- return Db::name('appadvposition')->where('ap_id', $apId)->delete();
- }
- /**
- * 获取一个广告位
- * @author csdeshang
- * @param array $condition 条件
- * @return type
- */
- public function getOneAppadv($condition = array()) {
- return Db::name('appadv')->where($condition)->find();
- }
- /**
- * 更新记录
- * @author csdeshang
- * @param array $data 更新内容
- * @return bool
- */
- public function editAppadv($adv_id,$data) {
- $adv_array = Db::name('appadv')->where('adv_id', $adv_id)->find();
- if ($adv_array) {
- // drop cache
- $apId = (int) $adv_array['ap_id'];
- dkcache("appadv/{$apId}");
- }
- return Db::name('appadv')->where('adv_id', $adv_id)->update($data);
- }
- /**
- * 删除一条广告
- * @author csdeshang
- * @param array $adv_id 广告位id
- * @return bool 布尔类型的返回结果
- */
- public function delAppadv($adv_id) {
- $adv = Db::name('appadv')->where('adv_id',$adv_id)->find();
- if ($adv) {
- // drop cache
- $apId = (int) $adv['ap_id'];
- dkcache("appadv/{$apId}");
- }
- @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_APPADV. DIRECTORY_SEPARATOR .$adv['adv_code']);
- return Db::name('appadv')->where('adv_id',$adv_id)->delete();
- }
- }
|