Search in sources :

Example 81 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project production_ssm by megagao.

the class ManufactureController method deleteBatch.

@RequestMapping(value = "/delete_batch")
@ResponseBody
private CustomResult deleteBatch(String[] ids) throws Exception {
    System.out.println(ids);
    CustomResult result = manufactureService.deleteBatch(ids);
    return result;
}
Also used : CustomResult(com.megagao.production.ssm.domain.customize.CustomResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 82 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project production_ssm by megagao.

the class LoginController method ajaxLogin.

/**
 * shiro ajax登录
 */
@RequestMapping(value = "/ajaxLogin")
@ResponseBody
public Map<String, Object> ajaxLogin(@RequestParam String username, @RequestParam String password, @RequestParam(required = false) String randomcode, HttpSession session) throws Exception {
    Map<String, Object> map = CollectionsFactory.newHashMap();
    if (randomcode != null && !randomcode.equals("")) {
        // 取出session的验证码(正确的验证码)
        String validateCode = (String) session.getAttribute(VALIDATE_CODE);
        // 页面中输入的验证和session中的验证进行对比
        if (validateCode != null && !randomcode.equals(validateCode)) {
            // 如果校验失败,将验证码错误失败信息放入map中
            map.put("msg", "randomcode_error");
            // 直接返回,不再校验账号和密码
            return map;
        }
    }
    Subject currentUser = SecurityUtils.getSubject();
    if (!currentUser.isAuthenticated()) {
        UsernamePasswordToken token = new UsernamePasswordToken(username, password);
        try {
            currentUser.login(token);
        } catch (UnknownAccountException ex) {
            map.put("msg", "account_error");
        } catch (IncorrectCredentialsException ex) {
            map.put("msg", "password_error");
        } catch (AuthenticationException ex) {
            map.put("msg", "authentication_error");
        }
    }
    // 返回json数据
    return map;
}
Also used : IncorrectCredentialsException(org.apache.shiro.authc.IncorrectCredentialsException) AuthenticationException(org.apache.shiro.authc.AuthenticationException) UnknownAccountException(org.apache.shiro.authc.UnknownAccountException) Subject(org.apache.shiro.subject.Subject) UsernamePasswordToken(org.apache.shiro.authc.UsernamePasswordToken) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 83 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project production_ssm by megagao.

the class PCountCheckController method deleteBatch.

@RequestMapping(value = "/delete_batch")
@ResponseBody
private CustomResult deleteBatch(String[] ids) throws Exception {
    System.out.println(ids);
    CustomResult result = pCountCheckService.deleteBatch(ids);
    return result;
}
Also used : CustomResult(com.megagao.production.ssm.domain.customize.CustomResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 84 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project production_ssm by megagao.

the class PCountCheckController method insert.

@RequestMapping(value = "/insert", method = RequestMethod.POST)
@ResponseBody
private CustomResult insert(@Valid ProcessCountCheck processCountCheck, BindingResult bindingResult) throws Exception {
    CustomResult result;
    if (bindingResult.hasErrors()) {
        FieldError fieldError = bindingResult.getFieldError();
        return CustomResult.build(100, fieldError.getDefaultMessage());
    }
    result = pCountCheckService.insert(processCountCheck);
    return result;
}
Also used : FieldError(org.springframework.validation.FieldError) CustomResult(com.megagao.production.ssm.domain.customize.CustomResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 85 with ResponseBody

use of org.springframework.web.bind.annotation.ResponseBody in project leopard by tanhaichao.

the class MultiVersionRequestMappingInfoBuilder method getHeaders.

// TODO 测试类
@Override
public void getHeaders(RequestMapping annotation, Method method, ExtensiveDomain extensiveDomain, Map<String, String> headers) {
    ResponseBody anno = method.getAnnotation(ResponseBody.class);
    if (anno == null) {
        return;
    }
    if (headers.containsKey("version")) {
        return;
    }
    headers.put("version", "0.2");
}
Also used : ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1991 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1700 HashMap (java.util.HashMap)458 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)212 IOException (java.io.IOException)207 JSONObject (com.alibaba.fastjson.JSONObject)200 Map (java.util.Map)172 ApiOperation (io.swagger.annotations.ApiOperation)170 ArrayList (java.util.ArrayList)169 GetMapping (org.springframework.web.bind.annotation.GetMapping)112 ResponseEntity (org.springframework.http.ResponseEntity)102 ApiRest (build.dream.common.api.ApiRest)101 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)101 AuthPassport (com.ngtesting.platform.util.AuthPassport)99 PostMapping (org.springframework.web.bind.annotation.PostMapping)94 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)87 Date (java.util.Date)81 UserVo (com.ngtesting.platform.vo.UserVo)78 LogDetail (com.bc.pmpheep.annotation.LogDetail)71 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)65