| | |
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserGoodsStorageException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @RequestMapping("api/v1/userstorage")
|
| | | public class UserGoodsStorageController {
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private UserGoodsStorageService userGoodsStorageService;
|
| | |
|
| | |
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = null;
|
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | long count = userGoodsStorageService.countQueryByUid(uid);
|
| | | if (count > 0) {
|
| | |
| | |
|
| | |
|
| | | /**
|
| | | * 根据商品id移除选品库
|
| | | * 单个商品加入选品库
|
| | | *
|
| | | * @param callback
|
| | | * @param storageIds
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param storageIds
|
| | | * id数组
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sharegoods", method = RequestMethod.POST)
|
| | | public void shareGoods(AcceptData acceptData, Long uid, String storageIds, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(storageIds)) {
|
| | | out.print(JsonUtil.loadFalseResult("分享商品不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> listStorageID = gson.fromJson(storageIds, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | if (listStorageID == null || listStorageID.size() < 9) {
|
| | | out.print(JsonUtil.loadFalseResult("分享商品数量不足"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = userGoodsStorageService.shareGoods(uid, listStorageID);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (UserGoodsStorageException e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|