修改productService包里的类,实现addController消息传递成功

master
jyx 7 years ago
parent 4405e645ee
commit dbbce10951

@ -16,10 +16,10 @@ public interface productHistroyMapper {
@Select("select * from producthistroy") @Select("select * from producthistroy")
public List<ProductHistroy> select(); public List<ProductHistroy> select();
@Insert("insert into productHistroy(productNum, productName, category, " + @Insert("insert into producthistory(productNum, productName, category, " +
"intrate, bankNum, productDescription, uploadTime, deleteTime, alterTime,managerNum)" + "intrate, bankNum, productDescription, uploadTime, deleteTime, alterTime,managerNum)" +
" values (#{productNum},#{productName},#{category},#{intrate},#{bankNum}," + " values (#{productNum},#{productName},#{category},#{intrate},#{bankNum}," +
"#{productDescription},#{uploadTime},#{deleteTime},#{alterTime})") "#{productDescription},#{upLoadTime},#{deleteTime},#{alterTime},#{managerNum})")
public void addProductHistroy(ProductHistroy productHistroys); public void addProductHistroy(ProductHistroy productHistroys);
// @Update("update producthistroy set productNum=#{productNum},productName=#{productName}" + // @Update("update producthistroy set productNum=#{productNum},productName=#{productName}" +

@ -1,8 +1,20 @@
package com.example.demo; package com.example.demo;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAspectJAutoProxy
@EnableTransactionManagement
@EnableCaching
@EnableScheduling
@ServletComponentScan // 扫描使用注解方式的servlet
@SpringBootApplication @SpringBootApplication
//@MapperScan("com.example.demo.Dao") //@MapperScan("com.example.demo.Dao")
public class DemoApplication { public class DemoApplication {

@ -22,7 +22,7 @@ public class ProductHistroy {
private String category; private String category;
private float intrate; private float intrate;
private String productDescription; private String productDescription;
private String upLoadTime; private String upLoadTime; //数据库是小写的uploadTime
private String deleteTime; private String deleteTime;
private String alterTime; private String alterTime;

@ -1,7 +1,7 @@
package com.example.demo.productService.controller; package com.example.demo.productService.controller;
import com.example.demo.bean.Product; import com.example.demo.bean.Product;
import com.example.demo.productService.tools.addPro; import com.example.demo.productService.service.addPro;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -20,11 +20,11 @@ public class addController extends HttpServlet {
Product product=new Product(); Product product=new Product();
PrintWriter writer=null; PrintWriter writer=null;
try{ try{
product.setProductNum(Integer.parseInt(request.getParameter("productNum"))); product.setProductNum(Long.parseLong(request.getParameter("productNum")));
product.setProductName(request.getParameter("productName")); product.setProductName(request.getParameter("productName"));
product.setBankNum(Integer.parseInt(request.getParameter("bankNum"))); product.setBankNum(Integer.parseInt(request.getParameter("bankNum")));
product.setCategory(request.getParameter("productName")); product.setCategory(request.getParameter("productName"));
product.setIntrate(Integer.parseInt(request.getParameter("intrate"))); product.setIntrate(Float.parseFloat(request.getParameter("intrate")));
product.setProductDescription(request.getParameter("description")); product.setProductDescription(request.getParameter("description"));
product.setPictureAddress(request.getParameter("address")); product.setPictureAddress(request.getParameter("address"));
int result= addPro.add(product); int result= addPro.add(product);

@ -2,7 +2,7 @@ package com.example.demo.productService.controller;
import com.example.demo.bean.Product; import com.example.demo.bean.Product;
import com.example.demo.productService.tools.deletePro; import com.example.demo.productService.service.deletePro;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -14,7 +14,7 @@ import java.io.PrintWriter;
@Controller @Controller
public class deleteController { public class deleteController {
@Autowired @Autowired
private deletePro deletes; deletePro deletes;
@RequestMapping("/deleteproduct") @RequestMapping("/deleteproduct")
public String doPost(HttpServletResponse response, HttpServletRequest request){ public String doPost(HttpServletResponse response, HttpServletRequest request){
PrintWriter writer=null; PrintWriter writer=null;

@ -1,7 +1,7 @@
package com.example.demo.productService.controller; package com.example.demo.productService.controller;
import com.example.demo.bean.Product; import com.example.demo.bean.Product;
import com.example.demo.productService.tools.updatePro; import com.example.demo.productService.service.updatePro;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;

@ -1,22 +1,22 @@
package com.example.demo.productService.tools; package com.example.demo.productService.service;
import com.example.demo.Dao.productHistroyMapper; import com.example.demo.Dao.productHistroyMapper;
import com.example.demo.Dao.productMapper; import com.example.demo.Dao.productMapper;
import com.example.demo.bean.Product; import com.example.demo.bean.Product;
import com.example.demo.bean.ProductHistroy; import com.example.demo.bean.ProductHistroy;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class addPro { public class addPro {
private nowTime nowTime=new nowTime(); private nowTime nowTime=new nowTime();
@Autowired @Autowired
private productMapper productMapper; private productMapper productMapper;
@Autowired @Autowired
private productHistroyMapper proHisMapper; private productHistroyMapper proHisMapper;
@Autowired
private ProductHistroy productHistroy;
public int add(Product product1){ public int add(Product product1){
ProductHistroy productHistroy = new ProductHistroy();
productMapper.addProduct(product1); productMapper.addProduct(product1);
productHistroy.setProductNum(product1.getProductNum()); productHistroy.setProductNum(product1.getProductNum());
productHistroy.setProductName(product1.getProductName()); productHistroy.setProductName(product1.getProductName());
@ -26,6 +26,7 @@ public class addPro {
//productHistroy.setManagerNum(); manager.setManagerNum();调用登陆里面的一个接口得到managerNum //productHistroy.setManagerNum(); manager.setManagerNum();调用登陆里面的一个接口得到managerNum
productHistroy.setProductDescription(product1.getProductDescription()); productHistroy.setProductDescription(product1.getProductDescription());
productHistroy.setUpLoadTime(nowTime.nowTime()); productHistroy.setUpLoadTime(nowTime.nowTime());
//System.out.println(productHistroy.getUpLoadTime()+productHistroy.getBankNum());
proHisMapper.addProductHistroy(productHistroy); proHisMapper.addProductHistroy(productHistroy);
return 1; return 1;
} }

@ -1,12 +1,17 @@
package com.example.demo.productService.tools; package com.example.demo.productService.service;
import com.example.demo.Dao.productHistroyMapper; import com.example.demo.Dao.productHistroyMapper;
import com.example.demo.bean.ProductHistroy; import com.example.demo.bean.ProductHistroy;
//@Service
public class deletePro { public class deletePro {
private com.example.demo.productService.tools.nowTime nowTime; // @Autowired
private com.example.demo.productService.service.nowTime nowTime;
// @Autowired
private com.example.demo.Dao.productMapper productMapper; private com.example.demo.Dao.productMapper productMapper;
// @Autowired
private productHistroyMapper proHisMapper; private productHistroyMapper proHisMapper;
//@Autowired
private ProductHistroy productHistroy; private ProductHistroy productHistroy;
public int delete(int productNum){ public int delete(int productNum){

@ -1,4 +1,4 @@
package com.example.demo.productService.tools; package com.example.demo.productService.service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;

@ -1,14 +1,19 @@
package com.example.demo.productService.tools; package com.example.demo.productService.service;
import com.example.demo.Dao.productHistroyMapper; import com.example.demo.Dao.productHistroyMapper;
import com.example.demo.Dao.productMapper; import com.example.demo.Dao.productMapper;
import com.example.demo.bean.Product; import com.example.demo.bean.Product;
import com.example.demo.bean.ProductHistroy; import com.example.demo.bean.ProductHistroy;
//@Service
public class updatePro { public class updatePro {
private com.example.demo.productService.tools.nowTime nowTime; // @Autowired
private com.example.demo.productService.service.nowTime nowTime;
// @Autowired
private productMapper productMapper; private productMapper productMapper;
//@Autowired
private productHistroyMapper proHisMapper; private productHistroyMapper proHisMapper;
//@Autowired
private ProductHistroy productHistroy; private ProductHistroy productHistroy;
public int update(Product product1){ public int update(Product product1){
Loading…
Cancel
Save