发表于: 2018-03-21 20:50:55
1 550
今日完成
1.用户实名详情接口
/**
* 后台:查询用户实名详情
*
* @param model
* @param id 用户id
* @return
*/
@RequestMapping(value = "/a/u/user/identify/{id}")
public String getUserIdentifyDetail(ModelMap model, @PathVariable("id") Long id) {
log.info("getUserIdentifyDetail : user id = " + id);
try {
User userGet = userService.getObjectById(id);
if (userGet == null) {
log.error("get user with error id , id is " + id);
model.addAttribute("code", -200000);
return "/polyFinance-lgd-server/user/json/userDetailJson";
}
String idCardFrontUrl = FilesUtil.getUrl(userGet.getIdCardFornt());
String idCardBackUrl = FilesUtil.getUrl(userGet.getIdCardBack());
userGet.setIdCardFornt(idCardFrontUrl);
userGet.setIdCardBack(idCardBackUrl);
model.addAttribute("code", 0);
model.addAttribute("user", userGet);
} catch (Throwable e) {
log.error(e);
e.printStackTrace();
log.error("get user error");
model.addAttribute("code", -100000);
e.printStackTrace();
}
return "/polyFinance-lgd-server/user/json/userDetailJson";
}
2.用户实名列表接口
/**
* 后台:用户实名认证列表
* 已测
*
* @param model
* @param name
* @param phoneNum
* @param identityStatus
* @param identityTimeStart
* @param identityTimeEnd
* @param serialNum
* @param page
* @param size
* @return
*/
@RequestMapping(value = "/a/u/user/identify/list", method = RequestMethod.GET)
public String getUserIdentifyList(ModelMap model, String name, String phoneNum, Integer identityStatus, Long identityTimeStart, Long identityTimeEnd, String serialNum, Integer page, Integer size) {
if (page == null) {
page = 1;
}
if (size == null) {
size = 10;
}
int start = (page - 1) * size;
if (start < 0) {
start = 0;
}
log.info("pageList : page= " + start + " , size=" + size);
Map<String, Object> param = DynamicUtil.getUserIdentifyList(name, phoneNum, identityStatus, identityTimeStart, identityTimeEnd, serialNum);
log.info("DynamicCondition SQL : getUserIdentifyList---->>> " + SQLUtil.convert2Sql(param, start, size));
try {
List<Long> ids = userService.getIdsByDynamicCondition(User.class, param, start, size);
List<Long> countIds = userService.getIdsByDynamicCondition(User.class, param, 0, userService.countUserIds());
Integer total = countIds.size();
List<User> users = userService.getObjectsByIds(ids);
model.addAttribute("userList", users);
model.addAttribute("total", total);
model.addAttribute("code", 0);
} catch (Throwable e) {
log.info(e.getMessage());
log.info("get user list error");
e.printStackTrace();
model.addAttribute("code", -100000);
e.printStackTrace();
}
return "/polyFinance-lgd-server/user/json/userListJson";
}
3.操作用户实名状态接口
/**
* 后台:操作用户实名状态
* 已测
*
* @param id 用户id
* @param identityStatus 用户实名状态
* @param refuseReason 拒绝理由
* @return
*/
@RequestMapping(value = "/a/u/user/identify/{id}", method = RequestMethod.PUT)
@ResponseBody
public String updateUserIdentifyStatus(@PathVariable("id") Long id, Integer identityStatus, String refuseReason) {
log.info("updateUserIdentifyStatus : id = " + id + " ; " + " identityStatus= " + identityStatus);
JSONObject a = new JSONObject();
if (CommonUtil.isEmpty(identityStatus, id)) {
a.put("code", -200000);
a.put("message", "necessary param wrong");
return a.toString();
}
Boolean flag;
try {
User userGet = userService.getObjectById(id);
if (userGet == null) {
log.error("update user error , id is " + id);
a.put("code", -200000);
a.put("message", "necessary param missing");
return a.toString();
}
//identityStatus 3:取消实名
userGet.setRefuseReason(refuseReason);
if (identityStatus.equals(3)) {
userGet.setName("");
userGet.setIdCard("");
userGet.setIdCardFornt("");
userGet.setIdCardBack("");
userGet.setRefuseReason("");
}
if (identityStatus.equals(2)) {
if (CommonUtil.isEmpty(refuseReason)) {
a.put("code", -200000);
a.put("message", "necessary param wrong");
return a.toString();
}
}
if (!identityStatus.equals(1)) {
userGet.setRefuseStatus(1);
}
userGet.setIdentityStatus(identityStatus);
flag = userService.update(userGet);
if (flag) {
a.put("code", 0);
a.put("message", "success");
}
} catch (Throwable e) {
log.error(e);
e.printStackTrace();
log.error("updateUserIdentifyStatus , id is " + id);
a.put("code", -100000);
a.put("message", "Server has something wrong");
}
return a.toString();
}
明日计划
1.用户投资记录接口,用户交易流水接口
2.redis配置与添加
遇到问题
1.jetty ,和tomcat 差异还是蛮大的 ,jetty可以默认支持put请求,但是tomcat 需要在springmvc中配置。
<!-- 浏览器不支持put,delete等method,由该filter将/xxx?_method=delete转换为标准的http delete方法 -->
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--put请求的过滤器,用于接收put请求的参数-->
<filter>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
收获
评论