package com.hzs.member.detail.controller.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.hzs.common.core.enums.EAssessStatus;
import com.hzs.common.core.enums.EAssessmentType;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.member.ext.CuMemberAssessExt;
import com.hzs.member.detail.param.MemberAssessParam;
import com.hzs.member.detail.service.ICuMemberAssessService;
import com.hzs.member.detail.vo.MemberAssessVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 会员考核控制器
 */
@RestController
@RequestMapping("/manager/member-assess")
public class CuMemberAssessController extends BaseController {

    @Autowired
    private ICuMemberAssessService iCuMemberAssessService;

    /**
     * 会员考核列表
     *
     * @param param
     * @return
     */
    @GetMapping("/assess-list")
    public TableDataInfo assessList(MemberAssessParam param) {
        startPage();
        List<MemberAssessVO> resultList = new ArrayList<>();
        List<CuMemberAssessExt> list = iCuMemberAssessService.listMemberAssess(param);
        if (CollectionUtil.isNotEmpty(list)) {
            for (CuMemberAssessExt cuMemberAssessExt : list) {
                MemberAssessVO memberAssessVO = BeanUtil.copyProperties(cuMemberAssessExt, MemberAssessVO.class);
                memberAssessVO.setAssessTypeVal(EAssessmentType.getLabelByValue(memberAssessVO.getAssessType()));
                memberAssessVO.setAssessStatusVal(EAssessStatus.getLabelByValue(memberAssessVO.getAssessStatus()));
                resultList.add(memberAssessVO);
            }
        }
        TableDataInfo tableDataInfo = getDataTable(list);
        tableDataInfo.setRows(resultList);
        return tableDataInfo;
    }

}
