package com.friday.controller; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; import com.friday.model.Employee; import com.friday.service.StaffService; import com.friday.service.impl.StaffServiceImpl; public class AddStaffController implements Controller { @Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> model = new HashMap<String, Object>(); try { StaffService staffService = new StaffServiceImpl(); String name = request.getParameter("name"); String sex = request.getParameter("sex"); if (sex != null) { if ("a".equals(sex)) { sex = "男"; } else { sex = "女"; } } String phone = request.getParameter("phone"); String address = request.getParameter("address"); Float price = Float.parseFloat(request.getParameter("price")); String note = request.getParameter("note"); SimpleDateFormat simformat = new SimpleDateFormat("yyyy-MM-dd"); String strbirthday = request.getParameter("birthday"); Date birthday = simformat.parse(strbirthday); Employee employee = new Employee(); employee.seteAddress(address); employee.seteDate(birthday); employee.setePhone(phone); employee.setePrice(price); employee.seteSex(sex); employee.seteName(name); if (!"".equals(note.trim())) { employee.seteBz(note); } UUID uuid = UUID.randomUUID(); employee.seteId(uuid.toString()); staffService.addStaff(employee); model.put("result", "success"); model.put("success", "成功"); return new ModelAndView("success", model); } catch (Exception e) { model.put("result", "fail"); model.put("success", "失败"); e.printStackTrace(); return new ModelAndView("success", model); } } }

lyh1989 LV34
2024年12月12日
zolscy LV24
2024年11月26日
微信网友_7044194812350464 LV8
2024年9月13日
wanglinddad LV55
2024年4月10日
sunlea LV20
2024年3月21日
小海脑洞大开 LV11
2024年2月4日
dongandmin LV9
2023年7月12日
1379585889 LV11
2023年6月7日
lvdong2023 LV10
2023年5月17日
yzshabzbbdvw LV4
2023年5月16日

dddding yang LV6
昨天
nanjifeng8
7月8日
暂无贡献等级
luhong LV4
4月1日
可是不知道么 LV23
3月29日
哪里的完整版 LV8
3月1日
docnnxxy688
3月1日
暂无贡献等级
wpkm2008 LV13
1月17日
xiaoaitx LV8
1月1日
bankroll LV5
2024年12月16日
lyh1989 LV34
2024年12月12日