Search in sources :

Example 6 with CustomResult

use of com.megagao.production.ssm.domain.customize.CustomResult in project production_ssm by megagao.

the class UserController method updateAll.

@RequestMapping(value = "/update_all")
@ResponseBody
private CustomResult updateAll(@Valid SysUser user, BindingResult bindingResult) throws Exception {
    CustomResult result;
    if (bindingResult.hasErrors()) {
        FieldError fieldError = bindingResult.getFieldError();
        return CustomResult.build(100, fieldError.getDefaultMessage());
    }
    if (userService.findByUserNameAndId(user.getUsername(), user.getId()).size() > 0) {
        return CustomResult.build(101, "该用户名已经存在,请更换用户名!");
    }
    result = userService.updateAll(user);
    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 7 with CustomResult

use of com.megagao.production.ssm.domain.customize.CustomResult in project production_ssm by megagao.

the class UserController method insert.

@RequestMapping(value = "/insert", method = RequestMethod.POST)
@ResponseBody
private CustomResult insert(@Valid SysUser user, BindingResult bindingResult) throws Exception {
    CustomResult result;
    if (bindingResult.hasErrors()) {
        FieldError fieldError = bindingResult.getFieldError();
        return CustomResult.build(100, fieldError.getDefaultMessage());
    }
    if (userService.findByUserNameAndId(user.getUsername(), user.getId()).size() > 0) {
        return CustomResult.build(101, "该用户名已经存在,请更换用户名!");
    } else if (userService.get(user.getId()) != null) {
        return CustomResult.build(101, "该用户编号已经存在,请更换用户编号!");
    }
    result = userService.insert(user);
    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 8 with CustomResult

use of com.megagao.production.ssm.domain.customize.CustomResult in project production_ssm by megagao.

the class MaterialConsumeController method deleteBatch.

@RequestMapping(value = "/delete_batch")
@ResponseBody
private CustomResult deleteBatch(String[] ids) throws Exception {
    System.out.println(ids);
    CustomResult result = materialConsumeService.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 9 with CustomResult

use of com.megagao.production.ssm.domain.customize.CustomResult in project production_ssm by megagao.

the class PMeasureCheckController method insert.

/*
	 *此处的method可以取两个值,
	 *一个是RequestMethod.GET,一个是RequestMethod.POST,
	 *就是请求该方法使用的模式,是get还是post,即参数提交的方法
	 *ajax或者form表单提交数据有两种方法,即get和post。
	 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
@ResponseBody
private CustomResult insert(@Valid ProcessMeasureCheck processMeasureCheck, BindingResult bindingResult) throws Exception {
    CustomResult result;
    if (bindingResult.hasErrors()) {
        FieldError fieldError = bindingResult.getFieldError();
        return CustomResult.build(100, fieldError.getDefaultMessage());
    }
    result = pMeasureCheckService.insert(processMeasureCheck);
    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)

Aggregations

CustomResult (com.megagao.production.ssm.domain.customize.CustomResult)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 FieldError (org.springframework.validation.FieldError)5