Search in sources :

Example 6 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class AddTestUser method addTestUser.

public void addTestUser() {
    String pmphUserData = "[" + "{'username':'yewutest01','realname':'业务测试账号A','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'主任'}]}," + "{'username':'yewutest02','realname':'业务测试账号B','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'系统管理员'},{'roleName':'项目编辑'}]}," + "{'username':'yewutest03','realname':'业务测试账号C','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest04','realname':'业务测试账号D','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest05','realname':'业务测试账号E','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest06','realname':'业务测试账号F','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest07','realname':'业务测试账号J','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'主任'}]}," + "{'username':'yewutest08','realname':'业务测试账号H','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[]}," + "{'username':'yewutest09','realname':'业务测试账号I','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'数字编辑'}]}," + "{'username':'yewutest10','realname':'业务测试账号J','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'数字编辑'},{'roleName':'其他用户'}]}" + "]";
    Gson gson = new Gson();
    List<TestPmphUserBo> testPmphUsers = gson.fromJson(pmphUserData, new TypeToken<ArrayList<TestPmphUserBo>>() {
    }.getType());
    for (TestPmphUserBo user : testPmphUsers) {
        PmphDepartment pmphDepartment = pmphDepartmentService.getPmphDepartmentByName(user.getDepartment());
        PmphUser pmphUser = new PmphUser();
        pmphUser.setUsername(user.getUsername());
        pmphUser.setRealname(user.getRealname());
        pmphUser.setPassword(user.getPassword());
        pmphUser.setDepartmentId(pmphDepartment == null ? 0L : pmphDepartment.getId());
        pmphUser.setAvatar(user.getAvatar());
        pmphUser = pmphUserService.add(pmphUser);
        for (PmphRole pmphRole : user.getRoles()) {
            pmphRole = pmphRoleService.getByName(pmphRole.getRoleName());
            PmphUserRole pmphUserRole = new PmphUserRole();
            pmphUserRole.setUserId(pmphUser.getId());
            pmphUserRole.setRoleId(pmphRole == null ? 0L : pmphRole.getId());
            pmphUserRoleService.addPmphUserRole(pmphUserRole);
        }
    }
    String orgData = "[" + "{'orgName':'北京测试学校','orgType':'本科','areaName':'北京市','username':'bjcsxxtest','password':'123456','realname':'北京学校管理员','avatar':'DEFAULT'," + "writerUsers:[" + "{'username':'bjzuojia01','password':'888888','nickname':'北京作家01','realname':'北京作家01'}," + "{'username':'bjzuojia02','password':'888888','nickname':'北京作家02','realname':'北京作家02'}," + "{'username':'bjzuojia03','password':'888888','nickname':'北京作家03','realname':'北京作家03'}," + "{'username':'bjzuojia04','password':'888888','nickname':'北京作家04','realname':'北京作家04'}," + "{'username':'bjzuojia05','password':'888888','nickname':'北京作家05','realname':'北京作家05'}," + "{'username':'bjzuojia06','password':'888888','nickname':'北京作家06','realname':'北京作家06'}," + "{'username':'bjzuojia07','password':'888888','nickname':'北京作家07','realname':'北京作家07'}," + "{'username':'bjzuojia08','password':'888888','nickname':'北京作家08','realname':'北京作家08'}," + "{'username':'bjzuojia09','password':'888888','nickname':'北京作家09','realname':'北京作家09'}," + "{'username':'bjzuojia10','password':'888888','nickname':'北京作家10','realname':'北京作家10'}," + "{'username':'bjzuojia11','password':'888888','nickname':'北京作家11','realname':'北京作家11'}" + "]" + "}," + "{'orgName':'天津测试学校','orgType':'本科','areaName':'天津市','username':'tjcsxxtest','password':'123456','realname':'天津学校管理员','avatar':'DEFAULT'," + "writerUsers:[" + "{'username':'tjzuojia01','password':'888888','nickname':'天津作家01','realname':'天津作家01'}," + "{'username':'tjzuojia02','password':'888888','nickname':'天津作家02','realname':'天津作家02'}," + "{'username':'tjzuojia03','password':'888888','nickname':'天津作家03','realname':'天津作家03'}," + "{'username':'tjzuojia04','password':'888888','nickname':'天津作家04','realname':'天津作家04'}," + "{'username':'tjzuojia05','password':'888888','nickname':'天津作家05','realname':'天津作家05'}," + "{'username':'tjzuojia06','password':'888888','nickname':'天津作家06','realname':'天津作家06'}," + "{'username':'tjzuojia07','password':'888888','nickname':'天津作家07','realname':'天津作家07'}," + "{'username':'tjzuojia08','password':'888888','nickname':'天津作家08','realname':'天津作家08'}," + "{'username':'tjzuojia09','password':'888888','nickname':'天津作家09','realname':'天津作家09'}," + "{'username':'tjzuojia10','password':'888888','nickname':'天津作家10','realname':'天津作家10'}," + "{'username':'tjzuojia11','password':'888888','nickname':'天津作家11','realname':'天津作家11'}" + "]" + "}" + "]";
    List<TestOrgBo> orgBos = gson.fromJson(orgData, new TypeToken<ArrayList<TestOrgBo>>() {
    }.getType());
    for (TestOrgBo testOrgBo : orgBos) {
        Org org = new Org();
        org.setParentId(0L);
        org.setOrgName(testOrgBo.getOrgName());
        org.setOrgTypeId(orgTypeService.listOrgTypeByTypeName(testOrgBo.getOrgType()).get(0).getId());
        org.setAreaId(areaService.getAreaIdByName(testOrgBo.getAreaName()));
        org = orgService.addOrg(org);
        OrgUser orgUser = new OrgUser();
        orgUser.setUsername(testOrgBo.getUsername());
        orgUser.setPassword(new DesRun("", testOrgBo.getPassword()).enpsw);
        orgUser.setOrgId(org.getId());
        orgUser.setRealname(testOrgBo.getRealname());
        orgUser.setAvatar(testOrgBo.getAreaName());
        orgUser = orgUserService.addOrgUser(orgUser);
        for (WriterUser writerUser : testOrgBo.getWriterUsers()) {
            writerUser.setOrgId(org.getId());
            writerUserService.add(writerUser);
        }
    }
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) Gson(com.google.gson.Gson) PmphRole(com.bc.pmpheep.back.po.PmphRole) TypeToken(com.google.gson.reflect.TypeToken) DesRun(com.bc.pmpheep.back.util.DesRun) WriterUser(com.bc.pmpheep.back.po.WriterUser) PmphDepartment(com.bc.pmpheep.back.po.PmphDepartment) PmphUserRole(com.bc.pmpheep.back.po.PmphUserRole)

Example 7 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class BookUserCommentServiceImpl method updateBookUserCommentByAuth.

@Override
public String updateBookUserCommentByAuth(Long[] ids, Integer isAuth, String sessionId) throws CheckedServiceException {
    String result = "FAIL";
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ArrayUtil.isEmpty(ids)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "评论id为空");
    }
    if (ObjectUtil.isNull(isAuth)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "审核内容为空");
    }
    int num = 0;
    for (Long id : ids) {
        BookUserComment bookUserComment = bookUserCommentDao.getBookUserCommentById(id);
        if (bookUserComment.getIsAuth() != 0) {
            throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.ILLEGAL_PARAM, "您选中的评论中有已经审核完成的评论,请确认后再次提交");
        }
        if (isAuth == 1) {
            WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
            writerUserTrendst.setUserId(bookUserComment.getWriterId());
            writerUserTrendst.setType(5);
            writerUserTrendst.setBookId(bookUserComment.getBookId());
            writerUserTrendst.setBookCommentId(id);
            writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
        }
        bookUserComment.setId(id);
        bookUserComment.setIsAuth(isAuth);
        bookUserComment.setAuthUserId(pmphUser.getId());
        bookUserComment.setAuthDate(DateUtil.getCurrentTime());
        num += bookUserCommentDao.updateBookUserComment(bookUserComment);
        if (isAuth == 1) {
            // 更新评分
            bookService.updateBookCore(bookUserComment.getBookId());
            // 更新书的评论数
            bookService.updateUpComments(bookUserComment.getBookId());
        }
        // 当用户评论过后 增加相应积分
        if (isAuth == 1) {
            String ruleName = "图书评论";
            writerPointLogService.addWriterPointLogByRuleName(ruleName, bookUserComment.getWriterId());
        }
    }
    if (num > 0) {
        result = "SUCCESS";
    }
    return result;
}
Also used : WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) PmphUser(com.bc.pmpheep.back.po.PmphUser) BookUserComment(com.bc.pmpheep.back.po.BookUserComment) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterPoint(com.bc.pmpheep.back.po.WriterPoint)

Example 8 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class BookVideoServiceImpl method addBookVideo.

@Override
public Integer addBookVideo(String sessionId, BookVideo bookVideo, MultipartFile cover) throws CheckedServiceException, IOException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(bookVideo.getBookId()) || StringUtil.isEmpty(bookVideo.getTitle()) || StringUtil.isEmpty(bookVideo.getFileName()) || StringUtil.isEmpty(bookVideo.getPath()) || StringUtil.isEmpty(bookVideo.getOrigFileName()) || StringUtil.isEmpty(bookVideo.getOrigPath()) || ObjectUtil.isNull(bookVideo.getFileSize()) || ObjectUtil.isNull(bookVideo.getOrigFileSize())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    bookVideo.setUserId(0L);
    bookVideo.setIsAuth(true);
    bookVideo.setAuthUserId(pmphUser.getId());
    bookVideo.setAuthDate(new Date());
    // 暂设为默认值
    bookVideo.setCover("DEFAULT");
    bookVideoDao.addBookVideo(bookVideo);
    /* 保存封面 */
    String coverId = fileService.save(cover, FileType.BOOKVEDIO_CONER, bookVideo.getId());
    bookVideo.setCover(coverId);
    return bookVideoDao.updateBookVideo(bookVideo);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Date(java.util.Date)

Example 9 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class CmsAdvertisementServiceImpl method deleteCmsAdvertisementImageById.

@Override
public Integer deleteCmsAdvertisementImageById(String[] image, Long[] id, String sessionId) {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (!pmphUser.getIsAdmin()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有操作权限");
    }
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null == image) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Integer count = 0;
    // 遍历数组 进行删除MongoDB的图
    for (int i = 0; i < image.length; i++) {
        if (null != id[i]) {
            // 取芒果图片上保存的id
            String ids = image[i].substring(15);
            fileService.remove(ids);
        }
    }
    // 删除本地相对应的图片信息
    for (int i = 0; i < id.length; i++) {
        if (null != id[i]) {
            count = cmsAdvertisementImageDao.deleteCmsAdvertisementByImages(id[i]);
        }
    }
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 10 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class CmsAdvertisementServiceImpl method updateCmsAdvertisement.

@Override
public Integer updateCmsAdvertisement(CmsAdvertisement cmsAdvertisement, String sessionId) throws CheckedServiceException {
    Integer count = 0;
    // session PmphUser用户验证
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (!pmphUser.getIsAdmin()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有操作权限");
    }
    if (ObjectUtil.isNull(cmsAdvertisement)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null == cmsAdvertisement.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "广告id");
    }
    count = cmsAdvertisementDao.updateCmsAdvertisement(cmsAdvertisement);
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

PmphUser (com.bc.pmpheep.back.po.PmphUser)102 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)81 ArrayList (java.util.ArrayList)33 PageResult (com.bc.pmpheep.back.plugin.PageResult)17 HashMap (java.util.HashMap)13 Material (com.bc.pmpheep.back.po.Material)11 WriterUser (com.bc.pmpheep.back.po.WriterUser)11 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)10 PmphRole (com.bc.pmpheep.back.po.PmphRole)9 UserMessage (com.bc.pmpheep.back.po.UserMessage)9 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)9 BaseTest (com.bc.pmpheep.test.BaseTest)9 Test (org.junit.Test)9 CmsContent (com.bc.pmpheep.back.po.CmsContent)8 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)8 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)7 Textbook (com.bc.pmpheep.back.po.Textbook)7 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)6 Gson (com.google.gson.Gson)6 OrgUser (com.bc.pmpheep.back.po.OrgUser)5