package com.fdkankan.ucenter.controller;


import cn.hutool.extra.servlet.ServletUtil;
import com.fdkankan.ucenter.common.BaseController;
import com.fdkankan.ucenter.common.RequestBase;
import com.fdkankan.ucenter.common.Result;
import com.fdkankan.ucenter.entity.ContactUs;
import com.fdkankan.ucenter.entity.ContactUsPoint;
import com.fdkankan.ucenter.geo.IPUtils;
import com.fdkankan.ucenter.service.IContactUsService;
import com.fdkankan.ucenter.vo.response.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2025-10-20
 */
@RestController
@RequestMapping("/ucenter/contactUs")
public class ContactUsController extends BaseController {

    @Autowired
    IContactUsService contactUsService;

    @GetMapping("/sceneList")
    public Result sceneList(){
        return Result.success(contactUsService.sceneList());
    }

    @PostMapping("/submit")
    public Result submit(@RequestBody ContactUs contactUs){
        String ip = IPUtils.getIpAddr(request);
        contactUs.setIpAddress(ip);
        contactUs.setSessionId(request.getSession().getId());
        contactUsService.submit(contactUs);
        return Result.success();
    }

    @GetMapping("/callBack/{uuid}")
    public Result callBack(@PathVariable String uuid){
        return Result.success(contactUsService.callBack(uuid));
    }

    @PostMapping("/point")
    public Result point(@RequestBody ContactUsPoint contactUsPoint){
        String ip = IPUtils.getIpAddr(request);
        contactUsPoint.setIpAddress(ip);
        contactUsPoint.setSessionId(request.getSession().getId());
        contactUsService.point(contactUsPoint);
        return Result.success();
    }
}

