package com.kiisoo.ic.job.detail;

import com.kiisoo.ic.job.entity.DataAccountDO;
import com.kiisoo.ic.job.mapper.DataAccountDOMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

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

@Controller
@RequestMapping("/job")
@Slf4j
public class SyncDetailJobController {
    @Autowired
    private CustomerDataJob customerDataJob;

    @Autowired
    private DataAccountDOMapper dataAccountDOMapper;

    @GetMapping("/sync/customer")
    public void getCustomerInfo(){
        try {
            customerDataJob.handle(null);
        }catch (Exception e){
            log.error("",e);
        }
    }
    @GetMapping("/sync/customer/shop")
    public void getCustomerInfo(@RequestParam("cpUserId")String cpUserIds){
        try {
            customerDataJob.handle(cpUserIds);
        }catch (Exception e){
            log.error("",e);
        }
    }

    @GetMapping("/sync/customer/account")
    @ResponseBody
    public void customerInfo(){
        try {
            List<String> cpUserIds = dataAccountDOMapper.selectByAccount();
            customerDataJob.handleList(cpUserIds);
        }catch (Exception e){
            log.error("",e);
        }
    }
}
