Browse Source

新增店铺修改名称接口和用户修改手机号及密码接口

cangku
chencheng 3 years ago
parent
commit
838a463d03
  1. 40
      hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java
  2. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
  3. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java

40
hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java

@ -17,6 +17,7 @@ import cc.hiver.core.service.*;
import cc.hiver.core.service.mybatis.IUserRoleService; import cc.hiver.core.service.mybatis.IUserRoleService;
import cc.hiver.core.vo.RoleDTO; import cc.hiver.core.vo.RoleDTO;
import cc.hiver.mall.entity.ShopUser; import cc.hiver.mall.entity.ShopUser;
import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.ShopUserService; import cc.hiver.mall.service.ShopUserService;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -88,6 +89,9 @@ public class UserController {
@Autowired @Autowired
private ShopUserService shopUserService; private ShopUserService shopUserService;
@Autowired
private ShopService shopService;
@PersistenceContext @PersistenceContext
private EntityManager entityManager; private EntityManager entityManager;
@ -127,6 +131,37 @@ public class UserController {
return ResultUtil.success("修改成功"); return ResultUtil.success("修改成功");
} }
/**
* 线上demo不允许测试账号改密码
*
* @param password
* @param newPass
* @return
*/
@RequestMapping(value = "/modifyPassAndMobile", method = RequestMethod.POST)
@ApiOperation(value = "修改密码和手机号")
public Result modifyPassAndMobile(
@ApiParam("用户id") @RequestParam String userId,
@ApiParam("手机号") @RequestParam String mobile,
@ApiParam("旧密码") @RequestParam String password,
@ApiParam("新密码") @RequestParam String newPass) {
User user = userService.findById(userId);
if (!new BCryptPasswordEncoder().matches(password, user.getPassword())) {
return ResultUtil.error("旧密码不正确");
}
String newEncryptPass = new BCryptPasswordEncoder().encode(newPass);
user.setPassword(newEncryptPass);
//user.setPassStrength(passStrength);
user.setMobile(mobile);
userService.update(user);
// 手动更新缓存
redisTemplate.delete(USER + user.getUsername());
// 删除缓存
redisTemplate.delete(USER + user.getUsername());
return ResultUtil.success("修改密码和手机号成功");
}
/** /**
* 线上demo不允许测试账号改密码 * 线上demo不允许测试账号改密码
* *
@ -272,6 +307,11 @@ public class UserController {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
userRoleService.saveOrUpdateAll(userRoles); userRoleService.saveOrUpdateAll(userRoles);
} }
//注册店主和默认店铺
//店主添加店员
//添加店铺和用户信息 //添加店铺和用户信息
ShopUser shopUser = shopUserService.selectByUserIdAndShopId(u.getId(), shopId); ShopUser shopUser = shopUserService.selectByUserIdAndShopId(u.getId(), shopId);
if (shopUser != null) { if (shopUser != null) {

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java

@ -29,6 +29,7 @@ import cc.hiver.mall.service.ShopUserService;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@ -120,6 +121,16 @@ public class ShopController {
return ResultUtil.success("编辑成功"); return ResultUtil.success("编辑成功");
} }
@RequestMapping(value = "/modifyShopNameById", method = RequestMethod.PUT)
@ResponseBody
@ApiOperation(value = "根据店铺id修改店铺名")
public Result<Object> modifyShopNameById(@ApiParam("店铺id") @RequestParam String id,@ApiParam("店铺名称") @RequestParam String shopName) {
Shop shop = shopService.findById(id);
shop.setShopName(shopName);
shopService.update(shop);
return ResultUtil.success("编辑成功");
}
@RequestMapping(value = "/delByIds", method = RequestMethod.POST) @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "通过id删除") @ApiOperation(value = "通过id删除")

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java

@ -37,6 +37,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
@Autowired @Autowired
private ProductService productService; private ProductService productService;
@Autowired
private StockService stockService;
@Transactional @Transactional
@Override @Override
public Result putIn(PurchaseVo purchaseVo) { public Result putIn(PurchaseVo purchaseVo) {
@ -53,6 +56,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
QueryWrapper<Stock> stockQueryWrapper = new QueryWrapper<>(); QueryWrapper<Stock> stockQueryWrapper = new QueryWrapper<>();
stockQueryWrapper.eq("product_id",productId); stockQueryWrapper.eq("product_id",productId);
stockQueryWrapper.eq("attribute_list",attributeList); stockQueryWrapper.eq("attribute_list",attributeList);
stockQueryWrapper.eq("shop_id",purchase.getShopId());
List<Stock> originList = this.list(stockQueryWrapper); List<Stock> originList = this.list(stockQueryWrapper);
Integer stockCount = 0; Integer stockCount = 0;
@ -73,14 +77,13 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
//存在库存则修改库存数量 //存在库存则修改库存数量
Stock origin = originList.get(0); Stock origin = originList.get(0);
stockCount = origin.getStockCount()!=null?origin.getStockCount():0; stockCount = origin.getStockCount()!=null?origin.getStockCount():0;
UpdateWrapper<Stock> updateWrapper = new UpdateWrapper<>(); origin.setStockCount(stockCount + purchaseDetail.getProductCount());
updateWrapper.eq("id",origin.getId()); stockService.saveOrUpdate(origin);
updateWrapper.set("stock_count",stockCount + purchaseDetail.getProductCount());
this.update();
}else { }else {
//没有则新建库存数据 //没有则新建库存数据
Stock stock = new Stock(); Stock stock = new Stock();
BeanUtils.copyBeanProp(stock,purchaseDetail); BeanUtils.copyBeanProp(stock,purchaseDetail);
stock.setStockCount(purchaseDetail.getProductCount());
save(stock); save(stock);
} }

Loading…
Cancel
Save