Search in sources :

Example 26 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project qiwen-file by qiwenshare.

the class UserFileService method deleteUserFile.

@Override
public void deleteUserFile(Long userFileId, Long sessionUserId) {
    UserFile userFile = userFileMapper.selectById(userFileId);
    String uuid = UUID.randomUUID().toString();
    if (userFile.getIsDir() == 1) {
        LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper = new LambdaUpdateWrapper<UserFile>();
        userFileLambdaUpdateWrapper.set(UserFile::getDeleteFlag, RandomUtil.randomInt(FileConstant.deleteFileRandomSize)).set(UserFile::getDeleteBatchNum, uuid).set(UserFile::getDeleteTime, DateUtil.getCurrentTime()).eq(UserFile::getUserFileId, userFileId);
        userFileMapper.update(null, userFileLambdaUpdateWrapper);
        String filePath = userFile.getFilePath() + userFile.getFileName() + "/";
        updateFileDeleteStateByFilePath(filePath, uuid, sessionUserId);
    } else {
        UserFile userFileTemp = userFileMapper.selectById(userFileId);
        LambdaUpdateWrapper<UserFile> userFileLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
        userFileLambdaUpdateWrapper.set(UserFile::getDeleteFlag, RandomUtil.randomInt(1, FileConstant.deleteFileRandomSize)).set(UserFile::getDeleteTime, DateUtil.getCurrentTime()).set(UserFile::getDeleteBatchNum, uuid).eq(UserFile::getUserFileId, userFileTemp.getUserFileId());
        userFileMapper.update(null, userFileLambdaUpdateWrapper);
    }
    RecoveryFile recoveryFile = new RecoveryFile();
    recoveryFile.setUserFileId(userFileId);
    recoveryFile.setDeleteTime(DateUtil.getCurrentTime());
    recoveryFile.setDeleteBatchNum(uuid);
    recoveryFileMapper.insert(recoveryFile);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) UserFile(com.qiwenshare.file.domain.UserFile) RecoveryFile(com.qiwenshare.file.domain.RecoveryFile)

Example 27 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project jeecg-boot by jeecgboot.

the class SysAnnouncementSendController method editById.

/**
 * @功能:更新用户系统消息阅读状态
 * @param json
 * @return
 */
@PutMapping(value = "/editByAnntIdAndUserId")
public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) {
    Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
    String anntId = json.getString("anntId");
    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    String userId = sysUser.getId();
    LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
    updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
    updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
    updateWrapper.last("where annt_id ='" + anntId + "' and user_id ='" + userId + "'");
    SysAnnouncementSend announcementSend = new SysAnnouncementSend();
    sysAnnouncementSendService.update(announcementSend, updateWrapper);
    result.setSuccess(true);
    return result;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) LoginUser(org.jeecg.common.system.vo.LoginUser) Date(java.util.Date) Result(org.jeecg.common.api.vo.Result) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 28 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project jeecg-boot by jeecgboot.

the class SysAnnouncementSendController method readAll.

/**
 * @功能:一键已读
 * @return
 */
@PutMapping(value = "/readAll")
public Result<SysAnnouncementSend> readAll() {
    Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
    LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    String userId = sysUser.getId();
    LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
    updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
    updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
    updateWrapper.last("where user_id ='" + userId + "'");
    SysAnnouncementSend announcementSend = new SysAnnouncementSend();
    sysAnnouncementSendService.update(announcementSend, updateWrapper);
    JSONObject socketParams = new JSONObject();
    socketParams.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
    webSocket.sendMessage(socketParams.toJSONString());
    result.setSuccess(true);
    result.setMessage("全部已读");
    return result;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) JSONObject(com.alibaba.fastjson.JSONObject) LoginUser(org.jeecg.common.system.vo.LoginUser) Date(java.util.Date) Result(org.jeecg.common.api.vo.Result) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 29 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project demo-SpringBoot by Max-Qiu.

the class TestUserService method saveOrUpdateWithWrapper.

/**
 * 更新或保存,带条件查询
 */
@Test
void saveOrUpdateWithWrapper() {
    // update(entity, updateWrapper) || saveOrUpdate(entity);
    // 先执行 update ,根据update结果执行 saveOrUpdate
    // UPDATE smp_user SET age=? WHERE (age = ?)
    // SELECT id,username,age,email FROM smp_user WHERE id=?
    // INSERT INTO smp_user ( id, age ) VALUES ( ?, ? )
    boolean save1 = userService.saveOrUpdate(new User().setId(2L).setAge(11), new LambdaUpdateWrapper<User>().eq(User::getAge, 18));
    System.out.println(save1);
    // UPDATE smp_user SET age=? WHERE (age = ?)
    boolean save2 = userService.saveOrUpdate(new User().setId(2L).setAge(18), new LambdaUpdateWrapper<User>().eq(User::getAge, 11));
    System.out.println(save2);
    // UPDATE smp_user SET username=?, age=? WHERE (age = ?)
    // SELECT id,username,age,email FROM smp_user WHERE id=?
    // UPDATE smp_user SET age=? WHERE id=?
    boolean save3 = userService.saveOrUpdate(new User().setId(2L).setAge(18), new LambdaUpdateWrapper<User>().eq(User::getAge, 1));
    System.out.println(save3);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) User(com.maxqiu.demo.entity.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with LambdaUpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project demo-SpringBoot by Max-Qiu.

the class TestUser method update2.

@Test
void update2() {
    // UPDATE smp_user SET email=? WHERE username=? AND (username = ?)
    // 构造WHERE条件
    User whereUser = new User();
    whereUser.setUsername("xxxxxx");
    LambdaUpdateWrapper<User> wrapper = new LambdaUpdateWrapper<>(whereUser);
    wrapper.eq(User::getUsername, "xxxxxx");
    // 构造 SET 值
    User user = new User();
    user.setEmail("123@126.com");
    boolean i = user.update(wrapper);
    System.out.println("更新结果:" + i);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) User(com.maxqiu.demo.entity.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)47 Transactional (org.springframework.transaction.annotation.Transactional)11 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)10 Date (java.util.Date)7 Result (org.jeecg.common.api.vo.Result)6 LoginUser (org.jeecg.common.system.vo.LoginUser)6 SysAnnouncementSend (org.jeecg.modules.system.entity.SysAnnouncementSend)6 Test (org.junit.jupiter.api.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 PutMapping (org.springframework.web.bind.annotation.PutMapping)6 OrderItem (cn.lili.modules.order.order.entity.dos.OrderItem)5 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)5 User (com.maxqiu.demo.entity.User)5 DateTime (cn.hutool.core.date.DateTime)4 UserFile (com.qiwenshare.file.domain.UserFile)4 ServiceException (cn.lili.common.exception.ServiceException)3 Order (cn.lili.modules.order.order.entity.dos.Order)3 SysOssConfig (com.ruoyi.system.domain.SysOssConfig)3 DistributionOrder (cn.lili.modules.distribution.entity.dos.DistributionOrder)2 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)2