package com.qqchen.deploy.backend.system.service;

import com.qqchen.deploy.backend.system.model.UserDTO;
import com.qqchen.deploy.backend.framework.annotation.Audited;
import com.qqchen.deploy.backend.framework.service.IBaseService;
import com.qqchen.deploy.backend.system.model.query.UserQuery;
import com.qqchen.deploy.backend.system.model.request.LoginRequest;
import com.qqchen.deploy.backend.system.model.response.LoginResponse;
import com.qqchen.deploy.backend.system.entity.User;
import com.qqchen.deploy.backend.system.model.request.UserRequest;
import com.qqchen.deploy.backend.system.model.RoleDTO;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface IUserService extends IBaseService<User, UserDTO, UserQuery, Long> {
    LoginResponse login(LoginRequest request);
    UserDTO register(UserRequest request);
    boolean checkUsernameExists(String username);
    boolean checkEmailExists(String email);
    List<RoleDTO> getUserRoles(Long userId);
    List<RoleDTO> getCurrentUserRoles();

    @Transactional(readOnly = false)
    @Audited(action = "CHANGE_PASSWORD", detail = "修改密码")
    void changePassword(Long userId, String oldPassword, String newPassword);

    /**
     * 获取当前用户信息(内部服务使用)
     * @return 当前用户DTO，包含完整信息
     */
    @Transactional(readOnly = true)
    @Audited(action = "GET_CURRENT_USER", detail = "获取当前用户信息")
    UserDTO getCurrentUser();

    /**
     * 获取当前用户信息(前端使用)
     * @return 当前用户响应，不包含敏感信息
     */
    @Transactional(readOnly = true)
    LoginResponse getCurrentUserResponse();

    @Transactional(readOnly = false)
    @Audited(action = "RESET_PASSWORD", detail = "重置密码")
    void resetPassword(Long userId, String newPassword);

    /**
     * 分配用户部门
     * @param userId 用户ID
     * @param departmentId 部门ID
     */
    @Transactional(readOnly = false)
    void assignDepartment(Long userId, Long departmentId);
}