| | |
| | | package com.yeshi.fanli.service.impl.config;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
|
| | | import org.springframework.cache.annotation.CacheEvict;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | |
| | | import org.yeshi.utils.entity.ProxyIP;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.config.ConfigDao;
|
| | | import com.yeshi.fanli.dao.mybatis.ConfigMapper;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.config.AppHomeFloatImg;
|
| | | import com.yeshi.fanli.entity.xcx.XCXSettingConfig;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
|
| | | @Service
|
| | | public class ConfigServiceImpl implements ConfigService {
|
| | |
|
| | | @Resource
|
| | | private ConfigDao configDao;
|
| | | private ConfigMapper configMapper;
|
| | |
|
| | | @Cacheable(value = "config")
|
| | | public List<Config> getAllList() {
|
| | | return configDao.list("from Config");
|
| | | return configMapper.listAll();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Config> listObjects(String key, int page) {
|
| | | int start = (page - 1) * Constant.PAGE_SIZE;
|
| | | StringBuffer hqlBuf = new StringBuffer("from Config pr where 1=1 ");
|
| | |
|
| | | if (key != null && !"".equals(key.trim())) {
|
| | | hqlBuf.append(" and (pr.name like ? )");
|
| | | }
|
| | |
|
| | | hqlBuf.append(" order by pr.id desc ");
|
| | | String hql = hqlBuf.toString();
|
| | | if (hql.contains("pr.name")) {
|
| | | return configDao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[] { "%" + key + "%" });
|
| | | } else {
|
| | | return configDao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[] {});
|
| | | }
|
| | |
|
| | | return configMapper.listSearchByName(key, start, Constant.PAGE_SIZE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int getCount(String key, int page) {
|
| | |
|
| | | StringBuffer hqlBuf = new StringBuffer("select count(*) from Config pr where 1=1 ");
|
| | |
|
| | | if (key != null && !"".equals(key.trim())) {
|
| | | hqlBuf.append(" and (pr.name like ? )");
|
| | | }
|
| | |
|
| | | String hql = hqlBuf.toString();
|
| | |
|
| | | if (hql.contains("pr.name")) {
|
| | | return (int) configDao.getCount(hqlBuf.toString(), new Serializable[] { "%" + key + "%" });
|
| | | } else {
|
| | | return (int) configDao.getCount(hqlBuf.toString(), new Serializable[] {});
|
| | | }
|
| | | public int getCount(String key) {
|
| | | return (int) configMapper.countSearchByName(key);
|
| | | }
|
| | |
|
| | | @CacheEvict(value = "config", allEntries = true)
|
| | |
| | | public void update(List<Config> list) {
|
| | | for (Config config : list) {
|
| | | config.setCreatetime(new Date().getTime() + "");
|
| | | configDao.update(config);
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | | }
|
| | |
|
| | | @CacheEvict(value = "config", allEntries = true)
|
| | | public void update(Config config) {
|
| | | config.setCreatetime(new Date().getTime() + "");
|
| | | configDao.update(config);
|
| | | configMapper.updateByPrimaryKeySelective(config);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "config", key = "#p0+'Str'")
|
| | | public String get(String key) {
|
| | | List<Config> list = configDao.list("from Config c where c.key=? ", new Serializable[] { key });
|
| | | List<Config> list = configMapper.listByKey(key);
|
| | | if (list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | |
|
| | | @Cacheable(value = "config", key = "#p0")
|
| | | public Config getConfig(String key) {
|
| | | List<Config> list = configDao.list("from Config c where c.key=? ", new Serializable[] { key });
|
| | | List<Config> list = configMapper.listByKey(key);
|
| | | if (list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public Config getConfig(long id) {
|
| | | return configDao.find(Config.class, id);
|
| | | return configMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return get("home_float_notify_img");
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void save(Config config) {
|
| | | List<Config> list = configMapper.listByKey(config.getKey());
|
| | | if (list == null || list.size() == 0) {
|
| | | configMapper.insertSelective(config);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|