package com.hzs.system.config.controller.manage;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.constant.msg.ConfigMsgConstants;
import com.hzs.common.core.enums.EOperationBusiness;
import com.hzs.common.core.enums.EOperationMethod;
import com.hzs.common.core.enums.EOperationModule;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.system.config.BdBonusExpand;
import com.hzs.common.domain.system.config.ext.BdBonusExpandExt;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.common.util.TransactionUtils;
import com.hzs.system.config.service.IBdBonusExpandService;
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;

/**
 * <p>
 * 奖金4—N配置
 前端控制器
 * </p>
 *
 * @author hzs
 * @since 2022-10-31
 */
@RestController
@RequestMapping("/manage/bd-bonus-expand")
public class BdBonusExpandController extends BaseController {
    @Autowired
    IBdBonusExpandService bonusExpandService;

    @Log(module = EOperationModule.LEVEL_CONFIG,business = EOperationBusiness.GRADE, method = EOperationMethod.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(BdBonusExpand bonusExpand) {
        QueryWrapper<BdBonusExpand> queryWrapper = new QueryWrapper();
        queryWrapper.eq("PK_COUNTRY", SecurityUtils.getPkCountry());
        queryWrapper.orderByDesc("CREATION_TIME");
        List<BdBonusExpand> list = bonusExpandService.list(queryWrapper);
        List<BdBonusExpandExt> listExt=new ArrayList<>();
        if(CollectionUtil.isNotEmpty(list)){
            for(BdBonusExpand be : list){
                BdBonusExpandExt bee = BeanUtil.copyProperties(be, BdBonusExpandExt.class);
                bee.setExpandName(TransactionUtils.getContent(ConfigMsgConstants.FOUR_N_DISPOSE));
                listExt.add(bee);
            }
        }else{
            BdBonusExpandExt bee = new BdBonusExpandExt();
            bee.setExpandName(TransactionUtils.getContent(ConfigMsgConstants.FOUR_N_DISPOSE));
            listExt.add(bee);
        }
        return getDataTable(listExt);
    }
}
