springboot 의 첨삭 검사 controller 계층 코드
                                            
 3419 단어  자바
                    
import java.io.IOException; import java.util.Date; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.wjh.dao.CommodityMapper; import com.wjh.dao.UserMapper; import com.wjh.dao.model.Commodity; import com.wjh.dao.model.CommodityExample; import com.wjh.dao.model.CommodityExample.Criteria; import com.wjh.dao.model.User; import com.wjh.untl.FileUtils;
@Controller public class CommodityController {
@Autowired
CommodityMapper comm;
@Autowired
UserMapper us;
@RequestMapping("login")
@ResponseBody
public int login(HttpSession session,User user) {
	User usr = us.login(user);
	
	if(usr!=null) {
		return 1;
	}else {
		return 0;
	}
	
}
@RequestMapping("/list") 
public String list(CommodityExample example,Model model,Commodity co,Integer current,Integer size) { 
	if(current == null) { 
		current = 1; 
	} 
	if(size == null) { 
		size = 4; 
	} 
	PageHelper.startPage(current, size); 
	if(co.getName()!= null) { 
		Criteria criteria =  example.createCriteria(); 
		
		 criteria.andNameLike("%"+co.getName()+"%"); 
	} 
	List list =comm.selectByExample(example); 
	PageInfo pageInfo = new  PageInfo(list); 
	model.addAttribute("current", current); 
	model.addAttribute("pageInfo", pageInfo); 
	model.addAttribute("co", co); 
	return "list"; 
}
/**
 *   
 * @return
 */
@RequestMapping("/del") 
@ResponseBody
public int del(int id) { 
	int i = comm.deleteByPrimaryKey(id);
	return i; 
}
/**
 *   
 * @return
 */
@RequestMapping("/dels") 
@ResponseBody
public int dels(String id) { 
	comm.dels(id);
	return 1; 
}
/**
 *       
 * @return
 */
@RequestMapping("/toadd") 
public String toadd() { 
	return "add"; 
}
/** 
 *    
 * @param br 
 * @return 
 */ 
@RequestMapping("/add") 
public String add(Commodity co,MultipartFile  file,HttpServletRequest request) throws 
 IllegalStateException, IOException{
	
	String str = FileUtils.upload(file, request); 
    String logo="http://localhost:8888/upload/"+str; 
    co.setCreationtime(new Date());
    co.setTurnovertime(new Date());
    co.setLogo(logo); 
	comm.insertSelective(co); 
	return "redirect:list"; 
}
@RequestMapping("/toupdate") 
public String toupdate(int id,Model model) { 
	Commodity co = comm.selectByPrimaryKey(id);
	model.addAttribute("co", co);
	return "update"; 
}
@RequestMapping("/update") 
public String update(Commodity co,MultipartFile file,HttpServletRequest request) throws 
 IllegalStateException ,IOException 
{  
	
	String str = FileUtils.upload(file, request); 
	String logo="http://localhost:8888/upload/"+str; 
	co.setLogo(logo);
	co.setTurnovertime(new Date());
	comm.updateByPrimaryKeySelective(co);
	
	return "redirect:list"; 
}
     }
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.