package com.hzs.activity.people.controller.manage;


import cn.hutool.core.bean.BeanUtil;
import com.hzs.activity.base.param.QueryActivityParam;
import com.hzs.activity.base.service.IActivityService;
import com.hzs.activity.base.vo.BaseConfigVo;
import com.hzs.activity.people.service.IAcPeopleServiceService;
import com.hzs.activity.people.vo.AcPeopleServiceVO;
import com.hzs.common.core.constant.msg.ActivityMsgConstants;
import com.hzs.common.core.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 新人礼包活动业务表 前端控制器
 * </p>
 *
 * @author hzs
 * @since 2023-04-26
 */
@RestController
@RequestMapping("/manage/people-service")
public class AcPeopleServiceController {

    @Autowired
    private IAcPeopleServiceService iAcPeopleServiceService;
    @Autowired
    private IActivityService iActivityService;

    /**
     * @description: 导出新人礼包活动
     * @author: zhang jing
     * @date: 2023/7/26 16:07
     * @param: [queryActivityParam, response]
     * @return: void
     **/
    @PostMapping("/export")
    public void export(QueryActivityParam queryActivityParam, HttpServletResponse response){
        List<BaseConfigVo> resultList = iActivityService.activityList(queryActivityParam);
        List<AcPeopleServiceVO> list=new ArrayList<>();
        resultList.forEach(item -> list.add(BeanUtil.copyProperties(item, AcPeopleServiceVO.class)));
        ExcelUtil<AcPeopleServiceVO> util = new ExcelUtil<>(AcPeopleServiceVO.class);
        util.exportExcel(response, list, ActivityMsgConstants.NEWCOMER_GIFT_PACKAGE);
    }

}
