package com.ruoyi.applet.contoller;

import com.ruoyi.applet.pojo.dto.ApiQueryIIdDTO;
import com.ruoyi.applet.pojo.vo.AppletIconVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.model.domain.*;
import com.ruoyi.model.service.*;
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.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Api(description = "伴宠师-工作台外部")
@RestController
@RequestMapping("/applet/workIn")
public class ApiAppletHhrWorkInController extends BaseController {

    @Autowired
    private IAppUsersService appUsersService;
    //1.查询轮播图接口
    @Autowired
    private IAppBannerService appletBannerService;

    @Autowired
    private IAppletIconService appletIconService;

    @ApiOperation("轮播图列表")
    @GetMapping("/bannerList")
    public AjaxResult bannerList(){
        List<AppBanner> bannerList = appletBannerService.getBannerList();
        return AjaxResult.success("轮播图列表",bannerList);
    }

    @ApiOperation("已加入的工作台图标配置查询")
    @GetMapping("/indexConfig")
    public TableDataInfo getIndexConfig(){

//        return getDataTable(appletIconService.list());

//        /*

        List<AppletIconVo> list = new ArrayList<>();
        AppletIconVo icon1 = new AppletIconVo();
        icon1.setType(0);
        icon1.setImage("https://image.hhlm1688.com/2025-06-16/7367ec79-710a-45a4-86fb-556ca70b4fb3.png");
//        icon1.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/1.png");
        icon1.setName("用户绑定");
        icon1.setUrl("/otherPages/workbenchManage/bindUser/index");

        AppletIconVo icon2 = new AppletIconVo();
        icon2.setType(0);
        icon2.setImage("https://image.hhlm1688.com/2025-06-16/7d9c08d1-74fc-4cb2-a5cf-5526f2b2e1b8.png");
//        icon2.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/2.png");
        icon2.setName("我的用户");
        //icon2.setUrl("/otherPages/workbenchManage/myUser/");
        icon2.setUrl("/otherPages/workbenchManage/myUser/index");

        AppletIconVo icon3 = new AppletIconVo();
        icon3.setType(0);
        icon3.setImage("https://image.hhlm1688.com/2025-06-16/14536ec9-4764-4f80-845c-7b9db9369623.png");
//        icon3.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/3.png");
        icon3.setName("我的等级");
        icon3.setUrl("/otherPages/workbenchManage/myLevel/index");

        AppletIconVo icon4 = new AppletIconVo();
        icon4.setType(0);
        icon4.setImage("https://image.hhlm1688.com/2025-06-16/cc12e682-20b2-4ebe-83a0-f38e5fc8fe34.png");
//        icon4.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/4.png");
        icon4.setName("我的钱包");
        icon4.setUrl("/otherPages/workbenchManage/myWallet/index");

        list.add(icon1);
        list.add(icon2);
        list.add(icon3);
        list.add(icon4);


        AppletIconVo icon5 = new AppletIconVo();
        icon5.setType(1);
        icon5.setImage("https://image.hhlm1688.com/2025-06-16/b9a62948-0c64-4a57-8078-3078a0f17a9e.png");
//        icon5.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/5.png");
        icon5.setName("服务信息");
        icon5.setUrl("/otherPages/authentication/serve/index");

        AppletIconVo icon6 = new AppletIconVo();
        icon6.setType(1);
        icon6.setImage("https://image.hhlm1688.com/2025-06-16/22fe91d5-98ed-49bd-82dd-31889fcb5761.png");
//        icon6.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/6.png");
        icon6.setName("服务记录");
        icon6.setUrl("/otherPages/authentication/serve/record");

        AppletIconVo icon7 = new AppletIconVo();
        icon7.setType(1);
        icon7.setImage("https://image.hhlm1688.com/2025-06-16/834671db-f277-4110-8913-e7b5024c7f23.png");
//        icon7.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/7.png");
        icon7.setName("平台手册");
        icon7.setUrl("");

        AppletIconVo icon8 = new AppletIconVo();
        icon8.setType(1);
        icon8.setImage("https://image.hhlm1688.com/2025-06-16/16132200-3e73-43f9-8549-aa1dce5fc167.png");
//        icon8.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/8.png");
        icon8.setName("我的评价");
        icon8.setUrl("/otherPages/orderTakingManage/evaluate/index");

        AppletIconVo icon9 = new AppletIconVo();
        icon9.setType(1);
        icon9.setImage("https://image.hhlm1688.com/2025-06-16/75e587a7-33a2-44e8-8036-6ba4cfc60176.png");
//        icon9.setImage("https://image.hhlm1688.com/img/work/log/indexInfo/9.png");
        icon9.setName("接单地址");
        icon9.setUrl("/otherPages/authentication/connectAddress/index");

        list.add(icon5);
        list.add(icon6);
        list.add(icon7);
        list.add(icon8);
        list.add(icon9);



        return getDataTable(list);

//         */
    }

    @ApiOperation("申请加入合伙人")
    @PostMapping("/joinHh")
    public AjaxResult joinHh(@RequestBody ApiQueryIIdDTO dto){
//        AppUsers localAppletUser = AppletUtil.getLocalAppletUser();
        if(dto.getAppUserId() == null){
            return AjaxResult.error("userId用户信息标识不能为空");
        }

        AppUsers localAppletUser = new AppUsers();
        localAppletUser.setUserId(dto.getAppUserId());
        localAppletUser.setUserHh(1);
        localAppletUser.setHhStartTime(LocalDateTime.now());
        appUsersService.updateAppUsers(localAppletUser);
        return AjaxResult.success("申请成功合伙人");
    }

}
