Search in sources :

Example 11 with User

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;
}
Also used : User(com.topcom.cms.domain.User) JSONObject(net.sf.json.JSONObject) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) BusinessException(com.topcom.cms.exception.BusinessException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 12 with User

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);
}
Also used : User(com.topcom.cms.domain.User)

Example 13 with 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);
}
Also used : User(com.topcom.cms.domain.User)

Example 14 with User

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);
}
Also used : User(com.topcom.cms.domain.User)

Example 15 with User

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);
}
Also used : Group(com.topcom.cms.domain.Group) CurrentUser(com.topcom.cms.web.bind.annotation.CurrentUser) User(com.topcom.cms.domain.User) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

User (com.topcom.cms.domain.User)24 CurrentUser (com.topcom.cms.web.bind.annotation.CurrentUser)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 PageRequest (org.springframework.data.domain.PageRequest)4 Pageable (org.springframework.data.domain.Pageable)4 Group (com.topcom.cms.domain.Group)3 Resource (com.topcom.cms.domain.Resource)3 ApiOperation (io.swagger.annotations.ApiOperation)3 JSONObject (net.sf.json.JSONObject)3 WeChat (com.topcom.cms.data.domain.WeChat)2 BusinessException (com.topcom.cms.exception.BusinessException)2 AuthenticationException (com.topcom.cms.perm.exception.AuthenticationException)2 UsernamePasswordToken (com.topcom.cms.perm.token.UsernamePasswordToken)2 UserManager (com.topcom.cms.service.UserManager)2 com.topcom.cms.yuqing.domain (com.topcom.cms.yuqing.domain)2 CustomSubjectManager (com.topcom.cms.yuqing.service.CustomSubjectManager)2 SubscriptionFollowerManager (com.topcom.cms.yuqing.service.SubscriptionFollowerManager)2 WarningLogManager (com.topcom.cms.yuqing.service.WarningLogManager)2 WarningManager (com.topcom.cms.yuqing.service.WarningManager)2