前端模板框架为Bootstrap,系统分为前台和后台。后台主要为管理员角色,功能有:
商品类型管理、商品管理、订单管理、会员管理、管理员管理等。前台用户功能有:登录、注册、查看商品、加入购物车、付款、查看订单、个人中心等。该系统总共9张表
二、项目运行运行环境:windows/linux、jdk1.8、mysql5.x、maven3.53.6、tomcat7.0
前端商品控制器:
@RestController
@RequestMapping("/goods")
public class GoodsController {
@Autowired
private GoodsService goodsService;
@Autowired
private ProviderService providerService;
@Autowired
private CategoryService categoryService;
@SysLog("商品查询 *** 作")
@RequestMapping("/goodsList")
public DataGridViewResult goodsList(GoodsVO goodsVO) {
//创建分页信息 参数1 当前页 参数2 每页显示条数
IPage
QueryWrapper
queryWrapper.eq(goodsVO.getProviderid() != null && goodsVO.getProviderid() != 0, "providerid", goodsVO.getProviderid());
queryWrapper.like(!StringUtils.isEmpty(goodsVO.getGname()), "gname", goodsVO.getGname());
IPage
List
for (Goods goods : records) {
Provider provider = providerService.getById(goods.getProviderid());
if (null != provider) {
goods.setProvidername(provider.getProvidername());
}
}
return new DataGridViewResult(goodsIPage.getTotal(), records);
}
@SysLog("商品添加 *** 作")
@PostMapping("/addgoods")
public Result addGoods(Goods goods) {
String id = RandomStringUtils.randomAlphanumeric(8);
if (goods.getGoodsimg()!=null&&goods.getGoodsimg().endsWith("_temp")){
String newName = AppFileUtils.renameFile(goods.getGoodsimg());
goods.setGoodsimg(newName);
}
goods.setGnumbering(id);
boolean bool = goodsService.save(goods);
if (bool) {
return Result.success(true, "200", "添加成功!");
}
return Result.error(false, null, "添加失败!");
}
@SysLog("商品修改 *** 作")
@PostMapping("/updategoods")
public Result updateGoods(Goods goods) {
//商品图片不是默认图片
if (!(goods.getGoodsimg()!=null&&goods.getGoodsimg().equals(Constast.DEFAULT_IMG))){
if (goods.getGoodsimg().endsWith("_temp")){
String newName = AppFileUtils.renameFile(goods.getGoodsimg());
goods.setGoodsimg(newName);
//删除原先的图片
String oldPath = goodsService.getById(goods.getGid()).getGoodsimg();
AppFileUtils.removeFileByPath(oldPath);
}
}
boolean bool = goodsService.updateById(goods);
if (bool) {
return Result.success(true, "200", "修改成功!");
}
return Result.error(false, null, "修改失败!");
}
@SysLog("商品删除 *** 作")
@RequestMapping("/deleteOne")
public Result deleteOne(int id) {
boolean bool = goodsService.removeById(id);
if (bool) {
return Result.success(true, "200", "删除成功!");
}
return Result.error(false, null, "删除失败!");
}
@RequestMapping("/initGoodsByCategoryId")
public DataGridViewResult initGoodsByCategoryId(int id) {
List
了解详情可以私聊,感谢大家支持与帮助!
需要Java资料、毕设源码、小游戏、练手项目、Java电子书、免费入门直播课的话可以私信免费领取喔~
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)