Пример #1
0
        public DriverInfo GetDriverInfo(DriverInfoParam param)
        {
            DriverInfo driverInfo = null;
            string     sqlstring  = "select * from driverinfo where DIUIID=@DIUIID " +
                                    " limit 1";
            var sqlParams = new
            {
                DIUIID = param.DIUIID
            };

            List <DriverInfo> driverInfos = hackMySqlHelper.DapperQuery <DriverInfo>(sqlstring, sqlParams, false);

            if (driverInfos != null && driverInfos.Count > 0)
            {
                driverInfo = driverInfos[0];
            }
            return(driverInfo);
        }
Пример #2
0
        public bool AddDriverInfo(DriverInfoParam param)
        {
            string sqlstring = @"INSERT INTO driverinfo
(
DITelPhone,
DICarType,
DICarNumber,
DICardNo,
DIDrivingLicense,
DIDrivingPermit,
DICardFront,
DICardFace,
DIUIID)
VALUES
(
 @DITelPhone,
 @DICarType,
 @DICarNumber,
 @DICardNo,
 @DIDrivingLicense,
 @DIDrivingPermit,
 @DICardFront,
 @DICardFace,
 @DIUIID);
";
            var    sqlParams = new
            {
                DITelPhone       = param.DITelPhone,
                DICarType        = param.DICarType,
                DICarNumber      = param.DICarNumber,
                DICardNo         = param.DICardNo,
                DIDrivingLicense = param.DIDrivingLicense,
                DIDrivingPermit  = param.DIDrivingPermit,
                DICardFront      = param.DICardFront,
                DICardFace       = param.DICardFace,
                DIUIID           = param.DIUIID
            };

            bool isSuc = hackMySqlHelper.DapperExcute(sqlstring, sqlParams);

            return(isSuc);
        }
Пример #3
0
        public HackResponse Post([FromBody] DriverInfoParam param)
        {
            DriverInfo driverInfo = service.GetDriverInfo(param);

            if (driverInfo == null)
            {
                bool isSuc = service.AddDriverInfo(param);
                return
                    (new HackResponse
                         (HackResType.Success, HackRspCode.HackRspCode_0000, "查询成功",
                         new { isSucess = isSuc }));
            }
            else
            {
                return
                    (new HackResponse
                         (HackResType.DataError, HackRspCode.HackRspCode_3000,
                         "重复添加", new { }));
            }
        }
Пример #4
0
        public HackResponse Get(long id)
        {
            DriverInfoParam param = new DriverInfoParam();

            param.DIUIID = id;
            DriverInfo driverInfo = service.GetDriverInfo(param);

            if (driverInfo == null)
            {
                return
                    (new HackResponse
                         (HackResType.DataError, HackRspCode.HackRspCode_0001, "查无结果", new { }));
            }
            else
            {
                return
                    (new HackResponse
                         (HackResType.Success, HackRspCode.HackRspCode_0001,
                         "查询成功", driverInfo));
            }
        }