..
This commit is contained in:
@@ -14,6 +14,7 @@ import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.utils.PwdUtil;
|
||||
import com.budwk.app.sys.models.Sys_dict;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
@@ -94,104 +95,6 @@ public class JugTest {
|
||||
dao.fastInsert(units);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void t0002() {
|
||||
String appId = "1926887238437818370";
|
||||
String secret = "32df31fcf4fc43f9a647ee1f47134f36";
|
||||
|
||||
List<Sys_user_source> allUsers = new ArrayList<>();
|
||||
int skip = 0;
|
||||
int totalCount = 0;
|
||||
boolean firstRequest = true;
|
||||
|
||||
do {
|
||||
long ts = System.currentTimeMillis();
|
||||
String sign = Base64.encode(DigestUtil.md5Hex(appId + secret + ts, CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
HttpRequest httpRequest = HttpUtil.createPost("https://sjzcpt.nnu.edu.cn/cdsp/data-api/v2/DS0026");
|
||||
httpRequest.header("Content-Type", "application/json");
|
||||
httpRequest.header("appId", appId);
|
||||
httpRequest.header("timestamp", String.valueOf(ts));
|
||||
httpRequest.header("sign", sign);
|
||||
|
||||
HashMap<String, Object> reqBody = new HashMap<>();
|
||||
reqBody.put("$count", true);
|
||||
reqBody.put("$skip", skip);
|
||||
reqBody.put("$top", 1000);
|
||||
|
||||
httpRequest.body(JSONUtil.toJsonStr(reqBody));
|
||||
String resBody = httpRequest.execute().body();
|
||||
|
||||
JSONObject entries = JSONUtil.parseObj(resBody);
|
||||
|
||||
if (firstRequest) {
|
||||
totalCount = entries.getInt("@odata.count", 0);
|
||||
firstRequest = false;
|
||||
}
|
||||
|
||||
JSONArray value = entries.getJSONArray("value");
|
||||
|
||||
if (!value.isEmpty()) {
|
||||
List<Sys_user_source> list = value.stream().map(v -> {
|
||||
JSONObject jsonObject = (JSONObject) v;
|
||||
Sys_user_source sysUser = new Sys_user_source();
|
||||
sysUser.setLoginname(jsonObject.getStr("zgh"));
|
||||
sysUser.setUsername(jsonObject.getStr("xm"));
|
||||
sysUser.setSex(jsonObject.getStr("xbmc"));
|
||||
sysUser.setBirthday(jsonObject.getDate("csrq"));
|
||||
sysUser.setNativePlace(jsonObject.getStr("jgmc"));
|
||||
sysUser.setNationality(jsonObject.getStr("gjdqmc"));
|
||||
sysUser.setNation(jsonObject.getStr("mzmc"));
|
||||
sysUser.setIdCardType(jsonObject.getStr("sfzjlxmc"));
|
||||
sysUser.setIdCard(jsonObject.getStr("sfzjh"));
|
||||
sysUser.setPolitical(jsonObject.getStr("zzmmmc"));
|
||||
sysUser.setUnitName(jsonObject.getStr("dwmc"));
|
||||
sysUser.setUnitId(jsonObject.getStr("dwdm"));
|
||||
|
||||
sysUser.setUserState(jsonObject.getStr("jzgdqztmc"));
|
||||
sysUser.setEmploymentType(jsonObject.getStr("yrfsmc"));
|
||||
|
||||
|
||||
sysUser.setEducation(jsonObject.getStr("zgxlmc"));
|
||||
sysUser.setAcademicDegree(jsonObject.getStr("zgxwmc"));
|
||||
|
||||
sysUser.setMobile(jsonObject.getStr("sjh"));
|
||||
|
||||
sysUser.setStaffCategory(jsonObject.getStr("jzglbmc"));
|
||||
|
||||
sysUser.setJoinPartyDate(jsonObject.getDate("rdsj"));
|
||||
|
||||
sysUser.setTechnicalTitle(jsonObject.getStr("zyjszwmc"));
|
||||
sysUser.setTechnicalTitleLevel(jsonObject.getStr("zyjszwjbmc"));
|
||||
|
||||
sysUser.setPosition(jsonObject.getStr("gbzw"));
|
||||
sysUser.setPositionLevel(jsonObject.getStr("gbzwjbmc"));
|
||||
|
||||
sysUser.setEmployeeLevel(jsonObject.getStr("zydjmc"));
|
||||
|
||||
|
||||
sysUser.setArrivalAtSchoolDate(jsonObject.getDate("lxny"));
|
||||
|
||||
|
||||
sysUser.setRetireDate(jsonObject.getDate("yjtxrq"));
|
||||
|
||||
sysUser.setIdentityType(jsonObject.getStr("grsfmc"));
|
||||
|
||||
return sysUser;
|
||||
}).toList();
|
||||
allUsers.addAll(list);
|
||||
skip += list.size();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
} while (skip < totalCount);
|
||||
|
||||
System.out.println(1);
|
||||
|
||||
// dao.insert(allUsers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void t003() {
|
||||
String s = """
|
||||
@@ -303,7 +206,17 @@ public class JugTest {
|
||||
} while (skip < totalCount);
|
||||
|
||||
System.out.println(allUsers.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userPwd(){
|
||||
List<Sys_user> users = dao.query(Sys_user.class, Cnd.NEW());
|
||||
String pwd = "1";
|
||||
for (Sys_user user : users) {
|
||||
user.setSalt(R.UU32());
|
||||
user.setPassword(PwdUtil.getPassword(pwd, user.getSalt()));
|
||||
}
|
||||
dao.update(users,"password|salt");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user