package com.czg.service.account.service.impl;

import com.czg.account.entity.UserInfo;
import com.czg.account.service.TestService;
import com.czg.account.service.UserInfoService;
import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SysParamsService;
import io.seata.spring.annotation.GlobalTransactional;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author GYJoker
 */
@Service
public class TestServiceImpl implements TestService {

    @Resource
    private UserInfoService userInfoService;

    @DubboReference
    private SysParamsService sysParamsService;

    @Override
    @GlobalTransactional
    public String insertData() {

        SysParamsDTO paramsDTO = new SysParamsDTO();
        paramsDTO.setParamCode("test22222");
        CzgResult<String> czgResult = sysParamsService.insertParams(paramsDTO);
        System.out.println(czgResult);
        if (czgResult.getCode() != 200){
            throw new RuntimeException("insert params error");
        }

        UserInfo userInfo = new UserInfo();
        userInfo.setPhone("18812345678");
        userInfo.setPassword("123456");

        userInfoService.save(userInfo);




        return "insert data success";
    }
}
