public IActionResult AddCode([FromBody] CodeDTO codeDTO)
        {
            try
            {
                _codeService.CodeValidation(codeDTO);
                _codeService.AddCode(codeDTO);
                return(Ok());
            }
            catch (AuthenticationException)
            {
                return(Forbid());
            }
            catch (ServiceException ex)
            {
                return(BadRequest(ex.Message));
            }

            catch (Exception ex)
            {
                return(BadRequest(ex.StackTrace));
            }
        }
        public Object AddCode([FromBody] Code code)
        {
            ReturnData result = new ReturnData();

            result.Msg = "";
            try
            {
                using (var sqlconnection = new SqlConnection(connectionString))
                {
                    CodeService repository = new CodeService(sqlconnection);
                    if (repository.AddCode(code))
                    {
                        result.Result = true;
                    }
                    else
                    {
                        result.Result = false;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                result.Result = false;
                if (ex.Message.Contains("重复键"))
                {
                    result.Msg = "已存在相同的编码,编码不能重复添加";
                }
                else
                {
                    result.Msg = ex.Message;
                }

                return(result);
            }
        }