yaf handler 添加展示 修改
来源:互联网 发布:开实体店在淘宝上拿货 编辑:程序博客网 时间:2024/06/07 13:47
<?php/** * Created by PhpStorm. * Date: 2017/5/17 * Time: 下午2:52 */use Handler\Handler as Y;use Respect\Validation\Validator as V;class LotteryController extends _BaseController{ /** *添加活动展示页面 */ public function 1addAction() { } /** *添加活动 */ public function 2addAction() { Y::disableView(); $this->rule['name'] = V::stringVal()->setTemplate('名称错误'); $this->rule['desc'] = V::stringVal()->setTemplate('活动简介错误'); $this->rule['content'] = V::stringVal()->setTemplate('活动详情错误'); $this->rule['start_time'] = V::date('Y-m-d H:i:s');//活动开始时间 $this->rule['end_time'] = V::date('Y-m-d H:i:s');//活动结束时间 $this->rule['pname'] = V::arrayType(); $this->rule['description'] = V::arrayType(); $this->rule['possibility'] = V::arrayType(); $this->rule['sort'] = V::arrayType(); $name= $this->post('name'); $desc= $this->post('desc'); $content= $this->post('content'); $start_time= $this->post('start_time'); $s_time=strtotime($start_time); $end_time= $this->post('end_time'); $e_time=strtotime($end_time); $pname= $this->post('pname'); $description= $this->post('description'); $possibility= $this->post('possibility'); $sort= $this->post('sort'); $awards=[]; foreach ($pname as $k=>$v){ $awards[$k]['name']=$v; $awards[$k]['description']=$description[$k]; $awards[$k]['possibility']=$possibility[$k]; $awards[$k]['sort']=$sort[$k]; } if($this->errorMsg){ return $this->error(100000004,$this->errorMsg); }else{ //获取用户ID $uid=$_SESSION['userId']; //获取发布人角色 ID $roleId=$_SESSION['user_relation']['role_type']; } $data = $this->KClient('apply', 'Lottery')->add($name, $desc, $content, $s_time, $e_time, $uid, $roleId, $awards); if ( $data['code'] == 0 ) { return $this->success($data); } else { return $this->error($data['code']); } } //活动列表 public function 3listAction(){ $pageSize=5; $order='id desc'; $this->rule['page'] = V::intVal()->min(0)->setTemplate('页码错误'); $page = $this->get('page',1); $offset=($page-1)*$pageSize; $data = $this->kClient("apply", "Lottery")->list($offset, $pageSize,$order); $pager = new Tools\AdminPager('lotterylist', $page, $data['data']['count'],$pageSize,1); $this->assign("itemList", $data['data']['list']); $this->assign("page", $pager->show()); } //活动奖项详情 public function 4descAction(){ $this->rule['rid'] = V::intVal()->setTemplate('活动不存在'); $rid = $this->get('rid'); $data = $this->kClient("apply", "LotteryAward")->getListByLotteryId($rid); $this->assign("lotteryList", $data['data']); } //展示单个活动详情 public function 5updescAction(){ $this->rule['rid'] = V::intVal()->setTemplate('活动不存在'); $rid = $this->get('rid',1); $data = $this->kClient("apply", "Lottery")->detail($rid); $this->assign("descList", $data['data']); } //修改活动详情 public function 6updateAction() { Y::disableView(); $this->rule['name'] = V::stringVal()->setTemplate('名称错误'); $this->rule['desc'] = V::stringVal()->setTemplate('活动简介错误'); $this->rule['content'] = V::stringVal()->setTemplate('活动详情错误'); $this->rule['start_time'] = V::intVal();//活动开始时间 $this->rule['end_time'] = V::intVal();//活动结束时间 $this->rule['id'] = V::intVal()->setTemplate('活动不存在');//活动ID $this->rule['rid'] = V::intVal()->setTemplate('用户ID不存在');//用户ID $this->rule['roleid'] = V::intVal()->setTemplate('角色ID不存在');//角色ID if($this->errorMsg){ return $this->error(100000004, $this->errorMsg); } $name= $this->post('name'); $desc= $this->post('desc'); $content= $this->post('content'); $s_time= $this->post('start_time'); $e_time= $this->post('end_time'); $uid= $this->post('rid'); $id= $this->post('id'); $roleid= $this->post('roleid'); $data = $this->kClient("apply", "Lottery")->update($id, $name, $s_time, $e_time, $desc, $content, $uid, $roleid); if ( $data['code'] == 0 ) { return $this->success($data); } else { return $this->error($data['code']); } } //渲染添加奖品页面 public function 7addAction(){// lottery活动id id 奖项id $this->rule['id'] = V::intVal()->setTemplate('奖项ID有误'); $this->rule['lottery'] = V::intVal()->setTemplate('活动ID有误'); if($this->errorMsg){ return $this->error(100000004, $this->errorMsg); } $awardId= $this->get('id'); $lotteryId= $this->get('lottery'); $this->assign("id", $awardId); $this->assign("lotteryid", $lotteryId); } /*添加奖品*/ public function 8addAction(){ $this->rule['name'] = V::stringVal()->setTemplate('奖品名称错误'); $this->rule['desc'] = V::stringVal()->setTemplate('奖项描述错误'); $this->rule['num'] = V::intVal()->setTemplate('奖品数量错误'); $this->rule['lotteryid'] = V::intVal()->setTemplate('活动ID有误'); $this->rule['id'] = V::intVal()->setTemplate('奖项ID有误'); if($this->errorMsg){ return $this->error(100000004, $this->errorMsg); } $name= $this->post('name'); $description= $this->post('desc'); $num= $this->post('num'); $lotteryId= $this->post('lotteryid'); $awardId= $this->post('id'); $data = $this->kClient("apply", "LotteryPrize")->add($lotteryId, $awardId, $name, $description, $num, $status=1); if ( $data['code'] == 0 ) { return $this->success($data); } else { return $this->error($data['code']); } }}
阅读全文
0 0
- yaf handler 添加展示 修改
- yaf
- yaf
- 添加 展示 清空
- swoole 增加 展示 修改
- Handler 添加水印~
- yaf框架 yaf-cms
- 自己添加数据listview展示
- AngularJS 动态添加展示数据
- laravel 后台权限 展示,修改
- 添加,修改
- Sharepoint Handler 添加删除权限
- YAF框架
- yaf笔记
- yaf(一)
- yaf扩展
- YAF redis
- mamp yaf
- mn
- 【代码】 状态压缩 周伟论文 代码补全计划
- MIT线性代数学习(1)——求解线性方程组
- HDU1273漫步森林
- ORACLE 查看SQL执行计划
- yaf handler 添加展示 修改
- OmniMarkupPreviewer 无法打开浏览器访问
- 三个线程依次顺序执行
- C++实现去掉字符串中连续相同K个0子串
- vue组件2-局部注册
- 67. Add Binary ershua二刷
- Android内存泄露——全解析和处理办法
- 行内块元素/行内元素/块级元素的区别
- restclient post 例子