Search in sources :

Example 11 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project lilishop by lilishop.

the class CategoryServiceImpl method updateCategory.

@Override
@Transactional(rollbackFor = Exception.class)
public void updateCategory(Category category) {
    // 判断分类佣金是否正确
    if (category.getCommissionRate() < 0) {
        throw new ServiceException(ResultCode.CATEGORY_COMMISSION_RATE_ERROR);
    }
    // 判断父分类与子分类的状态是否一致
    if (category.getParentId() != null && !"0".equals(category.getParentId())) {
        Category parentCategory = this.getById(category.getParentId());
        if (!parentCategory.getDeleteFlag().equals(category.getDeleteFlag())) {
            throw new ServiceException(ResultCode.CATEGORY_DELETE_FLAG_ERROR);
        }
    }
    UpdateWrapper<Category> updateWrapper = new UpdateWrapper<>();
    updateWrapper.eq("id", category.getId()).set("name", category.getName()).set("image", category.getImage()).set("sort_order", category.getSortOrder()).set(DELETE_FLAG_COLUMN, category.getDeleteFlag()).set("commission_rate", category.getCommissionRate());
    this.baseMapper.update(category, updateWrapper);
    removeCache();
}
Also used : Category(cn.lili.modules.goods.entity.dos.Category) ServiceException(cn.lili.common.exception.ServiceException) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project lilishop by lilishop.

the class GoodsGalleryServiceImpl method add.

@Override
@Transactional(rollbackFor = Exception.class)
public void add(List<String> goodsGalleryList, String goodsId) {
    // 删除原来商品相册信息
    this.baseMapper.delete(new UpdateWrapper<GoodsGallery>().eq("goods_id", goodsId));
    // 确定好图片选择器后进行处理
    int i = 0;
    for (String origin : goodsGalleryList) {
        // 获取带所有缩略的相册
        GoodsGallery galley = this.getGoodsGallery(origin);
        galley.setGoodsId(goodsId);
        // 默认第一个为默认图片
        galley.setIsDefault(i == 0 ? 1 : 0);
        i++;
        this.baseMapper.insert(galley);
    }
}
Also used : GoodsGallery(cn.lili.modules.goods.entity.dos.GoodsGallery) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project lilishop by lilishop.

the class MemberNoticeManagerController method read.

@ApiOperation(value = "阅读消息")
@PostMapping("/read/{ids}")
public ResultMessage<Object> read(@PathVariable List ids) {
    UpdateWrapper updateWrapper = new UpdateWrapper();
    updateWrapper.in("id", ids);
    updateWrapper.set("is_read", true);
    memberNoticeService.update(updateWrapper);
    return ResultUtil.success();
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) ApiOperation(io.swagger.annotations.ApiOperation)

Example 14 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project lilishop by lilishop.

the class SeckillServiceImpl method updateEsGoodsSeckill.

/**
 * 更新商品索引限时抢购信息
 *
 * @param seckill 限时抢购信息
 */
@Override
@Transactional(rollbackFor = Exception.class)
public void updateEsGoodsSeckill(Seckill seckill, List<SeckillApply> seckillApplies) {
    if (seckillApplies != null && !seckillApplies.isEmpty()) {
        // 更新促销范围
        seckill.setScopeId(ArrayUtil.join(seckillApplies.stream().map(SeckillApply::getSkuId).toArray(), ","));
        UpdateWrapper<Seckill> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", seckill.getId());
        updateWrapper.set("scope_id", seckill.getScopeId());
        this.update(updateWrapper);
        // 循环秒杀商品数据,将数据按照时间段进行存储
        for (SeckillApply seckillApply : seckillApplies) {
            if (seckillApply.getPromotionApplyStatus().equals(PromotionsApplyStatusEnum.PASS.name())) {
                this.setSeckillApplyTime(seckill, seckillApply);
            }
        }
        if (!seckillApplies.isEmpty()) {
            this.updateEsGoodsIndex(seckill);
        }
    }
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) SeckillApply(cn.lili.modules.promotion.entity.dos.SeckillApply) Seckill(cn.lili.modules.promotion.entity.dos.Seckill) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project shopzz by whoiszxl.

the class PurchaseOrderServiceImpl method updateFinishedBySupplierId.

@Override
public boolean updateFinishedBySupplierId(Long id) {
    UpdateWrapper<PurchaseOrder> updateWrapper = new UpdateWrapper<>();
    updateWrapper.eq("supplier_id", id);
    PurchaseOrder purchaseOrder = new PurchaseOrder();
    purchaseOrder.setSupplierId(id);
    purchaseOrder.setPurchaseOrderStatus(PurchaseOrderStatusConstants.FINISHED);
    return this.update(purchaseOrder, updateWrapper);
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder)

Aggregations

UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)97 Transactional (org.springframework.transaction.annotation.Transactional)41 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)40 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)34 StatusFailException (top.hcode.hoj.common.exception.StatusFailException)28 Session (org.apache.shiro.session.Session)24 StatusForbiddenException (top.hcode.hoj.common.exception.StatusForbiddenException)21 Judge (top.hcode.hoj.pojo.entity.judge.Judge)17 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)16 HttpSession (javax.servlet.http.HttpSession)14 Problem (top.hcode.hoj.pojo.entity.problem.Problem)14 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)13 StatusNotFoundException (top.hcode.hoj.common.exception.StatusNotFoundException)11 Group (top.hcode.hoj.pojo.entity.group.Group)11 Date (java.util.Date)10 Discussion (top.hcode.hoj.pojo.entity.discussion.Discussion)10 Contest (top.hcode.hoj.pojo.entity.contest.Contest)8 User (com.baomidou.mybatisplus.samples.wrapper.entity.User)5 Result (org.jeecg.common.api.vo.Result)5 LoginUser (org.jeecg.common.system.vo.LoginUser)5