喻健
2018-12-12 a70d35cd9a672deb0aed272c8209ddde096f917b
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
package com.yeshi.fanli.controller.apph5;
 
import java.io.PrintWriter;
 
import javax.annotation.Resource;
 
import net.sf.json.JSONObject;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
 
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
 
@Controller
@RequestMapping("api/apph5/v1/share")
public class AppH5ShareController {
 
    
    @Resource
    private UserShareGoodsGroupService userShareGoodsGroupService;
    
    @Resource
    private UserShareGoodsRecordService userShareGoodsRecordService;
    
    /**
     * 分享商品详情
     * @param callback
     * @param shareId  分享id
     * @param source   来源
     * @param out
     */
    @RequestMapping(value = "getDetail")
    public void getDetail(String callback, Long shareId, String source, String fingerprint, PrintWriter out) {
        
        try {
            
            if (shareId == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确"));
                return;
            }
            // 更新访问次数
            userShareGoodsGroupService.updateBrowseRecord(shareId, 1);
            // 获取商品信息
            JSONObject data = userShareGoodsRecordService.getGoodsGroup(shareId);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
            e.printStackTrace();
        }
    }
    
}