@ApiOperation("发帖接口") @ApiImplicitParams({ @ApiImplicitParam(name = "content", value = "帖子内容", dataType = "String"), @ApiImplicitParam(name = "title", value = "帖子标题", dataType = "String"), @ApiImplicitParam(name = "token", value = "用户令牌", dataType = "String"), @ApiImplicitParam(name = "labelId", value = "标签ID", dataType = "Integer") }) @PostMapping public QuarkResult CreatePosts(Posts posts, String token, Integer labelId) { QuarkResult result = restProcessor(() -> { if (token == null) return QuarkResult.warn("请先登录!"); User userbytoken = userService.getUserByToken(token); if (userbytoken == null) return QuarkResult.warn("用户不存在,请先登录!"); User user = userService.findOne(userbytoken.getId()); if (user.getEnable() != 1) return QuarkResult.warn("用户处于封禁状态!"); postsService.savePosts(posts, labelId, user); return QuarkResult.ok(); }); return result; }
/** * 查询某一个域的详细信息 * 如果http请求的参数domain_id为空,则返回null */ @RequestMapping(value = "/details", method = RequestMethod.GET) @ApiOperation(value = "查询域的详细信息", notes = "查询某一个指定域的详细定义信息,如果请求的参数为空,则返回用户自己所在域的详细信息") @ApiImplicitParams({ @ApiImplicitParam(required = true, name = "domain_id", value = "域编码") }) public String getDomainDetails(HttpServletRequest request) { String domainId = request.getParameter("domain_id"); if (domainId == null || domainId.isEmpty()) { logger.info("domain id is empty, return null"); return null; } // 检查用户对域有没有读权限 Boolean status = authService.domainAuth(request, domainId, "r").getStatus(); if (status) { return Hret.error(403, "您没有被授权访问域【" + domainId + "】", null); } DomainEntity domainEntity = domainService.getDomainDetails(domainId); return new GsonBuilder().create().toJson(domainEntity); }
/** * 更新域信息 */ @RequestMapping(method = RequestMethod.PUT) @ResponseBody @ApiOperation(value = "更新域定义信息", notes = "更新域的详细信息,如:域名称,域状态") @ApiImplicitParams({ @ApiImplicitParam(required = true, name = "domain_id", value = "域编码"), @ApiImplicitParam(required = true, name = "domain_desc", value = "域描述信息") }) public String update(HttpServletResponse response, HttpServletRequest request) { DomainEntity domainEntity = parse(request); Boolean status = authService.domainAuth(request, domainEntity.getDomain_id(), "w").getStatus(); if (!status) { response.setStatus(403); return Hret.error(403, "你没有权限编辑域 [ " + domainEntity.getDomain_desc() + " ]", domainEntity); } RetMsg retMsg = domainService.update(domainEntity); if (retMsg.checkCode()) { return Hret.success(retMsg); } response.setStatus(retMsg.getCode()); return Hret.error(retMsg); }
@ApiOperation("翻页查询帖子接口") @ApiImplicitParams({ @ApiImplicitParam(name = "search", value = "查询条件", dataType = "int"), @ApiImplicitParam(name = "type", value = "帖子类型[top : good : ]", dataType = "String"), @ApiImplicitParam(name = "pageNo", value = "页码[从1开始]", dataType = "int"), @ApiImplicitParam(name = "length", value = "返回结果数量[默认20]", dataType = "int") }) @GetMapping() public QuarkResult GetPosts( @RequestParam(required = false, defaultValue = "") String search, @RequestParam(required = false, defaultValue = "") String type, @RequestParam(required = false, defaultValue = "1") int pageNo, @RequestParam(required = false, defaultValue = "20") int length) { QuarkResult result = restProcessor(() -> { if (!type.equals("good") && !type.equals("top") && !type.equals("")) return QuarkResult.error("类型错误!"); Page<Posts> page = postsService.getPostsByPage(type, search, pageNo - 1, length); return QuarkResult.ok(page.getContent(), page.getTotalElements(), page.getNumberOfElements()); }); return result; }
@ApiOperation("翻页帖子详情与回复接口") @ApiImplicitParams({ @ApiImplicitParam(name = "postsid", value = "帖子的id", dataType = "int"), @ApiImplicitParam(name = "pageNo", value = "页码[从1开始]", dataType = "int"), @ApiImplicitParam(name = "length", value = "返回结果数量[默认20]", dataType = "int") }) @GetMapping("/detail/{postsid}") public QuarkResult GetPostsDetail( @PathVariable("postsid") Integer postsid, @RequestParam(required = false, defaultValue = "1") int pageNo, @RequestParam(required = false, defaultValue = "20") int length) { QuarkResult result = restProcessor(() -> { HashMap<String, Object> map = new HashMap<>(); Posts posts = postsService.findOne(postsid); if (posts == null) return QuarkResult.error("帖子不存在"); map.put("posts", posts); Page<Reply> page = replyService.getReplyByPage(postsid, pageNo - 1, length); map.put("replys", page.getContent()); return QuarkResult.ok(map, page.getTotalElements(), page.getNumberOfElements()); }); return result; }
@ApiOperation("根据labelId获取帖子接口") @ApiImplicitParams({ @ApiImplicitParam(name = "labelid", value = "标签的id", dataType = "int"), @ApiImplicitParam(name = "pageNo", value = "页码[从1开始]", dataType = "int"), @ApiImplicitParam(name = "length", value = "返回结果数量[默认20]", dataType = "int"), }) @GetMapping("/label/{labelid}") public QuarkResult GetPostsByLabel( @PathVariable("labelid") Integer labelid, @RequestParam(required = false, defaultValue = "1") int pageNo, @RequestParam(required = false, defaultValue = "20") int length) { QuarkResult result = restProcessor(() -> { Label label = labelService.findOne(labelid); if (label == null) return QuarkResult.error("标签不存在"); Page<Posts> page = postsService.getPostsByLabel(label, pageNo - 1, length); return QuarkResult.ok(page.getContent(), page.getTotalElements(), page.getNumberOfElements()); }); return result; }
@ApiOperation("注册接口") @ApiImplicitParams({ @ApiImplicitParam(name = "email", value = "用户邮箱",dataType = "String"), @ApiImplicitParam(name = "username", value = "用户名称",dataType = "String"), @ApiImplicitParam(name = "password", value = "用户密码",dataType = "String") }) @PostMapping public QuarkResult checkUserName(String email,String username,String password) { QuarkResult result = restProcessor(() -> { if (!userService.checkUserName(username)) return QuarkResult.warn("用户名已存在,请重新输入"); if (!userService.checkUserEmail(email)) return QuarkResult.warn("用户邮箱已存在,请重新输入"); else userService.createUser(email,username,password); return QuarkResult.ok(); }); return result; }
@ApiOperation("登录接口") @ApiImplicitParams({ @ApiImplicitParam(name = "email", value = "用户邮箱",dataType = "String"), @ApiImplicitParam(name = "password", value = "用户密码",dataType = "String") }) @PostMapping("/login") public QuarkResult Login(String email,String password) { QuarkResult result = restProcessor(() -> { User loginUser = userService.findByEmail(email); if (loginUser == null) return QuarkResult.warn("用户邮箱不存在,请重新输入"); if (!loginUser.getPassword().equals(DigestUtils.md5DigestAsHex(password.getBytes()))) return QuarkResult.warn("用户密码错误,请重新输入"); String token = userService.LoginUser(loginUser); return QuarkResult.ok(token); }); return result; }
@ApiOperation("根据Token获取用户的信息与通知消息数量") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "发送给用户的唯一令牌",dataType = "String"), }) @GetMapping("/message/{token}") public QuarkResult getUserAndMessageByToken(@PathVariable String token){ QuarkResult result = restProcessor(() -> { HashMap<String, Object> map = new HashMap<>(); User user = userService.getUserByToken(token); if (user == null) return QuarkResult.warn("session过期,请重新登录"); long count = notificationService.getNotificationCount(user.getId()); map.put("user",user); map.put("messagecount",count); return QuarkResult.ok(map); }); return result; }
@ApiOperation("根据Token修改用户的信息") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "发送给用户的唯一令牌",dataType = "String"), @ApiImplicitParam(name = "username", value = "要修改的用户名",dataType = "String"), @ApiImplicitParam(name = "signature", value = "用户签名",dataType = "String"), @ApiImplicitParam(name = "sex", value = "要修改的性别:数值0为男,1为女",dataType = "int"), }) @PutMapping("/{token}") public QuarkResult updateUser(@PathVariable("token") String token,String username,String signature,Integer sex){ QuarkResult result = restProcessor(() -> { if (!userService.checkUserName(username)) return QuarkResult.warn("用户名重复!"); if (sex != 0 && sex != 1) return QuarkResult.warn("性别输入错误!"); userService.updateUser(token, username, signature, sex); return QuarkResult.ok(); }); return result; }
@ApiOperation("根据用户ID获取用户详情与用户最近发布的十个帖子[主要用于用户主页展示]") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "用户的id", dataType = "int") }) @GetMapping("/detail/{userid}") public QuarkResult getUserById(@PathVariable("userid") Integer userid){ QuarkResult result = restProcessor(() -> { User user = userService.findOne(userid); if (user == null || userid == null) return QuarkResult.warn("用户不存在"); List<Posts> postss = postsService.getPostsByUser(user); HashMap<String, Object> map = new HashMap<>(); map.put("posts",postss); map.put("user",user); return QuarkResult.ok(map); }); return result; }
@ApiOperation("发布回复接口") @ApiImplicitParams({ @ApiImplicitParam(name = "content", value = "回复内容", dataType = "String"), @ApiImplicitParam(name = "token", value = "用户令牌", dataType = "String"), @ApiImplicitParam(name = "postsId", value = "帖子ID", dataType = "Integer") }) @PostMapping public QuarkResult CreateReply(Reply reply,Integer postsId,String token){ QuarkResult result = restProcessor(() -> { if (token == null) return QuarkResult.warn("请先登录!"); User userbytoken = userService.getUserByToken(token); if (userbytoken == null) return QuarkResult.warn("用户不存在,请先登录!"); User user = userService.findOne(userbytoken.getId()); if (user.getEnable() != 1) return QuarkResult.warn("用户处于封禁状态!"); replyService.saveReply(reply, postsId, user); return QuarkResult.ok(); }); return result; }
/** * 登录 */ @AuthIgnore @PostMapping("login") @ApiOperation(value = "登录",notes = "登录说明") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true), @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true) }) public R login(String mobile, String password){ Assert.isBlank(mobile, "手机号不能为空"); Assert.isBlank(password, "密码不能为空"); //用户登录 long userId = userService.login(mobile, password); //生成token Map<String, Object> map = tokenService.createToken(userId); return R.ok(map); }
/** * 注册 */ @AuthIgnore @PostMapping("register") @ApiOperation(value = "注册") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true), @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true) }) public R register(String mobile, String password){ Assert.isBlank(mobile, "手机号不能为空"); Assert.isBlank(password, "密码不能为空"); userService.save(mobile, password); return R.ok(); }
/** * Put test exec config. */ @Override @Path("/config") @ApiOperation(value="Update test exec config.", response=StatusMessage.class) @ApiImplicitParams({ @ApiImplicitParam(name="TestExecConfig", paramType="body", dataType="com.centurylink.mdw.test.TestExecConfig")}) public JSONObject put(String path, JSONObject content, Map<String,String> headers) throws ServiceException, JSONException { if (ApplicationContext.isMasterServer() || headers.get(Listener.METAINFO_MASTER_OP) != null) { TestingServices testingServices = ServiceLocator.getTestingServices(); testingServices.setTestExecConfig(new TestExecConfig(content)); return null; } else { return masterServerPut(path, content); } }
@GetMapping("/userListByPage.json") @ResponseBody @ApiOperation(value = "分页查询用户列表", notes = "不传分页默认1页15条") @ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "页码"), @ApiImplicitParam(name = "pageSize", value = "条数") }) public JsonResponse getUserList(@Validated({Search.class}) UserQuery user, BindingResult bindingResult, PageKey pageKey) throws ValidateException { BindingResultUtil.validateResult(bindingResult); Page<Object> objects = PageHelper.startPage(pageKey.getPage(), pageKey.getPageSize(), true); UserExample example = new UserExample(); example.createCriteria().andUserNameLike(StringUtil.turn2LikeStr(user.getName())); JsonResponse json = new JsonResponse(); List<User> users = userMapper.selectByExample(example); json.putData("list", users); System.out.println("**********共有" + objects.getTotal() + "条数据*********"); // redisTemplate.opsForList().rightPushAll("userList", users); return json; }
@GET @Produces(MediaType.APPLICATION_JSON) @ApiImplicitParams({ @ApiImplicitParam( name = "sort", value = "Sort the result list according to the given field value", paramType = "query", dataType = "string"), @ApiImplicitParam( name = "direction", value = "Sorting direction when a 'sort' field is provided. Can be 'asc' " + "(ascending) or 'desc' (descending)", paramType = "query", dataType = "string"), @ApiImplicitParam( name = "page", value = "Page number to return", paramType = "query", dataType = "integer", defaultValue = "1"), @ApiImplicitParam( name = "per_page", value = "Number of records per page", paramType = "query", dataType = "integer", defaultValue = "20"), @ApiImplicitParam( name = "query", value = "The search query to filter results on", paramType = "query", dataType = "string"), }) default ListResult<T> list(@Context UriInfo uriInfo) { Class<T> clazz = resourceKind().getModelClass(); return getDataManager().fetchAll( clazz, new ReflectiveFilterer<>(clazz, new FilterOptionsFromQueryParams(uriInfo).getFilters()), new ReflectiveSorter<>(clazz, new SortOptionsFromQueryParams(uriInfo)), new PaginationFilter<>(new PaginationOptionsFromQueryParams(uriInfo)) ); }
@ApiOperation(value = "session/user", nickname = "get session user", notes = "get session user") @ApiResponses({ @ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 500, message = "Failure") }) @ApiImplicitParams({ @ApiImplicitParam(name = "search", value = "Name to search", paramType = "query"), @ApiImplicitParam(name = "exclude_hidden", value = "Do not return hidden skills", paramType = "query", defaultValue = "true"), @ApiImplicitParam(name = "count", value = "Limit the number of skills to find", paramType = "query"), }) @RequestMapping(path = "/session/user", method = RequestMethod.GET) public ResponseEntity<String> getCurrentUser(@CookieValue("_oauth2_proxy") String oAuthToken) { logger.debug("Getting user from session {}", oAuthToken); User user = sessionService.getUserByToken(oAuthToken); if (user == null) { return new ResponseEntity<>(new StatusJSON("no current session").toString(), HttpStatus.UNAUTHORIZED); } return new ResponseEntity<>(user.toJSON().toString(), HttpStatus.OK); }
/** * get/suggest skills based on search query -> can be used for autocompletion when user started * typing */ @ApiOperation(value = "suggest skills", nickname = "suggest skills", notes = "suggest skills") @ApiResponses({ @ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Failure") }) @ApiImplicitParams({ @ApiImplicitParam(name = "search", value = "Name to search", paramType = "query"), @ApiImplicitParam(name = "exclude_hidden", value = "Do not return hidden skills", paramType = "query", defaultValue = "true"), @ApiImplicitParam(name = "count", value = "Limit the number of skills to find", paramType = "query"), }) @RequestMapping(path = "/skills", method = RequestMethod.GET) public ResponseEntity<String> getSkills(@RequestParam(required = false) String search, @RequestParam(required = false, defaultValue = "true") boolean exclude_hidden, @RequestParam(required = false, defaultValue = "-1") int count) { JSONArray skillsArr = new JSONArray( skillService.getSkills(search, exclude_hidden, count) .stream() .map(KnownSkill::toJSON) .collect(Collectors.toList()) ); return new ResponseEntity<>(skillsArr.toString(), HttpStatus.OK); }
/** * Overrides {@link MoviesService#get()} to return a single movie with the specified id. */ @Override @ApiOperation(value="Retrieve a movie by {id}", response=Movie.class) @ApiImplicitParams({ @ApiImplicitParam(name="id", paramType="path", dataType="string", required=true)}) public Response<JSONObject> get(Request<JSONObject> request) throws ServiceException { validate(request); String id = request.getPath().getSegment(1); Movie movie = getPersist().get(id); if (movie == null) throw new ServiceException(Status.NOT_FOUND, "Movie not found with id: " + id); else return new Response<>(movie.toJson()); }
@Override @ApiOperation(value="Update a movie.", response=StatusResponse.class) @ApiImplicitParams({ @ApiImplicitParam(name="id", paramType="path", dataType="string", required=true), @ApiImplicitParam(name="Movie", paramType="body", dataType="io.limberest.demo.model.Movie", required=true)}) public Response<JSONObject> put(Request<JSONObject> request) throws ServiceException { validate(request); String id = request.getPath().getSegment(1); if (id == null) throw new ServiceException(Status.BAD_REQUEST, "Missing path segment: id"); Movie movie = new Movie(request.getBody()); if (movie.getId() != null && !id.equals(movie.getId())) throw new ServiceException(Status.BAD_REQUEST, "Cannot modify movie id: " + id); if (movie.getId() == null) movie = new Movie(id, movie); getPersist().update(movie); StatusResponse statusResponse = new StatusResponse(Status.OK, "Movie updated: " + movie.getId()); return new Response<>(statusResponse.toJson()); }
@ApiOperation(value="Retrieve movies", notes="Returns an (optionally paginated) array of movies matching query criteria.", response=Movie.class, responseContainer="List") @ApiImplicitParams({ @ApiImplicitParam(name="title", paramType="query", dataType="string", value="Movie title"), @ApiImplicitParam(name="year", paramType="query", dataType="int", value="Year movie was made"), @ApiImplicitParam(name="rating", paramType="query", dataType="float", value="Rating (up to 5, multiple of 0.5)"), @ApiImplicitParam(name="director", paramType="query", dataType="string", value="Director"), @ApiImplicitParam(name="actors", paramType="query", dataType="string", value="Actor(s) match"), @ApiImplicitParam(name="sort", paramType="query", dataType="string", value="Sort property"), @ApiImplicitParam(name="descending", paramType="query", dataType="boolean", value="Sort descending"), @ApiImplicitParam(name="max", paramType="query", dataType="int", value="Limit retrieved items"), @ApiImplicitParam(name="start", paramType="query", dataType="int", value="Start with this item index"), @ApiImplicitParam(name="search", paramType="query", dataType="string", value="Search string"), @ApiImplicitParam(name="count", paramType="query", dataType="boolean", value="Return item count only"), }) public Response<JSONObject> get(Request<JSONObject> request) throws ServiceException { validate(request); List<Movie> movies = getPersist().retrieve(request.getQuery()); JsonList<Movie> jsonList = new JsonList<>(movies, "movies"); return new Response<>(jsonList.toJson()); }
/** * 查询某一个域的详细信息 * 如果http请求的参数domain_id为空,则返回null */ @RequestMapping(value = "/details", method = RequestMethod.GET) @ApiOperation(value = "查询域的详细信息", notes = "查询某一个指定域的详细定义信息,如果请求的参数为空,则返回用户自己所在域的详细信息") @ApiImplicitParams({ @ApiImplicitParam(required = true, name = "domain_id", value = "域编码") }) public String getDomainDetails(HttpServletRequest request) { String domainId = request.getParameter("domain_id"); if (domainId == null || domainId.isEmpty()) { logger.info("can not get parameter domain_id, request failed."); return ""; } // 检查用户对域有没有读权限 Boolean status = authService.domainAuth(request, domainId, "r").getStatus(); if (status) { return Hret.error(403, "您没有被授权访问域【" + domainId + "】", null); } DomainEntity domainEntity = domainService.getDomainDetails(domainId); return new GsonBuilder().create().toJson(domainEntity); }
@ApiOperation(value = "更新系统参数", notes = "更新结果只对当前操作的域有效") @ApiImplicitParams({ @ApiImplicitParam(required = true, name = "domain_id", value = "域编码"), @ApiImplicitParam(required = true, name = "config_id", value = "参数编码"), @ApiImplicitParam(required = true, name = "config_value", value = "参数值"), }) @RequestMapping(value = "/v1/dispatch/config/user", method = RequestMethod.POST) public String updateConfigValue(HttpServletResponse response, HttpServletRequest request) { String domainId = request.getParameter("domain_id"); String configId = request.getParameter("config_id"); String configValue = request.getParameter("config_value"); int size = sysConfigService.setValue(domainId, configId, configValue); if (size != 1) { response.setStatus(421); return Hret.error(421, "更新ETL调度系统核心参数失败", null); } return Hret.success(200, "success", null); }
@ApiOperation(value="分页查询表单内容", notes="根据传进来的查询参数,获取表单内容信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键ID", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "businessKey", value = "业务主键KEY,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "key", value = "内容键,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "value", value = "内容值,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "tenantId", value = "租户ID,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "page", value = "分页查询,开始查询的页码", defaultValue="0", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "size", value = "分页查询,每页显示的记录数", defaultValue="10", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "sort", value = "排序的字段,可以多值以逗号分割", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "order", value = "排序的方式,可以为asc或desc,可以多值以逗号分割", required = false, dataType = "string", paramType = "query") }) @RequestMapping(value = "/form-datas", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(value = HttpStatus.OK) public Page<FormData> getFormDatas(@ApiIgnore @RequestParam Map<String, String> requestParams) { Criteria<FormData> criteria = new Criteria<FormData>(); criteria.add(Restrictions.eq("id", requestParams.get("id"), true)); criteria.add(Restrictions.like("businessKey", requestParams.get("businessKey"), true)); criteria.add(Restrictions.like("key", requestParams.get("key"), true)); criteria.add(Restrictions.like("value", requestParams.get("value"), true)); criteria.add(Restrictions.like("tenantId", requestParams.get("tenantId"), true)); return formDataRepository.findAll(criteria, getPageable(requestParams)); }
@ApiOperation(value="更新表单内容", notes="根据表单内容的id来指定更新对象,并根据传过来的formDataRequest信息来更新表单内容") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "表单内容ID", required = true, dataType = "Long",paramType="path"), @ApiImplicitParam(name = "formDataRequest", value = "表单内容请求实体formDataRequest", required = true, dataType = "FormDataRequest") }) @RequestMapping(value = "/form-datas/{id}", method = RequestMethod.PUT, produces = "application/json") @ResponseStatus(value = HttpStatus.OK) public FormData updateFormData(@PathVariable Long id,@RequestBody FormDataRequest formDataRequest) throws InterruptedException { FormData formData = getFormDataFromRequest(id); if(formDataRequest.getKey() != null){ formData.setKey(formDataRequest.getKey()); } if(formDataRequest.getValue() != null){ formData.setValue(formDataRequest.getValue()); } if(formDataRequest.getBusinessKey() != null){ // formData.setBusinessKey(formDataRequest.getBusinessKey()); } if(formDataRequest.getTenantId() != null){ formData.setTenantId(formDataRequest.getTenantId()); } return formDataRepository.save(formData); }
@ApiOperation(value="分页查询表单定义", notes="根据传进来的查询参数,获取表单定义信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键ID", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "category", value = "定义分类,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "key", value = "定义键,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "name", value = "定义名称,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "tenantId", value = "租户ID,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "pageNum", value = "分页查询开始查询的页码", defaultValue="1", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "分页查询每页显示的记录数", defaultValue="10", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "sortName", value = "排序的字段,可以多值以逗号分割", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "sortOrder", value = "排序的方式,可以为asc或desc,可以多值以逗号分割", required = false, dataType = "string", paramType = "query") }) @RequestMapping(value = "/form-definitions", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(value = HttpStatus.OK) public PageResponse<FormDefinitionResponse> getFormDefinitions(@ApiIgnore @RequestParam Map<String, String> requestParams) { Criteria<FormDefinition> criteria = new Criteria<FormDefinition>(); criteria.add(Restrictions.eq("id", requestParams.get("id"), true)); criteria.add(Restrictions.like("category", requestParams.get("category"), true)); criteria.add(Restrictions.like("key", requestParams.get("key"), true)); criteria.add(Restrictions.like("name", requestParams.get("name"), true)); criteria.add(Restrictions.like("tenantId", requestParams.get("tenantId"), true)); return responseFactory.createFormDefinitionPageResponse(formDefinitionRepository.findAll(criteria, getPageable(requestParams))); }
@ApiOperation(value = "更新表单模型", notes = "根据表单模型的id来指定更新对象,并根据传过来的modelRequest信息来更新表单模型") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path"), @ApiImplicitParam(name = "modelRequest", value = "表单模型请求实体modelRequest", required = true, dataType = "FormModelRequest") }) @RequestMapping(value = "/form-models/{id}", method = RequestMethod.PUT, produces = "application/json") @ResponseStatus(value = HttpStatus.OK) public FormModelResponse updateFormModel(@PathVariable Long id, @RequestBody FormModelRequest modelRequest) { FormModel formModel = getFormModelFromRequest(id); if (modelRequest.getName() != null) { formModel.setName(modelRequest.getName()); } if (modelRequest.getKey() != null) { formModel.setKey(modelRequest.getKey()); } if (modelRequest.getCategory() != null) { formModel.setCategory(modelRequest.getCategory()); } if (modelRequest.getTenantId() != null) { formModel.setTenantId(modelRequest.getTenantId()); } formModelRepository.save(formModel); return responseFactory.createFormModelResponse(formModel); }
@ApiOperation(value = "分页查询表单模型", notes = "根据传进来的查询参数,获取表单模型信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键ID", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "category", value = "模型分类,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "key", value = "模型键,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "name", value = "模型名称,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "tenantId", value = "租户ID,模糊匹配", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "pageNum", value = "分页查询开始查询的页码", defaultValue = "1", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "分页查询每页显示的记录数", defaultValue = "10", required = false, dataType = "int", paramType = "query"), @ApiImplicitParam(name = "sortName", value = "排序的字段,可以多值以逗号分割", required = false, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "sortOrder", value = "排序的方式,可以为asc或desc,可以多值以逗号分割", required = false, dataType = "string", paramType = "query") }) @RequestMapping(value = "/form-models", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(value = HttpStatus.OK) public PageResponse<FormModelResponse> getFormModels(@ApiIgnore @RequestParam Map<String, String> requestParams) { Criteria<FormModel> criteria = new Criteria<FormModel>(); criteria.add(Restrictions.eq("id", requestParams.get("id"), true)); criteria.add(Restrictions.like("category", requestParams.get("category"), true)); criteria.add(Restrictions.like("key", requestParams.get("key"), true)); criteria.add(Restrictions.like("name", requestParams.get("name"), true)); criteria.add(Restrictions.like("tenantId", requestParams.get("tenantId"), true)); return responseFactory.createFormModelPageResponse(formModelRepository.findAll(criteria, getPageable(requestParams))); }
/** * 登录 */ @IgnoreAuth @PostMapping("login") @ApiOperation(value = "登录",notes = "登录说明") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true), @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true) }) public R login(String mobile, String password){ Assert.isBlank(mobile, "手机号不能为空"); Assert.isBlank(password, "密码不能为空"); //用户登录 long userId = userService.login(mobile, password); //生成token Map<String, Object> map = tokenService.createToken(userId); return R.ok(map); }
/** * 注册 */ @IgnoreAuth @PostMapping("register") @ApiOperation(value = "注册") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true), @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true) }) public R register(String mobile, String password){ Assert.isBlank(mobile, "手机号不能为空"); Assert.isBlank(password, "密码不能为空"); userService.save(mobile, password); return R.ok(); }
/** * 登录 */ @AuthIgnore @PostMapping("login") @ApiOperation(value = "登录", notes = "登录说明") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "string", name = "mobile", value = "手机号", required = true), @ApiImplicitParam(paramType = "query", dataType = "string", name = "password", value = "密码", required = true) }) public Result login(String mobile, String password) { Assert.isBlank(mobile, "手机号不能为空"); Assert.isBlank(password, "密码不能为空"); //用户登录 long userId = userService.login(mobile, password); //生成token String token = jwtConfig.generateToken(userId); Map<String, Object> map = new HashMap<>(16); map.put("token", token); map.put("expire", jwtConfig.getExpire()); return Result.ok(map); }
/** * 注册 */ @AuthIgnore @PostMapping("register") @ApiOperation(value = "注册") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "string", name = "mobile", value = "手机号", required = true), @ApiImplicitParam(paramType = "query", dataType = "string", name = "password", value = "密码", required = true) }) public Result register(String mobile, String password) { Assert.isBlank(mobile, "手机号不能为空"); Assert.isBlank(password, "密码不能为空"); try { userService.save(mobile, password); } catch (Exception e) { log.error("注册异常", e); return Result.error("注册异常"); } return Result.ok(); }
@ApiOperation(value="admin-获取文章列表") @ApiImplicitParams({ @ApiImplicitParam(name = "keyword", value = "查询关键字", required = false), @ApiImplicitParam(name = "pageNum", value = "页码", defaultValue="1", required = false), @ApiImplicitParam(name = "pageSize", value = "页大小", defaultValue="10",required = false) }) @GetMapping public RestResponse getArticles(@ModelAttribute SearchArticleParam searchArticleParam) { Page<Article> articles = null; if (Strings.isNullOrEmpty(searchArticleParam.getKeyword())) { articles = articleService.getArticleByPage(searchArticleParam.getPageNum(), searchArticleParam.getPageSize()); }else { articles = articleService.getArticleByTitle(searchArticleParam.getPageNum(), searchArticleParam.getPageSize(), searchArticleParam.getKeyword()); } return RestResponse.success(articles); }
@ApiOperation(value = "getOrganisationInvitations", nickname = "getOrganisationInvitations") @RequestMapping(value = "/CISCore/getOrganisationInvitations/{organisation}", method = RequestMethod.GET) @ApiImplicitParams({ @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "path") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = ResponseEntity.class), @ApiResponse(code = 400, message = "Bad Request", response = ResponseEntity.class), @ApiResponse(code = 500, message = "Failure", response = ResponseEntity.class)}) public ResponseEntity<List<CgorInvitation>> getOrganisationInvitations(String organisation) throws CISCommunicationException { log.info("--> getOrganisationInvitations"); List<CgorInvitation> cgorInvitationList = new ArrayList<CgorInvitation>(); try { cgorInvitationList = cisCore.getOrganisationInvitations(organisation); } catch (CISCommunicationException e) { log.error("Error executing the request: Communication Error" , e); cgorInvitationList = null; } HttpHeaders responseHeaders = new HttpHeaders(); log.info("getOrganisationInvitations -->"); return new ResponseEntity<List<CgorInvitation>>(cgorInvitationList, responseHeaders, HttpStatus.OK); }
@ApiOperation(value = "getOrganisationByName", nickname = "getOrganisationByName") @RequestMapping(value = "/CISCore/getOrganisationByName/{organisation}", method = RequestMethod.GET) @ApiImplicitParams({ @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = ResponseEntity.class), @ApiResponse(code = 400, message = "Bad Request", response = ResponseEntity.class), @ApiResponse(code = 500, message = "Failure", response = ResponseEntity.class)}) public ResponseEntity<Organisation> getOrganisationByName(@PathVariable String organisation) throws CISCommunicationException { log.info("--> getOrganisationByName: " + organisation); Organisation organisationRes = null; organisationRes = cisCore.getOrganisationByName(organisation); HttpHeaders responseHeaders = new HttpHeaders(); log.info("getOrganisationByName -->"); return new ResponseEntity<Organisation>(organisationRes, responseHeaders, HttpStatus.OK); }
@ApiOperation(value = "getParticipantFromCGOR", nickname = "getParticipantFromCGOR") @RequestMapping(value = "/CISConnector/getParticipantFromCGOR/{cgorName}", method = RequestMethod.GET) @ApiImplicitParams({ @ApiImplicitParam(name = "cgorName", value = "the CGOR name", required = true, dataType = "String", paramType = "path"), @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Participant.class), @ApiResponse(code = 400, message = "Bad Request", response = Participant.class), @ApiResponse(code = 500, message = "Failure", response = Participant.class)}) public ResponseEntity<Participant> getParticipantFromCGOR(@PathVariable String cgorName, @QueryParam("organisation") String organisation) { log.info("--> getParticipantFromCGOR: " + cgorName); Participant participant; try { participant = connector.getParticipantFromCGOR(cgorName, organisation); } catch (CISCommunicationException e) { log.error("Error executing the request: Communication Error" , e); participant = null; } HttpHeaders responseHeaders = new HttpHeaders(); log.info("getParticipantFromCGOR -->"); return new ResponseEntity<Participant>(participant, responseHeaders, HttpStatus.OK); }
@ApiOperation(value = "getOrganisationInvitations", nickname = "getOrganisationInvitations") @RequestMapping(value = "/CISConnector/getOrganisationInvitations/{organisation}", method = RequestMethod.GET) @ApiImplicitParams({ @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "path") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = ResponseEntity.class), @ApiResponse(code = 400, message = "Bad Request", response = ResponseEntity.class), @ApiResponse(code = 500, message = "Failure", response = ResponseEntity.class)}) public ResponseEntity<List<CgorInvitation>> getOrganisationInvitations(@PathVariable String organisation) throws CISCommunicationException { log.info("--> getOrganisationInvitations"); List<CgorInvitation> cgorInvitationList = new ArrayList<CgorInvitation>(); try { cgorInvitationList = connector.getOrganisationInvitations(organisation); } catch (CISCommunicationException e) { log.error("Error executing the request: Communication Error" , e); cgorInvitationList = null; } HttpHeaders responseHeaders = new HttpHeaders(); log.info("getOrganisationInvitations -->"); return new ResponseEntity<List<CgorInvitation>>(cgorInvitationList, responseHeaders, HttpStatus.OK); }
@ApiOperation(value = "getOrganisationByName", nickname = "getOrganisationByName") @RequestMapping(value = "/CISConnector/getOrganisationByName/{organisation}", method = RequestMethod.GET) @ApiImplicitParams({ @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "path") }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = ResponseEntity.class), @ApiResponse(code = 400, message = "Bad Request", response = ResponseEntity.class), @ApiResponse(code = 500, message = "Failure", response = ResponseEntity.class)}) public ResponseEntity<Organisation> getOrganisationByName(@PathVariable String organisation) throws CISCommunicationException { log.info("--> getOrganisationByName: " + organisation); Organisation organisationRes = null; try { organisationRes = connector.getOrganisationByName(organisation); } catch (CISCommunicationException e) { log.error("Error executing the request: Communication Error" , e); organisationRes = null; } HttpHeaders responseHeaders = new HttpHeaders(); log.info("getOrganisationByName -->"); return new ResponseEntity<Organisation>(organisationRes, responseHeaders, HttpStatus.OK); }
@ApiOperation(value = "授权", notes = "") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query",name = "appName", value = "应用的名字", required = true,dataType = "String"), @ApiImplicitParam(paramType = "query",name = "vq",value = "vq",required = true,dataType = "String"), @ApiImplicitParam(paramType = "query",name = "device",value = "设备的名字",required = true,dataType = "String")}) @RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST) public ResponseEntity<?> createAuthenticationToken(String appName,String vq, Device device) throws AuthenticationException { logger.info("应用:" + appName + " 正在授权!"); App app = appRepository.findFirstByAppname(appName); if (app == null) { return ResponseEntity.ok(new ErrorReporter(1, "未找到应用" + appName)); } YibanOAuth yibanOAuth = new YibanOAuth(vq, app); yibanOAuth.dealYibanOauth(); if (yibanOAuth.isHasError() == false) { upcYbUserFactory.createUser(yibanOAuth.getYibanBasicUserInfo()); String ybid = String.valueOf(yibanOAuth.getYibanBasicUserInfo().visit_user.userid); String ybtocken = yibanOAuth.getYibanBasicUserInfo().visit_oauth.access_token; logger.info("ybtocken: " + ybtocken); final JwtUser userDetails = (JwtUser) userDetailsService.loadUserByUsername(ybid); final String token = jwtTokenUtil.generateToken(userDetails, ybtocken,appName, device); logger.info("发放token:" + token); return ResponseEntity.ok(new JwtAuthenticationResponse(token)); } else { return ResponseEntity.ok(new ErrorReporter(2, "解析vq失败,可能是由于密钥长度不匹配")); } }