|  |  | 
 |  |  |  | 
 |  |  | import com.dy.common.webUtil.QueryResultVo; | 
 |  |  | import com.dy.pipIrrGlobal.daoBa.BaUserMapper; | 
 |  |  | import com.dy.pipIrrGlobal.daoBa.BaUserRoleMapper; | 
 |  |  | import com.dy.pipIrrGlobal.pojoBa.BaUser; | 
 |  |  | import com.dy.pipIrrGlobal.pojoBa.BaUserRole; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | 
 |  |  | public class UserSv { | 
 |  |  |  | 
 |  |  |     private BaUserMapper dao; | 
 |  |  |     private BaUserRoleMapper urDao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private void setDao(BaUserMapper dao){ | 
 |  |  |         this.dao = dao; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private void setDao(BaUserRoleMapper dao){ | 
 |  |  |         this.urDao = dao; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 设置用户角色 | 
 |  |  |      * @param userId 用户id | 
 |  |  |      * @param roleIds 选择的角色id集合 | 
 |  |  |      * @return 插入用户与角色关联记录数量 | 
 |  |  |      */ | 
 |  |  |     public int setRoles(Long userId, Long[] roleIds){ | 
 |  |  |         this.urDao.deleteByUserId(userId) ; | 
 |  |  |         int count = 0 ; | 
 |  |  |         if(roleIds != null && roleIds.length > 0){ | 
 |  |  |             for(Long roleId : roleIds){ | 
 |  |  |                 count += this.urDao.insertSelective(new BaUserRole(userId,roleId)) ; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return count ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 保存修改实体 | 
 |  |  |      * @param id 实体ID | 
 |  |  |      * @return 影响记录数量 |