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);
}
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());
}
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;
}
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);
}
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) {
/* 裴中惠 (电话:010-59787110 , Email:pzh@pmph.com) */
StringBuilder builder = new StringBuilder(contact.getContactUserName());
builder.append(" (电话:");
builder.append(contact.getContactPhone());
builder.append(" , 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", "简 介:");
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());
}
}
Aggregations