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

import com.brilliance.isc.common.forexmod.ForexmodVo;
import com.brilliance.isc.common.forexmod.service.ForexmodService;
import com.brilliance.isc.common.util.StringUtils;
import com.brilliance.isc.vo.ResponseSet;
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;

import javax.annotation.Resource;
import java.util.Map;

/**
 
 * @date 2024-08-23
 * @description
 */
@RestController
@RequestMapping("/forexmod")
public class ForexmodController {
    @Resource
    private ForexmodService forexmodService;

    @PostMapping("/search")
    public ResponseSet<ForexmodVo> search(@RequestBody Map<String, String> map){

        ForexmodVo forexmod = forexmodService.search(map.get("ptyinr"));
        if (forexmod==null){
            return ResponseSet.fail("查询失败");
        }
        return ResponseSet.simpleSuccess(forexmod);
    }

    @PostMapping("/downgrade")
    public ResponseSet downgrade(@RequestBody Map<String, String> map){
            String result = forexmodService.downgrade(map.get("ptyinr"), map.get("reason"));
            return StringUtils.isEmpty(result)?ResponseSet.simpleSuccess("成功"):ResponseSet.fail(result);
    }
}
