Search in sources :

Example 1 with CreateOperationLogging

use of com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging in project ballcat by ballcat-projects.

the class SysUserController method addSysUser.

/**
 * 新增用户
 * @param sysUserDTO userInfo
 * @return success/false
 */
@PostMapping
@CreateOperationLogging(msg = "新增系统用户")
@PreAuthorize("@per.hasPermission('system:user:add')")
@Operation(summary = "新增系统用户", description = "新增系统用户")
public R<Void> addSysUser(@Valid @RequestBody SysUserDTO sysUserDTO) {
    SysUser user = sysUserService.getByUsername(sysUserDTO.getUsername());
    if (user != null) {
        return R.failed(BaseResultCode.LOGIC_CHECK_ERROR, "用户名已存在");
    }
    // 明文密码
    String password = PasswordUtils.decodeAES(sysUserDTO.getPass(), securityProperties.getPasswordSecretKey());
    sysUserDTO.setPassword(password);
    return sysUserService.addSysUser(sysUserDTO) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "新增系统用户失败");
}
Also used : SysUser(com.hccake.ballcat.system.model.entity.SysUser) CreateOperationLogging(com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging) Operation(io.swagger.v3.oas.annotations.Operation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with CreateOperationLogging

use of com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging in project ballcat by ballcat-projects.

the class I18nDataController method save.

/**
 * 新增国际化信息
 * @param i18nDataCreateDTO 国际化信息
 * @return R 通用返回体
 */
@CreateOperationLogging(msg = "新增国际化信息")
@PostMapping
@PreAuthorize("@per.hasPermission('i18n:i18n-data:add')")
@Operation(summary = "新增国际化信息", description = "新增国际化信息")
public R<Void> save(@Valid @RequestBody I18nDataCreateDTO i18nDataCreateDTO) {
    // 转换为实体类列表
    List<I18nData> list = new ArrayList<>();
    List<I18nDataCreateDTO.LanguageText> languageTexts = i18nDataCreateDTO.getLanguageTexts();
    for (I18nDataCreateDTO.LanguageText languageText : languageTexts) {
        I18nData i18nData = new I18nData();
        i18nData.setCode(i18nDataCreateDTO.getCode());
        i18nData.setRemarks(i18nDataCreateDTO.getRemarks());
        i18nData.setLanguageTag(languageText.getLanguageTag());
        i18nData.setMessage(languageText.getMessage());
        list.add(i18nData);
    }
    return i18nDataService.saveBatch(list) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "新增国际化信息失败");
}
Also used : ArrayList(java.util.ArrayList) I18nData(com.hccake.ballcat.i18n.model.entity.I18nData) I18nDataCreateDTO(com.hccake.ballcat.i18n.model.dto.I18nDataCreateDTO) CreateOperationLogging(com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging) Operation(io.swagger.v3.oas.annotations.Operation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

CreateOperationLogging (com.hccake.ballcat.common.log.operation.annotation.CreateOperationLogging)2 Operation (io.swagger.v3.oas.annotations.Operation)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 I18nDataCreateDTO (com.hccake.ballcat.i18n.model.dto.I18nDataCreateDTO)1 I18nData (com.hccake.ballcat.i18n.model.entity.I18nData)1 SysUser (com.hccake.ballcat.system.model.entity.SysUser)1 ArrayList (java.util.ArrayList)1