com.cory.service.RoleResourceRelService Maven / Gradle / Ivy
package com.cory.service;
import com.cory.constant.CacheConstants;
import com.cory.dao.RoleResourceRelDao;
import com.cory.model.RoleResourceRel;
import com.cory.service.BaseService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* generated by CodeGenerator on 2017/5/10.
*/
@Service
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
@Transactional
public class RoleResourceRelService extends BaseService {
@Autowired
private RoleResourceRelDao roleResourceRelDao;
@Override
public RoleResourceRelDao getDao() {
return roleResourceRelDao;
}
@CacheEvict(value = {CacheConstants.User, CacheConstants.Role, CacheConstants.Resource}, allEntries = true)
public void assign(List roleResourceRelList) {
if (CollectionUtils.isEmpty(roleResourceRelList)) {
return;
}
roleResourceRelDao.deleteByRole(roleResourceRelList.get(0).getRoleId());
for (RoleResourceRel roleResourceRel : roleResourceRelList) {
roleResourceRelDao.add(roleResourceRel);
}
}
}