oracle 评论回复建表

-- Create table
create table T_OWS_HONOR_REPLY
(
  id          VARCHAR2(64) not null,
  comment_id  VARCHAR2(64),
  content     CLOB,
  from_uid    VARCHAR2(64),
  create_time VARCHAR2(64),
  from_uname  VARCHAR2(64)
)
tablespace OWS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
-- Add comments to the columns 
comment on column T_OWS_HONOR_REPLY.id
  is '主键id';
comment on column T_OWS_HONOR_REPLY.comment_id
  is '评论id';
comment on column T_OWS_HONOR_REPLY.content
  is '回复内容';
comment on column T_OWS_HONOR_REPLY.from_uid
  is '回复用户id';
comment on column T_OWS_HONOR_REPLY.create_time
  is '时间';
comment on column T_OWS_HONOR_REPLY.from_uname
  is '回复用户姓名';

 

 

-- Create table
create table T_OWS_HONOR_COMMENT
(
  id          VARCHAR2(64) not null,
  topic_id    VARCHAR2(64),
  content     CLOB,
  from_uid    VARCHAR2(64),
  create_time VARCHAR2(64),
  from_uname  VARCHAR2(64)
)
tablespace OWS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
-- Add comments to the columns 
comment on column T_OWS_HONOR_COMMENT.id
  is '主键id';
comment on column T_OWS_HONOR_COMMENT.topic_id
  is '主体id';
comment on column T_OWS_HONOR_COMMENT.content
  is '评论内容';
comment on column T_OWS_HONOR_COMMENT.from_uid
  is '评论用户id';
comment on column T_OWS_HONOR_COMMENT.create_time
  is '创建时间';
comment on column T_OWS_HONOR_COMMENT.from_uname
  is '评论用户姓名';

 

-- Create table
create table T_OWS_HONOR_PRAISE
(
  id                  VARCHAR2(64) not null,
  praise_count        NUMBER default 0,
  from_prs_id         VARCHAR2(64),
  prs_to_user_agentid VARCHAR2(64)
)
tablespace OWS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
-- Add comments to the columns 
comment on column T_OWS_HONOR_PRAISE.id
  is '主键id';
comment on column T_OWS_HONOR_PRAISE.praise_count
  is '点赞数量';
comment on column T_OWS_HONOR_PRAISE.from_prs_id
  is '被点赞人的工号或者主体';
comment on column T_OWS_HONOR_PRAISE.prs_to_user_agentid
  is '点赞人工号';

    @Select("")
    List>  listCommentAndReply(Map params);


    @Select("")
    List>  listReply(@Param("comment_id") String comment_id);

 

   @Select("\n" +
            " select \n" +
            " (case when sum(ot.p_count)>0 then 'N' else 'Y' end ) as is_praise,\n" +
            " sum(ot.praise_count) as praise_count\n" +
            "from (select max(t.praise_count) as praise_count,\n" +
            "            0 as p_count\n" +
            "       from T_OWS_HONOR_PRAISE t\n" +
            "      where t.from_prs_id = #{ID}\n" +
            "     union all\n" +
            "     select 0 as praise_count, count(*) as p_count\n" +
            "       from T_OWS_HONOR_PRAISE t\n" +
            "      where t.from_prs_id = #{ID}\n" +
            "       and t.prs_to_user_agentid like concat(concat('%',#{prs_to_user_agentid,jdbcType=VARCHAR}),'%') )) ot")
    Map getCommentPraiseInfo(Map params);

 

 /**
     * @author: bianqiang bwx686365
     * @date: 2020/6/9
     * @description: 保存回复
     */
    @PostMapping("/saveReply")
    public Result saveReply(@RequestBody Map params) throws Exception {
        String nowTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        String FROM_UID = (String) params.get("FROM_UID");
        FROM_UID = FROM_UID.toLowerCase();
        params.put("FROM_UID", FROM_UID);
        String TO_UID = (String) params.get("TO_UID");
        params.put("TO_UID", TO_UID);
        params.put("CREATE_TIME", nowTime);
        dao.saveOrUpdate(R.T_OWS_HONOR_REPLY, params);
        return Result.buildResult(Result.Status.OK,params);
    }

    /**
     * @author: bianqiang bwx686365
     * @date: 2020/6/9
     * @description: 显示所有的评论
     */
    @GetMapping("/listCommentAndReply")
    public Result listCommentAndReply(@RequestParam Map params) throws Exception {
        String TOPIC_ID = (String) params.get("TOPIC_ID");
        TOPIC_ID = TOPIC_ID.toLowerCase();
        params.put("TOPIC_ID", TOPIC_ID);
        List> list = honorMapper.listCommentAndReply(params);

        List> resList = new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (Map honorMap : list) {
                CLOB HONOR_BAG = (CLOB) honorMap.get("CONTENT");
                String honorBg = DBUtils.clobToStr(HONOR_BAG);
                honorMap.put("CONTENT", honorBg);
                resList.add(honorMap);
            }
        }

        if(resList!=null && resList.size()>0)
        {
            for (Map replay:resList)
            {
                String id= (String) replay.get("ID");
                List> list1 = honorMapper.listReply(id);

                if(list1!=null && list1.size()>0)
                {
                    for(Map rep:list1)
                    {
                        CLOB  CONTENT = (CLOB) rep.get("CONTENT");
                        String honorBg = DBUtils.clobToStr(CONTENT);
                        rep.put("CONTENT", honorBg);
                        replay.put("replayList",list1);
                    }
                }

            }
        }

        return Result.buildResult(Result.Status.OK, resList);
    }

 

 /**
     * @author: bianqiang bwx686365
     * @date: 2020/6/9
     * @description: 显示所有的评论
     */
    @GetMapping("/listCommentAndReply")
    public Result listCommentAndReply(@RequestParam Map params) throws Exception {
        String TOPIC_ID = (String) params.get("TOPIC_ID");
        TOPIC_ID = TOPIC_ID.toLowerCase();
        params.put("TOPIC_ID", TOPIC_ID);
        List> list = honorMapper.listCommentAndReply(params);
        String prs_to_user_agentid = AppContext.getCurrentUser().getUserAgentId().toLowerCase();

        List> resList = new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (Map honorMap : list) {
                CLOB HONOR_BAG = (CLOB) honorMap.get("CONTENT");
                String honorBg = DBUtils.clobToStr(HONOR_BAG);
                honorMap.put("CONTENT", honorBg);
                honorMap.put("prs_to_user_agentid", prs_to_user_agentid);
                Map praiseMap = honorMapper.getCommentPraiseInfo(honorMap);
                honorMap.putAll(praiseMap);
                resList.add(honorMap);
            }
        }

        if (resList != null && resList.size() > 0) {
            for (Map replay : resList) {
                String id = (String) replay.get("ID");
                List> list1 = honorMapper.listReply(id);

                if (list1 != null && list1.size() > 0) {
                    for (Map rep : list1) {
                        CLOB CONTENT = (CLOB) rep.get("CONTENT");
                        String honorBg = DBUtils.clobToStr(CONTENT);
                        rep.put("CONTENT", honorBg);
                        replay.put("replayList", list1);
                    }
                }

            }
        }

        return Result.buildResult(Result.Status.OK, resList);
    }

 

你可能感兴趣的:(oracle)