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

Commit 6c7d1c1f authored by zhengfuxin's avatar zhengfuxin

修改banner问题

parent 66c67dd2
...@@ -13,6 +13,9 @@ import org.springframework.beans.BeanUtils; ...@@ -13,6 +13,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/** /**
* <p> * <p>
* 轮播图 前端控制器 * 轮播图 前端控制器
...@@ -61,14 +64,18 @@ public class GoblinFrontBannerController extends BaseController { ...@@ -61,14 +64,18 @@ public class GoblinFrontBannerController extends BaseController {
} }
} }
@PostMapping("update") @PostMapping("updateOrCreate")
@ApiOperation(value = "修改banner") @ApiOperation(value = "修改或者增加banner")
@ResponseBody @ResponseBody
public AjaxResult update( @RequestBody GoblinFrontBannerBuildParam goblinFrontBannerBuildParam) { public AjaxResult updateOrCreate(@RequestBody List<GoblinFrontBannerBuildParam> list) {
GoblinFrontBanner goblinFrontBanner=new GoblinFrontBanner(); List<GoblinFrontBanner> goblinFrontBannerList=new ArrayList<>();
BeanUtils.copyProperties(goblinFrontBannerBuildParam,goblinFrontBanner); for(GoblinFrontBannerBuildParam goblinFrontBannerBuildParam1:list){
logger.info("修改banner{}", JSON.toJSONString(goblinFrontBanner)); GoblinFrontBanner goblinFrontBanner=new GoblinFrontBanner();
boolean result=goblinFrontBannerService.update(goblinFrontBanner); BeanUtils.copyProperties(goblinFrontBannerBuildParam1,goblinFrontBanner);
goblinFrontBannerList.add(goblinFrontBanner);
}
logger.info("修改banner{}", JSON.toJSONString(list));
boolean result=goblinFrontBannerService.update(goblinFrontBannerList);
if (result ) { if (result ) {
return success("操作成功"); return success("操作成功");
} else { } else {
...@@ -108,6 +115,12 @@ public class GoblinFrontBannerController extends BaseController { ...@@ -108,6 +115,12 @@ public class GoblinFrontBannerController extends BaseController {
logger.info("分页banner{}", JSON.toJSONString(goblinFrontBanner)); logger.info("分页banner{}", JSON.toJSONString(goblinFrontBanner));
return AjaxResult.success(goblinFrontBannerService.bannerPage(pageSize,pageNumber,null)); return AjaxResult.success(goblinFrontBannerService.bannerPage(pageSize,pageNumber,null));
} }
@PostMapping("list")
@ApiOperation(value = "list")
@ResponseBody
public AjaxResult page( @RequestParam(name = "type", required = true) String type) {
return AjaxResult.success(goblinFrontBannerService.listGoblinFrontBanner(type));
}
@PostMapping("online") @PostMapping("online")
@ApiOperation(value = "上线") @ApiOperation(value = "上线")
......
...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; ...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinFrontBannerService; import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinFrontBannerService;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil; import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
...@@ -61,10 +60,18 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM ...@@ -61,10 +60,18 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
* @Description: 修改 * @Description: 修改
* @date 2021/12/27 下午4:03 * @date 2021/12/27 下午4:03
*/ */
public boolean update(GoblinFrontBanner goblinFrontBanner){ public boolean update( List<GoblinFrontBanner> list){
goblinFrontBanner.setUpdateTime(LocalDateTime.now()); for(GoblinFrontBanner goblinFrontBanner:list){
//数据库修改 if(goblinFrontBanner.getMid()==0){
goblinFrontBannerMapper.updateById(goblinFrontBanner); this.create(goblinFrontBanner);
}else{
goblinFrontBanner.setUpdateTime(LocalDateTime.now());
//数据库修改
goblinFrontBannerMapper.updateById(goblinFrontBanner);
}
}
/* //mongodb修改 /* //mongodb修改
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontBanner))); BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontBanner)));
mongoTemplate.getCollection(GoblinFrontBanner.class.getSimpleName()).updateOne( mongoTemplate.getCollection(GoblinFrontBanner.class.getSimpleName()).updateOne(
...@@ -96,7 +103,7 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM ...@@ -96,7 +103,7 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
public boolean delte(Long id){ public boolean delte(Long id){
GoblinFrontBanner goblinFrontBanner=goblinFrontBannerMapper.selectById(id); GoblinFrontBanner goblinFrontBanner=goblinFrontBannerMapper.selectById(id);
goblinFrontBanner.setDelTag(1); goblinFrontBanner.setDelTag(1);
this.update(goblinFrontBanner); // this.update(goblinFrontBanner);
return true; return true;
} }
/** /**
...@@ -107,9 +114,9 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM ...@@ -107,9 +114,9 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
public PageInfo<GoblinFrontBanner> bannerPage(int pageSize,int pageNumber,GoblinFrontBanner goblinFrontBanner) { public PageInfo<GoblinFrontBanner> bannerPage(int pageSize,int pageNumber,GoblinFrontBanner goblinFrontBanner) {
PageInfo<GoblinFrontBanner> pageInfoTmp = null; PageInfo<GoblinFrontBanner> pageInfoTmp = null;
try { try {
PageHelper.startPage(pageNumber, pageSize); // PageHelper.startPage(pageNumber, pageSize);
LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class); LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class);
queryWrapper.orderByDesc(GoblinFrontBanner::getCreateTime); queryWrapper.orderByDesc(GoblinFrontBanner::getIndexs);
List<GoblinFrontBanner> list=goblinFrontBannerMapper.selectList(queryWrapper); List<GoblinFrontBanner> list=goblinFrontBannerMapper.selectList(queryWrapper);
pageInfoTmp = new PageInfo(list); pageInfoTmp = new PageInfo(list);
} catch (Exception e) { } catch (Exception e) {
...@@ -117,6 +124,15 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM ...@@ -117,6 +124,15 @@ public class GoblinFrontBannerServiceImpl extends ServiceImpl<GoblinFrontBannerM
} }
return pageInfoTmp; return pageInfoTmp;
} }
public List<GoblinFrontBanner> listGoblinFrontBanner(String type) {
//banner_type 1、首页顶部位置2、首页中部位置
// PageHelper.startPage(pageNumber, pageSize);
LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class);
queryWrapper.eq(GoblinFrontBanner::getBannerType,type);
queryWrapper.orderByAsc(GoblinFrontBanner::getIndexs);
List<GoblinFrontBanner> list=goblinFrontBannerMapper.selectList(queryWrapper);
return list;
}
public boolean online(){ public boolean online(){
//banner //banner
LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class); LambdaQueryWrapper<GoblinFrontBanner> queryWrapper = Wrappers.lambdaQuery(GoblinFrontBanner.class);
......
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