diff --git a/src/main/java/com/sztzjy/fund_investment/config/security/TokenProvider.java b/src/main/java/com/sztzjy/fund_investment/config/security/TokenProvider.java index 977fe8c..a64af0c 100644 --- a/src/main/java/com/sztzjy/fund_investment/config/security/TokenProvider.java +++ b/src/main/java/com/sztzjy/fund_investment/config/security/TokenProvider.java @@ -132,7 +132,7 @@ public class TokenProvider { //生成智云平台32字节密钥 public static void main(String[] args) { - getJWTUserByZhiYun("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb2xsZWdlIjoi5ryU56S65a2m6ZmiIiwiaWNpYnRTY2hvb2xJZCI6NCwibWQ1UHdkIjoiNDYtRjktNEMtOEQtRTEtNEYtQjMtNjYtODAtODUtMDctNjgtRkYtMUItN0YtMkEiLCJyb2xlaWQiOiI0Iiwic2V4Ijoi55S3IiwidXNlcklkIjoiNDkyIiwic3R1ZGVudElkIjoiNDA1MSIsInBhc3N3b3JkIjoiMTIzcXdlIiwiY2xhc3NJZCI6IjIxNiIsImljaWJ0Q2xhc3NJZCI6MjA5LCJtYWpvciI6IuS6p-WTgea8lOekuuS4k-S4miIsInNjaG9vbCI6IuWkqeaLqeWkp-WtpiIsInNjaG9vbElkIjoiMjMyIiwibmFtZSI6InR6czAwNiIsInN0dWRlbnRObyI6InR6czAwNiIsImFwcGxpY2F0aW9uSWQiOiIxMjIiLCJjbGFzcyI6IuWkqeaLqea8lOekujbnj60iLCJ1c2VybmFtZSI6InR6czAwNiJ9.P6EmI0cQoAZwuoPJrwRjtjZNSCANUtxcRebQTtm0HOI"); + getJWTUserByZhiYun("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb2xsZWdlIjoi5ryU56S65a2m6ZmiIiwiaWNpYnRTY2hvb2xJZCI6NCwibWQ1UHdkIjoiNDYtRjktNEMtOEQtRTEtNEYtQjMtNjYtODAtODUtMDctNjgtRkYtMUItN0YtMkEiLCJyb2xlaWQiOiI0Iiwic2V4Ijoi55S3IiwidXNlcklkIjoiNDkyIiwic3R1ZGVudElkIjoiNDA1MSIsInBhc3N3b3JkIjoiMTIzcXdlIiwiY2xhc3NJZCI6IjIxNiIsImljaWJ0Q2xhc3NJZCI6MjA5LCJtYWpvciI6IuS6p-WTgea8lOekuuS4k-S4miIsInNjaG9vbCI6IuWkqeaLqeWkp-WtpiIsInNjaG9vbElkIjoiMjMyIiwibmFtZSI6InR6czAwNiIsInN0dWRlbnRObyI6InR6czAwNiIsImFwcGxpY2F0aW9uSWQiOiIxMjIiLCJjbGFzcyI6IuWkqeaLqea8lOekujbnj60iLCJ1c2VybmFtZSI6InR6czAwNiJ9.252uWMvke17Es1P82g3xHMTx6yfAGKt0jU3Q0TJC_9I"); // String prefix = "zy_wh_mnjy_"; // String generatedKey = generateKey(prefix); // System.out.println("Generated Key: " + generatedKey); diff --git a/src/main/java/com/sztzjy/fund_investment/controller/UserController.java b/src/main/java/com/sztzjy/fund_investment/controller/UserController.java index c32aeac..ff32d57 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/UserController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/UserController.java @@ -7,10 +7,7 @@ import com.sztzjy.fund_investment.config.exception.UnAuthorizedException; import com.sztzjy.fund_investment.config.security.JwtUser; import com.sztzjy.fund_investment.config.security.LoginResult; import com.sztzjy.fund_investment.config.security.TokenProvider; -import com.sztzjy.fund_investment.entity.Flow; -import com.sztzjy.fund_investment.entity.PerformanceScore; -import com.sztzjy.fund_investment.entity.PerformanceScoreExample; -import com.sztzjy.fund_investment.entity.User; +import com.sztzjy.fund_investment.entity.*; import com.sztzjy.fund_investment.entity.dto.EvaluationLevel; import com.sztzjy.fund_investment.entity.dto.PerformanceTrainingScoreDto; import com.sztzjy.fund_investment.mapper.FlowMapper; @@ -31,10 +28,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.lang.reflect.Field; @@ -218,7 +212,7 @@ public class UserController { flow1.setFlowId(uuid); flowMapper.insert(flow1); map.put("flowId", uuid); - }else { + } else { map.put("flowId", flow.getFlowId()); } return new ResultEntity(HttpStatus.OK, map); @@ -226,6 +220,47 @@ public class UserController { } + @ApiOperation("根据用户Code查询该用户是否存在个人赛用户数据,存在则返回,不存在则新增后返回,用于智云3.0创建用户后调用该接口创建用户个人赛") + @PostMapping("/checkOrCreateForexSimulationUser") + @AnonymousAccess + public String checkOrCreateForexSimulationUser(@RequestBody List zyUserInfoList) { + List users = new ArrayList<>(); + for (int i = 0; i < zyUserInfoList.size(); i++) { + ZYUserInfo zyUserInfo = zyUserInfoList.get(i); + Integer zyUserId = zyUserInfo.getUserId(); + String username = zyUserInfo.getUsername(); // studentid + User user = userMapper.selectByPrimaryKey(String.valueOf(zyUserId)); + if (user != null) { + continue; + } + User stuUser = new User(); + stuUser.setUserid(String.valueOf(zyUserId)); + stuUser.setStudentId(zyUserInfo.getUsername()); + stuUser.setName(zyUserInfo.getName()); + stuUser.setUsername(username); + stuUser.setClassId(zyUserInfo.getClassId().toString()); + stuUser.setClassName(zyUserInfo.getClassName()); + stuUser.setPassword(zyUserInfo.getPassword()); + stuUser.setPhone(zyUserInfo.getPhone()); + stuUser.setRoleId( zyUserInfo.getRoleId()); //3教师 4学生 + stuUser.setSchoolId(zyUserInfo.getSchoolId().toString()); + stuUser.setSchoolName(zyUserInfo.getSchoolName()); + stuUser.setCreateTime(new Date()); + users.add(stuUser); + } + if (users.isEmpty()) { + return "账号已全部存在"; + } + try { + userMapper.batchInsertStudents(users); + return "ok"; + } catch (Exception e) { + e.printStackTrace(); + return "false"; + } + } + + /* 封装MAP并生成flow表数据 * @author xcj * @Date 2024/1/3 diff --git a/src/main/java/com/sztzjy/fund_investment/entity/ZYUserInfo.java b/src/main/java/com/sztzjy/fund_investment/entity/ZYUserInfo.java new file mode 100644 index 0000000..d14a95a --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/entity/ZYUserInfo.java @@ -0,0 +1,25 @@ +package com.sztzjy.fund_investment.entity; + +import lombok.Data; + +/** + * @Author xcj + * @Date 2024/8/7 + */ +@Data +public class ZYUserInfo { + private String username; + private String password; + private String name; + private Integer userId; + private Integer roleId; + private Integer schoolId; + private String schoolName; + private Integer classId; + private String className; + private String phone; + private Long collegeId; + private String collegeName; + private Long majorId; + private String majorName; +} diff --git a/src/main/java/com/sztzjy/fund_investment/mapper/UserMapper.java b/src/main/java/com/sztzjy/fund_investment/mapper/UserMapper.java index 47a399a..5dfdfb2 100644 --- a/src/main/java/com/sztzjy/fund_investment/mapper/UserMapper.java +++ b/src/main/java/com/sztzjy/fund_investment/mapper/UserMapper.java @@ -41,4 +41,5 @@ public interface UserMapper { ListgetStudentScoreDetails(@Param("schoolId") String schoolId, @Param("classId")String classId, @Param("studentIdOrName")String studentIdOrName); + void batchInsertStudents(@Param("list") List users); } \ No newline at end of file diff --git a/src/main/resources/mappers/UserMapper.xml b/src/main/resources/mappers/UserMapper.xml index 0a23aac..e37f9dc 100644 --- a/src/main/resources/mappers/UserMapper.xml +++ b/src/main/resources/mappers/UserMapper.xml @@ -1,434 +1,453 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - userid, name, student_id, class_name, class_id, username, password, phone, role_id, + + + + userid + , name, student_id, class_name, class_id, username, password, phone, role_id, create_time, school_id, school_name, un, dis, access_token, login_type - + - + - - - - delete from wx_user - where userid = #{userid,jdbcType=VARCHAR} - - - delete from wx_user - - - - - - insert into wx_user (userid, name, student_id, - class_name, class_id, username, - password, phone, role_id, - create_time, school_id, school_name, - un, dis, access_token, - login_type) - values (#{userid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, - #{className,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, - #{password,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{roleId,jdbcType=INTEGER}, - #{createTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=VARCHAR}, #{schoolName,jdbcType=VARCHAR}, - #{un,jdbcType=VARCHAR}, #{dis,jdbcType=VARCHAR}, #{accessToken,jdbcType=VARCHAR}, - #{loginType,jdbcType=INTEGER}) - - - insert into wx_user - - - userid, - - - name, - - - student_id, - - - class_name, - - - class_id, - - - username, - - - password, - - - phone, - - - role_id, - - - create_time, - - - school_id, - - - school_name, - - - un, - - - dis, - - - access_token, - - - login_type, - - - - - #{userid,jdbcType=VARCHAR}, - - - #{name,jdbcType=VARCHAR}, - - - #{studentId,jdbcType=VARCHAR}, - - - #{className,jdbcType=VARCHAR}, - - - #{classId,jdbcType=VARCHAR}, - - - #{username,jdbcType=VARCHAR}, - - - #{password,jdbcType=VARCHAR}, - - - #{phone,jdbcType=VARCHAR}, - - - #{roleId,jdbcType=INTEGER}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - #{schoolId,jdbcType=VARCHAR}, - - - #{schoolName,jdbcType=VARCHAR}, - - - #{un,jdbcType=VARCHAR}, - - - #{dis,jdbcType=VARCHAR}, - - - #{accessToken,jdbcType=VARCHAR}, - - - #{loginType,jdbcType=INTEGER}, - - - - - - update wx_user - - - userid = #{record.userid,jdbcType=VARCHAR}, - - + + + + delete + from wx_user + where userid = #{userid,jdbcType=VARCHAR} + + + delete from wx_user + + + + + + insert into wx_user (userid, name, student_id, + class_name, class_id, username, + password, phone, role_id, + create_time, school_id, school_name, + un, dis, access_token, + login_type) + values (#{userid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, + #{className,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, + #{password,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{roleId,jdbcType=INTEGER}, + #{createTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=VARCHAR}, #{schoolName,jdbcType=VARCHAR}, + #{un,jdbcType=VARCHAR}, #{dis,jdbcType=VARCHAR}, #{accessToken,jdbcType=VARCHAR}, + #{loginType,jdbcType=INTEGER}) + + + insert into wx_user + + + userid, + + + name, + + + student_id, + + + class_name, + + + class_id, + + + username, + + + password, + + + phone, + + + role_id, + + + create_time, + + + school_id, + + + school_name, + + + un, + + + dis, + + + access_token, + + + login_type, + + + + + #{userid,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{studentId,jdbcType=VARCHAR}, + + + #{className,jdbcType=VARCHAR}, + + + #{classId,jdbcType=VARCHAR}, + + + #{username,jdbcType=VARCHAR}, + + + #{password,jdbcType=VARCHAR}, + + + #{phone,jdbcType=VARCHAR}, + + + #{roleId,jdbcType=INTEGER}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{schoolId,jdbcType=VARCHAR}, + + + #{schoolName,jdbcType=VARCHAR}, + + + #{un,jdbcType=VARCHAR}, + + + #{dis,jdbcType=VARCHAR}, + + + #{accessToken,jdbcType=VARCHAR}, + + + #{loginType,jdbcType=INTEGER}, + + + + + + update wx_user + + + userid = #{record.userid,jdbcType=VARCHAR}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + student_id = #{record.studentId,jdbcType=VARCHAR}, + + + class_name = #{record.className,jdbcType=VARCHAR}, + + + class_id = #{record.classId,jdbcType=VARCHAR}, + + + username = #{record.username,jdbcType=VARCHAR}, + + + password = #{record.password,jdbcType=VARCHAR}, + + + phone = #{record.phone,jdbcType=VARCHAR}, + + + role_id = #{record.roleId,jdbcType=INTEGER}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + school_id = #{record.schoolId,jdbcType=VARCHAR}, + + + school_name = #{record.schoolName,jdbcType=VARCHAR}, + + + un = #{record.un,jdbcType=VARCHAR}, + + + dis = #{record.dis,jdbcType=VARCHAR}, + + + access_token = #{record.accessToken,jdbcType=VARCHAR}, + + + login_type = #{record.loginType,jdbcType=INTEGER}, + + + + + + + + update wx_user + set userid = #{record.userid,jdbcType=VARCHAR}, name = #{record.name,jdbcType=VARCHAR}, - - student_id = #{record.studentId,jdbcType=VARCHAR}, - - class_name = #{record.className,jdbcType=VARCHAR}, - - class_id = #{record.classId,jdbcType=VARCHAR}, - - username = #{record.username,jdbcType=VARCHAR}, - - password = #{record.password,jdbcType=VARCHAR}, - - phone = #{record.phone,jdbcType=VARCHAR}, - - role_id = #{record.roleId,jdbcType=INTEGER}, - - create_time = #{record.createTime,jdbcType=TIMESTAMP}, - - school_id = #{record.schoolId,jdbcType=VARCHAR}, - - school_name = #{record.schoolName,jdbcType=VARCHAR}, - - un = #{record.un,jdbcType=VARCHAR}, - - dis = #{record.dis,jdbcType=VARCHAR}, - - access_token = #{record.accessToken,jdbcType=VARCHAR}, - - - login_type = #{record.loginType,jdbcType=INTEGER}, - - - - - - - - update wx_user - set userid = #{record.userid,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, - student_id = #{record.studentId,jdbcType=VARCHAR}, - class_name = #{record.className,jdbcType=VARCHAR}, - class_id = #{record.classId,jdbcType=VARCHAR}, - username = #{record.username,jdbcType=VARCHAR}, - password = #{record.password,jdbcType=VARCHAR}, - phone = #{record.phone,jdbcType=VARCHAR}, - role_id = #{record.roleId,jdbcType=INTEGER}, - create_time = #{record.createTime,jdbcType=TIMESTAMP}, - school_id = #{record.schoolId,jdbcType=VARCHAR}, - school_name = #{record.schoolName,jdbcType=VARCHAR}, - un = #{record.un,jdbcType=VARCHAR}, - dis = #{record.dis,jdbcType=VARCHAR}, - access_token = #{record.accessToken,jdbcType=VARCHAR}, - login_type = #{record.loginType,jdbcType=INTEGER} - - - - - - update wx_user - - - name = #{name,jdbcType=VARCHAR}, - - - student_id = #{studentId,jdbcType=VARCHAR}, - - - class_name = #{className,jdbcType=VARCHAR}, - - - class_id = #{classId,jdbcType=VARCHAR}, - - - username = #{username,jdbcType=VARCHAR}, - - - password = #{password,jdbcType=VARCHAR}, - - - phone = #{phone,jdbcType=VARCHAR}, - - - role_id = #{roleId,jdbcType=INTEGER}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - school_id = #{schoolId,jdbcType=VARCHAR}, - - - school_name = #{schoolName,jdbcType=VARCHAR}, - - - un = #{un,jdbcType=VARCHAR}, - - - dis = #{dis,jdbcType=VARCHAR}, - - - access_token = #{accessToken,jdbcType=VARCHAR}, - - - login_type = #{loginType,jdbcType=INTEGER}, - - - where userid = #{userid,jdbcType=VARCHAR} - - - update wx_user - set name = #{name,jdbcType=VARCHAR}, - student_id = #{studentId,jdbcType=VARCHAR}, - class_name = #{className,jdbcType=VARCHAR}, - class_id = #{classId,jdbcType=VARCHAR}, - username = #{username,jdbcType=VARCHAR}, - password = #{password,jdbcType=VARCHAR}, - phone = #{phone,jdbcType=VARCHAR}, - role_id = #{roleId,jdbcType=INTEGER}, - create_time = #{createTime,jdbcType=TIMESTAMP}, - school_id = #{schoolId,jdbcType=VARCHAR}, - school_name = #{schoolName,jdbcType=VARCHAR}, - un = #{un,jdbcType=VARCHAR}, - dis = #{dis,jdbcType=VARCHAR}, - access_token = #{accessToken,jdbcType=VARCHAR}, - login_type = #{loginType,jdbcType=INTEGER} - where userid = #{userid,jdbcType=VARCHAR} - + login_type = #{record.loginType,jdbcType=INTEGER} + + + + + + update wx_user + + + name = #{name,jdbcType=VARCHAR}, + + + student_id = #{studentId,jdbcType=VARCHAR}, + + + class_name = #{className,jdbcType=VARCHAR}, + + + class_id = #{classId,jdbcType=VARCHAR}, + + + username = #{username,jdbcType=VARCHAR}, + + + password = #{password,jdbcType=VARCHAR}, + + + phone = #{phone,jdbcType=VARCHAR}, + + + role_id = #{roleId,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + school_id = #{schoolId,jdbcType=VARCHAR}, + + + school_name = #{schoolName,jdbcType=VARCHAR}, + + + un = #{un,jdbcType=VARCHAR}, + + + dis = #{dis,jdbcType=VARCHAR}, + + + access_token = #{accessToken,jdbcType=VARCHAR}, + + + login_type = #{loginType,jdbcType=INTEGER}, + + + where userid = #{userid,jdbcType=VARCHAR} + + + update wx_user + set name = #{name,jdbcType=VARCHAR}, + student_id = #{studentId,jdbcType=VARCHAR}, + class_name = #{className,jdbcType=VARCHAR}, + class_id = #{classId,jdbcType=VARCHAR}, + username = #{username,jdbcType=VARCHAR}, + password = #{password,jdbcType=VARCHAR}, + phone = #{phone,jdbcType=VARCHAR}, + role_id = #{roleId,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + school_id = #{schoolId,jdbcType=VARCHAR}, + school_name = #{schoolName,jdbcType=VARCHAR}, + un = #{un,jdbcType=VARCHAR}, + dis = #{dis,jdbcType=VARCHAR}, + access_token = #{accessToken,jdbcType=VARCHAR}, + login_type = #{loginType,jdbcType=INTEGER} + where userid = #{userid,jdbcType=VARCHAR} + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + insert into wx_user (userid, name, student_id, + class_name, class_id, username, + password, phone, role_id, + create_time, school_id, school_name) + values + + (#{student.userid,jdbcType=VARCHAR}, #{student.name,jdbcType=VARCHAR}, #{student.studentId,jdbcType=VARCHAR}, + #{student.className,jdbcType=VARCHAR}, #{student.classId,jdbcType=VARCHAR}, #{student.username,jdbcType=VARCHAR}, + #{student.password,jdbcType=VARCHAR}, #{student.phone,jdbcType=VARCHAR}, #{student.roleId,jdbcType=INTEGER}, + #{student.createTime,jdbcType=TIMESTAMP}, #{student.schoolId,jdbcType=VARCHAR}, #{student.schoolName,jdbcType=VARCHAR}) + + \ No newline at end of file