wuxw7
2018-07-08 80478815dcce0329fa192ffd53060e736f7b6700
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
package com.java110.shop.dao.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.common.constant.ResponseConstant;
import com.java110.common.exception.DAOException;
import com.java110.common.util.DateUtil;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.shop.dao.IShopServiceDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
 
/**
 * 商品服务 与数据库交互
 * Created by wuxw on 2017/4/5.
 */
@Service("shopServiceDaoImpl")
//@Transactional
public class ShopServiceDaoImpl extends BaseServiceDao implements IShopServiceDao {
 
    private final static Logger logger = LoggerFactory.getLogger(ShopServiceDaoImpl.class);
 
    /**
     * 商品信息封装
     * @param businessShopInfo 商品信息 封装
     * @throws DAOException
     */
    @Override
    public void saveBusinessShopInfo(Map businessShopInfo) throws DAOException {
        businessShopInfo.put("month", DateUtil.getCurrentMonth());
        // 查询business_user 数据是否已经存在
        logger.debug("保存商品信息 入参 businessShopInfo : {}",businessShopInfo);
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBusinessShopInfo",businessShopInfo);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品数据失败:"+ JSONObject.toJSONString(businessShopInfo));
        }
    }
 
    /**
     * 商品属性信息分装
     * @param businessShopAttr 商品属性信息封装
     * @throws DAOException
     */
    @Override
    public void saveBusinessShopAttr(Map businessShopAttr) throws DAOException {
        businessShopAttr.put("month", DateUtil.getCurrentMonth());
        // 查询business_user 数据是否已经存在
        logger.debug("保存商品属性信息 入参 businessShopAttr : {}",businessShopAttr);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBusinessShopAttr",businessShopAttr);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品属性数据失败:"+ JSONObject.toJSONString(businessShopAttr));
        }
    }
 
    /**
     * 商品属性参数保存
     * @param businessShopAttrParam 商品属性参数信息封装
     * @throws DAOException
     */
    @Override
    public void saveBusinessShopAttrParam(Map businessShopAttrParam) throws DAOException {
        businessShopAttrParam.put("month", DateUtil.getCurrentMonth());
        // 查询business_user 数据是否已经存在
        logger.debug("保存商品属性参数信息 入参 businessShopAttr : {}",businessShopAttrParam);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBusinessShopAttrParam",businessShopAttrParam);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品属性参数数据失败:"+ JSONObject.toJSONString(businessShopAttrParam));
        }
    }
 
    /**
     * 保存商品照片信息
     * @param businessShopPhoto 商品照片
     * @throws DAOException
     */
    @Override
    public void saveBusinessShopPhoto(Map businessShopPhoto) throws DAOException {
        businessShopPhoto.put("month", DateUtil.getCurrentMonth());
        logger.debug("保存商品照片信息 入参 businessShopPhoto : {}",businessShopPhoto);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBusinessShopPhoto",businessShopPhoto);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品照片数据失败:"+ JSONObject.toJSONString(businessShopPhoto));
        }
    }
 
    /**
     * 保存商品证件信息
     * @param businessShopPreferential 商品证件
     * @throws DAOException
     */
    @Override
    public void saveBusinessShopPreferential(Map businessShopPreferential) throws DAOException {
        businessShopPreferential.put("month", DateUtil.getCurrentMonth());
        logger.debug("保存商品优惠信息 入参 businessShopPreferential : {}",businessShopPreferential);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBusinessShopPreferential",businessShopPreferential);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品证件数据失败:"+ JSONObject.toJSONString(businessShopPreferential));
        }
    }
 
    /**
     * 保存 商品描述信息
     * @param businessShopDesc 商品 描述信息
     * @throws DAOException
     */
    @Override
    public void saveBusinessShopDesc(Map businessShopDesc) throws DAOException {
        businessShopDesc.put("month", DateUtil.getCurrentMonth());
        logger.debug("保存商品描述信息 入参 businessShopDesc : {}",businessShopDesc);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveBusinessShopDesc",businessShopDesc);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品描述数据失败:"+ JSONObject.toJSONString(businessShopDesc));
        }
    }
 
    /**
     * 查询商品信息
     * @param info bId 信息
     * @return 商品信息
     * @throws DAOException
     */
    @Override
    public Map getBusinessShopInfo(Map info) throws DAOException {
 
        logger.debug("查询商品信息 入参 info : {}",info);
 
        List<Map> businessShopInfos = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBusinessShopInfo",info);
        if(businessShopInfos == null){
            return null;
        }
        if(businessShopInfos.size() >1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessShopInfos,"+ JSONObject.toJSONString(info));
        }
 
        return businessShopInfos.get(0);
    }
 
    /**
     * 查询商品属性
     * @param info bId 信息
     * @return 商品属性
     * @throws DAOException
     */
    @Override
    public List<Map> getBusinessShopAttrs(Map info) throws DAOException {
        logger.debug("查询商品属性信息 入参 info : {}",info);
 
        List<Map> businessShopAttrs = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBusinessShopAttrs",info);
 
        return businessShopAttrs;
    }
 
    /**
     * 查询商品属性参数信息
     * @param info bId 信息
     * @return 商品属性参数信息
     * @throws DAOException
     */
    @Override
    public List<Map> getBusinessShopAttrParams(Map info) throws DAOException {
        logger.debug("查询商品属性参数信息 入参 info : {}",info);
 
        List<Map> businessShopAttrParams = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBusinessShopAttrParams",info);
 
        return businessShopAttrParams;
    }
 
    /**
     * 查询商品照片
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public List<Map> getBusinessShopPhoto(Map info) throws DAOException {
        logger.debug("查询商品照片信息 入参 info : {}",info);
 
        List<Map> businessShopPhotos = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBusinessShopPhoto",info);
 
        return businessShopPhotos;
    }
 
    /**
     * 查询商品优惠
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public Map getBusinessShopPreferential(Map info) throws DAOException {
        logger.debug("查询商品证件信息 入参 info : {}",info);
 
        List<Map> businessShopPreferentiales = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBusinessShopPreferential",info);
        if(businessShopPreferentiales == null){
            return null;
        }
        if(businessShopPreferentiales.size() >1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessShopPreferentiales,"+ JSONObject.toJSONString(info));
        }
 
        return businessShopPreferentiales.get(0);
    }
 
    /**
     * 查询商品描述
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public Map getBusinessShopDesc(Map info) throws DAOException {
        logger.debug("查询商品证件信息 入参 info : {}",info);
 
        List<Map> businessShopDesces = sqlSessionTemplate.selectList("shopServiceDaoImpl.getBusinessShopDesc",info);
        if(businessShopDesces == null){
            return null;
        }
        if(businessShopDesces.size() >1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:businessShopDesces,"+ JSONObject.toJSONString(info));
        }
 
        return businessShopDesces.get(0);
    }
 
 
    /**
     * 保存商品信息 到 instance
     * @param info   bId 信息
     * @throws DAOException
     */
    @Override
    public void saveShopInfoInstance(Map info) throws DAOException {
        logger.debug("保存商品信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveShopInfoInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    @Override
    public void saveShopAttrsInstance(Map info) throws DAOException {
        logger.debug("保存商品属性信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveShopAttrsInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 保存 商品属性 参数 至 business
     * @param info b_id
     * @throws DAOException
     */
    @Override
    public void saveShopAttrParamsInstance(Map info) throws DAOException {
        logger.debug("保存商品属性参数信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveShopAttrParamsInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品属性参数信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    @Override
    public void saveShopPhotoInstance(Map info) throws DAOException {
        logger.debug("保存商品照片信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveShopPhotoInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品照片信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    @Override
    public void saveShopPreferentialInstance(Map info) throws DAOException {
        logger.debug("保存商品证件信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveShopPreferentialInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    @Override
    public void saveShopDescInstance(Map info) throws DAOException {
        logger.debug("保存商品描述信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.insert("shopServiceDaoImpl.saveShopDescInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存商品证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 查询商品信息(instance)
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public Map getShopInfo(Map info) throws DAOException {
        logger.debug("查询商品信息 入参 info : {}",info);
 
        List<Map> businessShopInfos = sqlSessionTemplate.selectList("shopServiceDaoImpl.getShopInfo",info);
        if(businessShopInfos == null || businessShopInfos.size() == 0){
            return null;
        }
        if(businessShopInfos.size() >1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getShopInfo,"+ JSONObject.toJSONString(info));
        }
 
        return businessShopInfos.get(0);
    }
 
    /**
     * 商品属性查询(instance)
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public List<Map> getShopAttrs(Map info) throws DAOException {
        logger.debug("查询商品属性信息 入参 info : {}",info);
 
        List<Map> shopAttrs = sqlSessionTemplate.selectList("shopServiceDaoImpl.getShopAttrs",info);
 
        return shopAttrs;
    }
 
    /**
     * 商品属性参数查询(instance)
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public List<Map> getShopAttrParams(Map info) throws DAOException {
        logger.debug("查询商品属性参数信息 入参 info : {}",info);
 
        List<Map> shopAttrParams = sqlSessionTemplate.selectList("shopServiceDaoImpl.getShopAttrParams",info);
 
        return shopAttrParams;
    }
 
    /**
     * 商品照片查询(instance)
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public List<Map> getShopPhoto(Map info) throws DAOException {
        logger.debug("查询商品照片信息 入参 info : {}",info);
 
        List<Map> shopPhotos = sqlSessionTemplate.selectList("shopServiceDaoImpl.getShopPhoto",info);
 
        return shopPhotos;
    }
 
    /**
     * 商品优惠查询(instance)
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public Map getShopPreferential(Map info) throws DAOException {
        logger.debug("查询商品证件信息 入参 info : {}",info);
 
        List<Map> shopPreferentiales = sqlSessionTemplate.selectList("shopServiceDaoImpl.getShopPreferential",info);
        if(shopPreferentiales == null || shopPreferentiales.size() == 0){
            return null;
        }
        if(shopPreferentiales.size() >1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getShopInfo,"+ JSONObject.toJSONString(info));
        }
        return shopPreferentiales.get(0);
    }
 
    /**
     * 商品描述查询(instance)
     * @param info bId 信息
     * @return
     * @throws DAOException
     */
    @Override
    public Map getShopDesc(Map info) throws DAOException {
        logger.debug("查询商品证件信息 入参 info : {}",info);
 
        List<Map> shopDesces = sqlSessionTemplate.selectList("shopServiceDaoImpl.getShopDesc",info);
        if(shopDesces == null || shopDesces.size() == 0){
            return null;
        }
        if(shopDesces.size() >1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"根据条件查询有多条数据,数据异常,请检查:getShopInfo,"+ JSONObject.toJSONString(info));
        }
        return shopDesces.get(0);
    }
 
 
    /**
     * 修改商品信息
     * @param info 修改信息
     * @throws DAOException
     */
    @Override
    public void updateShopInfoInstance(Map info) throws DAOException {
        logger.debug("修改商品信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateShopInfoInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 修改商品属性信息(instance)
     * @param info 修改信息
     * @throws DAOException
     */
    @Override
    public void updateShopAttrInstance(Map info) throws DAOException {
        logger.debug("修改商品属性信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateShopAttrInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 修改商品属性参数(instance)
     * @param info 修改信息
     * @throws DAOException
     */
    @Override
    public void updateShopAttrParamInstance(Map info) throws DAOException {
        logger.debug("修改商品属性参数信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateShopAttrParamInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品属性参数信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 修改 商品照片信息
     * @param info 修改信息
     * @throws DAOException
     */
    @Override
    public void updateShopPhotoInstance(Map info) throws DAOException {
        logger.debug("修改商品照片信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateShopPhotoInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品照片信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 修改商品证件信息
     * @param info 修改信息
     * @throws DAOException
     */
    @Override
    public void updateShopPreferentialInstance(Map info) throws DAOException {
        logger.debug("修改商品证件信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateShopPreferentialInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品证件信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
 
    /**
     * 修改商品描述信息
     * @param info 修改信息
     * @throws DAOException
     */
    @Override
    public void updateShopDescInstance(Map info) throws DAOException {
        logger.debug("修改商品描述信息Instance 入参 info : {}",info);
 
        int saveFlag = sqlSessionTemplate.update("shopServiceDaoImpl.updateShopDescInstance",info);
 
        if(saveFlag < 1){
            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改商品描述信息Instance数据失败:"+ JSONObject.toJSONString(info));
        }
    }
}