Commit e97d0df9 by Huang Linyu

活动临时用户表

parent 66f41f70
package com.ctrip.fun.golf.api.user;
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ctrip.fun.common.vo.Request;
import com.ctrip.fun.common.vo.Response;
import com.ctrip.fun.common.vo.ResponseStatusEnum;
import com.ctrip.fun.common.vo.user.ActiveCustomerBean;
import com.ctrip.fun.golf.service.user.ActiveCustomerService;
@Controller
@RequestMapping(value = "/activeCustomer")
public class ActiveCustomerController {
@Autowired
private ActiveCustomerService activeCustomerService;
@ResponseBody
@RequestMapping(value = "/insertOne", method = RequestMethod.POST)
public Response<Serializable> insertOne(@RequestBody Request<ActiveCustomerBean> request) {
activeCustomerService.insertOne(request.getBody());
Response<Serializable> response = new Response<Serializable>();
response.setStatus(ResponseStatusEnum.SUCCESS.getValue());
response.setMessage(ResponseStatusEnum.SUCCESS.getMsg());
return response;
}
}
/**
* Copyright 2014 CTRIP Co.,Ltd. All rights reserved.
*/
package com.ctrip.fun.golf.dao.user;
import java.util.Date;
import org.hibernate.Query;
import com.ctrip.fun.common.core.util.DateUtil;
import com.ctrip.fun.common.vo.basic.VipGradeEnum;
import com.ctrip.fun.common.vo.user.ActiveCustomerBean;
import com.ctrip.fun.golf.dao.GenericHibernateDao;
import com.ctrip.fun.golf.domain.user.ActiveCustomer;
/**
* @author zgsong
* @version 1.0.0
*/
public class ActiveCustomerDao extends GenericHibernateDao<ActiveCustomer, Integer> {
public Integer insertOne(ActiveCustomerBean bean) {
StringBuilder sql = new StringBuilder("INSERT INTO active_customer (saleMobile,customerName,customerMobile,picUrl,sex,createTime,updateTime)")
.append("VALUES('"+bean.getSaleMobile()+"','"+bean.getCustomerName()+"','"+bean.getCustomerMobile()+"','"+bean.getPicUrl()+"',0,NOW(),NOW());")
;
Query query = getSession().createSQLQuery(sql.toString());
return query.executeUpdate();
}
}
package com.ctrip.fun.golf.domain.user;
import static javax.persistence.GenerationType.IDENTITY;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "usr_user_conracts")
public class ActiveCustomer implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = 4522059920101252668L;
private Integer id ;
private String saleMobile;
private String customerName;
private String customerMobile;
private String picUrl;
private String sex;
private Date createTime;
private Date updateTime;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "saleMobile", length = 20)
public String getSaleMobile() {
return saleMobile;
}
public void setSaleMobile(String saleMobile) {
this.saleMobile = saleMobile;
}
@Column(name = "customerName", length = 20)
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
@Column(name = "customerMobile", length = 20)
public String getCustomerMobile() {
return customerMobile;
}
public void setCustomerMobile(String customerMobile) {
this.customerMobile = customerMobile;
}
@Column(name = "picUrl", length = 255)
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
@Column(name = "sex", length = 2)
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Column(name = "createTime")
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
@Column(name = "updateTime")
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
package com.ctrip.fun.golf.service.user;
import java.util.Date;
import com.ctrip.fun.common.core.util.BeanConverter;
import com.ctrip.fun.common.vo.user.ActiveCustomerBean;
import com.ctrip.fun.golf.dao.user.ActiveCustomerDao;
import com.ctrip.fun.golf.domain.user.ActiveCustomer;
import com.ctrip.fun.golf.service.GenericService;
public class ActiveCustomerService extends GenericService<ActiveCustomerDao, ActiveCustomer, Integer, ActiveCustomerBean> {
private ActiveCustomerDao activeCustomerDao;
@Override
public ActiveCustomerDao getEntityDao() {
return activeCustomerDao;
}
public Integer insertOne(ActiveCustomerBean bean) {
return activeCustomerDao.insertOne(bean);
}
public ActiveCustomerDao getActiveCustomerDao() {
return activeCustomerDao;
}
public void setActiveCustomerDao(ActiveCustomerDao activeCustomerDao) {
this.activeCustomerDao = activeCustomerDao;
}
}
......@@ -134,6 +134,7 @@
<mapping class="com.ctrip.fun.golf.domain.user.UserVerifyCode" />
<mapping class="com.ctrip.fun.golf.domain.user.UserExt" />
<mapping class="com.ctrip.fun.golf.domain.user.UserConracts" />
<mapping class="com.ctrip.fun.golf.domain.user.ActiveCustomer" />
<mapping class="com.ctrip.fun.golf.domain.user.UserIpBlackList" />
<mapping class="com.ctrip.fun.golf.domain.user.IdentifyingCode" />
<mapping class="com.ctrip.fun.golf.domain.user.VipMemberLog" />
......
......@@ -117,6 +117,14 @@
<property name="userTokenDao" ref="userTokenDao"></property>
</bean>
<bean class="com.ctrip.fun.golf.dao.user.ActiveCustomerDao" name="activeCustomerDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean class="com.ctrip.fun.golf.service.user.ActiveCustomerService"
name="activeCustomerService">
<property name="activeCustomerDao" ref="activeCustomerDao"></property>
</bean>
<bean class="com.ctrip.fun.golf.service.user.UserAddressService"
name="userAddressService">
<property name="userAddressDao" ref="userAddressDao"></property>
......
......@@ -14,11 +14,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.unitils.spring.annotation.SpringApplicationContext;
import com.ctrip.fun.common.core.util.EncryptUtil;
import com.ctrip.fun.common.vo.user.ActiveCustomerBean;
import com.ctrip.fun.common.vo.user.CommuneExtQuery;
import com.ctrip.fun.common.vo.user.UserPhoneBean;
import com.ctrip.fun.golf.dao.user.UserExtDao;
import com.ctrip.fun.golf.domain.user.CommuneExt;
import com.ctrip.fun.golf.domain.user.UserExt;
import com.ctrip.fun.golf.service.user.ActiveCustomerService;
@RunWith(SpringJUnit4ClassRunner.class)
......@@ -27,6 +29,9 @@ public class UserExtServiceTest{
@Autowired
private UserExtDao userExtDao;
@Autowired
private ActiveCustomerService activeCustomerService;
/* @Test
public void testQueryList() throws Exception {
......@@ -39,23 +44,18 @@ public class UserExtServiceTest{
System.out.println("user:");
}*/
@Test
/* @Test
public void insertData(){
ExecutorService es = Executors.newFixedThreadPool(8);
synchronized (this) {
for (int i = 0; i < 1000000; i++) {
final int index = i;
saveUser(index);
/*es.execute(new Runnable() {
@Override
public void run() {
saveUser(index);
}
});*/
}
}
}
}*/
private synchronized void saveUser(int i){
String phone = "1366142895"+i;
String username = "aaron"+i;
......@@ -102,4 +102,17 @@ public class UserExtServiceTest{
System.out.println(Thread.currentThread().getName()+","+id);
}
@Test
public void insertOneTest(){
ActiveCustomerBean bean = new ActiveCustomerBean();
bean.setSaleMobile("18014006769");
bean.setCustomerMobile("18014006770");
bean.setCustomerName("hello");
bean.setPicUrl("http://iwanpic.png");
bean.setSex("0");
activeCustomerService.insertOne(bean );
}
}
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 sign in to comment