新增对管理后台的封装

master
星期八 6 years ago
parent e5da291b9c
commit 9cb1226fdc
  1. 6
      src/main/java/com/lq/cms/dao/AdminBaseDao.java
  2. 10
      src/main/java/com/lq/cms/service/AdminBaseService.java
  3. 3
      src/main/java/com/lq/cms/service/WechatMessageService.java
  4. 10
      src/main/java/com/lq/cms/service/impl/AdminBaseServiceImpl.java
  5. 3
      src/main/java/com/lq/cms/service/impl/WechatMessageServiceImpl.java
  6. 10
      src/main/java/com/lq/cms/vo/AdminBaseVo.java
  7. 26
      src/main/java/com/lq/cms/vo/WechatMessageVo.java
  8. 19
      src/main/java/com/lq/cms/web/AdminBaseController.java
  9. 2
      src/main/java/com/lq/cms/web/wechat/WechatMessageController.java
  10. 2
      src/main/java/com/lq/dao/WechatMessageDao.java
  11. 1
      src/main/webapp/WEB-INF/views/jsp/cms/sys/role/index.jsp
  12. 1
      src/main/webapp/WEB-INF/views/jsp/cms/sys/user/index.jsp
  13. 10
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/edit.jsp
  14. 36
      src/main/webapp/WEB-INF/views/jsp/cms/wechat/message/index.jsp

@ -5,10 +5,10 @@ import com.lq.code.dao.BaseDao;
import java.util.List;
public interface AdminBaseDao<T> extends BaseDao {
public interface AdminBaseDao<T,V extends AdminBaseVo> extends BaseDao {
List<AdminBaseVo> findLisatPage(AdminBaseVo vo);
List<V> findListPage(V vo);
int count(AdminBaseVo vo);
int count(V vo);
}

@ -5,13 +5,13 @@ import com.lq.code.service.BaseService;
import java.util.List;
public interface AdminBaseService<T> extends BaseService<T>{
public interface AdminBaseService<T,V extends AdminBaseVo> extends BaseService<T>{
List<AdminBaseVo> findListPage(AdminBaseVo vo);
List<V> findListPage(V vo);
int count(AdminBaseVo vo);
int count(V vo);
T save(AdminBaseVo vo)throws IllegalAccessException, InstantiationException;
T save(V vo)throws IllegalAccessException, InstantiationException;
T update(AdminBaseVo vo);
T update(V vo);
}

@ -1,9 +1,10 @@
package com.lq.cms.service;
import com.lq.cms.vo.WechatMessageVo;
import com.lq.entity.WechatMessage;
public interface WechatMessageService extends AdminBaseService<WechatMessage> {
public interface WechatMessageService extends AdminBaseService<WechatMessage,WechatMessageVo> {
}

@ -13,17 +13,17 @@ import java.lang.reflect.ParameterizedType;
import java.util.Date;
import java.util.List;
public abstract class AdminBaseServiceImpl<T> extends BaseServiceImpl<T> implements AdminBaseService<T>{
public abstract class AdminBaseServiceImpl<T,V extends AdminBaseVo> extends BaseServiceImpl<T> implements AdminBaseService<T,V>{
abstract AdminBaseDao<T> getAdminBaseDao();
abstract AdminBaseDao<T,V> getAdminBaseDao();
@Override
public List<AdminBaseVo> findListPage(AdminBaseVo vo) {
return this.getAdminBaseDao().findLisatPage(vo);
public List<V> findListPage(V vo) {
return this.getAdminBaseDao().findListPage(vo);
}
@Override
public int count(AdminBaseVo vo) {
public int count(V vo) {
return this.getAdminBaseDao().count(vo);
}

@ -2,13 +2,14 @@ package com.lq.cms.service.impl;
import com.lq.cms.dao.AdminBaseDao;
import com.lq.cms.service.WechatMessageService;
import com.lq.cms.vo.WechatMessageVo;
import com.lq.dao.WechatMessageDao;
import com.lq.entity.WechatMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class WechatMessageServiceImpl extends AdminBaseServiceImpl<WechatMessage> implements WechatMessageService {
public class WechatMessageServiceImpl extends AdminBaseServiceImpl<WechatMessage,WechatMessageVo> implements WechatMessageService {
@Autowired
private WechatMessageDao wechatMessageDao;

@ -8,6 +8,8 @@ public class AdminBaseVo extends BasePageVo {
private Date createTime;
private Date updateTime;
private Integer status;
public Long getId() {
@ -26,6 +28,14 @@ public class AdminBaseVo extends BasePageVo {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getStatus() {
return status;
}

@ -1,11 +1,15 @@
package com.lq.cms.vo;
import com.lq.cms.emun.WechatMessageTypeEnum;
import java.util.Date;
public class WechatMessageVo extends AdminBaseVo{
//消息类型
private String messageType;
private String messageTypeStr;
//消息标题
private String title;
//消息内容
@ -16,8 +20,6 @@ public class WechatMessageVo extends AdminBaseVo{
private String mediaId;
//跳转路径
private String toUrl;
//更新时间
private Date updateTime;
//创建用户
private Long userId;
@ -27,6 +29,17 @@ public class WechatMessageVo extends AdminBaseVo{
public void setMessageType(String messageType) {
this.messageType = messageType;
if (WechatMessageTypeEnum.hasValue(messageType)){
this.messageTypeStr = WechatMessageTypeEnum.getDesc(messageType);
}
}
public String getMessageTypeStr() {
return messageTypeStr;
}
public void setMessageTypeStr(String messageTypeStr) {
this.messageTypeStr = messageTypeStr;
}
public String getTitle() {
@ -69,15 +82,6 @@ public class WechatMessageVo extends AdminBaseVo{
this.toUrl = toUrl;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Long getUserId() {
return userId;
}

@ -18,7 +18,7 @@ import java.util.Map;
/**
* 管理后台 父类
*/
public abstract class AdminBaseController<T> {
public abstract class AdminBaseController<T,V extends AdminBaseVo> {
public static final Logger LOGGER = LoggerFactory.getLogger(AdminBaseController.class);
@ -26,7 +26,7 @@ public abstract class AdminBaseController<T> {
* 获取service
* @return
*/
public abstract AdminBaseService<T> getBaseService();
public abstract AdminBaseService<T,V> getBaseService();
/**
* 管理后台url用于权限控制
@ -34,16 +34,16 @@ public abstract class AdminBaseController<T> {
*/
public abstract String getIndexUrl();
public Map<String,Object> setPageDate(AdminBaseVo vo){
public Map<String,Object> setPageDate(V vo){
Map<String,Object> map=new HashMap();
map.put(DatagridParamEnum.TOTAL.getValue(),getBaseService().findListPage(vo));
map.put(DatagridParamEnum.ROWS.getValue(),getBaseService().count(vo));
map.put(DatagridParamEnum.ROWS.getValue(),getBaseService().findListPage(vo));
map.put(DatagridParamEnum.TOTAL.getValue(),getBaseService().count(vo));
return map;
}
@GetMapping("/list")
@RequestMapping("/list")
@ResponseBody
public Map<String,Object> list(AdminBaseVo vo){
public Map<String,Object> list(V vo){
Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.SELECT.getConstant());
Map<String,Object> resultMap = setPageDate(vo);
@ -52,7 +52,7 @@ public abstract class AdminBaseController<T> {
@PostMapping("/save")
@ResponseBody
public AjaxResult save(AdminBaseVo vo) throws InstantiationException, IllegalAccessException {
public AjaxResult save(V vo) throws InstantiationException, IllegalAccessException {
Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.INSERT.getConstant());
AjaxResult ajaxResult = new AjaxResult();
@ -63,7 +63,7 @@ public abstract class AdminBaseController<T> {
@PostMapping("/update")
@ResponseBody
public AjaxResult update(AdminBaseVo vo){
public AjaxResult update(V vo){
Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.UPDATE.getConstant());
AjaxResult ajaxResult= new AjaxResult();
@ -76,7 +76,6 @@ public abstract class AdminBaseController<T> {
public AjaxResult delete(@PathVariable("id")Long id){
Subject subject = SecurityUtils.getSubject();
subject.checkPermission(getIndexUrl()+":"+ PermissionTyepEnum.DELETE.getConstant());
AjaxResult ajaxResult = new AjaxResult();
getBaseService().delete(id);
return ajaxResult;

@ -21,7 +21,7 @@ import java.util.Map;
*/
@Controller
@RequestMapping("/cms/wechat/message")
public class WechatMessageController extends AdminBaseController<WechatMessage> {
public class WechatMessageController extends AdminBaseController<WechatMessage,WechatMessageVo> {
@Autowired
private WechatMessageService wechatMessageService;

@ -7,7 +7,7 @@ import com.lq.entity.WechatMessage;
import java.util.List;
public interface WechatMessageDao extends AdminBaseDao<WechatMessage> {
public interface WechatMessageDao extends AdminBaseDao<WechatMessage,WechatMessageVo> {
List<WechatMessageVo> findListPage(WechatMessageVo vo);

@ -22,7 +22,6 @@
{field:'updateTimeStr',title:'更新时间',width:100},
/* formatter 不能重复field,否则会失效**/
{field:'editId',title:'编辑',width:100,formatter:function (value,row,index) {
// console.log(row);
var html="<a href='#' onclick='openEdit(\"编辑\","+row.id+")'>编辑</a>&nbsp&nbsp";
html+="<a href='#' onclick='del("+row.id+")'>删除</a>&nbsp&nbsp";
html+="<a href='#' onclick='openPermission("+row.id+")'>权限</a>";

@ -35,7 +35,6 @@
{field:'imgUrl',title:'头像',width:100},
/* formatter 不能重复field,否则会失效**/
{field:'editId',title:'编辑',width:100,formatter:function (value,row,index) {
console.log(row);
var html="<a href='#' onclick='openEdit(\"编辑\","+row.id+")'>编辑</a>&nbsp&nbsp";
html+="<a href='#' onclick='del("+row.id+")'>删除</a>";
return html;

@ -39,14 +39,20 @@
<td><input class="easyui-textbox" type="text" id="content" data-options="required:true" value="${wechatMessage.content}"/></td>
</tr>
<tr>
<td>图片路径:</td>
<td><input class="easyui-textbox" type="text" id="imageUrl" data-options="required:true" value="${wechatMessage.content}"/></td>
</tr>
<tr>
<td>素材ID:</td>
<td><input class="easyui-textbox" type="text" id="imageUrl" data-options="required:true'" value="${wechatMessage.mediaId}"/></td>
<td><input class="easyui-textbox" type="text" id="mediaId" data-options="required:true'" value="${wechatMessage.mediaId}"/></td>
</tr>
<tr>
<td>消息跳转链接:</td>
<td><input class="easyui-textbox" type="text" id="mediaId" data-options="required:true" value="${wechatMessage.toUrl}" /></td>
<td><input class="easyui-textbox" type="text" id="toUrl" data-options="required:true" value="${wechatMessage.toUrl}" /></td>
</tr>
</table>

@ -81,11 +81,43 @@
$("#editDate").dialog('open').dialog('refresh',url);
}
function save() {
alert("提交保存");
var url = 'save';
var obj = new Object();
obj = attrObj(obj);
post(url,obj);
}
function update() {
alert("提交更新");
var url = 'update';
var obj = new Object();
obj.id = $("#id").val();
obj = attrObj(obj);
post(url,obj);
}
function attrObj(obj) {
obj.messageType = $("#messageType").val();
obj.title = $("#title").val();
obj.content = $("#content").val();
obj.imageUrl = $("#imageUrl").val();
obj.mediaId = $("#mediaId").val();
obj.toUrl = $("#toUrl").val();
return obj;
}
function post(url,obj) {
$.ajax({
url: url,
dataType:"json",
type:"post",
data:obj,
success: function(result){
if(result.success==true){
$.messager.alert('提醒','提交成功','warning');
$("#editDate").dialog('close');
$('#dataList').datagrid('reload',{});
}
}});
}
</script>

Loading…
Cancel
Save