package com.hzya.frame.sysnew.dictionaryshop.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.sysnew.buttonConfig.entity.SysButtonConfigEntity;
import com.hzya.frame.sysnew.dictionaryshop.entity.SysDictionaryshopEntity;
import com.hzya.frame.sysnew.dictionaryshop.dao.ISysDictionaryshopDao;
import com.hzya.frame.sysnew.dictionaryshop.service.ISysDictionaryshopService;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

import com.hzya.frame.basedao.service.impl.BaseService;

import java.util.List;

/**
 * 数据字典表(SysDictionaryshop)表服务实现类
 *
 * @author makejava
 * @since 2024-04-03 14:22:48
 */
@Service(value = "sysDictionaryshopService")
public class SysDictionaryshopServiceImpl extends BaseService<SysDictionaryshopEntity, String> implements ISysDictionaryshopService {

    private ISysDictionaryshopDao sysDictionaryshopDao;

    @Autowired
    public void setSysDictionaryshopDao(ISysDictionaryshopDao dao) {
        this.sysDictionaryshopDao = dao;
        this.dao = dao;
    }

    /**
     * @Author lvleigang
     * @Description  查询分页
     * @Date 11:52 上午 2024/3/27
     * @param jsonObject
     * @return com.hzya.frame.web.entity.JsonResultEntity
     **/
    @Override
    public JsonResultEntity queryEntityPage(JSONObject jsonObject) {
        SysDictionaryshopEntity entity = getData("jsonStr", jsonObject, SysDictionaryshopEntity.class);
        //判断分页
        if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
            return BaseResult.getFailureMessageEntity("分页查询参数不存在");
        }
        PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
        List<SysDictionaryshopEntity> list = sysDictionaryshopDao.queryByLike(entity);
        PageInfo pageInfo = new PageInfo(list);
        return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
    }


    /**
     * @Author lvleigang
     * @Description  查询列表
     * @Date 11:52 上午 2024/3/27
     * @param jsonObject
     * @return com.hzya.frame.web.entity.JsonResultEntity
     **/
    @Override
    public JsonResultEntity queryEntity(JSONObject jsonObject) {
        SysDictionaryshopEntity entity = getData("jsonStr", jsonObject, SysDictionaryshopEntity.class);
        if(entity == null ){
            entity = new SysDictionaryshopEntity();
        }
        List<SysDictionaryshopEntity> list = sysDictionaryshopDao.queryByLike(entity);
        return BaseResult.getSuccessMessageEntity("查询数据成功", list);
    }
}
