日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2016-7-4收藏夹接口

發布時間:2023/12/20 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2016-7-4收藏夹接口 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/*
?? ? * 用戶查看收藏列表
?? ? */
?? ?public String selectcollection() throws ParseException {
?? ??? ?// 通過用戶id查詢到收藏夾中該用戶收藏的所有商品的id
?? ??? ?collect = userservice.findByUidColl(uid);
?? ??? ?List<Goods> list2 = new ArrayList<Goods>();
?? ??? ?List<Collection> list1 = new ArrayList<Collection>();
?? ??? ?List<Goods> list3 = new ArrayList<Goods>();
?? ??? ?if (collect != null) {
?? ??? ??? ?for (Collection c1 : collect) {
?? ??? ??? ??? ?collection = new Collection(c1.getGid(), c1.getUid());
?? ??? ??? ??? ?list1.add(collection);
?? ??? ??? ?}
?? ??? ??? ?for (int i = 0; i < list1.size(); i++) {
?? ??? ??? ??? ?goods = goodsservice.findGoodsById1(list1.get(i).getGid());
?? ??? ??? ??? ?list3.add(goods);
?? ??? ??? ?}
?? ??? ??? ?for (Goods c2 : list3) {
?? ??? ??? ??? ?goods1 = new Goods(c2.getGoodsId(), c2.getGoodsName(),
?? ??? ??? ??? ??? ??? ?c2.getSourceId(), c2.getGoodsPrice(), c2.getUnitCost(),
?? ??? ??? ??? ??? ??? ?c2.getPhotoUrl(), c2.getWeblinkurl(), c2.getMonsales(),
?? ??? ??? ??? ??? ??? ?c2.getZhekou(), c2.getIsWeblink());
?? ??? ??? ??? ?list2.add(goods1);
?? ??? ??? ??? ?if (goods1 == null) {
?? ??? ??? ??? ??? ?code = 1;
?? ??? ??? ??? ??? ?msg = "獲取收藏列表失敗";
?? ??? ??? ??? ?} else {
?? ??? ??? ??? ??? ?code = 0;
?? ??? ??? ??? ??? ?msg = "獲取收藏列表成功";
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?} else {
?? ??? ??? ?code = 1;
?? ??? ??? ?msg = "您的收藏列表為空";
?? ??? ?}
?? ??? ?map = new HashMap<String, Object>();
?? ??? ?map.put("data", list2);
?? ??? ?map.put("code", code);
?? ??? ?map.put("msg", msg);
?? ??? ?gridjson = JSONObject.toJSONString(map);
?? ??? ?return SUCCESS;
?? ?}

?? ?/*
?? ? * 用戶刪除收藏商品
?? ? */
?? ?public String deletecollection() throws ParseException {
?? ??? ?String[] id;
?? ??? ?goodsObj = request.getParameter("gid");
?? ??? ?id = goodsObj.split(",");
?? ??? ?for (int i = 0; i < id.length; i++) {
?? ??? ??? ?collection1 = userservice.select(Integer.parseInt(id[i]), uid);
?? ??? ??? ?if (collection1 != null) {
?? ??? ??? ??? ?collection2 = userservice.deletecoll(collection1);
?? ??? ??? ??? ?if (collection2 == null) {
?? ??? ??? ??? ??? ?code = 1;
?? ??? ??? ??? ??? ?msg = "刪除失敗";
?? ??? ??? ??? ?} else {
?? ??? ??? ??? ??? ?code = 0;
?? ??? ??? ??? ??? ?msg = "刪除成功";
?? ??? ??? ??? ?}
?? ??? ??? ?} else {
?? ??? ??? ??? ?code = 1;
?? ??? ??? ??? ?msg = "商品為空";
?? ??? ??? ?}
?? ??? ?}
?? ??? ?map = new HashMap<String, Object>();
?? ??? ?map.put("code", code);
?? ??? ?map.put("msg", msg);
?? ??? ?gridjson = JSONObject.toJSONString(map);
?? ??? ?return SUCCESS;
?? ?}

?? ?/*
?? ? * 我的足跡列表
?? ? */
?? ?public String footmark() throws ParseException {
?? ??? ?String[] id;
?? ??? ?goodsObj = request.getParameter("gid");
?? ??? ?id = goodsObj.split(",");
?? ??? ?List<Goods> list1 = new ArrayList<Goods>();
?? ??? ?for (int i = 0; i < id.length; i++) {
?? ??? ??? ?goods = goodsservice.findGoodsById(Integer.parseInt(id[i]));
?? ??? ??? ?goods1 = new Goods(goods.getGoodsId(), goods.getGoodsName(),
?? ??? ??? ??? ??? ?goods.getSourceId(), goods.getGoodsPrice(),
?? ??? ??? ??? ??? ?goods.getUnitCost(), goods.getPhotoUrl(),
?? ??? ??? ??? ??? ?goods.getWeblinkurl(), goods.getMonsales(),
?? ??? ??? ??? ??? ?goods.getZhekou(), goods.getIsWeblink());
?? ??? ??? ?list1.add(goods1);
?? ??? ??? ?if (goods1 == null) {
?? ??? ??? ??? ?code = 1;
?? ??? ??? ??? ?msg = "獲取足跡列表失敗";
?? ??? ??? ?} else {
?? ??? ??? ??? ?code = 0;
?? ??? ??? ??? ?msg = "獲取足跡列表成功";
?? ??? ??? ?}
?? ??? ?}
?? ??? ?map = new HashMap<String, Object>();
?? ??? ?map.put("data", list1);
?? ??? ?map.put("code", code);
?? ??? ?map.put("msg", msg);
?? ??? ?gridjson = JSONObject.toJSONString(map);
?? ??? ?System.out.println(gridjson);
?? ??? ?return SUCCESS;
?? ?}
}
/*
?? ? * 用戶一鍵收藏、取消收藏商品
?? ? */
?? ?public String addcollection() throws ParseException {
?? ??? ?collection1 = userservice.select(gid, uid);
?? ??? ?if (collection1 == null) {
?? ??? ??? ?coll = new Collection();
?? ??? ??? ?coll.setGid(gid);
?? ??? ??? ?coll.setUid(uid);
?? ??? ??? ?collection = userservice.addcoll(coll);
?? ??? ??? ?if (collection == null) {
?? ??? ??? ??? ?code = 1;
?? ??? ??? ??? ?msg = "收藏失敗";
?? ??? ??? ?} else {
?? ??? ??? ??? ?code = 0;
?? ??? ??? ??? ?msg = "收藏成功";
?? ??? ??? ?}
?? ??? ?} else {

?? ??? ??? ?collection2 = userservice.deletecoll(collection1);
?? ??? ??? ?if (collection2 == null) {
?? ??? ??? ??? ?code = 1;
?? ??? ??? ??? ?msg = "取消收藏失敗";
?? ??? ??? ?} else {
?? ??? ??? ??? ?code = 0;
?? ??? ??? ??? ?msg = "取消收藏成功";
?? ??? ??? ?}
?? ??? ?}
?? ??? ?map = new HashMap<String, Object>();
?? ??? ?map.put("code", code);
?? ??? ?map.put("msg", msg);
?? ??? ?gridjson = JSONObject.toJSONString(map);
?? ??? ?return SUCCESS;
?? ?}
總結:如果訪問接口不進action的方法,struts配置文件有問題,如果進方法,但是不往服務層進,說明映射文件未配置,批量刪除列表數據時上傳參數為字符串,如23,32,43??? 足跡列表信息跟用戶無關,只是保存在軟件上的瀏覽記錄

轉載于:https://www.cnblogs.com/JOEH60/p/5641442.html

總結

以上是生活随笔為你收集整理的2016-7-4收藏夹接口的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。