|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.jwt.JWTUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
@ -8,6 +11,8 @@ import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
|
import com.ibeetl.jlw.dao.StudentAccountAssetAllocationDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.LoginTodo;
|
|
|
|
|
import com.ibeetl.jlw.entity.ResourcesApplication;
|
|
|
|
|
import com.ibeetl.jlw.entity.StudentAccountAssetAllocation;
|
|
|
|
|
import com.ibeetl.jlw.web.query.StudentAccountAssetAllocationQuery;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -18,6 +23,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotBlank;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -32,6 +39,8 @@ import java.util.List;
|
|
|
|
|
public class StudentAccountAssetAllocationService extends CoreBaseService<StudentAccountAssetAllocation>{
|
|
|
|
|
|
|
|
|
|
@Autowired private StudentAccountAssetAllocationDao studentAccountAssetAllocationDao;
|
|
|
|
|
@Autowired private LoginTodoService loginTodoService;
|
|
|
|
|
@Autowired private ResourcesApplicationService resourcesApplicationService;
|
|
|
|
|
|
|
|
|
|
public PageQuery<StudentAccountAssetAllocation>queryByCondition(PageQuery query){
|
|
|
|
|
PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query);
|
|
|
|
@ -150,11 +159,72 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateByApplicationToken(StudentAccountAssetAllocationQuery param) {
|
|
|
|
|
public void updateByApplicationToken(@NotBlank(message = "applicationToken 传递的token不能为空!") String applicationToken, StudentAccountAssetAllocationQuery param) {
|
|
|
|
|
|
|
|
|
|
// 获取资金账户信息
|
|
|
|
|
List<StudentAccountAssetAllocation> accountAssetAllocationList = getByApplicationToken(applicationToken, param);
|
|
|
|
|
|
|
|
|
|
Assert.isTrue(accountAssetAllocationList.size() == 1, "无法对多个账户进行修改操作!");
|
|
|
|
|
|
|
|
|
|
// 主键拿过来
|
|
|
|
|
param.setId(accountAssetAllocationList.get(0).getId());
|
|
|
|
|
|
|
|
|
|
updateTemplate(param.pojo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object getByApplicationToken(StudentAccountAssetAllocationQuery param) {
|
|
|
|
|
return null;
|
|
|
|
|
/**
|
|
|
|
|
* 通过token获取资金账户
|
|
|
|
|
*
|
|
|
|
|
* @param applicationToken token
|
|
|
|
|
* @param param 一些条件
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<StudentAccountAssetAllocation> getByApplicationToken(@NotBlank(message = "applicationToken 传递的token不能为空!") String applicationToken, StudentAccountAssetAllocationQuery param) {
|
|
|
|
|
|
|
|
|
|
LoginTodo loginTodo = validateAndGetLoginTodo(applicationToken);
|
|
|
|
|
|
|
|
|
|
// 学生ID
|
|
|
|
|
final String studentId = loginTodo.getStudentid();
|
|
|
|
|
|
|
|
|
|
Assert.notEmpty(studentId, "该接口只允许学生访问!");
|
|
|
|
|
|
|
|
|
|
// 应用ID
|
|
|
|
|
final String applicationId = loginTodo.getApplicationId();
|
|
|
|
|
// 院校ID
|
|
|
|
|
final String universitiesCollegesId = loginTodo.getSchoolid();
|
|
|
|
|
|
|
|
|
|
Assert.isTrue(StrUtil.isAllNotEmpty(studentId, applicationId, universitiesCollegesId), "学生ID、应用ID、院校ID,都不能为空!");
|
|
|
|
|
|
|
|
|
|
// 从token中获取必要条件
|
|
|
|
|
param.setStudentId(Long.valueOf(studentId));
|
|
|
|
|
param.setApplicationId(Long.valueOf(applicationId));
|
|
|
|
|
param.setUniversitiesCollegesId(Long.valueOf(universitiesCollegesId));
|
|
|
|
|
|
|
|
|
|
List<StudentAccountAssetAllocation> accountAssetAllocation = getValuesByQueryNotWithPermission(param);
|
|
|
|
|
|
|
|
|
|
Assert.notNull(accountAssetAllocation, "账户不存在!");
|
|
|
|
|
|
|
|
|
|
return accountAssetAllocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证并返回登录信息
|
|
|
|
|
*
|
|
|
|
|
* @param applicationToken 回传的token
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private LoginTodo validateAndGetLoginTodo(String applicationToken) {
|
|
|
|
|
LoginTodo payload = loginTodoService.getPayloadByString(applicationToken);
|
|
|
|
|
|
|
|
|
|
Assert.notNull(payload, "回传的token,不是有效的加密串!");
|
|
|
|
|
|
|
|
|
|
ResourcesApplication resourcesApplication = resourcesApplicationService.queryById(payload.getApplicationId());
|
|
|
|
|
|
|
|
|
|
Assert.notNull(resourcesApplication, "未查询到应用的相关信息!");
|
|
|
|
|
boolean verify = JWTUtil.verify(applicationToken, resourcesApplication.getLinkSecretKey().getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
Assert.isTrue(verify, "token被修改过,更新失败!");
|
|
|
|
|
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|