我寫的廣告模塊,架構是這樣的
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;
}
}