Commit df48e996 authored by liuchao's avatar liuchao

no message

parent b826ece5
package com.qiankun.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.qiankun.controller.base.BaseController;
import com.qiankun.entity.Points;
import com.qiankun.service.PointsService;
@Controller
public class PointsController extends BaseController<Object>{
@Autowired
private PointsService pointsService;
@RequestMapping("/points/type/list")
public ModelAndView list(HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
view.getModelMap().addAttribute("typelist", pointsService.findAllType());
view.setViewName("points/typelist");
return view;
}
@RequestMapping("/points/type/add")
public ModelAndView typeAdd(String id) throws Exception {
ModelAndView view = new ModelAndView();
Points type = new Points();
if(StringUtils.isNotBlank(id)) {
type = pointsService.findById(id);
}
view.setViewName("points/savetype");
view.getModel().put("type", type);
return view;
}
@RequestMapping("/points/type/save")
public ModelAndView saveType(Points type, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
if (StringUtils.isNotEmpty(type.getId())) {
Points t = pointsService.findById(type.getId());
t.setAvailable(type.isAvailable());
t.setId(type.getId());
t.setName(type.getName());
t.setPoint(type.getPoint());
view.getModelMap().addAttribute("status", 2);
} else {
pointsService.saveType(type);
view.getModelMap().addAttribute("status", 1);
}
return view;
}
@RequestMapping("/points/type/del")
public ModelAndView delActivity(String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
ModelAndView view = new ModelAndView();
pointsService.removeType(id);
return view;
}
}
\ No newline at end of file
package com.qiankun.dao;
import com.qiankun.dao.core.IDao;
import com.qiankun.entity.Points;
public interface PointsTypeDao extends IDao<Points, String> {
}
package com.qiankun.dao;
import org.springframework.stereotype.Repository;
import com.qiankun.dao.core.AbsDao;
import com.qiankun.entity.Points;
@Repository
public class PointsTypeDaoImpl extends AbsDao<Points, String> implements PointsTypeDao {
}
package com.qiankun.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Gift {
@Id
@GenericGenerator(name = "systemUUID", strategy = "uuid2")
@GeneratedValue(generator = "systemUUID")
private String id;
private String name; //礼品名称
private String content; //礼品介绍
private String point; //礼品积分
private String uploadImage;//礼物照片路径
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getPoint() {
return point;
}
public void setPoint(String point) {
this.point = point;
}
public String getUploadImage() {
return uploadImage;
}
public void setUploadImage(String uploadImage) {
this.uploadImage = uploadImage;
}
}
package com.qiankun.entity;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
......@@ -25,14 +22,10 @@ public class Points {
private String name; //名称
private String type; //积分类别
private Long point; //积分
private Integer point; //积分
private boolean available; //是否可用
@ManyToOne
private User user = new User();
private Date updateTime = new Date();
public String getId() {
return id;
......@@ -50,42 +43,21 @@ public class Points {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getPoint() {
public Long getPoint() {
return point;
}
public void setPoint(Integer point) {
public void setPoint(Long point) {
this.point = point;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
public boolean isAvailable() {
return available;
}
public Date getUpdateTime() {
return updateTime;
public void setAvailable(boolean available) {
this.available = available;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
......@@ -90,7 +90,7 @@ public class User {
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL}, orphanRemoval = true, mappedBy = "user")
@JsonIgnore
private Set<Points> points = new HashSet<Points>();
private Set<UserPoints> points = new HashSet<UserPoints>();
private Boolean isRemove=false;//是否删除用户,默认false
......@@ -301,10 +301,10 @@ public class User {
public void setStatus(String status) {
this.status = status;
}
public Set<Points> getPoints() {
public Set<UserPoints> getPoints() {
return points;
}
public void setPoints(Set<Points> points) {
public void setPoints(Set<UserPoints> points) {
this.points = points;
}
public String getWeixin() {
......
package com.qiankun.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class UserGift {
@Id
@GenericGenerator(name = "systemUUID", strategy = "uuid2")
@GeneratedValue(generator = "systemUUID")
private String id;
private String name; //礼品名称
private String content; //礼品介绍
private String point; //礼品积分
private String uploadImage;//礼物照片路径
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getPoint() {
return point;
}
public void setPoint(String point) {
this.point = point;
}
public String getUploadImage() {
return uploadImage;
}
public void setUploadImage(String uploadImage) {
this.uploadImage = uploadImage;
}
}
package com.qiankun.entity;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class UserPoints {
@Id
@GenericGenerator(name = "systemUUID", strategy = "uuid2")
@GeneratedValue(generator = "systemUUID")
private String id;
@ManyToOne
private Points type = new Points(); //积分类别
private Long point; //积分
@ManyToOne
private User user = new User();
private Date updateTime = new Date();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Points getType() {
return type;
}
public void setType(Points type) {
this.type = type;
}
public Long getPoint() {
return point;
}
public void setPoint(Long point) {
this.point = point;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
package com.qiankun.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.qiankun.dao.PointsTypeDao;
import com.qiankun.entity.Points;
@Service
public class PointsService {
@Autowired
private PointsTypeDao typeDao;
public Points findById(String id) {
Points type = typeDao.find(id);
return type;
}
@Transactional
public Points saveType(Points type) {
return typeDao.save(type);
}
@Transactional
public void removeType(String id) {
typeDao.remove(id);
}
public List<Points> findAllType() {
List<Points> list = typeDao.findAll();
return list;
}
}
......@@ -278,14 +278,14 @@
</li>
<li>
<a href="widgets.html">
<a href="/points/type/list">
<i class="icon-list-alt"></i>
<span class="menu-text"> 积分管理 </span>
</a>
</li>
<li>
<a href="calendar.html">
<a href="#">
<i class="icon-briefcase "></i>
<span class="menu-text">
......@@ -306,14 +306,14 @@
<ul class="submenu">
<li>
<a href="profile.html">
<a href="#">
<i class="icon-double-angle-right"></i>
消息设置
</a>
</li>
<li>
<a href="inbox.html">
<a href="#">
<i class="icon-double-angle-right"></i>
消息管理
</a>
......
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="webpath" uri="/WEB-INF/tlds/path.tld"%>
<%@ taglib prefix="webpage" uri="/WEB-INF/tlds/pageview.tld"%>
<head>
</head>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="icon-home home-icon"></i>
<a href="#">首页</a>
</li>
<li class="active">积分管理</li>
<li class="active">保存</li>
</ul><!-- .breadcrumb -->
</div>
<div class="page-content">
<div class="row">
<div class="col-xs-12">
<form action="#" id="typeForm" name="typeForm" method="post" onsubmit="return false" class="form-horizontal" role="form">
<input type="hidden" id="id" name="id" value="${type.id}"/>
<div class="row">
<div class="col-xs-12">
<h3 class="header smaller lighter blue">积分类别</h3></div>
</div>
<div class="row">
<div class="col-xs-5">
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 名称 </label>
<div class="col-sm-9">
<input type="text" id="name" name="name" class="col-xs-10 col-sm-10" value="${type.name}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 积分</label>
<div class="col-sm-9">
<input type="text" id="point" name="point" class="col-xs-10 col-sm-10" value="${type.point}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> 状态 </label>
<div class="col-sm-9">
<select name="available" id="available" class="col-xs-10 col-sm-10">
<option value="true" <c:if test="${activity.available==true}">selected</c:if>>正常</option>
<option value="false" <c:if test="${activity.available==false}">selected</c:if>>关闭</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-sm btn-success" type="submit">
<i class="icon-save bigger-110"></i>
保存
</button>
&nbsp; &nbsp; &nbsp;
<a class="btn btn-sm btn-success" href="javascript:history.go(-1)">
<i class="icon-reply bigger-110"></i>
返回
</a>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="<webpath:path/>/resources/js/points/points.js" type="text/javascript"></script>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="webpath" uri="/WEB-INF/tlds/path.tld"%>
<%@ taglib prefix="webpage" uri="/WEB-INF/tlds/pageview.tld"%>
<head>
</head>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="icon-home home-icon"></i>
<a href="#">首页</a>
</li>
<li class="active">积分管理</li>
<li class="active">类别</li>
</ul><!-- .breadcrumb -->
</div>
<div class="page-content">
<div class="row">
<div class="col-xs-12">
<div class="widget-toolbox">
<div class="btn-group">
<button class="btn btn-sm btn-success" onclick="window.location.href='<webpath:path/>/points/type/add'">
<i class="icon-plus-sign-alt bigger-110"></i>
新增
</button>
</div>
</div>
<div class="pull-left"></div>
<table id="table-data" class="table table-bordered ">
<thead>
<tr class="">
<th>名称</th>
<th>积分</th>
<th>是否可用</th>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<c:forEach var="type" items="${typelist}">
<tr class="tr-highlight">
<td title="">${type.name}</td>
<td title="">${type.point}</td>
<td title=""> <c:if test="${type.available}"><font color=green>正常</font></c:if><c:if test="${!type.available}"><font color=red>关闭</font></c:if></td>
<td>
<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
<button class="btn btn-xs btn-info" onclick="window.location.href='<webpath:path/>/points/type/add?id=${type.id}'">
<i class="icon-edit bigger-120"></i>
</button>
&nbsp;
<button class="btn btn-xs btn-danger" onclick="points.remove('${type.id}')">
<i class="icon-trash bigger-120"></i>
</button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="<webpath:path/>/resources/js/points/points.js" type="text/javascript"></script>
\ No newline at end of file
var isSubmit = true;
$(document).ready(function(){
if ($('#typeForm').length>0){
$('#typeForm').validate({
rules : {
"name" : {
required : true
},
"point" : {
required : true
}
},
messages:{
"name" : {
required : "不能为空"
},
"point" : {
required : "不能为空"
}
},
submitHandler: function(form){
points.save(form);
}
});
}
})
var points = {
remove : function(id){
bootbox.confirm({
buttons: {
cancel: {
label: '取消',
className: 'btn-default'
},
confirm: {
label: '确认',
className: 'btn-myStyle'
}
},
message: '请确认是否删除?',
callback: function(result) {
if(result) {
$.ajax({
type: 'GET',
url: webPath + '/points/type/del?id='+id,
dataType:'json',
success: function(data){
window.location.reload();
}
})
} else {
}
},
title: "删除"
});
},
save : function(form){
if (isSubmit){
isSubmit = false;
var formData = new FormData();
formData.append('id', $('#id').val());
formData.append('name', $('#name').val());
formData.append('point', $('#point').val());
formData.append('available', $('#available').val());
$.ajax({
url: webPath + '/points/type/save',
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false,
dataType:"json",
beforeSend: function(){
},
success: function(data){
var status=data.status;
if(status==1){//成功
bootbox.dialog({
message:"新增成功",
buttons:{
"cancel":{
"label":"返回",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.href = webPath + '/points/type/list';
}
},
"success":{
"label":"继续添加",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.href = webPath + '/points/type/add';
}
}
}
});
} else if (status == 2){
isSubmit = true;
bootbox.dialog({
message:"修改成功",
buttons:{
"success":{
"label":"确定",
"className":"btn-sm btn-primary",
"callback": function () {
window.location.reload();
}
}
}
});
}
}
});
}
},
search : function(){
var type = $("#type").val();
var searchStr = $("#searchStr").val();
var url = webPath + "/activity/list";
if(type!="" || searchStr!=""){
var param = "?"
if (type != ""){
param = param + "type=" + type ;
}
if (searchStr != ""){
if (param == "?"){
param = param + "searchStr=" + searchStr;
} else {
param = param + "&searchStr=" + searchStr;
}
}
url = url + param;
}
window.location.href = url;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment