package com.ruoyi.cms.controller.app;

import com.ruoyi.cms.domain.AppUser;
import com.ruoyi.cms.domain.Company;
import com.ruoyi.cms.domain.Job;
import com.ruoyi.cms.domain.JobFair;
import com.ruoyi.cms.domain.query.MineJobQuery;
import com.ruoyi.cms.service.*;
import com.ruoyi.common.annotation.BussinessLog;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * app用户Controller
 * 
 * @author lishundong
 * @date 2024-09-03
 */
@RestController
@RequestMapping("/app/user")
@Api(tags = "移动端:用户相关")
public class AppUserController extends BaseController
{
    @Autowired
    private IAppUserService appUserService;
    @Autowired
    private IAppReviewJobService appReviewJobService;
    @Autowired
    private IJobCollectionService jobCollectionService;
    @Autowired
    private ICompanyCollectionService companyCollectionService;
    @Autowired
    private IJobApplyService jobApplyService;
    @Autowired
    private IFairCollectionService fairCollectionService;
    /**
     * 查询岗位列表
     */
    @ApiOperation("保存简历")
    @PostMapping("/resume")
    @BussinessLog(title = "保存简历")
    public AjaxResult saveResume(@RequestBody AppUser appUser)
    {
        appUser.setUserId(SecurityUtils.getUserId());
        appUserService.updateAppUser(appUser);
        return AjaxResult.success();
    }
    @ApiOperation("查看简历")
    @GetMapping("/resume")
    public AjaxResult getResume()
    {
        AppUser appUser = appUserService.selectAppUserByUserId(SecurityUtils.getUserId());
        return AjaxResult.success(appUser);
    }
    @ApiOperation("我的浏览")
    @GetMapping("/review")
    public TableDataInfo review(MineJobQuery jobQuery)
    {
        startPage();
        List<Job> jobs = appReviewJobService.review(jobQuery);
        return getDataTable(jobs);
    }
    @ApiOperation("我的浏览-日期数组")
    @GetMapping("/review/array")
    public AjaxResult reviewArray(MineJobQuery jobQuery)
    {

        List<String> dateList = appReviewJobService.reviewArray();
        return AjaxResult.success(dateList);
    }
    @ApiOperation("我的岗位收藏")
    @GetMapping("/collection/job")
    public TableDataInfo collectionJob()
    {
        startPage();
        List<Job> jobs = jobCollectionService.collectionJob();
        return getDataTable(jobs);
    }
    @ApiOperation("我的公司收藏")
    @GetMapping("/collection/company")
    public TableDataInfo collectionCompany()
    {
        startPage();
        List<Company> jobs = companyCollectionService.collectionCompany();
        return getDataTable(jobs);
    }
    @ApiOperation("我的招聘会收藏")
    @GetMapping("/collection/fair")
    public TableDataInfo collectionFair(@RequestParam(name = "type") Integer type)
    {
        startPage();
        List<JobFair> jobs = fairCollectionService.appCollectionFair(type);
        return getDataTable(jobs);
    }
    @ApiOperation("我申请的岗位")
    @GetMapping("/apply/job")
    public TableDataInfo applyJob()
    {
        startPage();
        List<Job> jobs = jobApplyService.applyJob();
        return getDataTable(jobs);
    }
    @ApiOperation("统计")
    @GetMapping("/statistics")
    public AjaxResult statistics()
    {
        HashMap<String,Integer> result = jobApplyService.statistics();
        return AjaxResult.success(result);
    }
}
