Returned object result Encapsulation

Source: Internet
Author: User
Import tf56.sofa. serializer. jsongenerateutil;/*** returned object result encapsulation * @ athor changmeng. liu * @ date 2014-7-25 * @ version 1.0 * @ update */public class result {final string success = "success"; final string error = "error "; private string COUNT = "";/** response data */private object data;/** response page * // ** response status */private Boolean status = true; /** Response Message */private string message; public result () {} public result (Object dat A) {This. data = data;} public result (string message, Boolean status) {This. set (message, status);} public result (string message, Boolean status, string count, object data) {This. set (message, status); this. data = data; this. count = count;} public void set (string message, Boolean status) {This. status = status; this. message = message; this. count = ""; this. data = "";} public void set (string message, Boolean status, string count, object data) {This. status = status; this. message = message; this. data = data; this. count = count;} public Boolean getstatus () {return status;} public void setstatus (Boolean status) {This. status = status; this. message = This. status? "Successful": "failed"; this. count = ""; this. data = "";} Public String getmessage () {return message;} public void setmessage (string message) {This. message = message;} public object getdata () {return data;} public void setdata (Object Data) {This. data = data;} Public String getcommonjson () {return jsongenerateutil. getcommonjson (status = true? Success: error, message, Count = NULL? "": Count, Data = NULL? "": Data );}}
 
<PRE name = "code" class = "Java"> public class invitationcodeserviceimpl implements invitationcodeservice {@ autowiredprivate invitationcodedao; @ autowiredprivate partyservice; protected result = new result (); protected final log logger = logfactory. getlog (getclass ();/*** @ athor changmeng. liu * @ date 2014-7-15 * @ version 1.0 * @ function * @ Param * @ update */@ override Public result getinvitationcodebytypeandid (MAP map) {string type = (string) map. get ("type"); string fromid = (string) map. get ("fromid"); If (stringutils. isempty (type) {This. result. set ("type cannot be blank", false); logger. debug (this. result. getmessage (); return this. result;} If (stringutils. isempty (fromid) {This. result. set ("source ID cannot be blank", false); logger. debug (this. result. getmessage (); return this. result;} If (! "Xiao 'er". Equals (type )&&! "Member ". equals (type) {This. result. set ("incorrect type", false); logger. debug (this. result. getmessage (); return this. result;} Map <string, Object> parammap = new hashmap <string, Object> (); parammap. put ("type", type); parammap. put ("fromid", fromid); invitationcode = invitationcodedao. selectbytypeandid (parammap); If (invitationcode = NULL) {This. result. set ("the user's invitation code is not found", true, "", ""); logger. debug (this. result. getmessage (); return this. result;} This. result. set ("successful", true, "1", invitationcode); return this. result ;}}


 


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.