Search in sources :

Example 51 with UpdateWrapper

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

the class AttrServiceImpl method saveAttrInfo.

public String saveAttrInfo(PmsBaseAttrInfo pmsBaseAttrInfo) {
    Long id = pmsBaseAttrInfo.getId();
    if (id == null) {
        // id为空,直接插入数据
        // 保存属性
        attrInfoMapper.insert(pmsBaseAttrInfo);
        // 保存属性值
        List<PmsBaseAttrValue> attrValueList = pmsBaseAttrInfo.getAttrValueList();
        for (PmsBaseAttrValue pmsBaseAttrValue : attrValueList) {
            pmsBaseAttrValue.setAttrId(pmsBaseAttrInfo.getId());
            attrValueMapper.insert(pmsBaseAttrValue);
        }
    } else {
        attrInfoMapper.update(pmsBaseAttrInfo, new UpdateWrapper<PmsBaseAttrInfo>().eq("id", id));
        // id不为空,修改数据:先删除后插入
        attrValueMapper.delete(new QueryWrapper<PmsBaseAttrValue>().eq("attr_id", id));
        List<PmsBaseAttrValue> attrValueList = pmsBaseAttrInfo.getAttrValueList();
        for (PmsBaseAttrValue pmsBaseAttrValue : attrValueList) {
            pmsBaseAttrValue.setAttrId(pmsBaseAttrInfo.getId());
            attrValueMapper.insert(pmsBaseAttrValue);
        }
    }
    return "success";
}
Also used : PmsBaseAttrValue(com.xatu.gmall.entity.PmsBaseAttrValue) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)

Example 52 with UpdateWrapper

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

the class PaymentServiceImpl method updatePaymentInfo.

@Override
public void updatePaymentInfo(PaymentInfo paymentInfo) {
    // 进行幂等性检查
    PaymentInfo paymentInfoResult = paymentMapper.selectOne(new QueryWrapper<PaymentInfo>().eq("alipay_trade_no", paymentInfo.getOrderSn()));
    if (StringUtils.isNotBlank(paymentInfoResult.getPaymentStatus()) && paymentInfoResult.getPaymentStatus().equals("已支付")) {
        return;
    } else {
        Connection connection = null;
        Session session = null;
        try {
            connection = activeMQUtil.getConnectionFactory().createConnection();
            session = connection.createSession(true, Session.SESSION_TRANSACTED);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            paymentMapper.update(paymentInfo, new UpdateWrapper<PaymentInfo>().eq("order_sn", paymentInfo.getOrderSn()));
            // 支付成功后,引起的系统服务,订单服务的更新   --》库存服务  --》物流服务
            // 调用mq发送支付成功的消息
            Queue payment_success_quene = session.createQueue("PAYMENT_SUCCESS_QUENE");
            MessageProducer producer = session.createProducer(payment_success_quene);
            // 字符串文本
            TextMessage textMessage = new ActiveMQTextMessage();
            // hash结构
            MapMessage mapMessage = new ActiveMQMapMessage();
            mapMessage.setString("out_trade_no", paymentInfo.getOrderSn());
            session.commit();
        } catch (Exception e) {
            // 消息回滚
            try {
                session.rollback();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } finally {
            try {
                connection.close();
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : PaymentInfo(com.xatu.gmall.entity.PaymentInfo) ActiveMQMapMessage(org.apache.activemq.command.ActiveMQMapMessage) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ActiveMQMapMessage(org.apache.activemq.command.ActiveMQMapMessage) AlipayApiException(com.alipay.api.AlipayApiException) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage)

Example 53 with UpdateWrapper

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

the class MemberNoticeManagerController method readAll.

@ApiOperation(value = "阅读全部")
@PostMapping("/read/all")
public ResultMessage<Object> readAll() {
    UpdateWrapper updateWrapper = new UpdateWrapper();
    updateWrapper.in("member_id", UserContext.getCurrentUser().getId());
    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 54 with UpdateWrapper

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

the class PurchaseOrderServiceImpl method close.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean close(String id) {
    PurchaseOrder purchaseOrder = this.getById(id);
    purchaseOrder.setStatus("CLOSE");
    UpdateWrapper<PurchaseOrder> updateWrapper = new UpdateWrapper<>();
    updateWrapper.eq("id", id);
    updateWrapper.set("status", "CLOSE");
    return this.update(updateWrapper);
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) PurchaseOrder(cn.lili.modules.purchase.entity.dos.PurchaseOrder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 55 with UpdateWrapper

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

the class GoodsServiceImpl method updateStoreDetail.

@Override
@Transactional(rollbackFor = Exception.class)
public void updateStoreDetail(Store store) {
    UpdateWrapper updateWrapper = new UpdateWrapper<>().eq("store_id", store.getId()).set("store_name", store.getStoreName()).set("self_operated", store.getSelfOperated());
    this.update(updateWrapper);
    goodsSkuService.update(updateWrapper);
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

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