作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

bug修改

@@ -169,7 +169,7 @@ class Topic extends Api @@ -169,7 +169,7 @@ class Topic extends Api
169 //$matches[1] 为图片路径数组 169 //$matches[1] 为图片路径数组
170 preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches); 170 preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches);
171 // 不小于3张就显示3张,小于3张就显示1张图片 171 // 不小于3张就显示3张,小于3张就显示1张图片
172 - $v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,2) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []); 172 + $v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,3) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
173 // 显示数据 173 // 显示数据
174 $v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']); 174 $v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']);
175 $v->getRelation('user')->visible(['id','image','nickname']); 175 $v->getRelation('user')->visible(['id','image','nickname']);
@@ -302,7 +302,7 @@ class Topic extends Api @@ -302,7 +302,7 @@ class Topic extends Api
302 //$matches[1] 为图片路径数组 302 //$matches[1] 为图片路径数组
303 preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches); 303 preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches);
304 // 不小于3张就显示3张,小于3张就显示1张图片 304 // 不小于3张就显示3张,小于3张就显示1张图片
305 - $v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,2) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []); 305 + $v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,3) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
306 // 显示数据 306 // 显示数据
307 $v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']); 307 $v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']);
308 $v->getRelation('user')->visible(['id','image','nickname']); 308 $v->getRelation('user')->visible(['id','image','nickname']);
@@ -1230,7 +1230,7 @@ class User extends Api @@ -1230,7 +1230,7 @@ class User extends Api
1230 //$matches[1] 为图片路径数组 1230 //$matches[1] 为图片路径数组
1231 preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches); 1231 preg_match_all('/\<img\s+src\=\"([\w:\/\.]+)\"/', $imgs, $matches);
1232 // 不小于3张就显示3张,小于3张就显示1张图片 1232 // 不小于3张就显示3张,小于3张就显示1张图片
1233 - $v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,2) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []); 1233 + $v->imgs = count($matches[1]) >=3 ? array_slice($matches[1],0,3) : (count($matches[1]) >=1 ? array_slice($matches[1],0,1) : []);
1234 // 显示数据 1234 // 显示数据
1235 $v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']); 1235 $v->visible(['id','title','cover','content','createtime','download_num','user','good_num','appraise_num'])->append(['imgs']);
1236 $v->getRelation('user')->visible(['id','image','nickname']); 1236 $v->getRelation('user')->visible(['id','image','nickname']);
@@ -1265,6 +1265,19 @@ class User extends Api @@ -1265,6 +1265,19 @@ class User extends Api
1265 { 1265 {
1266 $page = $this->request->param('page', 1, 'intval'); 1266 $page = $this->request->param('page', 1, 'intval');
1267 $page_num = $this->request->param('page_num', 10, 'intval'); 1267 $page_num = $this->request->param('page_num', 10, 'intval');
  1268 + $topic_id_arr = Topic::where('user_id',$this->auth->id)->column('id');
  1269 + $topic_appraise_id_arr = db('topic_appraise')
  1270 + ->alias('ta')
  1271 + ->join('topic t','t.id = ta.topic_id')
  1272 + ->where('ta.pid',0)
  1273 + ->where('ta.is_replied','0')
  1274 + ->column('ta.id');
  1275 + $topic_appraise_id_arr = db('topic_appraise')
  1276 + ->alias('ta')
  1277 + ->join('topic_appraise ta1','ta1.id = ta.cue_appraise_id')
  1278 + ->where('ta1.user_id',$this->auth->id)
  1279 + ->where('ta.is_replied','0')
  1280 + ->column('ta.id');
1268 $data = Topic::with(['user']) 1281 $data = Topic::with(['user'])
1269 ->where('user_id',$this->auth->id) 1282 ->where('user_id',$this->auth->id)
1270 ->order('createtime desc') 1283 ->order('createtime desc')
@@ -1284,7 +1297,7 @@ class User extends Api @@ -1284,7 +1297,7 @@ class User extends Api
1284 * @ApiMethod (POST) 1297 * @ApiMethod (POST)
1285 * 1298 *
1286 * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") 1299 * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
1287 - * @ApiParams (name="problem_id", type="inter", required=true, description="问题ID") 1300 + * @ApiParams (name="flag", type="inter", required=true, description="0=我发布的,1=我投递的")
1288 * 1301 *
1289 * @ApiReturn({ 1302 * @ApiReturn({
1290 "code": 1, 1303 "code": 1,
@@ -1303,11 +1316,40 @@ class User extends Api @@ -1303,11 +1316,40 @@ class User extends Api
1303 */ 1316 */
1304 public function userJob() 1317 public function userJob()
1305 { 1318 {
1306 - $problem_id = $this->request->param('problem_id');  
1307 - empty($problem_id) && $this->error('缺少必需参数');  
1308 - $info = Problem::get($problem_id);  
1309 - empty($info) && $this->error('问题不存在');  
1310 - $this->success('成功', $info); 1319 + $page = $this->request->param('page', 1, 'intval');
  1320 + $page_num = $this->request->param('page_num', 10, 'intval');
  1321 + $keyword = $this->request->param('keyword');
  1322 + $type = $this->request->param('type');
  1323 + $user_job_ability_id = $this->request->param('user_job_ability_id');
  1324 + $where = [];
  1325 + // 搜索关键词
  1326 + if(!empty($keyword)){
  1327 + $where[] = ['name', 'like', "%{$keyword}%"];
  1328 + }
  1329 + // 求职类型
  1330 + if(!empty($type)){
  1331 + $where[] = ['type', $type];
  1332 + }
  1333 + // 求职类型
  1334 + if(!empty($user_job_ability_id)){
  1335 + $where[] = "FIND_IN_SET('{$user_job_ability_id}',user_job_ability_ids)";
  1336 + }
  1337 + // 整合where
  1338 + $where = function ($query) use ($where) {
  1339 + foreach ($where as $k => $v) {
  1340 + if (is_array($v)) {
  1341 + call_user_func_array([$query, 'where'], $v);
  1342 + } else {
  1343 + $query->where($v);
  1344 + }
  1345 + }
  1346 + };
  1347 + $data = UserJob::where($where)
  1348 + ->field('id,name,type,salary,address,mobile')
  1349 + ->order('createtime desc')
  1350 + ->paginate($page_num,false,['page'=>$page])
  1351 + ->toArray();
  1352 + $this->success('成功', $data);
1311 } 1353 }
1312 1354
1313 /** 1355 /**