All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.base4j.mvc.sys.service.impl.SysUserRoleServiceImpl Maven / Gradle / Ivy

There is a newer version: 1.3.0
Show newest version
package com.base4j.mvc.sys.service.impl;

import com.base4j.mvc.base.service.impl.BaseServiceImpl;
import com.base4j.mvc.sys.entity.SysUserRole;
import com.base4j.mvc.sys.service.SysUserRoleService;
import com.base4j.mybatis.base.QueryParams;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class SysUserRoleServiceImpl extends BaseServiceImpl implements SysUserRoleService {

    @Transactional
    public void saveUserRoles(long userId, Long[] roleIds) {
        QueryParams sysUserRoleParams = new QueryParams(SysUserRole.class);
        QueryParams.Criteria criteria = sysUserRoleParams.createCriteria();
        criteria.andEqualTo("sysUserId", userId);
        deleteByParams(sysUserRoleParams);
        List userRoleList = new ArrayList();
        for (Long roleId : roleIds) {
            SysUserRole sur = new SysUserRole();
            sur.setSysUserId(userId);
            sur.setSysRoleId(roleId);
            insert(sur);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy