Test style problems, test Style

Source: Internet
Author: User

Test style problems, test Style

Package com. licy. projects. study. action. search;

Import java. util. ArrayList;
Import java. util. HashMap;
Import java. util. List;
Import java. util. Map;

Import javax. annotation. Resource;

Import org. apache. log4j. Logger;
Import org. apache. log4j. PropertyConfigurator;
Import org. springframework. stereotype. Controller;
Import org. springframework. web. bind. annotation. RequestMapping;


Import com. licy. projects. study. action. BaseAction;
Import com. licy. projects. study. entity. ResourceEntity;
Import com. licy. projects. study. service. search. SearchService;

/**
* Search for resources
* @ ClassName: SearchAction
* @ Description: TODO ()
* @ Author A18ccms a18ccms_gmail_com
* @ Date 3:52:41
*/
@ Controller
@ RequestMapping ("/search ")
Public class SearchAction extends BaseAction {

@ Resource (name = "searchService ")
Private SearchService searchService;

Private static final Logger LOG = Logger. getLogger (SearchAction. class );



/** Query the resource list by keyword ID */
@ RequestMapping ("/queryResource ")
Public String queryResourceList (){
// Query input parameters
Map <String, Object> map = new HashMap <String, Object> ();
// Query output parameters
List <ResourceEntity> list = new ArrayList <ResourceEntity> ();
// Search for keywords
String keyword = this. getValue ("keyword ");
// Topic id
String column_id = this. getValue ("column_id ");
// The size of each page. The default value is 5.
String pageSize = "". equals (this. getValue ("pageSize "))? "5": this. getValue ("pageSize ");
// The current page number. The default value is 1.
String nowPage = "". equals (this. getValue ("nowPage "))? "1": this. getValue ("nowPage ");

Map. put ("keyword", keyword );
Map. put ("column_id", column_id );
Int start = (Integer. parseInt (nowPage)-1) * Integer. parseInt (pageSize );
Map. put ("pageSize", pageSize );
Map. put ("start", start );
LOG.info ("info search keyword =" + keyword );
LOG. error ("error search keyword =" + keyword );
List <Object> list1 = searchService. queryResourceList (map );
List = (List <ResourceEntity>) list1.get (0 );
Int totalSize = (Integer) list1.get (1 );

Request. setAttribute ("keyword", keyword );
Request. setAttribute ("column_id", column_id );
Request. setAttribute ("pageSize", pageSize );
Request. setAttribute ("nowPage", nowPage );
Request. setAttribute ("totalSize", totalSize );
Request. setAttribute ("resourceList", list );

Return "/study/search/searchResult ";
}

/**
* Get the prompt information in the input box
* @ Title: getResourceTips
* @ Author: Li Changyu
* @ Date 11:28:26
* @ Description: TODO () void
* @ Throws
*/
@ RequestMapping ("/queryResourceTips ")
Public void queryResourceTips (){
String keyword = this. getValue ("keyword"). toLowerCase ();
String column_id = this. getValue ("column_id ");
Map <String, Object> map = new HashMap <String, Object> ();
Map. put ("keyword", keyword );
Map. put ("column_id", column_id );

List <ResourceEntity> list = searchService. queryResourceTips (map );

This. writeJsonData (list );
}

@ RequestMapping ("/saveSearchRecord ")
Public void saveSearchRecord (){
String id = this. getValue ("id ");
Int search_count = Integer. parseInt (this. getValue ("search_count "));

Map <String, Object> map = new HashMap <String, Object> ();
Map. put ("id", id );
Map. put ("search_count", search_count + 1); // Add 1 to the number of searches and store them in the database

Int result = searchService. saveSearchRecord (map );
This. writeData (result );
}


/** Go to The add resource page */
@ RequestMapping ("/toAddResource ")
Public String toAddResource (){
Return "/study/search/saveResource ";
}


/** Add resources */
@ RequestMapping ("/saveResource ")
Public void addResource (){
String save_column_id = this. getValue ("save_column_id ");
String save_resource_name = this. getValue ("save_resource_name ");
String save_resource_remark = this. getValue ("save_resource_remark ");
String save_resource_url = this. getValue ("save_resource_url ");
Map <String, Object> map = new HashMap <String, Object> ();
Map. put ("column_id", save_column_id );
Map. put ("resource_name", save_resource_name );
Map. put ("resource_remark", save_resource_remark );
Map. put ("resource_url", save_resource_url );

Int result = searchService. saveResource (map );
This. writeData (result );
}


Public static void main (String [] args ){
PropertyConfigurator. configure ("D:/1 _ workspace/gong_si_space/sywg_space/licy/src/com/licy/config/log4j. properties ");
Logger logger = Logger. getLogger (SearchAction. class );


}


@ RequestMapping ("/testSave ")
Public void testSave (){
String content = this. getValue ("content ");
System. out. println ("the obtained content is =" + content );
}
}

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.