

-- heart
ALTER TABLE epdc_act_info ADD COLUMN VOLUNTEER_FLAG VARCHAR (1) NOT NULL COMMENT '是否只允许志愿者参加  0否  1是';
UPDATE epdc_act_info SET VOLUNTEER_FLAG = '1';
ALTER TABLE epdc_act_user_relation MODIFY SEX VARCHAR (1) NULL COMMENT '性别(0-女，1-男)';
ALTER TABLE epdc_act_user_relation MODIFY AGE INT (11) NULL COMMENT '年龄';
ALTER TABLE epdc_act_user_relation MODIFY IDENTITY_NO VARCHAR (20) NULL COMMENT '身份证号';



-- property
ALTER TABLE epdc_group ADD COLUMN `SECTION_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '所属版块编码';
ALTER TABLE epdc_group ADD COLUMN `CATEGORY_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '社群类别编码';
ALTER TABLE epdc_group ADD COLUMN  `TYPE_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '社区部门类别';

CREATE TABLE `epdc_activity_info`  (
  `ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键',
  `TITLE` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '标题',
  `HEAD_PIC` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动头图',
  `SECTION_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属版块编码',
  `CATEGORY_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属类别编码',
  `CATEGORY_NAME` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属类别名称',
  `SIGN_UP_START_TIME` datetime(0) NULL DEFAULT NULL COMMENT '报名开始时间',
  `SIGN_UP_END_TIME` datetime(0) NOT NULL COMMENT '报名截止时间',
  `ACT_START_TIME` datetime(0) NOT NULL COMMENT '活动开始时间',
  `ACT_END_TIME` datetime(0) NOT NULL COMMENT '活动结束时间',
  `ACT_ADDRESS` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动地点',
  `ACT_LONGITUDE` decimal(32, 10) NOT NULL COMMENT '活动位置经度',
  `ACT_LATITUDE` decimal(32, 10) NOT NULL COMMENT '活动位置纬度',
  `ACT_QUOTA_FLAG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '是否限制名额(0-不限名额，1-固定名额)',
  `ACT_QUOTA` int(11) NULL DEFAULT 0 COMMENT '活动名额',
  `SIGN_UP_NUM` int(11) NOT NULL DEFAULT 0 COMMENT '已报名人数',
  `CONTACTS` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '联系人',
  `TEL` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '联系电话',
  `REQUIREMENT` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '招募要求',
  `ACT_CONTENT` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动内容',
  `ACT_STATUS` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1' COMMENT '活动发布状态（0-下架，1上架）',
  `CANCEL_REASON` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '活动下架原因',
  `PUBLISH_TIME` datetime(0) NULL DEFAULT NULL COMMENT '活动发布时间',
  `SPONSOR` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '活动主办方',
  `DEPT_ID` bigint(20) NULL DEFAULT NULL COMMENT '创建部门ID',
  `REVISION` int(11) NOT NULL DEFAULT 0 COMMENT '乐观锁',
  `CREATED_BY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NOT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NOT NULL COMMENT '更新时间',
  `DEL_FLAG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标识',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '社区活动信息表' ROW_FORMAT = Compact;


CREATE TABLE `epdc_activity_participant`  (
  `ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键',
  `ACT_ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动ID',
  `USER_ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户ID',
  `NICKNAME` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户昵称',
  `FACE_IMG` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户头像',
  `PARTY_FLAG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '党员标识（0-否，1-是）',
  `REAL_NAME` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '报名人真实姓名',
  `SEX` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '性别(0-女，1-男)',
  `AGE` int(11) NULL DEFAULT NULL COMMENT '年龄',
  `MOBILE` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '联系电话',
  `IDENTITY_NO` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号',
  `SIGN_UP_TIME` datetime(0) NOT NULL COMMENT '报名时间',
  `REVISION` int(11) NOT NULL DEFAULT 0 COMMENT '乐观锁',
  `CREATED_BY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NOT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NOT NULL COMMENT '更新时间',
  `DEL_FLAG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户活动关系表' ROW_FORMAT = Compact;


CREATE TABLE `epdc_section_category`  (
  `ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键',
  `NAME` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
  `CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类编码',
  `SECTION_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '所属版块编码（数据字典类型function_setcion）',
  `FRONT_STYLE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '前端样式',
  `SORT` int(10) NOT NULL COMMENT '显示排序，正序',
  `EXTEND` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '扩展字段，在业务中说明含义',
  `REMARK` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
  `DEL_FLAG` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除标记 0：未删除，1：已删除',
  `REVISION` int(11) NOT NULL COMMENT '乐观锁',
  `CREATED_BY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NOT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '微笑榆山相关类别管理' ROW_FORMAT = Compact;

UPDATE epdc_group SET SECTION_CODE = 'theme_group',CATEGORY_CODE = 'police_group' ,TYPE_KEY = 'grid_party' WHERE GROUP_CATEGORY = '3';
UPDATE epdc_group SET SECTION_CODE = 'theme_group',CATEGORY_CODE = 'property_group' ,TYPE_KEY = 'grid_party' WHERE GROUP_CATEGORY = '2';

-- news

ALTER TABLE epdc_news ADD COLUMN `SECTION_CODE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '所属版块编码';

ALTER TABLE epdc_news_category ADD COLUMN `SECTION_CODE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '所属版块编码';


UPDATE epdc_news_category
SET section_code = 'safety_living'
WHERE
	CATEGORY_CODE = 'police_notice'
	OR CATEGORY_CODE = 'safety_precautions';


	UPDATE epdc_news_category
SET section_code = 'home_page_news'
WHERE
	section_code = '';

---

	UPDATE epdc_news
SET section_code = 'safety_living'
WHERE
	NEWS_PROPERTY = '警情通报' or NEWS_PROPERTY = '平安防范';


	UPDATE epdc_news
SET section_code = 'home_page_news'
WHERE
	section_code = '';



	UPDATE epdc_banner b
SET SECTION_CODE = ( SELECT n.SECTION_CODE FROM epdc_news n WHERE n.id = b.NEWS_ID )
WHERE
	b.NEWS_FLAG = '1';

