发表于: 2018-03-30 21:16:24
1 650
今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin)
把之前写了的几个模块的接口一一完成:
/**
* 后台管理员修改密码接口
*
* @param modelMap
* @param id 管理员id
* @param oldPassword 旧密码
* @param newPassword 新密码
* @return
*/
@RequestMapping(value = "a/u/admin/pswd", method = RequestMethod.PUT)
public String changePswd(ModelMap modelMap, Long id, String oldPassword, String newPassword) {
if (CommonUtil.isEmpty(id, oldPassword, newPassword)) {
modelMap.addAttribute("code", -200);
return "polyFinance-lgd-server/admin/json/adminChangePSWD";
}
try {
Admin admin = adminService.getObjectById(id);
if (admin.getPswd().equals(SecureUtil.messageDigest(oldPassword + admin.getSalt()))) {
String salt = SecureUtil.getSalt();
admin.setPswd(SecureUtil.messageDigest(newPassword + salt));
admin.setSalt(salt);
adminService.update(admin);
modelMap.addAttribute("code", 0);
} else {
modelMap.addAttribute("code", 4002);
}
} catch (Throwable e) {
modelMap.addAttribute("code", -100);
e.printStackTrace();
}
return "polyFinance-lgd-server/admin/json/adminChangePSWD";
}
/**
* 删除管理员的接口
*
* @param modelMap
* @param id 管理员ID
* @return
*/
@RequestMapping(value = "/a/u/admin/{id}", method = RequestMethod.DELETE)
public String deleteAdmin(ModelMap modelMap, @PathVariable Long id) {
if (CommonUtil.isEmpty(id)) {
modelMap.addAttribute("code", -200);
return "polyFinance-lgd-server/admin/json/adminDelete";
}
if (id == 1) {
modelMap.addAttribute("code", -300);
return "polyFinance-lgd-server/admin/json/adminDelete";
}
try {
adminService.delete(id);
modelMap.addAttribute("code", 0);
} catch (Throwable e) {
modelMap.addAttribute("code", -100);
e.printStackTrace();
}
return "polyFinance-lgd-server/admin/json/adminDelete";
}
前台产品查询列表加入了产品状态
/**
* 查询用户投资记录列表
*
* @param id 当前登录用户id
* @param page 当前显示页数
* @param size 每页数量
* @param investStatus 产品状态
* @param modelMap
* @return
*/
@RequestMapping(value = "/a/u/investRecord/list", method = RequestMethod.GET)
public String getUserInverstRecord(Long id, Integer page, Integer size,
Integer investStatus, ModelMap modelMap) {
System.out.println(investStatus);
if (page == null) {
page = 1;
}
if (size == null) {
size = 10;
}
int start = (page - 1) * size;
if (start < 0) {
start = 0;
}
if(CommonUtil.isEmpty(id,investStatus)){
modelMap.addAttribute("code", -200);
return "polyFinance-lgd-server/investRecord/json/investRecordListJson";
}
try {
List<Long> ids = investRecordService.getInvestRecordIdsByUserIdAndInvestStatusOrderByCreateAt(id,investStatus, start, size);
List<InvestRecord> investRecords = investRecordService.getObjectsByIds(ids);
modelMap.addAttribute("investRecordList", investRecords);
modelMap.addAttribute("code", 0);
modelMap.addAttribute("total", investRecordService.countInvestRecordIdsByUserIdAndInvestStatusOrderByCreateAt(id,investStatus));
modelMap.addAttribute("size", size);
} catch (Throwable e) {
modelMap.addAttribute("code", -100);
e.printStackTrace();
}
return "polyFinance-lgd-server/investRecord/json/investRecordListJson";
}
把每天完成的接口加入到wiki接口文档中, 前端好测试使用.
明天计划的事情:(一定要写非常细致的内容)
接着接口的开发.在晨报中具体汇报.
遇到的问题:(遇到什么困难,怎么解决的)
get传参的过程中同时使用@PathVariable和?参数=value这种,导致拿不到参数.
后全部改成get方式.
收获:(通过今天的学习,学到了什么知识)
将所有的更新和改动都规范到接口文档,一切以文档为准.
评论