| | |
| | | |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/exam/{id}", method = RequestMethod.GET) |
| | | public Result exam(@PathVariable String id) { |
| | | Topic topic = topicService.selectById(id); |
| | | topic.setExamine(true); |
| | | |
| | | boolean insert = topic.updateById(); |
| | | |
| | | if (insert) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/add", method = RequestMethod.GET) |
| | | public Result add(HttpServletRequest request) { |
| | | String id = request.getParameter("id"); |
| | | String title = request.getParameter("title"); |
| | | String userId = request.getParameter("userId"); |
| | | if(StringUtils.isEmpty(title)) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | String desp = request.getParameter("desp"); |
| | | Topic topic = new Topic().setUserId(userId).setTitle(title).setDesp(desp).setCreateTime(new Date()); |
| | | topic.setId(DbUtils.getUUID()); |
| | | boolean insert = topic.insert(); |
| | | if (insert) { |
| | | return Result.success(null); |
| | | if (StringUtils.isEmpty(id)) { |
| | | Topic topic = new Topic().setUserId(userId).setTitle(title).setDesp(desp).setCreateTime(new Date()); |
| | | topic.setId(DbUtils.getUUID()); |
| | | boolean insert = topic.insert(); |
| | | if (insert) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | } else { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | Topic topic = topicService.selectById(id); |
| | | boolean b = topic.setDesp(desp).setTitle(title).updateById(); |
| | | if (b) { |
| | | return Result.success(null); |
| | | } else { |
| | | return Result.error(CodeMsg.INSERT_ERROR); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |