package com.brilliance.isc.common.entmod.controller;

import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.entmod.service.EntmodService;
import com.brilliance.isc.common.entmod.vo.EntmodVo;
import com.brilliance.isc.vo.ResponseSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/entmod")
public class EntmodController {

    @Autowired
    private EntmodService entmodService;

    @Autowired
    private SettleContext settleContext;

    @PostMapping("/search")
    public ResponseSet<EntmodVo> callGe34(@RequestBody EntmodVo entmodVo) {
        try {
            settleContext.loadSettleSession(entmodVo.getRec().getTransName(), "", "");
            entmodService.searchEntmod(entmodVo);
            return ResponseSet.simpleSuccess(entmodVo);
        }  catch (Exception e) {
            throw e;
        } finally {
            SettleContext.removeUserSession();
        }
    }
}
