package com.hzs.system.config.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.enums.EDelFlag;
import com.hzs.common.domain.member.attest.CuAuthorityControl;
import com.hzs.common.domain.member.attest.ext.CuAuthorityControlExt;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.system.config.mapper.CuAuthorityControlMapper;
import com.hzs.system.config.service.ICuAuthorityControlService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 会员显示权限控制 服务实现类
 * </p>
 *
 * @author zhangjing
 * @since 2024-06-21
 */
@Service
public class CuAuthorityControlServiceImpl extends ServiceImpl<CuAuthorityControlMapper, CuAuthorityControl> implements ICuAuthorityControlService {

    /**
     * @description: 会员控制配置列表
     * @author: zhang jing
     * @date: 2024/6/21 14:53
     * @param: [cuAuthorityControlExt]
     * @return: java.util.List<com.hzs.common.domain.member.attest.ext.CuAuthorityControlExt>
     **/
    @Override
    public List<CuAuthorityControlExt> queryAuthorityControlList(CuAuthorityControlExt cuAuthorityControlExt) {
        return baseMapper.queryAuthorityControlList(cuAuthorityControlExt);
    }

    /**
     * @description: 批量删除会员控制配置
     * @author: zhang jing
     * @date: 2024/6/21 16:32
     * @param: [pkIdList]
     * @return: boolean
     **/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateControl(List<Long> pkIdList) {
        pkIdList.forEach(itm->{
            UpdateWrapper<CuAuthorityControl> updateWrapper=new UpdateWrapper();
            updateWrapper.eq("PK_ID",itm);
            updateWrapper.set("MODIFIED_TIME",new Date());
            updateWrapper.set("PK_MODIFIED", SecurityUtils.getUserId());
            updateWrapper.set("DEL_FLAG", EDelFlag.DELETE.getValue());
            baseMapper.update(null,updateWrapper);
        });
        return true ;
    }
}
