欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

使用Java语言开发的软件学院思政案例库系统——核心代码公开

最编程 2024-01-21 22:09:43
...

4.1 查询思政案例

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询思政案例")
public Result<IPage<ThoCase>> getByPage(@ModelAttribute ThoCase thoCase ,@ModelAttribute PageVo page){
    QueryWrapper<ThoCase> qw = new QueryWrapper<>();
    User currUser = securityUtil.getCurrUser();
    QueryWrapper<User> userQw = new QueryWrapper<>();
    userQw.eq("id",currUser.getId());
    userQw.inSql("id","SELECT user_id FROM a_user_role WHERE del_flag = 0 AND role_id = '1536606659751841799'");
    if(iUserService.count(userQw) < 1L) {
        qw.eq("status","审核通过");
    }
    if(!ZwzNullUtils.isNull(thoCase.getTitle())) {
        qw.like("title",thoCase.getTitle());
    }
    if(!ZwzNullUtils.isNull(thoCase.getQues())) {
        qw.like("ques",thoCase.getQues());
    }
    if(!ZwzNullUtils.isNull(thoCase.getType())) {
        qw.like("type",thoCase.getType());
    }
    IPage<ThoCase> data = iThoCaseService.page(PageUtil.initMpPage(page),qw);
    for (ThoCase c : data.getRecords()) {
        QueryWrapper<ThoZan> zanQw = new QueryWrapper<>();
        zanQw.eq("case_id",c.getId());
        zanQw.eq("user_id",currUser.getId());
        c.setZanFlag(iThoZanService.count(zanQw));
    }
    return new ResultUtil<IPage<ThoCase>>().setData(data);
}

4.2 审核思政案例

@RequestMapping(value = "/audit", method = RequestMethod.POST)
@ApiOperation(value = "审核思政案例")
public Result<Object> audit(@RequestParam String id,@RequestParam String type,@RequestParam String msg){
    ThoCase c = iThoCaseService.getById(id);
    if(c == null) {
        return ResultUtil.error("案例不存在");
    }
    c.setStatus(type);
    c.setAuditMsg(msg);
    iThoCaseService.saveOrUpdate(c);
    return ResultUtil.success();
}

4.3 查询思政课程

@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询思政课程")
public Result<IPage<ThoCurriculum>> getByPage(@ModelAttribute ThoCurriculum thoCurriculum ,@ModelAttribute PageVo page){
    QueryWrapper<ThoCurriculum> qw = new QueryWrapper<>();
    if(!ZwzNullUtils.isNull(thoCurriculum.getTitle())) {
        qw.like("title",thoCurriculum.getTitle());
    }
    if(!ZwzNullUtils.isNull(thoCurriculum.getContent())) {
        qw.like("content",thoCurriculum.getContent());
    }
    IPage<ThoCurriculum> data = iThoCurriculumService.page(PageUtil.initMpPage(page),qw);
    return new ResultUtil<IPage<ThoCurriculum>>().setData(data);
}

4.4 思政案例点赞

@RequestMapping(value = "/addOne", method = RequestMethod.GET)
@ApiOperation(value = "新增点赞")
public Result<Object> addOne(@RequestParam String id){
    ThoCase c = iThoCaseService.getById(id);
    if(c == null) {
        return ResultUtil.error("案例不存在");
    }
    User currUser = securityUtil.getCurrUser();
    ThoZan z = new ThoZan();
    z.setCaseId(c.getId());
    z.setTitle(c.getTitle());
    z.setUserId(currUser.getId());
    iThoZanService.saveOrUpdate(z);
    return ResultUtil.success();
}

4.5 新增思政案例评语

@RequestMapping(value = "/addOne", method = RequestMethod.GET)
@ApiOperation(value = "新增评语")
public Result<Object> addOne(@RequestParam String id,@RequestParam String value,@RequestParam String content){
    ThoCase c = iThoCaseService.getById(id);
    if(c == null) {
        return ResultUtil.error("案例不存在");
    }
    User currUser = securityUtil.getCurrUser();
    ThoScore z = new ThoScore();
    z.setCaseId(c.getId());
    z.setTitle(c.getTitle());
    z.setValue(value);
    z.setContent(content);
    z.setUserId(currUser.getId());
    iThoScoreService.saveOrUpdate(z);
    return ResultUtil.success();
}