Search in sources :

Example 6 with UserStyle

use of com.topcom.cms.yuqing.domain.UserStyle in project topcom-cloud by 545314690.

the class UserStyleController method setUserStyle.

@ApiOperation("保存userStyle,保证每个用户只有一个UserStyle")
@RequestMapping(value = { "setUserStyle" }, method = { RequestMethod.POST }, produces = { "application/json" }, consumes = { "application/json" })
@ResponseBody
public UserStyle setUserStyle(@CurrentUser User user, @RequestBody UserStyle userStyle) throws Exception {
    UserStyle us = this.userStyleManager.findByUserId(user.getId());
    if (us == null) {
        Date date = new Date();
        userStyle.setDateCreated(date);
        userStyle.setDateModified(date);
        userStyle.setUserId(user.getId());
        userStyle = this.manager.save(userStyle);
        return userStyle;
    } else {
        userStyle.setId(us.getId());
        userStyle.setDateModified(new Date());
        userStyle.setUserId(user.getId());
        userStyle = this.manager.save(userStyle);
        return userStyle;
    }
}
Also used : UserStyle(com.topcom.cms.yuqing.domain.UserStyle) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

UserStyle (com.topcom.cms.yuqing.domain.UserStyle)6 ApiOperation (io.swagger.annotations.ApiOperation)5 Group (com.topcom.cms.domain.Group)3 GroupStyle (com.topcom.cms.yuqing.vo.request.GroupStyle)2 Date (java.util.Date)2 AggPageImpl (com.topcom.cms.es.vo.AggPageImpl)1 ArrayList (java.util.ArrayList)1 Page (org.springframework.data.domain.Page)1