package com.czg.service.account.service.impl;

import com.czg.account.entity.SysUsersRoles;
import com.czg.account.service.SysUsersRolesService;
import com.czg.service.account.mapper.SysUsersRolesMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 用户角色关联 服务层实现。
 *
 * @author Administrator
 * @since 2025-02-10
 */
@Service
public class SysUsersRolesServiceImpl extends ServiceImpl<SysUsersRolesMapper, SysUsersRoles>  implements SysUsersRolesService {
    @Override
    public Boolean updateRole(long sysUserId, Long roleId) {
        remove(new QueryWrapper().eq(SysUsersRoles::getUserId, sysUserId));

        SysUsersRoles usersRoles = new SysUsersRoles();
        usersRoles.setUserId(sysUserId);
        usersRoles.setRoleId(roleId);
        return save(usersRoles);
    }
}
