Search in sources :

Example 6 with RelationOrgGroupUserVo

use of com.ngtesting.platform.vo.RelationOrgGroupUserVo in project ngtesting-platform by aaronchen2k.

the class RelationOrgGroupUserServiceImpl method saveRelations.

@Override
public boolean saveRelations(List<RelationOrgGroupUserVo> orgGroupUserVos) {
    if (orgGroupUserVos == null) {
        return false;
    }
    for (Object obj : orgGroupUserVos) {
        RelationOrgGroupUserVo vo = JSON.parseObject(JSON.toJSONString(obj), RelationOrgGroupUserVo.class);
        if (vo.getSelecting() != vo.getSelected()) {
            // 变化了
            TestRelationOrgGroupUser relationOrgGroupUser = this.getRelationOrgGroupUser(vo.getOrgGroupId(), vo.getUserId());
            if (vo.getSelecting() && relationOrgGroupUser == null) {
                // 勾选
                relationOrgGroupUser = new TestRelationOrgGroupUser(vo.getOrgId(), vo.getOrgGroupId(), vo.getUserId());
                saveOrUpdate(relationOrgGroupUser);
            } else if (relationOrgGroupUser != null) {
                // 取消
                getDao().delete(relationOrgGroupUser);
            }
        }
    }
    return true;
}
Also used : TestRelationOrgGroupUser(com.ngtesting.platform.entity.TestRelationOrgGroupUser) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo)

Aggregations

RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)6 TestOrgGroup (com.ngtesting.platform.entity.TestOrgGroup)4 TestRelationOrgGroupUser (com.ngtesting.platform.entity.TestRelationOrgGroupUser)3 JSONObject (com.alibaba.fastjson.JSONObject)2 TestUser (com.ngtesting.platform.entity.TestUser)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 OrgGroupVo (com.ngtesting.platform.vo.OrgGroupVo)2 UserVo (com.ngtesting.platform.vo.UserVo)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 List (java.util.List)1