记得上下班打卡 | git大法好,push需谨慎

Commit 39c4ad8c authored by 胡佳晨's avatar 胡佳晨

Merge remote-tracking branch 'origin/dev_goblin' into dev_goblin

parents fd4a0fd5 467d3f8d
......@@ -70,7 +70,7 @@ public class GoblinFrontNavigationController extends BaseController {
@ResponseBody
public AjaxResult delete( @RequestBody GoblinFrontNavigation goblinFrontNavigation) {
logger.info("删除金刚位{}", JSON.toJSONString(goblinFrontNavigation));
boolean result=goblinFrontNavigationService.delte(goblinFrontNavigation.getMid());
boolean result=goblinFrontNavigationService.delete(goblinFrontNavigation.getMid());
if (result ) {
return success("操作成功");
} else {
......
......@@ -16,6 +16,7 @@ import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.entity.GoblinFrontBanner;
import com.liquidnet.service.goblin.entity.GoblinFrontNavigation;
import com.liquidnet.service.goblin.mapper.GoblinFrontBannerMapper;
import com.liquidnet.service.kylin.dao.BannerDetailsListDao;
import com.liquidnet.service.kylin.dto.param.BannersSearchParam;
......@@ -58,18 +59,11 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
//mongo db增加
mongoTemplate.save(goblinFrontBanner,GoblinFrontBanner.class.getSimpleName());
//redis 增加
if(redisDataSourceUtil.getRedisGoblinUtil().hasKey(GoblinRedisConst.FRONT_BANNER)){
//从redis里面取出
ArrayList<GoblinFrontBanner> list = (ArrayList<GoblinFrontBanner>) redisDataSourceUtil.getRedisGoblinUtil().get(GoblinRedisConst.FRONT_BANNER);
list.add(goblinFrontBanner);
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_BANNER,list);
}else{
//创建一个list
ArrayList<Object> list= CollectionUtil.arrayListObject();
list.add(goblinFrontBanner);
//redis 没有这个键
LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class);
queryWrapper.ne(GoblinFrontBanner::getDelTag,1);
queryWrapper.orderByDesc(GoblinFrontBanner::getIndexs);
List<GoblinFrontBanner> list=goblinFrontBannerMapper.selectList(queryWrapper);
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_BANNER,list);
}
return true;
}
/***
......@@ -87,7 +81,13 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
orderObject
);
//redis 修改
if(redisDataSourceUtil.getRedisGoblinUtil().hasKey(GoblinRedisConst.FRONT_BANNER+"0")){
//从数据库中查出来,从新塞进去
LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class);
queryWrapper.ne(GoblinFrontBanner::getDelTag,1);
queryWrapper.orderByDesc(GoblinFrontBanner::getIndexs);
List<GoblinFrontBanner> list=goblinFrontBannerMapper.selectList(queryWrapper);
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_BANNER,list);
/* if(redisDataSourceUtil.getRedisGoblinUtil().hasKey(GoblinRedisConst.FRONT_BANNER+"0")){
ArrayList<GoblinFrontBanner> list = (ArrayList<GoblinFrontBanner>) redisDataSourceUtil.getRedisGoblinUtil().get(GoblinRedisConst.FRONT_BANNER+0);
list= (ArrayList<GoblinFrontBanner>) list.stream().map(goblinFrontBanner1->{
if(goblinFrontBanner1.getBannerId().equals(goblinFrontBanner.getBannerId())){
......@@ -96,7 +96,7 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
return goblinFrontBanner1;
}).collect(Collectors.toList());
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_BANNER+"0",list);
}
}*/
return true;
}
/**
......@@ -113,7 +113,10 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
* @date 2021/12/27 下午4:36
*/
public boolean delte(Long id){
//数据库
GoblinFrontBanner goblinFrontBanner=goblinFrontBannerMapper.selectById(id);
goblinFrontBanner.setDelTag(1);
this.update(goblinFrontBanner);
/* //数据库
goblinFrontBannerMapper.deleteById(id);
//mongodb 删除
mongoTemplate.remove(Query.query(Criteria.where("mid").is(id)), GoblinFrontBanner.class, GoblinFrontBanner.class.getSimpleName());
......@@ -127,7 +130,7 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
return goblinFrontBanner1;
}).collect(Collectors.toList());
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_BANNER+"0",list);
}
}*/
return true;
}
/**
......
package com.liquidnet.client.admin.zhengzai.goblin.service.imp;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinFrontNavigationService;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.entity.GoblinFrontBanner;
import com.liquidnet.service.goblin.entity.GoblinFrontNavigation;
import com.liquidnet.service.goblin.mapper.GoblinFrontBannerMapper;
import com.liquidnet.service.goblin.mapper.GoblinFrontNavigationMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mongodb.BasicDBObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
......@@ -31,7 +40,7 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
GoblinFrontNavigationMapper goblinFrontNavigationMapper;
private GoblinFrontNavigationMapper goblinFrontNavigationMapper;
@Autowired
private RedisDataSourceUtil redisDataSourceUtil;
......@@ -43,30 +52,52 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav
//mongo db增加
mongoTemplate.save(goblinFrontNavigation,GoblinFrontNavigation.class.getSimpleName());
//redis增加
if(redisDataSourceUtil.getRedisGoblinUtil().hasKey(GoblinRedisConst.FRONT_NAVIGATION)){
//从redis里面取出
ArrayList<GoblinFrontNavigation> list = (ArrayList<GoblinFrontNavigation>) redisDataSourceUtil.getRedisGoblinUtil().get(GoblinRedisConst.FRONT_BANNER);
list.add(goblinFrontNavigation);
LambdaQueryWrapper<GoblinFrontNavigation> queryWrapper = Wrappers.lambdaQuery(GoblinFrontNavigation.class);
queryWrapper.ne(GoblinFrontNavigation::getDelTag,1);
queryWrapper.orderByDesc(GoblinFrontNavigation::getIndexs);
List<GoblinFrontNavigation> list=goblinFrontNavigationMapper.selectList(queryWrapper);
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_NAVIGATION,list);
}else{
//创建一个list
ArrayList<Object> list= CollectionUtil.arrayListObject();
list.add(goblinFrontNavigation);
//redis 没有这个键
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_NAVIGATION,list);
}
return true;
}
public boolean update(GoblinFrontNavigation goblinFrontBanner){
public boolean update(GoblinFrontNavigation goblinFrontNavigation){
//数据库修改
goblinFrontNavigationMapper.updateById(goblinFrontNavigation);
//mongodb修改
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontNavigation)));
mongoTemplate.getCollection(GoblinFrontNavigation.class.getSimpleName()).updateOne(
Query.query(Criteria.where("navigationId").is(goblinFrontNavigation.getNavigationId())).getQueryObject(),
orderObject
);
//redis 修改
//从数据库中查出来,从新塞进去
LambdaQueryWrapper<GoblinFrontNavigation> queryWrapper = Wrappers.lambdaQuery(GoblinFrontNavigation.class);
queryWrapper.ne(GoblinFrontNavigation::getDelTag,1);
queryWrapper.orderByDesc(GoblinFrontNavigation::getIndexs);
List<GoblinFrontNavigation> list=goblinFrontNavigationMapper.selectList(queryWrapper);
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_NAVIGATION,list);
return true;
}
public GoblinFrontNavigation getOne(Long id){
return null;
return goblinFrontNavigationMapper.selectById(id);
}
public boolean delte(Long id){
public boolean delete(Long id){
GoblinFrontNavigation goblinFrontNavigation=goblinFrontNavigationMapper.selectById(id);
goblinFrontNavigation.setDelTag(1);
this.update(goblinFrontNavigation);
return true;
}
public PageInfo<GoblinFrontNavigation> page(int pageSize, int pageNumber, GoblinFrontNavigation goblinFrontNavigation) {
return null;
PageInfo<GoblinFrontNavigation> pageInfoTmp = null;
try {
PageHelper.startPage(pageNumber, pageSize);
LambdaQueryWrapper<GoblinFrontNavigation> queryWrapper = Wrappers.lambdaQuery(GoblinFrontNavigation.class);
queryWrapper.orderByDesc(GoblinFrontNavigation::getCreateTime);
List<GoblinFrontNavigation> list=goblinFrontNavigationMapper.selectList(queryWrapper);
pageInfoTmp = new PageInfo(list);
} catch (Exception e) {
return new PageInfo();
}
return pageInfoTmp;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment