Search in sources :

Example 46 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper in project sduoj-server by SDUOJ.

the class ContestManageService method update.

public void update(ContestManageDTO reqDTO, UserSessionDTO userSessionDTO) {
    ContestDO contestDO = contestDao.lambdaQuery().select(ContestDO::getContestId, ContestDO::getUserId, ContestDO::getVersion).eq(ContestDO::getContestId, reqDTO.getContestId()).one();
    AssertUtils.notNull(contestDO, ApiExceptionEnum.CONTEST_NOT_FOUND);
    // 超级管理员、创建者、权限组用户 才能更新比赛详情
    AssertUtils.isTrue(contestCommonService.isContestManager(contestDO, userSessionDTO), ApiExceptionEnum.USER_NOT_MATCHING, "只有超级管理员、创建者才能修改比赛");
    ContestDO contestUpdateDO = contestManageConverter.from(reqDTO);
    contestUpdateDO.setParticipantNum(contestUpdateDO.getParticipants().length / 8);
    contestUpdateDO.setVersion(contestDO.getVersion());
    UpdateWrapper<ContestDO> updater = new UpdateWrapper<>();
    updater.eq(ContestDOField.ID, contestUpdateDO.getContestId());
    if (!contestDao.update(contestUpdateDO, updater)) {
        throw new ApiException(ApiExceptionEnum.SERVER_BUSY);
    }
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) ContestDO(cn.edu.sdu.qd.oj.contest.entity.ContestDO) ApiException(cn.edu.sdu.qd.oj.common.exception.ApiException)

Example 47 with UpdateWrapper

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

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);
    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) 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 48 with UpdateWrapper

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

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 49 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper 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 50 with UpdateWrapper

use of com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper 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)

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