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 com.yonge.cooleshow.biz.dal.entity.SysSuggestionType;
import com.yonge.cooleshow.biz.dal.mapper.SysSuggestionTypeMapper;
import com.yonge.cooleshow.biz.dal.service.SysSuggestionTypeService;
import com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionTypeWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 平台建议类型表
 * 2023-08-30 11:26:33
 */
@Slf4j
@Service
public class SysSuggestionTypeServiceImpl extends ServiceImpl<SysSuggestionTypeMapper, SysSuggestionType> implements SysSuggestionTypeService {

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

        return baseMapper.selectById(id);
    }

    /**
     * 分页查询
     *
     * @param page  IPage<SysSuggestionType>
     * @param query SysSuggestionTypeWrapper.SysSuggestionTypeQuery
     * @return IPage<SysSuggestionType>
     */
    @Override
    public IPage<SysSuggestionType> selectPage(IPage<SysSuggestionType> page, SysSuggestionTypeWrapper.SysSuggestionTypeQuery query) {

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

    /**
     * 添加
     *
     * @param sysSuggestionType SysSuggestionTypeWrapper.SysSuggestionType
     * @return Boolean
     */
    @Override
    public Boolean add(SysSuggestionTypeWrapper.SysSuggestionType sysSuggestionType) {

        return this.save(JSON.parseObject(sysSuggestionType.jsonString(), SysSuggestionType.class));
    }

    /**
     * 更新
     *
     * @param sysSuggestionType SysSuggestionTypeWrapper.SysSuggestionType
     * @return Boolean
     */
    @Override
    public Boolean update(SysSuggestionTypeWrapper.SysSuggestionType sysSuggestionType) {

        return this.updateById(JSON.parseObject(sysSuggestionType.jsonString(), SysSuggestionType.class));
    }
}
