Search in sources :

Example 1 with CmsCategory

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

the class CmsCategoryServiceTest method testDeleteCmsCategoryById.

@Test
public void testDeleteCmsCategoryById() {
    CmsCategory category = this.addCmsCategory();
    Assert.assertTrue("是否删除成功", cmsCategoryService.deleteCmsCategoryById(category.getId()) > 0);
    CmsCategory cg = this.addCmsCategory();
    List<Long> idList = new ArrayList<Long>(1);
    idList.add(cg.getId());
    Assert.assertTrue("批量删除是否成功", cmsCategoryService.deleteCmsCategoryByIds(idList) > 0);
}
Also used : ArrayList(java.util.ArrayList) CmsCategory(com.bc.pmpheep.back.po.CmsCategory) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 2 with CmsCategory

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

the class CmsCategoryServiceTest method testAddCmsCategory.

@Test
public void testAddCmsCategory() {
    CmsCategory category = this.addCmsCategory();
    logger.info(category.toString());
    Assert.assertNotNull("插入内容后返回的CmsCategory.id不应为空", category.getId());
}
Also used : CmsCategory(com.bc.pmpheep.back.po.CmsCategory) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 3 with CmsCategory

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

the class CmsCategoryServiceImpl method getCmsCategoryDetail.

@Override
public Map<String, Object> getCmsCategoryDetail(Long id) throws CheckedServiceException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Map<String, Object> resultMap = new HashMap<String, Object>();
    CmsCategory cmsCategory = this.getCmsCategoryById(id);
    resultMap.put("cmsCategory", cmsCategory);
    // 按Category查询对应权限
    List<CmsCategoryRoleVO> cmsCategoryRoles = this.getCmsCategoryRoleByCategoryId(id);
    for (CmsCategoryRoleVO cmsCategoryRole : cmsCategoryRoles) {
        if (Const.CMS_CATEGORY_PERMISSSION_1 == cmsCategoryRole.getPermissionType()) {
            resultMap.put("permissionId", cmsCategoryRole.getRoleId());
        } else {
            resultMap.put("authRoleId", cmsCategoryRole.getRoleId());
        }
    }
    return resultMap;
}
Also used : HashMap(java.util.HashMap) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) CmsCategory(com.bc.pmpheep.back.po.CmsCategory) CmsCategoryRoleVO(com.bc.pmpheep.back.vo.CmsCategoryRoleVO)

Example 4 with CmsCategory

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

the class MigrationStageTen method cmsCategory.

public void cmsCategory() {
    // 要迁移的旧库表名
    String tableName = "site_column";
    // 增加new_pk字段
    JdbcHelper.addColumn(tableName);
    // 取得该表中所有数据
    List<Map<String, Object>> maps = JdbcHelper.queryForList(tableName);
    // 迁移成功的条目数
    int count = 3;
    /* 只有三条有效数据,直接新建CmsCategory保存 */
    CmsCategory category3 = new CmsCategory(0L, "0", "医学随笔", false);
    category3.setIsAuthRequired(true);
    category3.setIsAuthorVisible(true);
    category3.setIsClicksVisible(true);
    category3.setIsCommentsAllow(true);
    category3.setIsCommentsVisible(true);
    category3.setIsLikesVisible(true);
    category3.setIsBookmarksVisible(true);
    category3.setId(1L);
    category3 = cmsCategoryService.addCmsCategory(category3);
    long pk = category3.getId();
    // 更新旧表中new_pk字
    JdbcHelper.updateNewPrimaryKey(tableName, pk, "colid", "1005");
    CmsCategory category2 = new CmsCategory(0L, "0", "快报管理", true);
    category2.setIsClicksVisible(true);
    category2.setId(2L);
    category2 = cmsCategoryService.addCmsCategory(category2);
    pk = category2.getId();
    // 更新旧表中new_pk字
    JdbcHelper.updateNewPrimaryKey(tableName, pk, "colid", "1004");
    CmsCategory category1 = new CmsCategory(0L, "0", "公告管理", true);
    category1.setIsMaterialNotice(true);
    category1.setIsClicksVisible(true);
    category1.setId(3L);
    category1 = cmsCategoryService.addCmsCategory(category1);
    pk = category1.getId();
    // 更新旧表中new_pk字段
    JdbcHelper.updateNewPrimaryKey(tableName, pk, "colid", "1003");
    /* 新增帮助管理栏目 */
    CmsCategory category4 = new CmsCategory(0L, "0", "帮助管理", true);
    category4.setId(4L);
    cmsCategoryService.addCmsCategory(category4);
    logger.info("'{}'表迁移完成", tableName);
    logger.info("原数据库中共有{}条数据,迁移了{}条数据", maps.size(), count);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CmsCategory(com.bc.pmpheep.back.po.CmsCategory)

Example 5 with CmsCategory

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

the class MigrationStageTen method materialNotice.

public void materialNotice() {
    List<Material> materials = materialService.getListMaterial("轮");
    List<CmsCategory> categorys = cmsCategoryService.getCmsCategoryListByCategoryName("公告");
    Long categoryId = categorys.get(0).getId();
    final String html = "<p><strong><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">$f</span></strong>$d</p>";
    final String htmlS1 = "<p><strong><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">$d</span></strong></p>";
    final String htmlS2 = "<p style=\"box-sizing: border-box; margin-top: 0px; margin-bottom: 10px; padding: 0px;\">$d</p>";
    for (Material material : materials) {
        CmsContent cmsContent = new CmsContent();
        cmsContent.setParentId(0L);
        cmsContent.setCategoryId(categoryId);
        cmsContent.setPath("0");
        cmsContent.setTitle(material.getMaterialName());
        cmsContent.setAuthorType((short) 0);
        cmsContent.setMaterialId(material.getId());
        /* 生成通知内容 */
        StringBuilder sb = new StringBuilder();
        String str = html.replace("$f", "截止日期:");
        str = str.replace("$d", sdf.format(material.getDeadline()));
        sb.append(str);
        /* 获取教材联系人 */
        List<MaterialContact> contacts = materialContactService.listMaterialContactByMaterialId(categoryId);
        if (CollectionUtil.isNotEmpty(contacts)) {
            str = htmlS1.replace("$f", "联系人:");
            sb.append(str);
            for (MaterialContact contact : contacts) {
                /* 裴中惠&nbsp;(电话:010-59787110&nbsp;,&nbsp;Email:pzh@pmph.com) */
                StringBuilder builder = new StringBuilder(contact.getContactUserName());
                builder.append("&nbsp;(电话:");
                builder.append(contact.getContactPhone());
                builder.append("&nbsp;,&nbsp;Email:");
                builder.append(contact.getContactEmail());
                builder.append(")");
                str = htmlS2.replace("$d", builder.toString());
                sb.append(str);
            }
        }
        str = html.replace("$f", "邮寄地址:");
        str = str.replace("$d", material.getMailAddress());
        sb.append(str);
        /* 获取通知内容和备注 */
        MaterialExtra extra = materialExtraService.getMaterialExtraByMaterialId(material.getId());
        str = htmlS1.replace("$d", "简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;介:");
        sb.append(str);
        if (null != extra) {
        // str = htmlS2.replace("$d", extra.getNotice()) /* 存入MongoDB */
        }
        Content content = new Content(sb.toString());
        content = contentService.add(content);
        cmsContent.setMid(content.getId());
    }
}
Also used : CmsContent(com.bc.pmpheep.back.po.CmsContent) CmsContent(com.bc.pmpheep.back.po.CmsContent) Content(com.bc.pmpheep.general.po.Content) MaterialContact(com.bc.pmpheep.back.po.MaterialContact) Material(com.bc.pmpheep.back.po.Material) CmsCategory(com.bc.pmpheep.back.po.CmsCategory) MaterialExtra(com.bc.pmpheep.back.po.MaterialExtra)

Aggregations

CmsCategory (com.bc.pmpheep.back.po.CmsCategory)7 BaseTest (com.bc.pmpheep.test.BaseTest)4 Test (org.junit.Test)4 CmsContent (com.bc.pmpheep.back.po.CmsContent)1 Material (com.bc.pmpheep.back.po.Material)1 MaterialContact (com.bc.pmpheep.back.po.MaterialContact)1 MaterialExtra (com.bc.pmpheep.back.po.MaterialExtra)1 CmsCategoryRoleVO (com.bc.pmpheep.back.vo.CmsCategoryRoleVO)1 Content (com.bc.pmpheep.general.po.Content)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1