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

Commit 019cd14f authored by zhengfuxin's avatar zhengfuxin

魔方和金刚位修改

parent d293d9ea
package com.liquidnet.service.goblin.param;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author liquidnet
* @since 2022-01-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinFrontCubeParam implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
/**
* 魔方id
*/
@ApiModelProperty(value = "魔方id")
private String cubeId;
/**
* 1、一行一个2一行二个3一行三个4上一下三
*/
@ApiModelProperty(value = "1、一行一个2一行二个3一行三个4上一下三")
private Integer rowType;
/**
* 1、单商品2、合集
*/
@ApiModelProperty(value = "1、单商品2、合集")
private Integer pageType;
/**
* 商品名称
*/
@ApiModelProperty(value = "商品名称")
private String spuName;
/**
* 商品id
*/
@ApiModelProperty(value = "商品id")
private String spuId;
/**
* 推荐文案
*/
@ApiModelProperty(value = "推荐文案1")
private String informationA;
@ApiModelProperty(value = "推荐文案2")
private String informationB;
@ApiModelProperty(value = "推荐文案3")
private String informationC;
@ApiModelProperty(value = "推荐文案4")
private String informationD;
/**
* 合集id
*/
@ApiModelProperty(value = "合集ids")
private String compilationsId;
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
private LocalDateTime createTime;
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern=DateUtil.DATE_FULL_STR)
private LocalDateTime updateTime;
/**
* spu
*/
@ApiModelProperty(value = "spu信息")
private GoblinGoods goblinGoods;
}
package com.liquidnet.client.admin.web.controller.zhengzai.goblin;
import com.liquidnet.client.admin.common.core.controller.BaseController;
import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.zhengzai.goblin.service.impl.GoblinFrontCubeServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author liquidnet
* @since 2022-01-07
*/
@Api(tags = "魔方管理")
@RestController
@RequestMapping("/goblin-front-cube")
public class GoblinFrontCubeController extends BaseController {
@Autowired
GoblinFrontCubeServiceImpl goblinFrontCubeService;
/**
* 获取魔方列表
*/
@PostMapping("list")
@ApiOperation(value = "list")
@ResponseBody
public AjaxResult list() {
return AjaxResult.success(goblinFrontCubeService.listGoblinFrontCubeParam());
}
/* *//***
* @author zhangfuxin
* @Description: 修改或者删除魔方
* @date 2022/1/7 下午6:30
*//*
@PostMapping("updateOrCreate")
@ApiOperation(value = "修改或者删除魔方")
@ResponseBody
public AjaxResult updateOrCreate(@RequestBody List<GoblinFrontBannerBuildParam> list) {
List<GoblinFrontBanner> goblinFrontBannerList=new ArrayList<>();
for(GoblinFrontBannerBuildParam goblinFrontBannerBuildParam1:list){
GoblinFrontBanner goblinFrontBanner=new GoblinFrontBanner();
BeanUtils.copyProperties(goblinFrontBannerBuildParam1,goblinFrontBanner);
goblinFrontBannerList.add(goblinFrontBanner);
}
logger.info("修改banner{}", JSON.toJSONString(list));
boolean result=goblinFrontBannerService.update(goblinFrontBannerList);
if (result ) {
return success("操作成功");
} else {
return error("操作失败");
}
}
*/
}
...@@ -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>
* 首页导航栏 * 首页导航栏
...@@ -36,23 +39,28 @@ public class GoblinFrontNavigationController extends BaseController { ...@@ -36,23 +39,28 @@ public class GoblinFrontNavigationController extends BaseController {
@PostMapping("create") @PostMapping("create")
@ApiOperation(value = "增加金刚位") @ApiOperation(value = "增加金刚位")
@ResponseBody @ResponseBody
public AjaxResult create(@RequestBody GoblinFrontNavigationBuildParam goblinFrontNavigationBuildParam) { public AjaxResult create(@RequestBody List<GoblinFrontNavigationBuildParam> list) {
GoblinFrontNavigation goblinFrontNavigation=new GoblinFrontNavigation(); ArrayList<GoblinFrontNavigation> arrayList=new ArrayList();
BeanUtils.copyProperties(goblinFrontNavigationBuildParam,goblinFrontNavigation); for(GoblinFrontNavigationBuildParam goblinFrontNavigationBuildParam1:list){
logger.info("增加金刚位{}", JSON.toJSONString(goblinFrontNavigation)); GoblinFrontNavigation goblinFrontNavigation=new GoblinFrontNavigation();
boolean result=goblinFrontNavigationService.create(goblinFrontNavigation); BeanUtils.copyProperties(goblinFrontNavigationBuildParam1,goblinFrontNavigation);
arrayList.add(goblinFrontNavigation);
}
logger.info("增加金刚位{}", JSON.toJSONString(list));
boolean result=goblinFrontNavigationService.createOrUpdate(arrayList);
if (result ) { if (result ) {
return success("操作成功"); return success("操作成功");
} else { } else {
return error("操作失败"); return error("操作失败");
} }
} }
/*
/** *//**
* @author zhangfuxin * @author zhangfuxin
* @Description:修改金刚位 * @Description:修改金刚位
* @date 2021/12/28 上午11:23 * @date 2021/12/28 上午11:23
*/ *//*
@PostMapping("update") @PostMapping("update")
@ApiOperation(value = "修改金刚位") @ApiOperation(value = "修改金刚位")
@ResponseBody @ResponseBody
...@@ -66,7 +74,7 @@ public class GoblinFrontNavigationController extends BaseController { ...@@ -66,7 +74,7 @@ public class GoblinFrontNavigationController extends BaseController {
} else { } else {
return error("操作失败"); return error("操作失败");
} }
} }*/
/** /**
* 删除金刚位 * 删除金刚位
*/ */
...@@ -87,7 +95,7 @@ public class GoblinFrontNavigationController extends BaseController { ...@@ -87,7 +95,7 @@ public class GoblinFrontNavigationController extends BaseController {
/** /**
* 分页金刚位 * 分页金刚位
*/ *//*
@PostMapping("page") @PostMapping("page")
@ApiOperation(value = "分页") @ApiOperation(value = "分页")
@ResponseBody @ResponseBody
...@@ -96,8 +104,14 @@ public class GoblinFrontNavigationController extends BaseController { ...@@ -96,8 +104,14 @@ public class GoblinFrontNavigationController extends BaseController {
BeanUtils.copyProperties(goblinFrontNavigationBuildParam,goblinFrontNavigation); BeanUtils.copyProperties(goblinFrontNavigationBuildParam,goblinFrontNavigation);
logger.info("分页金刚位{}", JSON.toJSONString(goblinFrontNavigation)); logger.info("分页金刚位{}", JSON.toJSONString(goblinFrontNavigation));
return AjaxResult.success(goblinFrontNavigationService.page(pageSize,pageNumber,null)); return AjaxResult.success(goblinFrontNavigationService.page(pageSize,pageNumber,null));
}*/
@PostMapping("list")
@ApiOperation(value = "list")
@ResponseBody
public AjaxResult list( ) {
return AjaxResult.success(goblinFrontNavigationService.listGoblinFrontNavigation());
} }
/** /**
* @author zhangfuxin * @author zhangfuxin
* @Description:查看金刚位 * @Description:查看金刚位
......
package com.liquidnet.client.admin.zhengzai.goblin.service;
import com.liquidnet.service.goblin.entity.GoblinFrontCube;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author liquidnet
* @since 2022-01-07
*/
public interface IGoblinFrontCubeService extends IService<GoblinFrontCube> {
}
package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinFrontCubeService;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.goblin.entity.GoblinFrontCube;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.mapper.GoblinFrontCubeMapper;
import com.liquidnet.service.goblin.mapper.GoblinGoodsMapper;
import com.liquidnet.service.goblin.param.GoblinFrontCubeParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author liquidnet
* @since 2022-01-07
*/
@Service
public class GoblinFrontCubeServiceImpl extends ServiceImpl<GoblinFrontCubeMapper, GoblinFrontCube> implements IGoblinFrontCubeService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
GoblinFrontCubeMapper goblinFrontCubeMapper;
@Autowired
private RedisDataSourceUtil redisDataSourceUtil;
@Autowired
GoblinGoodsMapper goblinGoodsMapper;
public boolean create(GoblinFrontCube goblinFrontCube){
goblinFrontCube.setCreateTime(LocalDateTime.now());
//设置bannerid
goblinFrontCube.setCubeId(IDGenerator.nextSnowId());
//增加 banner
goblinFrontCubeMapper.insert(goblinFrontCube);
return true;
}
public boolean updateOrCreate(GoblinFrontCube goblinFrontCube) {
if (goblinFrontCube.getMid() == 0) {
this.create(goblinFrontCube);
} else {
goblinFrontCube.setUpdateTime(LocalDateTime.now());
//数据库修改
goblinFrontCubeMapper.updateById(goblinFrontCube);
}
return true;
}
public List<GoblinFrontCubeParam> listGoblinFrontCubeParam(){
LambdaQueryWrapper<GoblinFrontCube> queryWrapper = Wrappers.lambdaQuery(GoblinFrontCube.class);
queryWrapper.ne(GoblinFrontCube::getDelTag,1);
List<GoblinFrontCube> list=goblinFrontCubeMapper.selectList(queryWrapper);
List<GoblinFrontCubeParam> list1=new ArrayList<>();
for(GoblinFrontCube goblinFrontCube:list){
//找到 spu详情
LambdaQueryWrapper<GoblinGoods> queryWrappers = Wrappers.lambdaQuery(GoblinGoods.class);
queryWrappers.ne(GoblinGoods::getDelFlg,"1");
queryWrappers.eq(GoblinGoods::getSpuId,goblinFrontCube.getSpuId());
List<GoblinGoods> goodsList= goblinGoodsMapper.selectList(queryWrappers);
GoblinFrontCubeParam goblinFrontCubeParam=new GoblinFrontCubeParam();
BeanUtils.copyProperties(goblinFrontCube,goblinFrontCubeParam);
goblinFrontCubeParam.setGoblinGoods(goodsList.get(0));
list1.add(goblinFrontCubeParam);
}
return list1;
}
}
...@@ -13,7 +13,9 @@ import com.liquidnet.commons.lang.util.JsonUtils; ...@@ -13,7 +13,9 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst; import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.entity.GoblinFrontNavigation; import com.liquidnet.service.goblin.entity.GoblinFrontNavigation;
import com.liquidnet.service.goblin.mapper.GoblinFrontNavigationMapper; import com.liquidnet.service.goblin.mapper.GoblinFrontNavigationMapper;
import com.liquidnet.service.goblin.param.GoblinFrontNavigationBuildParam;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -21,6 +23,7 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -21,6 +23,7 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -57,10 +60,17 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav ...@@ -57,10 +60,17 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_NAVIGATION,list);*/ redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.FRONT_NAVIGATION,list);*/
return true; return true;
} }
public boolean update(GoblinFrontNavigation goblinFrontNavigation){ public boolean createOrUpdate(List<GoblinFrontNavigation> list){
goblinFrontNavigation.setUpdateTime(LocalDateTime.now()); for(GoblinFrontNavigation goblinFrontNavigation:list){
//数据库修改 if(goblinFrontNavigation.getMid()>0){
goblinFrontNavigationMapper.updateById(goblinFrontNavigation); goblinFrontNavigation.setUpdateTime(LocalDateTime.now());
//数据库修改
goblinFrontNavigationMapper.updateById(goblinFrontNavigation);
}else{
this.create(goblinFrontNavigation);
}
}
/*//mongodb修改 /*//mongodb修改
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontNavigation))); BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontNavigation)));
mongoTemplate.getCollection(GoblinFrontNavigation.class.getSimpleName()).updateOne( mongoTemplate.getCollection(GoblinFrontNavigation.class.getSimpleName()).updateOne(
...@@ -82,7 +92,7 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav ...@@ -82,7 +92,7 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav
public boolean delete(Long id){ public boolean delete(Long id){
GoblinFrontNavigation goblinFrontNavigation=goblinFrontNavigationMapper.selectById(id); GoblinFrontNavigation goblinFrontNavigation=goblinFrontNavigationMapper.selectById(id);
goblinFrontNavigation.setDelTag(1); goblinFrontNavigation.setDelTag(1);
this.update(goblinFrontNavigation); // this.update(goblinFrontNavigation);
return true; return true;
} }
public PageInfo<GoblinFrontNavigation> page(int pageSize, int pageNumber, GoblinFrontNavigation goblinFrontNavigation) { public PageInfo<GoblinFrontNavigation> page(int pageSize, int pageNumber, GoblinFrontNavigation goblinFrontNavigation) {
...@@ -98,6 +108,19 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav ...@@ -98,6 +108,19 @@ public class GoblinFrontNavigationServiceImpl extends ServiceImpl<GoblinFrontNav
} }
return pageInfoTmp; return pageInfoTmp;
} }
public List<GoblinFrontNavigationBuildParam> listGoblinFrontNavigation() {
LambdaQueryWrapper<GoblinFrontNavigation> queryWrapper = Wrappers.lambdaQuery(GoblinFrontNavigation.class);
queryWrapper.ne(GoblinFrontNavigation::getDelTag,1);
queryWrapper.orderByDesc(GoblinFrontNavigation::getCreateTime);
List<GoblinFrontNavigation> list=goblinFrontNavigationMapper.selectList(queryWrapper);
ArrayList<GoblinFrontNavigationBuildParam> list1=new ArrayList<>();
for(GoblinFrontNavigation goblinFrontNavigation:list){
GoblinFrontNavigationBuildParam goblinFrontNavigationBuildParam=new GoblinFrontNavigationBuildParam();
BeanUtils.copyProperties(goblinFrontNavigation,goblinFrontNavigationBuildParam);
list1.add(goblinFrontNavigationBuildParam);
}
return list1;
}
public boolean online(){ public boolean online(){
LambdaQueryWrapper<GoblinFrontNavigation> queryWrapper = Wrappers.lambdaQuery(GoblinFrontNavigation.class); LambdaQueryWrapper<GoblinFrontNavigation> queryWrapper = Wrappers.lambdaQuery(GoblinFrontNavigation.class);
......
package com.liquidnet.service.goblin.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author liquidnet
* @since 2022-01-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinFrontCube implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
/**
* 魔方id
*/
private String cubeId;
/**
* 1、一行一个2一行二个3一行三个4上一下三
*/
private Integer rowType;
/**
* 1、单商品2、合集
*/
private Integer pageType;
/**
* 商品名称
*/
private String spuName;
/**
* 商品id
*/
private String spuId;
/**
* 推荐文案
*/
private String information;
/**
* 合集id
*/
private String compilationsId;
private LocalDateTime createTime;
private LocalDateTime updateTime;
/**
* 0未删除1已删除
*/
private Integer delTag;
}
package com.liquidnet.service.goblin.mapper;
import com.liquidnet.service.goblin.entity.GoblinFrontCube;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author liquidnet
* @since 2022-01-07
*/
public interface GoblinFrontCubeMapper extends BaseMapper<GoblinFrontCube> {
}
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