下面列出了org.springframework.web.bind.annotation.ResponseBody#org.springframework.web.bind.annotation.RequestParam 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@RequestMapping(value = "/findAll.action", method = RequestMethod.GET)
@ResponseBody
public Map<String,Object> findAll(@RequestParam Integer start, @RequestParam Integer limit, @RequestParam Enum statusValue,
@DefaultValue("no") @QueryParam("trashed") String trashed) throws Exception {
start = (start != null) ? start : 0;
limit = (limit != null) ? limit : 50;
try {
List<Collection> data = collectionService.findAllForPublic(start, limit, statusValue);
logger.info("[findAll] fetched data size: " + ((data != null) ? data.size() : 0));
return getUIWrapper(data, true);
} catch (Exception e) {
logger.error("Error in find All collection for public",e);
return getUIWrapper(false);
}
//return getUIWrapper(false);
}
/**
* 新增机构
*
* @param name 名称
* @param description 描述
* @param fullName 全称
* @param parentId 父级id
* @param isFinal 是否可修改
* @return
*/
@ApiOperation(value = "新增机构", httpMethod = "POST", produces = "application/json", response = Result.class)
@RequiresPermissions("organization:insert")
@ResponseBody
@RequestMapping(value = "insert", method = RequestMethod.POST)
public Result insert(@RequestParam String name,
@RequestParam String description,
@RequestParam String fullName,
@RequestParam long parentId,
@RequestParam(defaultValue = "1") int isFinal) {
boolean isExistFullName = sysOrganizationService.isExistFullName(fullName);
if (isExistFullName) {
return Result.error(ResponseCode.fullname_already_exist.getMsg());
}
SysOrganization organization = new SysOrganization();
organization.setFullName(fullName);
organization.setName(name);
organization.setDescription(description);
organization.setParentId(parentId);
organization.setIsFinal(isFinal);
long i = sysOrganizationService.insertOrganization(organization);
return Result.success();
}
String handleInInterface(
@CookieValue("cookie") int cookieV,
@PathVariable("pathvar") String pathvarV,
@RequestHeader("header") String headerV,
@RequestHeader(defaultValue = "#{systemProperties.systemHeader}") String systemHeader,
@RequestHeader Map<String, Object> headerMap,
@RequestParam("dateParam") Date dateParam,
@RequestParam Map<String, Object> paramMap,
String paramByConvention,
@Value("#{request.contextPath}") String value,
@ModelAttribute("modelAttr") @Valid TestBean modelAttr,
Errors errors,
TestBean modelAttrByConvention,
Color customArg,
HttpServletRequest request,
HttpServletResponse response,
@SessionAttribute TestBean sessionAttribute,
@RequestAttribute TestBean requestAttribute,
User user,
@ModelAttribute OtherUser otherUser,
Model model,
UriComponentsBuilder builder);
@PostMapping(value = "/match/upload", headers = "Content-Type=multipart/form-data")
public String upload(
@RequestParam(value = "taskName") String jobName,
@RequestParam(value = "selectOntologies") String ontologyIri,
@RequestParam(value = "file") MultipartFile file,
Model model,
HttpServletRequest httpServletRequest)
throws IOException {
if (isEmpty(ontologyIri) || file == null) {
return init(model);
}
validateJobName(jobName);
try (InputStream inputStream = file.getInputStream()) {
return startMatchJob(jobName, ontologyIri, model, httpServletRequest, inputStream);
}
}
@RequestMapping("bpm-conf-notice-list")
public String list(@RequestParam("bpmConfNodeId") Long bpmConfNodeId,
Model model) {
BpmConfNode bpmConfNode = bpmConfNodeManager.get(bpmConfNodeId);
Long bpmConfBaseId = bpmConfNode.getBpmConfBase().getId();
List<BpmConfNotice> bpmConfNotices = bpmConfNoticeManager.findBy(
"bpmConfNode", bpmConfNode);
List<BpmMailTemplate> bpmMailTemplates = bpmMailTemplateManager
.getAll();
model.addAttribute("bpmConfBaseId", bpmConfBaseId);
model.addAttribute("bpmConfNotices", bpmConfNotices);
model.addAttribute("bpmMailTemplates", bpmMailTemplates);
return "bpm/bpm-conf-notice-list";
}
@RequestMapping(value = "/removeAttributeFromCrises.action", method = {RequestMethod.GET})
@ResponseBody
public Map<String, Object> removeAttributeFromCrises(@RequestParam Integer id) {
//logger.info("Remove classifier from crises by modelFamilyID");
try {
boolean success = taggerService.removeAttributeFromCrises(id);
if (success){
return getUIWrapper(true, "Classifier was successful removed from crisis");
} else {
return getUIWrapper(false, "Error while remove classifier from crises in Tagger");
}
} catch (Exception e) {
logger.error("Error while removing classifier from crises by modelFamilyID: "+id, e);
return getUIWrapper(false, e.getMessage());
}
}
/**
* 查询操作日志列表
*
* @author fengshuonan
* @Date 2018/12/23 5:34 PM
*/
@RequestMapping("/list")
public LayuiPageInfo list(@RequestParam(required = false) String beginTime,
@RequestParam(required = false) String endTime,
@RequestParam(required = false) String logName,
@RequestParam(required = false) Integer logType) {
//获取分页参数
Page page = LayuiPageFactory.defaultPage();
//根据条件查询操作日志
List<Map<String, Object>> result = restOperationLogService.getOperationLogs(page, beginTime, endTime, logName, BizLogType.valueOf(logType));
page.setRecords(new LogWrapper(result).wrap());
return LayuiPageFactory.createPageInfo(page);
}
@RequestMapping(value="/update", method=RequestMethod.POST)
public @ResponseBody User update(
@RequestParam String username,
@RequestParam String firstName,
@RequestParam String lastName,
@RequestParam Integer role) {
Role existingRole = new Role();
existingRole.setRole(role);
User existingUser = new User();
existingUser.setUsername(username);
existingUser.setFirstName(firstName);
existingUser.setLastName(lastName);
existingUser.setRole(existingRole);
return service.update(existingUser);
}
@RequestMapping(value = "/listSpecificProducts", method = RequestMethod.GET)
public String listSpecificProducts(
@RequestParam(value = "brand", required = true) String brand,
@RequestParam(value = "type", required = true) String type,
@RequestParam(value = "gender", required = true) String gender,
@RequestParam(value = "inStock", required = false) boolean inStock,
Model model) {
Collection<Product> products;
if (inStock) {
products = productRepository.findAllWithStockByBrandTypeGender(brand, type, gender);
}
else {
products = productRepository.findAllByBrandTypeGender(brand, type, gender);
}
model.addAttribute("products", products);
return "listProducts";
}
/**
* 对应校区
*
* @param foodId
* @return
*/
@RequestMapping("cancelRecommend")
public @ResponseBody
Map<String, Object> cancelRecommend(@RequestParam Long foodId,
@RequestParam Integer campusId) {
Map<String, Object> responseMap = new HashMap<String, Object>();
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("foodId", foodId);
paramMap.put("toHome", 0);
paramMap.put("campusId", campusId);
Integer cancel = foodService.cancelRecommend(paramMap);
if (cancel == -1 || cancel == 0) {
responseMap.put(Constants.STATUS, Constants.FAILURE);
responseMap.put(Constants.MESSAGE, "取消推荐失败!");
} else {
responseMap.put(Constants.STATUS, Constants.SUCCESS);
responseMap.put(Constants.MESSAGE, "取消推荐成功!");
}
return responseMap;
}
/**
* 申购
*
* @param productName
* @param orderAmount
* @param currentAmount
* @param response
*/
@RequestMapping(value = "/purchase", method = RequestMethod.GET)
public void puchase(@RequestParam String productName, @RequestParam BigDecimal orderAmount,
@RequestParam BigDecimal currentAmount, HttpServletResponse response) {
response.setHeader("Content-type", "text/html;charset=UTF-8");
try {
this.sysout(response, "购买商品:[" + new String(productName.getBytes("iso8859-1"), "utf-8") + "],订单金额:["
+ orderAmount + "],账户余额:[" + currentAmount + "]");
PurchaseContext context = new PurchaseContext();
context.setCurrentAmount(currentAmount);
context.setOrderAmount(orderAmount);
context.setProductName(new String(productName.getBytes("iso8859-1"), "utf-8"));
log.info(context.toString());
String activityId = purchaseService.puchase(context);
this.sysout(response, "业务活动ID:" + activityId);
List<String> list = tradeLog.getNewLog(activityId);
for (String an : list) {
this.sysout(response, an);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
/**
* 删除
* @return
*/
@RequestMapping(params="doDelete",method = RequestMethod.GET)
@ResponseBody
public AjaxJson doDelete(@RequestParam(required = true, value = "id" ) String id){
AjaxJson j = new AjaxJson();
try {
QywxMenu qywxMenu = new QywxMenu();
qywxMenu.setId(id);
qywxMenuDao.delete(qywxMenu);
j.setMsg("删除成功");
} catch (Exception e) {
log.info(e.getMessage());
j.setSuccess(false);
j.setMsg("删除失败");
}
return j;
}
@PostMapping("keep")
public ServerNode keep(@RequestParam String id, @RequestParam(required = false) String ip, @RequestParam String port, HttpServletRequest request) {
BoundHashOperations imKeep = getNodes();
ServerNode serverNode = null;
if (!imKeep.hasKey(id)) {
serverNode = new ServerNode();
serverNode.setId(id);
if (StringUtils.isEmpty(ip))
ip = IpUtil.getIpAddr(request);
serverNode.setUrl(ip + ":" + port);
serverNode.setLastCheckTime(System.currentTimeMillis());
} else {
serverNode = (ServerNode) imKeep.get(id);
serverNode.setLastCheckTime(System.currentTimeMillis());
}
logger.debug("keep:{} {} {}", id, ip, port);
imKeep.put(id, serverNode);
return serverNode;
}
/**
* 登录
*
* @param loginName 登录名
* @param password 密码
* @param platform 终端类型
* @return
*/
@ApiOperation(value = "登录", httpMethod = "POST", produces = "application/json", response = Result.class)
@ResponseBody
@RequestMapping(value = "login", method = RequestMethod.POST)
public Result login(@RequestParam String loginName,
@RequestParam String password,
@RequestParam int platform,
HttpServletRequest request) throws Exception {
//极限验证二次服务验证
if (!verifyCaptcha(request)) {
return Result.instance(ResponseCode.verify_captcha_error.getCode(), ResponseCode.verify_captcha_error.getMsg());
}
SysUser user = sysUserService.selectByLoginName(loginName);
if (user == null) {
return Result.instance(ResponseCode.unknown_account.getCode(), ResponseCode.unknown_account.getMsg());
}
if (user.getStatus() == 3) {
return Result.instance(ResponseCode.forbidden_account.getCode(), ResponseCode.forbidden_account.getMsg());
}
Subject subject = SecurityUtils.getSubject();
subject.login(new UsernamePasswordToken(loginName, password));
LoginInfo loginInfo = sysUserService.login(user, subject.getSession().getId(), platform);
subject.getSession().setAttribute("loginInfo", loginInfo);
log.debug("登录成功");
return Result.success(loginInfo);
}
@RequestMapping("/list")
@ResponseBody
public Object referenceList(@RequestParam String group, @RequestParam String profile,
@RequestParam(required = false) String groupLike,
@RequestParam(required = false) String dataIdLike,
@RequestParam(required = false, defaultValue = "1") int page,
@RequestParam(required = false, defaultValue = "15") int pageSize) {
checkLegalGroup(group);
checkLegalProfile(profile);
try {
return JsonV2.successOf(
referenceService.getReferenceInfo(
group, profile, groupLike, dataIdLike, page, pageSize, true));
} catch (RuntimeException e) {
logger.error("get reference list error, group={}, profile={}", group, profile, e);
throw e;
}
}
@RequestMapping( value = "/eventReport/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } )
public void writeEventReportInterpretation( @PathVariable( "uid" ) String uid,
@RequestParam( value = "ou", required = false ) String orgUnitUid, @RequestBody String text,
HttpServletResponse response, HttpServletRequest request )
throws WebMessageException
{
EventReport eventReport = idObjectManager.get( EventReport.class, uid );
if ( eventReport == null )
{
throw new WebMessageException(
WebMessageUtils.conflict( "Event report does not exist or is not accessible: " + uid ) );
}
OrganisationUnit orgUnit = getUserOrganisationUnit( orgUnitUid, eventReport,
currentUserService.getCurrentUser() );
createIntepretation( new Interpretation( eventReport, orgUnit, text ), request, response );
}
@RequestMapping(value = "{event}/depositAdvancement", method = RequestMethod.POST)
public String depositAdvancement(final @PathVariable Event event, final User user, final Model model,
@RequestParam final Event eventToRefund) {
accessControlService.checkEventOwnerOrPaymentManager(eventToRefund, user);
try {
accountingManagementService.depositAdvancement(event, eventToRefund, user);
}
catch (DomainException e) {
e.printStackTrace();
model.addAttribute("error", e.getLocalizedMessage());
return depositAdvancementInput(event, user, model);
}
return redirectToEventDetails(event);
}
/**
* @param code 需要显示的pick code
* @param key 可选参数:根据具体情况定义,如当为模块是,key代表父id
* @param radio 是否为单选
* @param def 默认值
* @param tag 保存选中结果的id
* @param tagName 显示名称的输入框id
* @param notNull 是否可以为空:当为单选,且notNull=false是,则可以选着为空
* @return
* @throws Exception
*/
@RequestMapping(value = "newPick.do")
@AuthPassport
public String newPick(String code,
@RequestParam(defaultValue = "") String key,
@RequestParam(defaultValue = "true") String radio,
String def,
String tag,
String tagName,
String notNull) throws Exception {
String pickContent = customMenuService.pick(radio, code, key, def, notNull);
HttpServletRequest request = ThreadContext.request();
request.setAttribute("radio", radio);
request.setAttribute("tag", tag);
request.setAttribute("def", def);
request.setAttribute("iCallBack", getParam("iCallBack", "voidFunction"));
request.setAttribute("iCallBackParam", getParam("iCallBackParam", ""));
request.setAttribute("tagName", tagName);
request.setAttribute("pickContent", pickContent);
return "WEB-INF/views/newPick.jsp";
}
@RequestMapping(value = "/users/upload", method = RequestMethod.POST)
public String postMultipart(@RequestParam("file") final MultipartFile file) {
if (!file.isEmpty()) {
try {
final DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH.mm.ss");
final String fileName = dateFormat.format(new Date());
final File fileServer = new File(fileName);
fileServer.createNewFile();
final byte[] bytes = file.getBytes();
final BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(fileServer));
stream.write(bytes);
stream.close();
return "You successfully uploaded ";
} catch (final Exception e) {
return "You failed to upload " + e.getMessage();
}
} else {
return "You failed to upload because the file was empty.";
}
}
@PostMapping( value = "", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE )
public void postRelationshipJson(
@RequestParam( defaultValue = "CREATE_AND_UPDATE" ) ImportStrategy strategy,
ImportOptions importOptions,
HttpServletRequest request, HttpServletResponse response
)
throws IOException
{
importOptions.setStrategy( strategy );
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat( request.getInputStream() );
ImportSummaries importSummaries = relationshipService.addRelationshipsJson( inputStream, importOptions );
importSummaries.getImportSummaries().stream()
.filter( filterImportSummary( importOptions ) )
.forEach( setImportSummaryHref( request ) );
webMessageService.send( WebMessageUtils.importSummaries( importSummaries ), response, request );
}
@GetMapping(value = "/login")
public ModelAndView login(
@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
logger.info("******login(error): {} ***************************************", error);
logger.info("******login(logout): {} ***************************************", logout);
ModelAndView model = new ModelAndView();
if (error != null) {
model.addObject("error", "Invalid username and password!");
}
if (logout != null) {
model.addObject("message", "You've been logged out successfully.");
}
model.setViewName("login");
return model;
}
/**
* <p>
* 部门搜索功能方法,根据关键字模糊搜索相关部门
* </p>
*
* @param keyWord
* @return
*/
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
try {
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
if (treeList.size() == 0 || treeList == null) {
throw new Exception();
}
result.setSuccess(true);
result.setResult(treeList);
return result;
} catch (Exception e) {
e.fillInStackTrace();
result.setSuccess(false);
result.setMessage("查询失败或没有您想要的任何数据!");
return result;
}
}
/**
* API returns details of the given ruleId.
*
* @param ruleId the rule id
* @return ResponseEntity<Object>
*/
@RequestMapping(path = "/v1/policydescription", method = RequestMethod.GET)
public ResponseEntity<Object> getPolicyDescription(@RequestParam("ruleId") String ruleId) {
if (Strings.isNullOrEmpty(ruleId)) {
return ResponseUtils.buildFailureResponse(new Exception("ruleId Mandatory"));
}
PolicyDescription response = null;
try {
response = new PolicyDescription(complianceService.getRuleDescription(ruleId));
} catch (ServiceException e) {
return complianceService.formatException(e);
}
return ResponseUtils.buildSucessResponse(response);
}
@Test
public void resolveStringArray() throws Exception {
String[] expected = new String[] {"foo", "bar"};
request.addParameter("name", expected);
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(String[].class);
Object result = resolver.resolveArgument(param, null, webRequest, null);
assertTrue(result instanceof String[]);
assertArrayEquals("Invalid result", expected, (String[]) result);
}
@RequestMapping("cms-site-remove")
public String remove(@RequestParam("selectedItem") List<Long> selectedItem,
RedirectAttributes redirectAttributes) {
List<CmsSite> cmsSites = cmsSiteManager.findByIds(selectedItem);
cmsCatalogManager.removeAll(cmsSites);
messageHelper.addFlashMessage(redirectAttributes,
"core.success.delete", "删除成功");
return "redirect:/cms/cms-site-list.do";
}
/**
* 上传文件
*
* @param file
* @return
* @throws IOException
*/
@PostMapping("/upload")
public Object upload(@RequestParam("file") MultipartFile file) throws IOException {
logger.info("【请求开始】上传文件,请求参数,file:{}", file.getOriginalFilename());
String originalFilename = file.getOriginalFilename();
String url = storageService.store(file.getInputStream(), file.getSize(), file.getContentType(),
originalFilename);
Map<String, Object> data = new HashMap<>();
data.put("url", url);
logger.info("【请求结束】上传文件,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
/**
* 通过id查询
* @param id
* @return
*/
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
public Result<SysRole> queryById(@RequestParam(name="id",required=true) String id) {
Result<SysRole> result = new Result<SysRole>();
SysRole sysrole = sysRoleService.getById(id);
if(sysrole==null) {
result.error500("未找到对应实体");
}else {
result.setResult(sysrole);
result.setSuccess(true);
}
return result;
}
@RequestMapping(value="like" )
public void like(
@RequestParam("weiboId") int weiboId,
HttpServletResponse response,
HttpSession session) throws Exception{
UserCustom user = (UserCustom) session.getAttribute("user");
likesService.like(weiboId,user.getUserId());
}
/**
* 通用电脑模式,更改底部的二维码,提交保存
*/
@RequestMapping(value = "popupQrImageUpdateSubmit${url.suffix}", method = RequestMethod.POST)
public void popupQrImageUpdateSubmit(Model model,HttpServletRequest request,HttpServletResponse response,
@RequestParam("qrImageFile") MultipartFile multipartFile) throws IOException{
JSONObject json = new JSONObject();
Site site = getSite();
if(!(multipartFile.getContentType().equals("image/pjpeg") || multipartFile.getContentType().equals("image/jpeg") || multipartFile.getContentType().equals("image/png") || multipartFile.getContentType().equals("image/gif"))){
json.put("result", "0");
json.put("info", "请传入jpg、png、gif格式的二维码图");
}else{
//格式转换
BufferedImage bufferedImage = ImageUtil.inputStreamToBufferedImage(multipartFile.getInputStream());
BufferedImage tag = ImageUtil.formatConversion(bufferedImage);
BufferedImage tag1 = ImageUtil.proportionZoom(tag, 400);
//上传
AttachmentFile.put("site/"+site.getId()+"/images/qr.jpg", ImageUtil.bufferedImageToInputStream(tag1, "jpg"));
AliyunLog.addActionLog(getSiteId(), "通用电脑模式,更改底部的二维码,提交保存");
json.put("result", "1");
}
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
PrintWriter out = null;
try {
out = response.getWriter();
out.append(json.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}
@RequestMapping("pim-remind-list")
public String list(@ModelAttribute Page page,
@RequestParam Map<String, Object> parameterMap, Model model) {
String userId = currentUserHolder.getUserId();
List<PropertyFilter> propertyFilters = PropertyFilter
.buildFromMap(parameterMap);
propertyFilters.add(new PropertyFilter("EQS_userId", userId));
page = pimRemindManager.pagedQuery(page, propertyFilters);
model.addAttribute("page", page);
return "pim/pim-remind-list";
}