package thyyxxk.webserver.controller.readcard;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.dao.his.readcard.ReadCardDao;
import thyyxxk.webserver.entity.readcard.SiBusinessAddress;

@RestController
@RequestMapping("/readCard")
public class ReadCardController {
    private final ReadCardDao dao;

    @Autowired
    public ReadCardController(ReadCardDao dao) {
        this.dao = dao;
    }

    @PassToken
    @GetMapping("/getSiBusinessAddress")
    public String getSiBusinessAddress() {
        SiBusinessAddress siBusinessAddress = dao.getSiBusinessAddress();
        if (null == siBusinessAddress) {
            siBusinessAddress = new SiBusinessAddress();
            siBusinessAddress.setValidFlag(0);
        }
        return JSONObject.toJSONStringWithDateFormat(siBusinessAddress, "yyyy-MM-dd HH:mm:ss");
    }
}
