我写的广告模块,架构是这样的
admin层的resources有一些前端的页面,调用controller层
controller调用Dto
dto相当于数据库domain层
api就是接口相当于dao层
api通过restful进行映射到service层,service架构是这样的
这里我通过逆向工程生成了dao层 domain层以及xml文件
上面的api映射service里的provide
provide调用manager来操纵数据库
分别看看代码如何实现的由上到下依次展示
首先是前端的add ,edit,和首页index
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<#import '/common/common.ftl' as commonMacro>
<@commonMacro.commonStyle />
</head>
<body class="page-content">
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-home"></i>
<a href="/welcome">首页</a>
<i class="iconfont iconiconfontjiantou4"></i>
</li>
<li>
<i class="fa fa-cube"></i>
<a href="index">商户管理</a>
<i class="iconfont iconiconfontjiantou4"></i>
</li>
<li class=" active">
<i class="fa fa-plus "></i>
<a href="#">添加</a>
</li>
</ul>
</div>
<div class="page-content">
<div class="tab-pane active" id="tab_0">
<div class="portlet box grey-cascade">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-adn"></i>增加商户
</div>
<div class="tools">
<a href="javascript:;" class="collapse">
</a>
<a href="#portlet-config" data-toggle="modal" class="config">
</a>
<a href="javascript:;" class="reload">
</a>
<a href="javascript:;" class="remove" data-original-title="" title="" onclick="history.go(-1)">
</a>
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form action="" class="form-horizontal" id="spuForm">
<input type="text" name="categoryId" id="categoryId" hidden>
<input name="primaryAttributes" id="primaryAttributes" hidden>
<div class="form-body">
<!-- 另起一行 -->
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="col-md-3 control-label">
是否开机广告
</label>
<div class="col-md-5">
<div class="input-icon margin-top-10">
<select id="isBootUp" name="isBootUp" class="form-control selectpicker show-tick"
validate="{required: true}">
<option value="0">是</option>
<option value="1">否</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-2 control-label">
比赛头图<span class="required">* </span>
</label>
<div class="col-md-10">
<div class="file-loading">
<input id="mainImgFile" class="file" name="logoImg" type="file"
data-min-file-count="1" validate='{required: true}'
style="width: 500px">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">
跳转地址<span class="required">* </span>
</label>
<div class="col-md-8">
<div class="input-icon margin-top-10">
<i class="fa fa-user "></i>
<input type="text" name="jumpAdd" class="form-control" placeholder="跳转地址"
validate='{required: true,maxlength:8,number:true}' maxlength="20">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">
开始时间<span class="required">* </span>
</label>
<div class="col-md-8">
<div class="input-icon margin-top-10 ">
<i class="fa fa-calendar "></i>
<input type="text" id="creaded" name="creaded" class="form-control "
readonly=""
validate='{required: true}'>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">
排序规则<span class="required">* </span>
</label>
<div class="col-md-8">
<div class="input-icon margin-top-10">
<i class="fa fa-user "></i>
<input type="text" name="orderNo" id="orderNo" class="form-control"
placeholder="排序规则"
validate='{required: true,maxlength:20,number:true}' maxlength="20">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions right">
<button type="button" class="btn default" onclick="history.go(-1)"><i
class="fa fa-rotate-left"></i> 取消
</button>
<button type="button" class="btn green" id="submitForm"><i class="fa fa-check"></i> 保存</button>
</div>
</form>
<!-- END FORM-->
</div>
</div>
</div>
</div>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog " style="width:400px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">选择类目</h4>
</div>
<div class="modal-body">
<div id="categoryTree"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="modalSubmit">确定</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<@commonMacro.commonScript />
</body>
<script>
$(document).ready(function () {
$("#mainImgFile").fileinput({
language: 'zh',
showUpload: false, //是否显示上传按钮
required: true,
removeTitle: '删除文件',
removeLabel: '全部删除',
browseLabel: '选择文件',
msgPlaceholder: '请选中',
dropZoneTitle: '请将文件拖拽此区域...',
msgZoomModalHeading: '文件预览',
msgNoFilesSelected: '没有选择文件',
dropZoneEnabled: false,
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
uploadUrl: '#', // you must set a valid URL here else you will get an error
allowedFileExtensions: ['jpg', 'png', 'gif'],
overwriteInitial: false,
maxFileSize: 1000,
maxFilesNum: 1,
//allowedFileTypes: ['image', 'video', 'flash'],
slugCallback: function (filename) {
return filename.replace('(', '_').replace(']', '_');
}
});
$("#carouselFigureImgFile").fileinput({
language: 'zh',
showUpload: false, //是否显示上传按钮
required: true,
removeTitle: '删除文件',
removeLabel: '全部删除',
browseLabel: '选择文件',
msgPlaceholder: '请选中',
dropZoneTitle: '请将文件拖拽此区域...',
msgZoomModalHeading: '文件预览',
msgNoFilesSelected: '没有选择文件',
uploadUrl: '#', // you must set a valid URL here else you will get an error
allowedFileExtensions: ['jpg', 'png', 'gif'],
overwriteInitial: false,
maxFileSize: 1000,
maxFilesNum: 10,
layoutTemplates: {
actionUpload: ''
},
fileActionSettings: {},
//allowedFileTypes: ['image', 'video', 'flash'],
slugCallback: function (filename) {
return filename.replace('(', '_').replace(']', '_');
},
uploadExtraData: function (previewId, index) { //额外参数的关键点
alert("不能独立提交!");
}
});
var carouselFigureImgFile = new Array();
$('#carouselFigureImgFile').on('filebatchselected', function (event, files) {
for (var i = 0; i < files.length; i++) {
var alread = false;
for (var a = 0; a < carouselFigureImgFile.length; a++) {
var objName = carouselFigureImgFile[a].name;
if (objName == undefined) {
continue;
}
if (objName == files[i].name)
alread = true;
}
if (alread == false) {
carouselFigureImgFile.push(files[i]);
}
}
});
$('#carouselFigureImgFile').on('fileremoved', function (event, id, index) {
carouselFigureImgFile.splice(index, 1);
alert(carouselFigureImgFile.length);
});
$('#carouselFigureImgFile').on('fileclear', function (event) {
carouselFigureImgFile.splice(0, carouselFigureImgFile.length);
});
$("#submitForm").click(function () {
$.propertyJson('property', 'primaryAttributes');
//表单ajax提交
$("#spuForm").ajaxSubmitForm({
url: "/billiards/advertisement/addCacheAdvertisement",
success: function (result) {
if (result.success) {
if (result.message) {
window.wxc.xcConfirm(result.message ? result.message : "提交成功", window.wxc.xcConfirm.typeEnum.success, {
title: '提示'
, onOk: function () {
if (!result || !result.backUrl) {
window.location.href = 'index';
} else {
window.location.href = contextPath + result.backUrl;
}
}
});
} else {
if (!result || !result.backUrl) {
window.location.href = 'index';
} else {
window.location.href = contextPath + result.backUrl;
}
}
window.wxc.xcConfirm("操作成功", window.wxc.xcConfirm.typeEnum.info);
window.location.href = "/billiards/advertisement/index";
} else {
window.wxc.xcConfirm(result.message, window.wxc.xcConfirm.typeEnum.error);
}
},
error: function (result) {
window.wxc.xcConfirm("网络异常", window.wxc.xcConfirm.typeEnum.error);
}
});
});
//初始化属性
$.initProperty("addGroup", "addProperty", "property", true);
$('#creaded').datetimepicker({format: 'yyyy-mm-dd hh:ii:ss'});
// 广告选择
$.ajax({
url: contextPath + '/billiards/advertisement/listAdvertisement',
type: 'get',
dataType: 'json',
success: function (data) {
if (data.success != true) {
alert("获取广告失败!");
return false;
}
var select2 = document.getElementById("id");
select2.options.add(new Option("请选择类型", ""));
var obj = eval('(' + data.data + ')');
for (var i = 0; i < obj.length; i++) {
var id = obj[i].id;
select2.options.add(new Option(id));
}
}
});
});
</script>
$("#spuForm").ajaxSubmitForm({
url: "/billiards/advertisement/addCacheAdvertisement",
success: function (result) {
if (result.success) {
</html>
edit层这里要传个id值,根据id编辑的
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<#import '/common/common.ftl' as commonMacro>
<@commonMacro.commonStyle />
</head>
<body class="page-content">
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-home"></i>
<a href="/welcome">首页</a>
<i class="iconfont iconiconfontjiantou4"></i>
</li>
<li>
<i class="fa fa-cube"></i>
<a href="index">商户管理</a>
<i class="iconfont iconiconfontjiantou4"></i>
</li>
<li class=" active">
<i class="fa fa-plus "></i>
<a href="#">编辑</a>
</li>
</ul>
</div>
<div class="page-content">
<div class="tab-pane active" id="tab_0">
<div class="portlet box grey-cascade">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-adn"></i>编辑
</div>
<div class="tools">
<a href="javascript:;" class="collapse">
</a>
<a href="#portlet-config" data-toggle="modal" class="config">
</a>
<a href="javascript:;" class="reload">
</a>
<a href="javascript:;" class="remove" data-original-title="" title="" onclick="history.go(-1)">
</a>
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form action="" class="form-horizontal" id="spuForm">
<input type="hidden" name="id" id="id" value="${data.id}"/>
<div class="form-body">
<!-- 另起一行 -->
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="col-md-3 control-label">
是否开机广告
</label>
<div class="col-md-5">
<div class="input-icon margin-top-10">
<select id="isBootUp" name="isBootUp" class="form-control selectpicker show-tick"
validate="{required: true}">
<option value="0">是</option>
<option value="1">否</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-2 control-label">
比赛头图<span class="required">* </span>
</label>
<div class="col-md-10">
<div class="file-loading">
<input id="mainImgFile" class="file" name="logoImg" type="file"
data-min-file-count="1" validate='{required: true}'
style="width: 500px">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">
跳转地址<span class="required">* </span>
</label>
<div class="col-md-8">
<div class="input-icon margin-top-10">
<i class="fa fa-user "></i>
<input type="text" name="jumpAdd" class="form-control" placeholder="跳转地址"
validate='{required: true,maxlength:8,number:true}' maxlength="20" value="${data.jumpAdd}">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">
开始时间<span class="required">* </span>
</label>
<div class="col-md-8">
<div class="input-icon margin-top-10 ">
<i class="fa fa-calendar "></i>
<input type="text" id="creaded" name="creaded" class="form-control "
readonly=""
validate='{required: true}'>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">
排序规则<span class="required">* </span>
</label>
<div class="col-md-8">
<div class="input-icon margin-top-10">
<i class="fa fa-user "></i>
<input type="text" name="orderNo" id="orderNo" class="form-control"
placeholder="排序规则"
validate='{required: true,maxlength:20,number:true}' maxlength="20">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions right">
<button type="button" class="btn default" onclick="history.go(-1)"><i
class="fa fa-rotate-left"></i> 取消
</button>
<button type="button" class="btn green" id="submitForm"><i class="fa fa-check"></i> 保存</button>
</div>
</form>
<!-- END FORM-->
</div>
</div>
</div>
</div>
<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog " style="width:400px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">选择类目</h4>
</div>
<div class="modal-body">
<div id="categoryTree"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="modalSubmit">确定</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<@commonMacro.commonScript />
</body>
<script>
var $submit = $('#submitForm');
$('#creaded').datetimepicker({format: 'yyyy-mm-dd hh:ii:ss'});
$submit.click(function () {
$("#content").val($("#info").val());
$.propertyJson('property', 'primaryAttributes');
//表单ajax提交
$("#spuForm").ajaxSubmitForm({
url: "/billiards/advertisement//updateCache",
success: function (result) {
if (result.success) {
if (result.message) {
window.wxc.xcConfirm(result.message ? result.message : "提交成功", window.wxc.xcConfirm.typeEnum.success, {
title: '提示'
, onOk: function () {
if (!result || !result.backUrl) {
window.location.href = 'index';
} else {
window.location.href = contextPath + result.backUrl;
}
}
});
} else {
if (!result || !result.backUrl) {
window.location.href = 'index';
} else {
window.location.href = contextPath + result.backUrl;
}
}
window.wxc.xcConfirm("操作成功", window.wxc.xcConfirm.typeEnum.info);
window.location.href = "/billiards/advertisement/index";
} else {
window.wxc.xcConfirm(result.message, window.wxc.xcConfirm.typeEnum.error);
}
},
error: function (result) {
window.wxc.xcConfirm("网络异常", window.wxc.xcConfirm.typeEnum.error);
}
});
});
var mainInitialPreviewConfig = [];
var mainInitialPreview = [];
mainInitialPreview.push("${data.mainImage?if_exists}");
mainInitialPreviewConfig.push("file1");
$("#mainImgFile").fileinput({
/**
* theme icon 主题 需要引入相应的主题包
* language 语言设置 需要引入相应的语言包
* uploadUrl 上传路径 可不写在下面与表单一起手动上传
* showCaption 是否展示 input 文字的说明 -- 标题
* showUpload 是否显示上传按钮
* showRemove 是否可以删除
* dropZoneEnabled 是否开启拖拽上传功能
* maxFileCount 最多的文件数量
* maxFileSize 最大的尺寸
* allowedFileExtensions 允许的文件扩展后缀名
* autoReplace 是否自动替换当前图片,设置为true时,再次选择文件, 会将当前的文件替换掉
*/
theme: 'fa',
language: 'zh',
showUpload: false,
showRemove: true,
dropZoneEnabled: false,
maxFileCount: 1,
allowedFileExtensions: ['jpg', 'png'],
autoReplace: true,
initialPreviewAsData: true,
initialPreview: mainInitialPreview,
initialPreviewConfig: mainInitialPreviewConfig,
})
// 实现图片被选中后自动提交
.on('filebatchselected', function (event, files) {
// 选中事件
$(event.target).fileinput('upload')
})
// 异步上传错误结果处理
.on('fileerror', function (event, data, msg) {
// 清除当前的预览图 ,并隐藏 【移除】 按钮
$(event.target)
.fileinput('clear')
.fileinput('unlock')
$(event.target)
.parent()
.siblings('.fileinput-remove')
.hide()
// 打开失败的信息弹窗
// me.openAlertModel('请求失败,请稍后重试')
});
//初始化属性
$.initProperty("addGroup", "addProperty", "property", true);
</script>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<#import '/common/common.ftl' as commonMacro>
<@commonMacro.commonStyle />
</head>
<body class="page-content">
<!-- BEGIN PAGE HEADER-->
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-home"></i>
<a href="/welcome">首页</a>
<i class="iconfont iconiconfontjiantou4"></i>
</li>
<li>
<a href="#">商户管理</a>
<i class="fa fa-cube"></i>
</li>
</ul>
</div>
<div class="page-content">
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<div class="row">
<div class="col-md-12">
<!-- BEGIN EXAMPLE TABLE PORTLET-->
<div class="portlet box grey-cascade">
<div class="portlet-title">
<div class="caption">
<i class="icon-user"></i>商户管理
</div>
<div class="tools">
<a href="javascript:;" class="collapse">
</a>
<a href="#portlet-config" data-toggle="modal" class="config">
</a>
<a href="javascript:;" class="reload" onclick="init()">
</a>
</div>
</div>
<div class="portlet-body" id="spuInfoTable">
<div class="table-toolbar">
<div class="row">
<div class="col-md-10">
<div class="btn-group">
<button id="newSpuInfoButton" class="btn green" onclick="location.href = 'add';">
添加商户 <i class="fa fa-plus"></i>
</button>
</div>
</div>
</div>
</div>
<table class="table table-striped table-bordered table-hover ">
<thead>
<tr>
<th column="id">商户ID</th>
<th column="creaded">创建时间</th>
<th column="address" type="image">图片视频地址</th>
<th column="jumpAdd">跳转地址</th>
<th column="orderNo">排序规则</th>
<th column="isBootUp" type="enum" enum-v="{0:'banner',1:'开机广告'}">是否开机广告</th>
<th type="action">操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="table-toolbar pagination-toolbar">
</div>
</div>
</div>
<!-- END EXAMPLE TABLE PORTLET-->
</div>
</div>
</div>
<@commonMacro.commonScript />
<script>
function init() {
$("#spuInfoTable").pagingGrid(
{
dataUrl: '/billiards/advertisement/listAdvertisement'
, pageSize: 10
, scroll: false
, dockedItems: [{
name: '删除'
, iconClass: 'iconfont iconshanchu'
, action: '/billiards/advertisement/removeAdvertisement'
, ajax: true
, confirm: true
, parmaName: 'id'
, column: 'id'
}, {
name: '编辑'
, iconClass: 'iconfont iconshangjia'
, action: '/billiards/advertisement/editView'
, confirm: true
, parmaName: 'id'
, column: 'id'
}],
pagingtoolbar: {
displayInfo: true
}
}
);
}
//初始化
init();
</script>
</body>
</html>
然后是其调用的controller
package com.yuyuka.billiards.admin.controller;
import com.apus.common.page.PageVo;
import com.yuyuka.billiards.api.BilliardsAdvertisementServiceApi;
import com.yuyuka.billiards.api.dto.BilliardsAdvertisementDto;
import com.yuyuka.billiards.common.JsonResult;
import com.yuyuka.billiards.external.oss.impl.type.AliyunRegionEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
/**
* 比赛后台
*/
@Slf4j
@Controller
@RequestMapping("/billiards/advertisement")
public class AdvertisementController extends AbstractController {
@Resource
private BilliardsAdvertisementServiceApi billiardsAdvertisementServiceApi;
private BilliardsAdvertisementDto billiardsAdvertisementDto;
/**
* 图片或视频地址
* @param billiardsAdvertisementDto
* @return
* @throws Exception
*/
@RequestMapping(value = "/addCacheAdvertisement")
@ResponseBody
public JsonResult addAdvertisement(BilliardsAdvertisementDto billiardsAdvertisementDto,
// 视频或者图片地址
@RequestParam("logoImg") MultipartFile mainImgFile) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
if (mainImgFile != null) {
String imagePath = aliyunObjectStore.save(AliyunRegionEnum.BEIJING, "cripple", mainImgFile.getOriginalFilename(), mainImgFile.getInputStream());
billiardsAdvertisementDto.setAddress(imagePath);
}
Boolean data = billiardsAdvertisementServiceApi.addAdvertisements(billiardsAdvertisementDto);
if (!data) {
throw new Exception("添加图片视频地址失败");
}
jsonResult.put("data", data);
jsonResult.setMessage("成功");
jsonResult.setSuccess(true);
} catch (Exception e) {
log.error("添加图片视频地址异常", e);
jsonResult.setMessage(e.getMessage());
jsonResult.setSuccess(false);
}
return jsonResult;
}
/**
* 排序规则
* @param billiardsAdvertisementDto
* @return
*/
@RequestMapping(value = "/updateCache", method = RequestMethod.POST)
@ResponseBody
public JsonResult updateCache(BilliardsAdvertisementDto billiardsAdvertisementDto,
// 视频或者图片地址
@RequestParam("logoImg") MultipartFile mainImgFile) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
if (mainImgFile != null) {
String imagePath = aliyunObjectStore.save(AliyunRegionEnum.BEIJING, "cripple", mainImgFile.getOriginalFilename(), mainImgFile.getInputStream());
billiardsAdvertisementDto.setAddress(imagePath);
}
Boolean data = billiardsAdvertisementServiceApi.updateCache(billiardsAdvertisementDto);
if (!data) {
throw new Exception("更改图片视频地址失败");
}
jsonResult.put("data", data);
jsonResult.setMessage("成功");
jsonResult.setSuccess(true);
} catch (Exception e) {
log.error("更改图片视频地址异常", e);
jsonResult.setMessage(e.getMessage());
jsonResult.setSuccess(false);
}
return jsonResult;
}
/**
* 查看信息
* @param id
* @return
*/
@RequestMapping(value = "/getAdvertisement")
@ResponseBody
public JsonResult get(Long id) {
JsonResult jsonResult = new JsonResult();
try {
BilliardsAdvertisementDto data = billiardsAdvertisementServiceApi.getAdvertisement(id);
jsonResult.put("data",data);
jsonResult.setMessage("成功");
jsonResult.setSuccess(true);
} catch (Exception e) {
log.error("查询残局后台异常", e);
jsonResult.setMessage("查询失败");
jsonResult.setSuccess(false);
}
return jsonResult;
}
/**
* 获取全部信息列表
* @return
*/
@RequestMapping(value = "/listAdvertisement")
@ResponseBody
public JsonResult listAll( BilliardsAdvertisementDto billiardsAdvertisementDto) {
JsonResult jsonResult = new JsonResult();
try {
PageVo<BilliardsAdvertisementDto> datas = billiardsAdvertisementServiceApi.listAdvertisement(billiardsAdvertisementDto);
jsonResult.put("list", datas.getDataList());
jsonResult.put("rowCount", datas.getTotalCount());
jsonResult.setMessage("成功");
jsonResult.setSuccess(true);
} catch (Exception e) {
log.error("查询商户后台异常", e);
jsonResult.setMessage("查询失败");
jsonResult.setSuccess(false);
}
return jsonResult;
}
/**
* 删除
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/removeAdvertisement")
@ResponseBody
public JsonResult del(@RequestParam("id") Long id) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
Boolean data = billiardsAdvertisementServiceApi.removeAdvertisement(id);
jsonResult.put("data", data);
jsonResult.setMessage("成功");
jsonResult.setSuccess(true);
} catch (Exception e) {
log.error("删除异常", e);
jsonResult.setMessage(e.getMessage());
jsonResult.setSuccess(false);
}
return jsonResult;
}
/**
* 跳转列表页面
*
* @return
*/
@RequestMapping("/index")
public String index() {
return "/advertisement/index";
}
/**
* 跳转列表页面
*
* @return
*/
@RequestMapping("/add")
public String add() {
return "/advertisement/add";
}
/**
* 编辑展示页面
* @param id
* @return
*/
@RequestMapping("/editView")
public ModelAndView add(@RequestParam("id") Long id) throws Exception {
BilliardsAdvertisementDto billiardsAdvertisementDto = billiardsAdvertisementServiceApi.getAdvertisement(id);
ModelAndView returnValue = new ModelAndView("/advertisement/edit");
returnValue.addObject("data", billiardsAdvertisementDto);
return returnValue;
}
}
controller调用的api
package com.yuyuka.billiards.api;
import com.apus.common.page.PageVo;
import com.yuyuka.billiards.api.dto.BilliardsAdvertisementDto;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient("billiards-server-center")
public interface BilliardsAdvertisementServiceApi {
/**
* 添加广告
* @param billiardsAdvertisementdto
* @return
* @throws Exception
*/
@RequestMapping("/billiards/advertisement/addCacheAdvertisement")
public Boolean addAdvertisements(@RequestBody BilliardsAdvertisementDto billiardsAdvertisementdto) throws Exception;
/**
* 查看广告列表
* @param billiardsAdvertisementDto
* @return
*/
@RequestMapping("/billiards/advertisement/listAdvertisement")
public PageVo<BilliardsAdvertisementDto> listAdvertisement(@RequestBody BilliardsAdvertisementDto billiardsAdvertisementDto);
/**
* 删除广告
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/billiards/advertisement/removeAdvertisement")
public boolean removeAdvertisement(@RequestParam("id") Long id) throws Exception;
/**
* 修改广告信息
* @param billiardsAdvertisementDto
* @return
* @throws Exception
*/
@RequestMapping("/billiards/advertisement/updateCache")
public Boolean updateCache(@RequestBody BilliardsAdvertisementDto billiardsAdvertisementDto) throws Exception;
/**
* 查看广告信息
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/billiards/advertisement/getAdvertisement")
public BilliardsAdvertisementDto getAdvertisement(@RequestParam("id") Long id) throws Exception;
}
与api映射的service层中的provide
package com.yuyuka.billiards.service.service.impl;
import com.apus.common.page.PageVo;
import com.yuyuka.billiards.common.JsonUtils;
import com.yuyuka.billiards.service.cache.CacheKeyEnum;
import com.yuyuka.billiards.service.domain.BilliardsAdvertisement;
import com.yuyuka.billiards.service.manager.BilliardsAdvertisementManager;
import com.yuyuka.billiards.service.service.AbstractbServiceProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/billiards/advertisement")
public class BilliardsAdvertisementServiceProvider extends AbstractbServiceProvider {
@Autowired
private BilliardsAdvertisementManager billiardsAdvertisementManager;
private BilliardsAdvertisement billiardsAdvertisement;
@RequestMapping("/addCacheAdvertisement")
public Boolean addAdvertisements(@RequestBody BilliardsAdvertisement billiardsAdvertisement) throws Exception {
logInstanceInfo();
return billiardsAdvertisementManager.addAdvertisement(billiardsAdvertisement);
}
/**
* 分页查询广告列表
*
* @return
* @throws Exception
*/
@RequestMapping("/listAdvertisement")
public PageVo<BilliardsAdvertisement> listAdvertisement(@RequestBody BilliardsAdvertisement billiardsAdvertisement) throws Exception {
logInstanceInfo();
return billiardsAdvertisementManager.listAdvertisement(billiardsAdvertisement);
}
/**
* 获取广告信息
* @param id
* @param
* @return
* @throws Exception
*/
@RequestMapping("/getAdvertisement")
public BilliardsAdvertisement getAdvertisement(@RequestParam("id") Long id) throws Exception {
logInstanceInfo();
if(id == null){
throw new Exception("id不能为空");
}
return billiardsAdvertisementManager.getAdvertisement(id);
}
/**
* 删广告信息
*
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/removeAdvertisement")
public boolean removeAdvertisement(@RequestParam("id") Long id) throws Exception {
logInstanceInfo();
return billiardsAdvertisementManager.removeAdvertisement(id);
}
/**
* 改
*
* @param billiardsAdvertisement
* @return
* @throws Exception
*/
@RequestMapping("/updateCache")
public Boolean updateCache(@RequestBody BilliardsAdvertisement billiardsAdvertisement) throws Exception {
logInstanceInfo();
boolean isSuccess = billiardsAdvertisementManager.updateOrderNo(billiardsAdvertisement);
if (!isSuccess) {
throw new Exception("数据库更新失败");
}
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_ADDRESS_LIST.createKey(billiardsAdvertisement.getId().toString()),Double.parseDouble(billiardsAdvertisement.getAddress()),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_ORDERNO_LIST.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getOrderNo(),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_CREADED_LIST.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getCreaded().getTime(),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_ISBOOTUO_LIST.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getIsBootUp(),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_JUMPADD_LIST.createKey(billiardsAdvertisement.getId().toString()),Double.parseDouble(billiardsAdvertisement.getJumpAdd()),billiardsAdvertisement.getId().toString());
jedisCluster.hset(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getId().toString(), JsonUtils.toJSON(billiardsAdvertisement));
return isSuccess;
}
}
provide调用的接口与其实现
package com.yuyuka.billiards.service.service.impl;
import com.apus.common.page.PageVo;
import com.yuyuka.billiards.common.JsonUtils;
import com.yuyuka.billiards.service.cache.CacheKeyEnum;
import com.yuyuka.billiards.service.domain.BilliardsAdvertisement;
import com.yuyuka.billiards.service.manager.BilliardsAdvertisementManager;
import com.yuyuka.billiards.service.service.AbstractbServiceProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/billiards/advertisement")
public class BilliardsAdvertisementServiceProvider extends AbstractbServiceProvider {
@Autowired
private BilliardsAdvertisementManager billiardsAdvertisementManager;
private BilliardsAdvertisement billiardsAdvertisement;
@RequestMapping("/addCacheAdvertisement")
public Boolean addAdvertisements(@RequestBody BilliardsAdvertisement billiardsAdvertisement) throws Exception {
logInstanceInfo();
return billiardsAdvertisementManager.addAdvertisement(billiardsAdvertisement);
}
/**
* 分页查询广告列表
*
* @return
* @throws Exception
*/
@RequestMapping("/listAdvertisement")
public PageVo<BilliardsAdvertisement> listAdvertisement(@RequestBody BilliardsAdvertisement billiardsAdvertisement) throws Exception {
logInstanceInfo();
return billiardsAdvertisementManager.listAdvertisement(billiardsAdvertisement);
}
/**
* 获取广告信息
* @param id
* @param
* @return
* @throws Exception
*/
@RequestMapping("/getAdvertisement")
public BilliardsAdvertisement getAdvertisement(@RequestParam("id") Long id) throws Exception {
logInstanceInfo();
if(id == null){
throw new Exception("id不能为空");
}
return billiardsAdvertisementManager.getAdvertisement(id);
}
/**
* 删广告信息
*
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/removeAdvertisement")
public boolean removeAdvertisement(@RequestParam("id") Long id) throws Exception {
logInstanceInfo();
return billiardsAdvertisementManager.removeAdvertisement(id);
}
/**
* 改
*
* @param billiardsAdvertisement
* @return
* @throws Exception
*/
@RequestMapping("/updateCache")
public Boolean updateCache(@RequestBody BilliardsAdvertisement billiardsAdvertisement) throws Exception {
logInstanceInfo();
boolean isSuccess = billiardsAdvertisementManager.updateOrderNo(billiardsAdvertisement);
if (!isSuccess) {
throw new Exception("数据库更新失败");
}
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_ADDRESS_LIST.createKey(billiardsAdvertisement.getId().toString()),Double.parseDouble(billiardsAdvertisement.getAddress()),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_ORDERNO_LIST.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getOrderNo(),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_CREADED_LIST.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getCreaded().getTime(),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_ISBOOTUO_LIST.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getIsBootUp(),billiardsAdvertisement.getId().toString());
jedisCluster.zadd(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_JUMPADD_LIST.createKey(billiardsAdvertisement.getId().toString()),Double.parseDouble(billiardsAdvertisement.getJumpAdd()),billiardsAdvertisement.getId().toString());
jedisCluster.hset(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.createKey(billiardsAdvertisement.getId().toString()),billiardsAdvertisement.getId().toString(), JsonUtils.toJSON(billiardsAdvertisement));
return isSuccess;
}
}
@RequestBody主要用来接收前端传递给后端的json字符串中的数据的(请求体中的数据的);GET方式无请求体,所以使用@RequestBody接收数据时,前端不能使用GET方式提交数据,而是用POST方式进行提交。
controller api provide都要加注解传参数给前端
package com.yuyuka.billiards.service.manager.impl;
import com.apus.common.page.PageVo;
import com.google.common.reflect.TypeToken;
import com.yuyuka.billiards.api.type.AdvertisementTypeEnum;
import com.yuyuka.billiards.common.JsonUtils;
import com.yuyuka.billiards.external.pay.wx.util.StringUtils;
import com.yuyuka.billiards.service.cache.CacheDataHanlder;
import com.yuyuka.billiards.service.cache.CacheKeyEnum;
import com.yuyuka.billiards.service.cache.CacheProxy;
import com.yuyuka.billiards.service.dao.BilliardsAdvertisementMapper;
import com.yuyuka.billiards.service.domain.BilliardsAdvertisement;
import com.yuyuka.billiards.service.domain.BilliardsAdvertisementExample;
import com.yuyuka.billiards.service.manager.AbstractbManager;
import com.yuyuka.billiards.service.manager.BilliardsAdvertisementManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import redis.clients.jedis.JedisCluster;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Slf4j
@Component("billiardsAdvertisementManager")
public class BilliardsAdvertisementManagerImpl extends AbstractbManager implements BilliardsAdvertisementManager {
@Resource
private BilliardsAdvertisementMapper billiardsAdvertisementMapper;
@Override
public PageVo<BilliardsAdvertisement> listAdvertisement(BilliardsAdvertisement billiardsAdvertisement) throws Exception {
PageVo<BilliardsAdvertisement> returnValue = new PageVo<>();
BilliardsAdvertisementExample billiardsAdvertisementExample = new BilliardsAdvertisementExample();
BilliardsAdvertisementExample.Criteria c = billiardsAdvertisementExample.createCriteria();
billiardsAdvertisementExample.setOffset(billiardsAdvertisement.getStart());
billiardsAdvertisementExample.setLimit(billiardsAdvertisement.getLimit());
returnValue.setDataList(billiardsAdvertisementMapper.selectByExample(billiardsAdvertisementExample));
returnValue.setTotalCount(billiardsAdvertisementMapper.countByExample(billiardsAdvertisementExample));
return returnValue;
}
@Transactional
//注解用于处理事务,注解的方法如果抛出异常了,那么他之下的方法都回滚
@Override
public Boolean addAdvertisement(BilliardsAdvertisement billiardsAdvertisement) throws Exception {
int count = new CacheDataHanlder<BilliardsAdvertisementMapper>(billiardsAdvertisementMapper, new CacheProxy() {
@Override
public Object doBegin(Object[] args, JedisCluster jedisClusterCommon) {
return null;
}
@Override
public Object doEnd(Object[] args, Object result, JedisCluster jedisClusterCommon) throws Exception {
String isBootUp = billiardsAdvertisement.getIsBootUp().toString();
if (((Integer) result) != null && ((Integer) result) <= 0) {
return result;
}
jedisClusterCommon.hset(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.getKey(),billiardsAdvertisement.getId().toString(),JsonUtils.toJSON(billiardsAdvertisement));
return result;
}
},jedisCluster).getProxy().insert(billiardsAdvertisement);
if(count>0){
return true;
}
throw new Exception("数据库插入错误");
}
@Override
public Boolean removeAdvertisement(Long id) throws Exception {
BilliardsAdvertisementExample example = new BilliardsAdvertisementExample();
BilliardsAdvertisementExample.Criteria c = example.createCriteria();
c.andIdEqualTo(id);
int count = new CacheDataHanlder<BilliardsAdvertisementMapper>(billiardsAdvertisementMapper, new CacheProxy() {
@Override
public Object doBegin(Object[] args, JedisCluster jedisClusterCommon) {
return null;
}
@Override
public Object doEnd(Object[] args, Object result, JedisCluster jedisClusterCommon) throws Exception {
jedisClusterCommon.hdel(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.getKey(),id.toString());
return result;
}
},jedisCluster).getProxy().deleteByExample(example);
if (count > 0) {
return true;
}
throw new Exception("删除数据失败");
}
@Transactional
@Override
public Boolean updateOrderNo(BilliardsAdvertisement billiardsAdvertisement) throws Exception {
if(billiardsAdvertisement == null || billiardsAdvertisement.getId() == null){
throw new Exception("参数为空,不能更新呢");
}
int count = billiardsAdvertisementMapper.updateByPrimaryKeySelective(billiardsAdvertisement);
if (count > 0) {
return true;
}
throw new Exception("更新数据失败");
}
@Override
public BilliardsAdvertisement getAdvertisement(Long id) {
return new CacheDataHanlder<BilliardsAdvertisementMapper>(billiardsAdvertisementMapper, new CacheProxy() {
@Override
public Object doBegin(Object[] args, JedisCluster jedisClusterCommon) {
String json = jedisClusterCommon.hget(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.getKey(),id.toString());
if(StringUtils.isEmpty(json)){
return null;
}
return com.apus.util.JsonUtils.fromJson(json,new TypeToken<BilliardsAdvertisement>(){}.getType()); //获取泛型参数类型
//等同于字符串换成json
// for (JsonElement user : jsonArray) {
//
// //使用GSON,直接转成Bean对象
//
// UserBean userBean = gson.fromJson(user, UserBean.class);
//
// userBeanList.add(userBean);
//
// }
}
@Override
public Object doEnd(Object[] args, Object result, JedisCluster jedisClusterCommon) throws Exception {
if (result == null && ((BilliardsAdvertisement)result).getId()==null){
return result;
}
BilliardsAdvertisement billiardsAdvertisement = (BilliardsAdvertisement)result;
jedisClusterCommon.hset(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.getKey(),billiardsAdvertisement.getId().toString(),JsonUtils.toJSON(result));
return result;
}
},jedisCluster).getProxy().selectByPrimaryKey(id);
}
}
这里的
jedisClusterCommon.hset(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.getKey(),billiardsAdvertisement.getId().toString(),JsonUtils.toJSON(billiardsAdvertisement));
第一个getkey是缓存的表名字,后面两个参数对应key-values值
删除的时候
jedisClusterCommon.hdel(CacheKeyEnum.BILLIARDS_ADVERTISEMENT_INFO.getKey(),id.toString());
return result;
根据表名和id就可删除对应的一行数据,用del是批量删除
这里穿插一个dobagin和doend方法
public class CacheDataHanlder<T> implements InvocationHandler {
private Object target;
private CacheProxy cacheProxy;
private JedisCluster jedisClusterCommon;
public CacheDataHanlder(T t, CacheProxy cacheProxy, JedisCluster jedisClusterCommon) {
this.target = t;
this.jedisClusterCommon = jedisClusterCommon;
this.cacheProxy = cacheProxy;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = cacheProxy.doBegin(args, jedisClusterCommon);
if (result != null) {
return result;
} else {
result = method.invoke(target, args);
}
result = cacheProxy.doEnd(args, result, jedisClusterCommon);
return result;
}
/**
* 获取目标对象的代理对象
*
* @return 代理对象
*/
public T getProxy() {
return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
target.getClass().getInterfaces(), this);
}
}
先dobagin然后执行数据库操作判断result再执行doend,这里的insert要加几个东西,因为insert是逆向工程自动生成的,所以不会插入id,需要我们改一改
<insert id="insert" parameterType="com.yuyuka.billiards.service.domain.BilliardsAdvertisement" useGeneratedKeys="true" keyProperty="id">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Nov 04 11:50:37 CST 2019.
-->
insert into BILLIARDS_ADVERTISEMENT (ID, ADDRESS, JUMP_ADD,
CREADED, IS_BOOT_UP, ORDER_NO
)
values (#{id,jdbcType=BIGINT}, #{address,jdbcType=VARCHAR}, #{jumpAdd,jdbcType=VARCHAR},
#{creaded,jdbcType=TIMESTAMP}, #{isBootUp,jdbcType=INTEGER}, #{orderNo,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yuyuka.billiards.service.domain.BilliardsAdvertisement" useGeneratedKeys="true" keyProperty="id">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Nov 04 11:50:37 CST 2019.
-->
insert into BILLIARDS_ADVERTISEMENT
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
ID,
</if>
<if test="address != null">
ADDRESS,
</if>
<if test="jumpAdd != null">
JUMP_ADD,
</if>
<if test="creaded != null">
CREADED,
</if>
<if test="isBootUp != null">
IS_BOOT_UP,
</if>
<if test="orderNo != null">
ORDER_NO,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="jumpAdd != null">
#{jumpAdd,jdbcType=VARCHAR},
</if>
<if test="creaded != null">
#{creaded,jdbcType=TIMESTAMP},
</if>
<if test="isBootUp != null">
#{isBootUp,jdbcType=INTEGER},
</if>
<if test="orderNo != null">
#{orderNo,jdbcType=INTEGER},
</if>
</trim>
</insert>
两处添加了以下内容,表示往里面插入id
useGeneratedKeys="true" keyProperty="id"
运行过程启动EurekaServer
启动webapp
启动admin层
启动service层
输入页面ip对应的rest就可以了,最后测试成功就写对外接口
package com.yuyuka.billiards.service.gateway.service.impl.advertisement;
import com.google.common.reflect.TypeToken;
import com.yuyuka.billiards.gateway.dto.vo.AdvertisementQueryVo;
import com.yuyuka.billiards.gateway.dto.vo.AssistanceManQueryVo;
import com.yuyuka.billiards.service.domain.BilliardsAdvertisement;
import com.yuyuka.billiards.service.gateway.provider.GlobalErrorMessage;
import com.yuyuka.billiards.service.gateway.provider.HttpRequestBody;
import com.yuyuka.billiards.service.gateway.provider.HttpResponseBody;
import com.yuyuka.billiards.service.gateway.service.GateWayService;
import com.yuyuka.billiards.service.service.impl.BilliardsAdvertisementServiceProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Slf4j
@Component
public class ListBilliardsAdvertisementServiceImpl implements GateWayService {
private String method = "com.yuyuka.billiards.api.advertisement.list";
@Resource
private BilliardsAdvertisementServiceProvider billiardsAdvertisementServiceProvider;
@Override
public String getMethodName() {
return method;
}
@Override
public HttpResponseBody gateWay(HttpRequestBody httpRequestBody) throws Exception {
HttpResponseBody responseBody = new HttpResponseBody();
try {
//获取请求参数
AdvertisementQueryVo parmas = com.apus.util.JsonUtils.fromJson(httpRequestBody.getBizContent(), new TypeToken<AssistanceManQueryVo>() {
}.getType());
if (parmas == null || parmas.getId() == null || parmas.getIsBootUp() == null) {
responseBody.setCode(String.valueOf(GlobalErrorMessage.MISSING_PARAMETERS.getCode()));
responseBody.setMsg(GlobalErrorMessage.MISSING_PARAMETERS.getMessage());
return responseBody;
}
BilliardsAdvertisement billiardsAdvertisement = new BilliardsAdvertisement();
billiardsAdvertisement.setIsBootUp(parmas.getIsBootUp());
billiardsAdvertisement.setId(parmas.getId());
// Object object = billiardsAdvertisementServiceProvider.listAdvertisement(billiardsAdvertisement.getId(),billiardsAdvertisement.getStart(),billiardsAdvertisement.getLimit());
// if(object != null){
// responseBody.setBizContent(JsonUtils.toJSON(object));
// responseBody.setMsg(GlobalErrorMessage.SUCCESS.getMessage());
// responseBody.setCode(String.valueOf(GlobalErrorMessage.SUCCESS.getCode()));
// }else{
// PageVo<BilliardsAdvertisement> billiardsAdvertisementList = billiardsAdvertisementServiceProvider.listAdvertisement(billiardsAdvertisement.getId(),billiardsAdvertisement.getStart(),billiardsAdvertisement.getLimit());
// responseBody.setBizContent(JsonUtils.toJSON(billiardsAdvertisementList));
// responseBody.setMsg(GlobalErrorMessage.SUCCESS.getMessage());
// responseBody.setCode(String.valueOf(GlobalErrorMessage.SUCCESS.getCode()));
// }
} catch (Exception e) {
log.error("获取助教信息列表异常", e);
responseBody.setCode(GlobalErrorMessage.UNKNOW.getCode().toString());
responseBody.setMsg("获取助教信息列表异常!");
}
return responseBody;
}
}