首页>代码>ssm开发e律通律师事务所管理系统>/src/com/sxl/controller/admin/AdminCustomerController.java
package com.sxl.controller.admin;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sxl.controller.MyController;

@Controller("adminCustomerController")
@RequestMapping(value = "/admin/customer")
public class AdminCustomerController extends MyController {
	

	@RequestMapping(value = "/frame")
	public String frame(Model model, HttpServletRequest request)throws Exception {
		return "/admin/customer/frame";
	}
	
	@RequestMapping(value = "/list")
	public String list(Model model, HttpServletRequest request,String username,String customerName)throws Exception {
		String sql="select a.* from t_customer a where 1=1";


	if(username!=null&&!"".equals(username)){
			sql+=" and username like '%"+username+"%'";
		}
	if(customerName!=null&&!"".equals(customerName)){
			sql+=" and customerName like '%"+customerName+"%'";
		}
		sql+=" order by id desc";
		List list = db.queryForList(sql);
		request.setAttribute("list", list);
		return "/admin/customer/list";
	}
	
	@RequestMapping(value = "/editSave")
	public ResponseEntity<String> editSave(Model model,HttpServletRequest request,Long id
		,String username,String password,String customerName,String sex,String address,String phone,Integer account,Integer jf) throws Exception{
		int result = 0;
		if(id!=null){
			String sql="update t_customer set username=?,password=?,customerName=?,sex=?,address=?,phone=?,account=?,jf=? where id=?";
			result = db.update(sql, new Object[]{username,password,customerName,sex,address,phone,account,jf,id});
		}else{
			String sql="insert into t_customer(username,password,customerName,sex,address,phone,account,jf) values(?,?,?,?,?,?,?,?)";
			result = db.update(sql, new Object[]{username,password,customerName,sex,address,phone,account,jf});
		}
		if(result==1){
			return renderData(true,"操作成功",null);
		}else{
			return renderData(false,"操作失败",null);
		}
	}
	
	@RequestMapping(value = "/editDelete")
	public ResponseEntity<String> editDelete(Model model,HttpServletRequest request,Long id) throws Exception {
		
		String sql="delete from t_customer where id=?";
		int result = db.update(sql, new Object[]{id});
		if(result==1){
			return renderData(true,"操作成功",null);
		}else{
			return renderData(false,"操作失败",null);
		}
		
	}
	@RequestMapping(value = "/updateColumnsex")
	public ResponseEntity<String> updateColumnsex(Model model,HttpServletRequest request,Long id,String sex) throws Exception {
		
		String sql="update t_customer set sex=?   where id=?";
		int result = db.update(sql, new Object[]{sex,id});
		if(result==1){
			return renderData(true,"操作成功",null);
		}else{
			return renderData(false,"操作失败",null);
		}
		
	}
	
	@RequestMapping(value = "/edit")
	public String edit(Model model, HttpServletRequest request,Long id)throws Exception {
		if(id!=null){
			//修改
			String sql="select * from t_customer where id=?";
			Map map = db.queryForMap(sql,new Object[]{id});
			model.addAttribute("map", map);
		}String sql="";

		return "/admin/customer/edit";
	}
}
最近下载更多
peureux  LV1 3月15日
咩咩咩咩咩  LV2 2月22日
lilong007  LV20 2023年12月30日
zhuizi0000  LV1 2023年2月11日
testuser1234567  LV24 2022年5月23日
houliukou  LV37 2022年5月11日
109683670  LV9 2022年4月18日
一起来看火星雨  LV2 2022年3月25日
恒久乐  LV4 2022年3月3日
rodert  LV14 2022年2月16日
最近浏览更多
peureux  LV1 3月15日
咩咩咩咩咩  LV2 2月14日
orville 2月11日
暂无贡献等级
shuangfu  LV24 2023年12月2日
limenghaoqwer  LV2 2023年11月27日
Noah_aaa 2023年11月8日
暂无贡献等级
ha8018 2023年10月17日
暂无贡献等级
yichang123  LV1 2023年10月12日
zhaozhiqi  LV5 2023年10月2日
903201717 2023年9月12日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友