You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.3 KiB
60 lines
2.3 KiB
package com.fr.plugin.web.hander.member; |
|
|
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.json.JSONObject; |
|
import com.fr.plugin.yt.MyCoreDBAccess; |
|
import com.fr.plugin.dao.MyUserDao; |
|
import com.fr.plugin.entitys.YTUserEntity; |
|
import com.fr.plugin.utils.MyUtils; |
|
import com.fr.stable.db.action.DBAction; |
|
import com.fr.stable.db.dao.DAOContext; |
|
import com.fr.stable.query.QueryFactory; |
|
import com.fr.stable.query.condition.QueryCondition; |
|
import com.fr.stable.query.restriction.RestrictionFactory; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
public class SaveRelation extends BaseHttpHandler { |
|
@Override |
|
public RequestMethod getMethod() { |
|
return RequestMethod.POST; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/yt/user/relation"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return false; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
|
String opendId = WebUtils.getHTTPRequestParameter(httpServletRequest, "weiXinUser"); |
|
String fsUser = WebUtils.getHTTPRequestParameter(httpServletRequest, "fsUser"); |
|
|
|
YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTUserEntity>() { |
|
public YTUserEntity run(DAOContext content) throws Exception { |
|
QueryCondition queryCondition = QueryFactory.create(); |
|
queryCondition.addRestriction(RestrictionFactory.eq("openId", opendId)); |
|
return content.getDAO(MyUserDao.class).findOne(queryCondition); |
|
} |
|
}); |
|
entity.setFsUserName(fsUser); |
|
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
|
public YTUserEntity run(DAOContext content) throws Exception { |
|
content.getDAO(MyUserDao.class).update(entity); |
|
return null; |
|
} |
|
}); |
|
JSONObject responseJSONObject = MyUtils.createSuccessResponseJSONObject(); |
|
responseJSONObject.put("id", entity.getId()); |
|
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, responseJSONObject); |
|
} |
|
} |
|
|
|
|