package com.yonge.cooleshow.biz.dal.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumCategoryDetail;
import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumCategoryDetailWrapper;
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumCategoryDetailMapper;
import com.yonge.cooleshow.biz.dal.service.TenantAlbumCategoryDetailService;

/**
 * 机构专辑分类详情
 * 2023-10-10 10:17:38
 */
@Slf4j
@Service
public class TenantAlbumCategoryDetailServiceImpl extends ServiceImpl<TenantAlbumCategoryDetailMapper, TenantAlbumCategoryDetail> implements TenantAlbumCategoryDetailService {

    /**
     * 查询详情
     * @param id 详情ID
     * @return TenantAlbumCategoryDetail
     */
    @Override
    public TenantAlbumCategoryDetail detail(Long id) {

        return baseMapper.selectById(id);
    }

    /**
     * 分页查询
     * @param page IPage<TenantAlbumCategoryDetail>
     * @param query TenantAlbumCategoryDetailWrapper.TenantAlbumCategoryDetailQuery
     * @return IPage<TenantAlbumCategoryDetail>
     */
    @Override
    public IPage<TenantAlbumCategoryDetail> selectPage(IPage<TenantAlbumCategoryDetail> page, TenantAlbumCategoryDetailWrapper.TenantAlbumCategoryDetailQuery query) {

        return page.setRecords(baseMapper.selectPage(page, query));
    }

    /**
     * 添加
     * @param tenantAlbumCategoryDetail TenantAlbumCategoryDetailWrapper.TenantAlbumCategoryDetail
     * @return Boolean
     */
    @Override
    public Boolean add(TenantAlbumCategoryDetailWrapper.TenantAlbumCategoryDetail tenantAlbumCategoryDetail) {

        return this.save(JSON.parseObject(tenantAlbumCategoryDetail.jsonString(), TenantAlbumCategoryDetail.class));
    }

    /**
     * 更新
     * @param tenantAlbumCategoryDetail TenantAlbumCategoryDetailWrapper.TenantAlbumCategoryDetail
     * @return Boolean
     */
    @Override
    public Boolean update(TenantAlbumCategoryDetailWrapper.TenantAlbumCategoryDetail tenantAlbumCategoryDetail){

        return this.updateById(JSON.parseObject(tenantAlbumCategoryDetail.jsonString(), TenantAlbumCategoryDetail.class));
    }
}