package org.jeecg.modules.api.employController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.CommonApiService;
import org.jeecg.modules.apiService.ShareService;
import org.jeecg.modules.employAhthenticationCompany.entity.EmployAhthenticationCompany;
import org.jeecg.modules.employAuthenticationPerson.entity.EmployAuthenticationPerson;
import org.jeecg.modules.employBillInfo.entity.EmployBillInfo;
import org.jeecg.modules.employFeedback.entity.EmployFeedback;
import org.jeecg.modules.employNotebook.entity.EmployNotebook;
import org.jeecg.modules.employVipUser.entity.EmployVipUser;
import org.jeecg.modules.employWorkInfo.entity.EmployWorkInfo;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import sun.security.krb5.internal.PAData;

import javax.annotation.Resource;

@Api(tags="小程序-公共接口")
@RestController
@RequestMapping("/api/common")
@Slf4j
public class CommonApiController {
    /******************************公共接口********************************************/
    @Resource
    private CommonApiService commonApiService;

    //面对面分享
    @Resource
    private ShareService shareService;
    /***************首页***************/
    //获取banner图列表带分页
    @ApiOperation(value="首页-获取banner图列表", notes="0-首页 1-会员中心")
    @RequestMapping(value = "/queryBannerList", method = {RequestMethod.GET})
    public Result<?> queryBannerList(String bannerCategoryType, PageBean pageBean){
        return commonApiService.queryBannerList(bannerCategoryType, pageBean);
    }

    //获取工种列表
    @ApiOperation(value="首页-获取工种列表", notes="首页-获取工种列表")
    @RequestMapping(value = "/queryJobTypeList", method = {RequestMethod.GET})
    public Result<?> queryJobTypeList(PageBean pageBean){
        return commonApiService.queryJobTypeList(pageBean);
    }

    //获取工作性质列表
    @ApiOperation(value="首页-获取工作性质列表", notes="首页-获取工作性质列表")
    @RequestMapping(value = "/queryJobNatureList", method = {RequestMethod.GET})
    public Result<?> queryJobNatureList(PageBean pageBean){
        return commonApiService.queryJobNatureList(pageBean);
    }

    //获取地址列表
    @ApiOperation(value="首页-获取地址列表", notes="首页-获取地址列表")
    @RequestMapping(value = "/queryAddressList", method = {RequestMethod.GET})
    public Result<?> queryAddressList(PageBean pageBean){
        return commonApiService.queryAddressList(pageBean);
    }

    /***************记工记账***************/
    //个人记工-新建账本
    @ApiOperation(value="记工记账-新建账本", notes="Type：0-个人 1-班组")
    @RequestMapping(value = "/addNoteBook", method = {RequestMethod.POST})
    public Result<?> addNoteBook(@RequestHeader("X-Access-Token") String token, EmployNotebook employNotebook){
        return commonApiService.addNoteBook(token, employNotebook);
    }

    //个人记工-账本信息修改
    @ApiOperation(value="记工记账-账本信息修改", notes="记工记账-账本信息修改")
    @RequestMapping(value = "/updateNoteBook", method = {RequestMethod.POST})
    public Result<?> updateNoteBook(@RequestHeader("X-Access-Token") String token, EmployNotebook employNotebook){
        return commonApiService.updateNoteBook(token, employNotebook);
    }

    @ApiOperation(value="记工记账-在建/结束项目", notes="Type：0-个人 1-班组， status: 0-在建项目 1-结束项目")
    @RequestMapping(value = "/queryNotebookList", method = {RequestMethod.GET})
    public Result<?> queryNotebookList(@RequestHeader("X-Access-Token") String token, String type, String status, PageBean pageBean){
        return commonApiService.queryNotebookList(token, type, status, pageBean);
    }

    //个人记工-全年收支
    @ApiOperation(value="记工记账-全年收支", notes="记工记账-全年收支")
    @RequestMapping(value = "/queryBill", method = {RequestMethod.GET})
    public Result<?> queryBill(@RequestHeader("X-Access-Token") String token, String employNoteBookId, PageBean pageBean){
        return commonApiService.queryBill(token, employNoteBookId, pageBean);
    }

    //个人记工-技工问题
    @ApiOperation(value="记工记账-技工问题", notes="记工记账-技工问题")
    @RequestMapping(value = "/addQuestion", method = {RequestMethod.POST})
    public Result<?> addQuestion(@RequestHeader("X-Access-Token") String token, EmployFeedback employFeedback){
        return commonApiService.addQuestion(token, employFeedback);
    }

    @ApiOperation(value="记工记账-项目记账", notes="记工记账-项目记账")
    @RequestMapping(value = "/addBillInfo", method = {RequestMethod.POST})
    public Result<?> addBillInfo(@RequestHeader("X-Access-Token") String token, EmployBillInfo employBillInfo){
        String message = null;
        //参数校验
        if(null == employBillInfo.getNotebookId()){
            message = "账本id为空，请输入正确的账本id";
        }else if(null == employBillInfo.getAmount()){
            message = "记账金额为空，请输入金额";
        }else if(null == employBillInfo.getBillDate()){
            message = "记账日期为空，请输入记账日期";
        }else if(null == employBillInfo.getType()){
            message = "记账类型为空，请输入记账类型";
        }
        //参数输入有误，返回错误信息
        if(null != message){
            return Result.OK(message);
        }

        //业务处理
        return commonApiService.addBillInfo(token, employBillInfo);
    }

    @ApiOperation(value="记工记账-项目记工", notes="记工记账-项目记工")
    @RequestMapping(value = "/addWorkInfo", method = {RequestMethod.POST})
    public Result<?> addWorkInfo(@RequestHeader("X-Access-Token") String token, EmployWorkInfo employWorkInfo){
        String message = null;
        //参数校验
        if(null == employWorkInfo.getNotebookId()){
            message = "账本id为空，请输入正确的账本id";
        }else if(null == employWorkInfo.getType()){
            message = "工作类型为空，请输入工作类型";
        }else if(null == employWorkInfo.getOvertime()){
            message = "加班时长为空，请输入加班时长";
        }else if(null == employWorkInfo.getWorkDate()){
            message = "记工日期为空，请输入记工日期";
        }

        //参数输入有误，返回错误信息
        if(null != message){
            return Result.OK(message);
        }

        //业务处理
        return commonApiService.addWorkInfo(token, employWorkInfo);
    }


    /***************会员中心***************/
    //会员中心-我的积分
    @ApiOperation(value="会员中心-我的积分", notes="会员中心-我的积分")
    @RequestMapping(value = "/queryScore", method = {RequestMethod.GET})
    public Result<?> queryScore(@RequestHeader("X-Access-Token") String token){
        return commonApiService.queryScore(token);
    }

    //会员中心-积分记录
    @ApiOperation(value="会员中心-积分记录", notes="type：0-收入 1-消耗")
    @RequestMapping(value = "/queryScoreRecord", method = {RequestMethod.GET})
    public Result<?> queryScoreRecord(@RequestHeader("X-Access-Token") String token, String type, PageBean pageBean){
        return commonApiService.queryScoreRecord(token, type, pageBean);
    }

    //我的服务-获取VIP信息
    @ApiOperation(value="我的服务-获取VIP配置信息", notes="type: 0-个人 1-企业")
    @RequestMapping(value = "/queryVipType", method = {RequestMethod.GET})
    public Result<?> queryVipType(String type, PageBean pageBean){
        return commonApiService.queryVipType(type, pageBean);
    }

    //我的服务-会员充值(开通VIP)
    @ApiOperation(value="我的服务-会员充值(开通VIP)", notes="我的服务-会员充值(开通VIP)")
    @RequestMapping(value = "/addRecharge", method = {RequestMethod.POST})
    public Result<?> addVip(@RequestHeader("X-Access-Token") String token, EmployVipUser employVipUser){
        return commonApiService.addVip(token, employVipUser);
    }

    //我的服务-获取积分-邀请工友获取积分
    @ApiOperation(value="我的服务-获取积分-邀请工友获取积分", notes="我的服务-获取积分-邀请工友获取积分")
    @RequestMapping(value = "/addScoreByShare", method = {RequestMethod.POST})
    public Result<?> addScoreByShare(@RequestHeader("X-Access-Token") String token, String score){
        return commonApiService.addScoreByShare(token, score);
    }

    //我的服务-获取积分-每日签到获取积分
    @ApiOperation(value="我的服务-获取积分-每日签到获取积分", notes="我的服务-获取积分-每日签到获取积分")
    @RequestMapping(value = "/addScoreBySign", method = {RequestMethod.POST})
    public Result<?> addScoreBySign(@RequestHeader("X-Access-Token") String token, Double score){
        return commonApiService.addScoreBySign(token, score);
    }

    //我的服务-个人实名认证
    @ApiOperation(value="我的服务-个人实名认证", notes="我的服务-个人实名认证")
    @RequestMapping(value = "/addAuthenticationPerson", method = {RequestMethod.POST})
    public Result<?> addAuthenticationPerson(@RequestHeader("X-Access-Token") String token, EmployAuthenticationPerson employAuthenticationPerson){
        String message = null;
        //参数校验
        if(null == employAuthenticationPerson.getCerNo()){
            message = "证件号码为空，请输入正确的证件号码";
        }else if(null == employAuthenticationPerson.getName()){
            message = "姓名为空，请输入姓名";
        }else if(null == employAuthenticationPerson.getPhone()){
            message = "联系方式为空，请输入手机号码";
        }
        //参数输入有误，返回错误信息
        if(null != message){
            return Result.OK(message);
        }

        //业务处理
        return commonApiService.addAuthenticationPerson(token, employAuthenticationPerson);
    }

    //我的服务-企业实名认证
    @ApiOperation(value="我的服务-企业实名认证", notes="我的服务-企业实名认证")
    @RequestMapping(value = "/addAuthenticationCompany", method = {RequestMethod.POST})
    public Result<?> addAuthenticationCompany(@RequestHeader("X-Access-Token") String token, EmployAhthenticationCompany employAhthenticationCompany){
        String message = null;
        //参数校验
        if(null == employAhthenticationCompany.getBusinessLicense()){
            message = "营业执照未上传，请上传营业执照";
        }else if(null == employAhthenticationCompany.getCompanyName()){
            message = "企业名称为空，请填写企业名称";
        }else if(null == employAhthenticationCompany.getLegalPerson()){
            message = "法定代表人姓名为空，请填写法定代表人姓名";
        }else if(null == employAhthenticationCompany.getCompanyAddress()){
            message = "企业地址为空，请填写企业地址";
        }
        //参数输入有误，返回错误信息
        if(null != message){
            return Result.OK(message);
        }

        //业务处理
        return commonApiService.addAuthenticationCompany(token, employAhthenticationCompany);
    }

    //我的服务-兑换码
    @ApiOperation(value="我的服务-兑换码", notes="我的服务-兑换码")
    @RequestMapping(value = "/addExchange", method = {RequestMethod.POST})
    public Result<?> addExchange(){
        return null;
    }

    //我的服务-面对面分享
    @ApiOperation(value="我的服务-面对面分享", notes="我的服务-面对面分享")
    @RequestMapping(value = "/getInviteCode", method = {RequestMethod.POST})
    public Result<?> getInviteCode(String token){
        return shareService.getInviteCode(token);
    }
//    /***************设置与帮助***************/
//    //系统设置-切换账号
//    @ApiOperation(value="系统设置-切换账号", notes="系统设置-切换账号")
//    @RequestMapping(value = "/changeAccount", method = {RequestMethod.GET})
//    public Result<?> changeAccount(){
//        return null;
//    }
//    //系统设置-退出登录
//    @ApiOperation(value="系统设置-退出登录", notes="系统设置-退出登录")
//    @RequestMapping(value = "/loginOut", method = {RequestMethod.GET})
//    public Result<?> loginOut(){
//        return null;
//    }
//
//    //系统设置-切换身份
//    @ApiOperation(value="系统设置-切换身份", notes="系统设置-切换身份")
//    @RequestMapping(value = "/changeRole", method = {RequestMethod.GET})
//    public Result<?> changeRole(){
//        return null;
//    }
//
//    //帮助与反馈
//    @ApiOperation(value="帮助与反馈", notes="帮助与
//    反馈")
//    @RequestMapping(value = "/help", method = {RequestMethod.GET})
//    public Result<?> help(){
//        return null;
//    }

    //关于本程序
    @ApiOperation(value="关于本程序", notes="关于本程序")
    @RequestMapping(value = "/aboutUs", method = {RequestMethod.GET})
    public Result<?> aboutUs(){
        return Result.OK("招聘小程序");
    }

}
