Search in sources :

Example 1 with ISuperBaseService

use of com.hb0730.boot.admin.domain.service.ISuperBaseService in project boot-admin by hb0730.

the class IBaseSaveController method save.

/**
 * 保存
 *
 * @param dto 参数
 * @return 是否成功
 */
@PostMapping("/save")
@SuppressWarnings({ "rawtypes", "unchecked" })
@Log(value = "保存", paramsName = { "dto" }, businessType = BusinessTypeEnum.INSERT)
@PreAuthorize("@bootAdmin.hasAnyAuthority(this,'ROLE_ADMINISTRATOR','save')")
default Result<String> save(@RequestBody @Validated DTO dto) {
    ValidatorUtils.validate(dto);
    ISuperBaseService baseService = getBaseService();
    if (null != baseService) {
        baseService.save(dto);
        return R.success("保存成功");
    }
    return R.result(ResponseStatusEnum.PARAMS_REQUIRED_IS_NULL, "service is null");
}
Also used : ISuperBaseService(com.hb0730.boot.admin.domain.service.ISuperBaseService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(com.hb0730.boot.admin.annotation.Log) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with ISuperBaseService

use of com.hb0730.boot.admin.domain.service.ISuperBaseService in project boot-admin by hb0730.

the class IBaseUpdateController method updateById.

/**
 * 根据id修改
 *
 * @param id  id
 * @param dto 修改参数
 * @return 是否成功
 */
@PutMapping("/update/{id}")
@SuppressWarnings({ "rawtypes", "unchecked" })
@Log(value = "修改", paramsName = { "dto" }, businessType = BusinessTypeEnum.UPDATE)
@PreAuthorize("@bootAdmin.hasAnyAuthority(this,'ROLE_ADMINISTRATOR','update')")
default Result<String> updateById(@PathVariable("id") ID id, @Validated @RequestBody DTO dto) {
    ValidatorUtils.validate(dto);
    ISuperBaseService service = getBaseService();
    if (null != service) {
        service.updateById(id, dto);
        return R.success("修改成功");
    }
    return R.result(ResponseStatusEnum.PARAMS_REQUIRED_IS_NULL, "service is null");
}
Also used : ISuperBaseService(com.hb0730.boot.admin.domain.service.ISuperBaseService) Log(com.hb0730.boot.admin.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

Log (com.hb0730.boot.admin.annotation.Log)2 ISuperBaseService (com.hb0730.boot.admin.domain.service.ISuperBaseService)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 PutMapping (org.springframework.web.bind.annotation.PutMapping)1