码迷,mamicode.com
首页 > 其他好文 > 详细

短学期第二篇随笔

时间:2017-07-02 16:17:41      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:ram   ice   review   tco   eth   new   add   getc   stact   

 这三天明显感觉有节奏了,老师采取了先拉进度,然后纠错,这样可以给我们一个方向,明确当天的任务。很好的解决了做的快的同学被挂起,只能等老师先帮同学调试,有时候会调试到很晚,快下课才发布新任务,导致大家一起加班。

这几天做了直接查询功能,代码如下:

CustomerListAction:

package com.crm.action;

import java.util.Map;

import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerListAction extends ActionSupport{
 private CustomerService service;
 public void setService(CustomerService service){
  this.service = service;
 }
 
 @Override
 public String execute() throws Exception{
  Map map = (Map)ActionContext.getContext().get("request");
  map.put("list",this.service.findAllCustomer());
  return SUCCESS;
 }
}

 

CustomerDao中新增的直接查询代码:

技术分享

 

 

CustomerDaoImpl中新增的直接查询代码:

技术分享

CustomerService中新增的直接查询代码:

技术分享

 

CustomerServiceImpl中新增的直接查询代码:

技术分享

applicationContext中新增的直接查询代码:

技术分享

在http://127.0.0.1:8080/sshtest/jsp/customerInfo.jsp页面中会将所有信息直接列出。

 

 

 

接下来还做了条件查询和删除操作:

 

1.条件查询:

新增代码:

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

新建了CustomerFindByCdAction,代码如下:

技术分享

点击查询才列出信息,如果无输入,直接点击查询,就会列出所有信息,如图:

点击前:

 技术分享

点击后:

技术分享

2.删除功能:

新增的代码:

CustomerDao中:

/**
  * 删除客户信息
  * @param customer
  */
 public void deleteCustomer(Customer customer);

CustomerDaoImpl中:

public void deleteCustomer(Customer customer) {
  // TODO Auto-generated method stub
  this.getHibernateTemplate().delete(customer);
 }

CustomerService中:

/**
  * 删除客户信息
  * @param cust
  */
 public void deleteCustomer(Customer customer);

CustomerServiceImpl中:

public void deleteCustomer(Customer customer) {
  // TODO Auto-generated method stub
  this.customerdao.deleteCustomer(customer);
 }

strurs中:

<!-- 删除 -->
  <action name="deleteCustomer" class="customerRemoveAction">
   <result>/jsp/customerInfo.jsp</result>
  </action>

applicationContext.xml中:

<!--配置-删除deleteAction  -->
 <bean id="customerRemoveAction" class="com.crm.action.CustomerRemoveAction">
  <property name="removeService" ref="CustomerService"></property>
 </bean>

新建了一个CustomerRemoveAction类:

package com.crm.action;

import com.crm.bean.Customer;
import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerRemoveAction extends ActionSupport {
 private Customer customer;
 private CustomerService removeService;
 
 public void setService(CustomerService removeService) {
  this.removeService = removeService;
 }

 public CustomerService getRemoveService() {
  return getRemoveService();
 }
 
 public void setRemoveService(CustomerService removeService) {
  this.removeService = removeService;
 }

 public Customer getCustomer() {
  return customer;
 }

 public void setCustomer(Customer customer) {
  this.customer = customer;
 }

 @Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  this.removeService.deleteCustomer(customer);
  return SUCCESS;
 }

 
}

点击删除,就会删掉该条信息效果如下:

技术分享

技术分享

最后还添加了修改操作以及下拉菜单功能:

添加的代码和条件查询功能、删除功能相似,主要列举新建的CustomerUpdateAction、CustomerUpdatePreviewAction、TypeAction和Type类

1.代码:

CustomerUpdatePreviewAction:

 

package com.crm.action;

 

import com.crm.bean.Customer;
import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;

 

public class CustomerUpdatePreviewAction extends ActionSupport{
 private CustomerService  updatePvService;
 private Customer customer;
 
 public CustomerService getUpdatePvService() {
  return updatePvService;
 }
 
 public void setUpdatePvService(CustomerService updatePvService) {
  this.updatePvService = updatePvService;
 }
 
 public Customer getCustomer() {
  return customer;
 }
 
 public void setCustomer(Customer customer) {
  this.customer = customer;
 }
 
 @Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  customer = this.updatePvService.findCustomerById(customer.getID());
  return SUCCESS;
 }
}

 

 

 

CustomerUpdateAction

 

package com.crm.action;

 

import java.util.ArrayList;
import java.util.List;

 


import com.crm.bean.Customer;
import com.crm.service.CustomerService;
import com.opensymphony.xwork2.ActionSupport;

 

public class CustomerUpdateAction extends ActionSupport{
 private CustomerService updateService;
 private Customer customer;
 List strList = new ArrayList();
 
 public List getStrList() {
  return strList;
 }

 

 public void setStrList(List strList) {
  this.strList = strList;
 }

 

 public CustomerService getUpdateService() {
  return updateService;
 }
 
 public void setUpdateService(CustomerService updateService) {
  this.updateService = updateService;
 }
 
 public Customer getCustomer() {
  return customer;
 }
 
 public void setCustomer(Customer customer) {
  this.customer = customer;
 }
 
 
 
 @Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  this.customer.setCussex(this.strList.get(0).toString());
  this.updateService.updateCustomer(customer);
  return SUCCESS;
 }
}

 

 

TypeAction

package com.crm.action;

import java.util.ArrayList;
import java.util.List;

import com.crm.bean.Type;
import com.opensymphony.xwork2.ActionSupport;

public class TypeAction extends ActionSupport {
 private List<Type> strList = new ArrayList<Type>();

 public List<Type> getStrList() {
  List<Type> list = new ArrayList<Type>();
  Type type1 = new Type();
  type1.setID("1");
  type1.setName("男");
  
  Type type2 = new Type();
  type2.setID("2");
  type2.setName("女");
  
  Type type3 = new Type();
  type3.setID("3");
  type3.setName("其他");
  
  list.add(type1);
  list.add(type2);
  list.add(type3);
  this.strList = list;
  return strList;
 }

 public void setStrList(List<Type> strList) {
  this.strList = strList;
 }

 @Override
 public String execute() throws Exception {
  // TODO Auto-generated method stub
  return SUCCESS;
 }

}

 

 

Type:

 

package com.crm.bean;

 

public class Type {

 

 private String ID;//下拉框值
 private String name;//下拉框名称

 

 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;
 }

 

}

 

点击“修改”可修改该条信息,如图:

修改前:

技术分享

修改中:

技术分享

 

点击”性别“的下拉菜单可选择:

技术分享

技术分享

修改后:

技术分享

我基本没有遇到错误,遇到的都是些匹配错误,自己找找就调试好了,所以就不列举了。

 

这周的任务就结束了,下周要分组做项目,还要继续努力。

 

短学期第二篇随笔

标签:ram   ice   review   tco   eth   new   add   getc   stact   

原文地址:http://www.cnblogs.com/F-Victor/p/7106152.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!