作者 sgj
1 个管道 的构建 失败 耗费 9 秒

新闻机制

... ... @@ -6,5 +6,5 @@ stages:
job1:
stage: pull
script:
- cd /alidata/www/online/volunteer.cnpu.org/
- cd /alidata/www/online/volunteer.cnpu.org1/
- git pull
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/9/26
* Time: 17:40
*/
namespace api\common\model;
use think\Model;
class ActivityNews extends Model
{
protected $name = 'activity_news';
/**
* 通过类型获取新闻
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNewsByType($type){
$map['activity_type']=$type;
$list=$this->where($map)->select()->order('weight desc')->toArray();
return $list;
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/9/26
* Time: 15:34
*/
namespace api\common\model;
use think\Model;
class LevelModel extends Model
{
protected $name = 'level';
// // 自动写入时间戳字段
// protected $autoWriteTimestamp = 'int';
//
// // 定义时间戳字段名
// protected $createTime = 'createtime';
// protected $updateTime = 'updatetime';
// protected $deleteTime = false;
//
// // 追加属性
// protected $append = [
// 'type_text'
// ];
/**
* 获取级别详情
* @param $level 级别
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getLevelTime($level){
$map['level']=$level;
$level_info=$this->where($map)->find();
return $level_info;
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/9/26
* Time: 17:31
*/
namespace api\common\model;
use think\Model;
class NewsTypeMode extends Model
{
protected $name = 'news_type';
/**
* 获取新闻类型
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNewsType(){
$map['delete_time']=null;
$list=$this->where($map)->order('weight desc')->select()->toArray();
return $list;
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/9/26
* Time: 16:06
*/
namespace api\common\model;
use think\Model;
class TeamModel extends Model
{
protected $name = 'team';
/**
* 获取地址
* @param $order 排序方式
* @param $field 获取字段
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTeamList($order,$field){
$map['status']=1;
$info=$this->where($map)->order($order)->select()->toArray();
return $info;
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/9/26
* Time: 15:42
*/
namespace api\common\model;
use think\Model;
class VolunteerModel extends Model
{
protected $name = 'volunteer';
/**
* 获取对应级别用户
* @param $level
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListByLevel($level){
$levelModel=new LevelModel();
$info=$levelModel->getLevelTime($level);
$map['work_time']=['>',$info['min']];
$map1['work_time']=['<=',$info['max']];
$map['status']=2;
$info=$this->where($map)->where($map1)->order('work_time','DESC')->select()->toArray();
return $info;
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/9/26
* Time: 14:46
*/
namespace api\index\controller;
use api\common\model\LevelModel;
use api\common\model\TeamModel;
use api\common\model\VolunteerModel;
use cmf\controller\RestBaseController;
/**
* @title 志愿者二开接口
* @description 志愿者二开接口
*/
class SecondController extends RestBaseController
{
/**
* @title 获取排行
* @description 获取排行
* @author SGJ
* @url /index/second/getRank
* @method POST
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:type type:int require:1 other: desc:类型1,志愿者2,团队
* @param name:star type:int require:1 other: desc:类型6,金牌1,一星2,二星
*
* @return list:志愿者@
* @list rank:排名 name:姓名 province:省市 work_time:工作时间
*/
public function getRank(){
$type=input('type');
if ($type==1){
$star=input('star');
$userModel=new VolunteerModel();
$list=$userModel->getListByLevel($star);
$return=[];
foreach ($list as $k=>$v){
$return[$k]['name']=$v['name'];
$return[$k]['province']=$v['province'];
$return[$k]['work_time']=$v['work_time'];
}
}else{
$teamModel=new TeamModel();
$list=$teamModel->getTeamList('work_total_time desc','');
if(!empty($list)){
foreach ($list as $k=>$v){
$return[$k]['name']=$v['name'];
$return[$k]['work_time']=$v['work_total_time'];
}
}
}
$this->success('',$return);
}
}
\ No newline at end of file
... ...
... ... @@ -17,4 +17,5 @@ use think\Model;
class UserModel extends Model
{
//
protected $name = 'user';
}
... ...
... ... @@ -9,7 +9,7 @@ return [
// 服务器地址
'hostname' => 'rm-m5eblhc9o3515i25neo.mysql.rds.aliyuncs.com',
// 数据库名
'database' => 'volunteer',
'database' => 'volunteer_dev',
// 用户名
'username' => 'db136s1ehvo1yn73',
// 密码
... ...
... ... @@ -8,6 +8,7 @@ class Doc
'version'=>'1.0.0',
'copyright'=>'银河百荣科技',
'controller' => [
'api\\index\\controller\\SecondController',
'api\\home\\controller\\IndexController',
'api\\user\\controller\\UploadController',
'api\\wxapp\\controller\\PublicController',
... ...