package com.aegis.web.controller.resource.team;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aegis.common.core.controller.BaseController;
import com.aegis.common.core.domain.AjaxResult;
import com.aegis.common.core.page.TableDataInfo;
import com.aegis.resource.team.domain.TeamLog;
import com.aegis.resource.team.service.IResourceTeamLogService;

/**
 * 队伍操作日志Controller
 * 
 * @author aegis
 */
@RestController
@RequestMapping("/resources/teams/{teamId}/logs")
public class ResourceTeamLogController extends BaseController {
    @Autowired
    private IResourceTeamLogService teamLogService;

    /**
     * 查询队伍操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('resource:team:log:list')")
    @GetMapping
    public TableDataInfo list(@PathVariable Long teamId, TeamLog teamLog) {
        teamLog.setTeamId(teamId);
        startPage();
        List<TeamLog> list = teamLogService.listByCondition(teamLog);
        return getDataTable(list);
    }

    /**
     * 根据ID获取日志详情
     */
    @PreAuthorize("@ss.hasPermi('resource:team:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long teamId, @PathVariable Long id) {
        TeamLog log = teamLogService.getById(id);
        if (log != null && !log.getTeamId().equals(teamId)) {
            return error("日志不属于该队伍");
        }
        return success(log);
    }
}