2016-7-4 Favorites Interface

Source: Internet
Author: User

/*
* User View Favorites List
*/
Public String selectcollection () throws ParseException {
The ID of all items in the collection that the user collects through the user 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 = "Failed to get collection list";
} else {
Code = 0;
msg = "Get Favorites list Success";
}
}
} else {
Code = 1;
msg = "Your Favorites list is empty";
}
Map = new hashmap<string, object> ();
Map.put ("Data", list2);
Map.put ("code", code);
Map.put ("msg", MSG);
Gridjson = jsonobject.tojsonstring (map);
return SUCCESS;
}

/*
* Users Delete favorite items
*/
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 = "Delete Failed";
} else {
Code = 0;
msg = "Delete succeeded";
}
} else {
Code = 1;
msg = "Product is empty";
}
}
Map = new hashmap<string, object> ();
Map.put ("code", code);
Map.put ("msg", MSG);
Gridjson = jsonobject.tojsonstring (map);
return SUCCESS;
}

/*
* List of my tracks
*/
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 = "Failed to get footstep list";
} else {
Code = 0;
msg = "Get list of footprints succeeded";
}
}
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;
}
}
/*
* Users a button to collect, cancel the collection of products
*/
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 = "Collection Failed";
} else {
Code = 0;
msg = "collection Success";
}
} else {

Collection2 = Userservice.deletecoll (Collection1);
if (Collection2 = = null) {
Code = 1;
msg = "Cancel collection failed";
} else {
Code = 0;
msg = "Cancel collection succeeded";
}
}
Map = new hashmap<string, object> ();
Map.put ("code", code);
Map.put ("msg", MSG);
Gridjson = jsonobject.tojsonstring (map);
return SUCCESS;
}
Summary: If the provider does not enter the action method, the struts profile has a problem, if the method, but do not go to the service layer, the mapping file is not configured, bulk delete list data when the upload parameter is a string, such as 23,32,43 footstep list information is not related to the user, Just the browsing history saved on the software.

2016-7-4 Favorites Interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.