清空数据表(实则更改状态)

时间:2021-05-25 12:14:48
业务需求:
     1.“删除 ”app用户下的文章  补:“删除”为伪删除,即更新文章状态,状态更新后再次调用文章查询接口显示为空
  1. 输入:accessId,appObjectId,这两天参数用来定位到具体的文章数据行
  2. 后台数据清除成功后,页面提示操作成功
  3. 设计到的类和表名如下:
              类:
    • com.contx.cssp.console.article.controller.ContentOperationController
    • com.contx.cssp.console.article.service.ContentOperationService
    • com.contx.cssp.console.article.dao.ContentOperationDao 
                     表:
    • cms.cms_app_content
                    页面:
    • article/appArticleManager/FeedOperation.html
页面:
//对文章数据进行清空
    $("#clearContentBtn").click(function(){
        var appObjectId=$('#appObjectId').val();
        var accessId=$('#accessId').val();
        framework.confirm("确定清空内容?",function() {
            clearContent(accessId,appObjectId)
        },function(){
            return;
        });
    });

    function clearContent(accessId,appObjectId){
        var url = "/content/operation/clearContent";
        $.rest("get",
                url,
                {accessId: accessId, appObjectId: appObjectId},
                {},
                function (data) {
                    if (data) {
                        framework.hint("操作成功");
                        search();
                    } else {
                        framework.hint("操作失败");
                    }
                }, function () {
                });
    }


控制层:
com.contx.cssp.console.article.controller.ContentOperationController     
     /**
     * 清空文章内容
     * @param accessId 频道ID
     * @param appObjectIdappID
     */
    @RequestMapping(value = "/clearContent", method = RequestMethod.GET)
    @ResponseBody
    public boolean clearContentOperation(String accessId, String appObjectId) {
        logger.info("accessId:" + accessId, "appObjectId:" + appObjectId);
        return contentOperationService.clearContentOperation(accessId, appObjectId);
    }
业务层:
com.contx.cssp.console.article.service.ContentOperationService  
     /**
     * 清空文章内容操作
     * @param accessId
     * @param appObjectId
     */
    public boolean clearContentOperation(String accessId ,String appObjectId){
        try {
            contentOperationDao.updatateContentOperationIsdownloadStatus(accessId, appObjectId);
        } catch (Exception e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             logger.info("数据清除失败!");
             return false;
        }
        return true;
    }
数据层:
    com.contx.cssp.console.article.dao.ContentOperationDao 
    @Transactional
    @Modifying
    @Query(nativeQuery=true,value="update cms.cms_app_content o set o.is_download=2 where o.is_download = 1 and                                      o.access_id =? and o.app_object_id = ?")
    public void updatateContentOperationIsdownloadStatus(String accessId ,String appObjectId);