package com.ruoyi.web.controller.fieldchangerecord;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.fieldchangerecord.vo.FieldChangeRecordQuery;
import com.ruoyi.system.service.fieldchangerecord.DataFieldChangeRecordService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 字段级变更统计对外接口。
 *
 * <p>房源侧、经营主体侧、涉及房源侧的 GET 接口：</p>
 * <ul>
 *     <li>{@code /houseResource}：HR 侧明细分页</li>
 *     <li>{@code /houseResource/summary}：HR 侧按字段 + 操作的计数</li>
 *     <li>{@code /businessEntity}：BE 侧明细分页（展开每个关联房源）</li>
 *     <li>{@code /businessEntity/summary}：BE 侧汇总（按日志去重）</li>
 *     <li>{@code /affectedHouseResources}：HR + BE 涉及房源分页（按房源去重）</li>
 *     <li>{@code /affectedHouseResources/summary}：HR + BE 涉及房源汇总（按房源去重）</li>
 * </ul>
 *
 * <p>入参形态详见 {@link FieldChangeRecordQuery}。{@code changeStartTime /
 * changeEndTime} 必填；{@code wgCodes} 由 Service 层按当前登录人注入，前端不传。</p>
 */
@RestController
@RequestMapping("/api/house/fieldChangeRecords")
public class DataFieldChangeRecordController {

    private final DataFieldChangeRecordService service;

    public DataFieldChangeRecordController(DataFieldChangeRecordService service) {
        this.service = service;
    }

    @GetMapping("/houseResource")
    public AjaxResult pageHouseResource(FieldChangeRecordQuery query) {
        return AjaxResult.success(service.pageHouseResourceFieldChanges(query));
    }

    @GetMapping("/houseResource/summary")
    public AjaxResult summaryHouseResource(FieldChangeRecordQuery query) {
        return AjaxResult.success(service.summaryHouseResourceFieldChanges(query));
    }

    @GetMapping("/businessEntity")
    public AjaxResult pageBusinessEntity(FieldChangeRecordQuery query) {
        return AjaxResult.success(service.pageBusinessEntityFieldChanges(query));
    }

    @GetMapping("/businessEntity/summary")
    public AjaxResult summaryBusinessEntity(FieldChangeRecordQuery query) {
        return AjaxResult.success(service.summaryBusinessEntityFieldChanges(query));
    }

    @GetMapping("/affectedHouseResources")
    public AjaxResult pageAffectedHouseResources(FieldChangeRecordQuery query) {
        return AjaxResult.success(service.pageAffectedHouseResources(query));
    }

    @GetMapping("/affectedHouseResources/summary")
    public AjaxResult summaryAffectedHouseResources(FieldChangeRecordQuery query) {
        return AjaxResult.success(service.summaryAffectedHouseResources(query));
    }
}
