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>房源侧和经营主体侧完全分开的 4 个 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>
 * </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));
    }
}
