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

master
jyx 7 years ago
parent 4405e645ee
commit dbbce10951

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

@ -1,8 +1,20 @@
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
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
//@MapperScan("com.example.demo.Dao")
public class DemoApplication {

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

@ -1,7 +1,7 @@
package com.example.demo.productService.controller;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -20,11 +20,11 @@ public class addController extends HttpServlet {
Product product=new Product();
PrintWriter writer=null;
try{
product.setProductNum(Integer.parseInt(request.getParameter("productNum")));
product.setProductNum(Long.parseLong(request.getParameter("productNum")));
product.setProductName(request.getParameter("productName"));
product.setBankNum(Integer.parseInt(request.getParameter("bankNum")));
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.setPictureAddress(request.getParameter("address"));
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.productService.tools.deletePro;
import com.example.demo.productService.service.deletePro;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -14,7 +14,7 @@ import java.io.PrintWriter;
@Controller
public class deleteController {
@Autowired
private deletePro deletes;
deletePro deletes;
@RequestMapping("/deleteproduct")
public String doPost(HttpServletResponse response, HttpServletRequest request){
PrintWriter writer=null;

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

@ -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.productMapper;
import com.example.demo.bean.Product;
import com.example.demo.bean.ProductHistroy;
//@Service
public class updatePro {
private com.example.demo.productService.tools.nowTime nowTime;
// @Autowired
private com.example.demo.productService.service.nowTime nowTime;
// @Autowired
private productMapper productMapper;
//@Autowired
private productHistroyMapper proHisMapper;
//@Autowired
private ProductHistroy productHistroy;
public int update(Product product1){
Loading…
Cancel
Save