use of com.topcom.cms.domain.User in project topcom-cloud by 545314690.
the class BriefingCreatorImpl method saveBriefingToMongo.
/**
* 报存专报到mongodb
*
* @param briefing
* @return
*/
public Boolean saveBriefingToMongo(JSONObject briefing) {
try {
DBObject dbObject = (DBObject) JSON.parse(briefing.toString());
Date endDate = new Date();
if (briefing.get("dateCreated") != null) {
endDate.setTime((Long) briefing.get("dateCreated"));
}
dbObject.put("dateCreated", endDate);
dbObject.put("dateModified", endDate);
Long userId = briefing.getLong("userId");
User currentUser = userManager.findById(userId);
dbObject.put("author", currentUser.getFullName() == null ? currentUser.getUsername() : currentUser.getFullName());
JSONObject json = JSONObject.fromObject(dbObject);
String attachment_doc = null;
attachment_doc = createAttachment(json, "doc");
String attachment_html = createAttachment(json, "html");
if (attachment_doc != null && attachment_html != null) {
dbObject.put("attachment", new String[] { attachment_doc, attachment_html });
}
MongoDBUtil.insertDocument(Constants.Mongo.COLLECTION_BRIEFING, dbObject);
} catch (Exception e) {
e.printStackTrace();
String message = "生成报告失败";
LogUtil.logger.error(message);
return false;
}
String message = "生成报告成功@";
LogUtil.logger.info(message);
return true;
}
use of com.topcom.cms.domain.User in project topcom-cloud by 545314690.
the class PasswordEncoder method main.
public static void main(String[] args) {
String salt = "admin43a76cad665299f1beaa85a0430dab";
PasswordEncoder encoderMd5 = new PasswordEncoder(salt, "MD5");
String encode = encoderMd5.encode("admin");
System.out.println(encode);
boolean passwordValid = encoderMd5.isPasswordValid("21d7d72746f11cdff39a03aa1ae9eb28", "admin");
System.out.println(passwordValid);
PasswordEncoder encoderSha = new PasswordEncoder(salt, "SHA");
String pass2 = encoderSha.encode("test");
System.out.println(pass2);
boolean passwordValid2 = encoderSha.isPasswordValid("1bd98ed329aebc7b2f89424b5a38926e", "test");
System.out.println(passwordValid2);
User user = new User();
user.setUsername("ahmj");
user.setPassword("ahmj123");
PasswordHelper.encryptPassword(user);
System.out.println(user);
}
use of com.topcom.cms.domain.User in project topcom-cloud by 545314690.
the class PasswordHelper method main.
public static void main(String[] args) {
User u = new User();
u.setUsername("ahmj");
u.setPassword("ahmj123");
PasswordHelper passwordHelper = new PasswordHelper();
passwordHelper.encryptPassword(u);
LogUtil.logger.info(u);
}
use of com.topcom.cms.domain.User in project topcom-cloud by 545314690.
the class TokenManagerImpl method createAndSaveToken.
@Override
public void createAndSaveToken(User user) {
// TODO:防止取出的时候报序列化失败的错,把用户组和角色置为空
// org.springframework.data.redis.serializer.SerializationException: Could not read JSON: failed to lazily initialize a collection, could not initialize proxy - no Session (through reference chain: com.topcom.cms.domain.User["groups"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: failed to lazily initialize a collection, could not initialize proxy - no Session (through reference chain: com.topcom.cms.domain.User["groups"])
// 新构造一个user,只保存以下信息
User userToSave = new User();
userToSave.setUsername(user.getUsername());
userToSave.setId(user.getId());
userToSave.setState(user.getState());
String token = createToken(userToSave.getUsername());
LogUtil.logger.info(token);
saveToken(token, userToSave);
}
use of com.topcom.cms.domain.User in project topcom-cloud by 545314690.
the class SearchWordController method addClickCount.
/**
* 增加点击次数 对于单个搜索词 可以支持累加
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/add", produces = "application/json")
@ResponseBody
public SearchWord addClickCount(@CurrentUser User user, @ApiParam("Word") @RequestParam(required = true) String word, @ApiParam("type") @RequestParam(required = true) Integer type) {
User user1 = this.userManager.findById(user.getId());
Set<Group> groups = user1.getGroups();
return searchWordManager.addClickCount(groups, word, type);
}
Aggregations