Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程
該系統(tǒng)分為前臺和后臺,前臺可以自主注冊,后臺管理員角色,除基礎(chǔ)腳手架外,實現(xiàn)的功能有:
后臺管理員功能有:
商品分類管理、商品管理、套餐管理、新聞分類管理、新聞管理、常見問題、關(guān)于我們、團(tuán)隊管理、訂單查看和前臺用戶查看等功能。
前臺用戶功能有:注冊登錄、查看商品、購物車、支付訂單、評價、照片庫、新聞列表、個人中心、購買套餐等功能。
運行環(huán)境:windows/Linux均可、jdk1.8、mysql5.7、maven3.5\maven3.6、idea/eclipse均可。






系統(tǒng)控制器代碼:
/**
* 系統(tǒng)控制器
* @author Admin
*
*/
@RequestMapping("/system")
@Controller
public class SystemController {
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private UserService userService;
@Autowired
private DatabaseBakService databaseBakService;
@Autowired
private StaffService staffService;
@Autowired
private OrderAuthService orderAuthService;
private Logger log = LoggerFactory.getLogger(SystemController.class);
/**
* 登錄頁面
* @param model
* @return
*/
@RequestMapping(value="/login",method=RequestMethod.GET)
public String login(Model model){
model.addAttribute("loginTypes", LoginType.values());
return "admin/system/login";
}
/**
* 用戶登錄提交表單處理方法
* @param request
* @param cpacha
* @return
*/
@RequestMapping(value="/login",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> login(HttpServletRequest request,String username,String password,String cpacha,Integer type){
if(StringUtils.isEmpty(username)){
return Result.error(CodeMsg.ADMIN_USERNAME_EMPTY);
}
if(StringUtils.isEmpty(password)){
return Result.error(CodeMsg.ADMIN_PASSWORD_EMPTY);
}
//表示實體信息合法,開始驗證驗證碼是否為空
if(StringUtils.isEmpty(cpacha)){
return Result.error(CodeMsg.CPACHA_EMPTY);
}
//說明驗證碼不為空,從session里獲取驗證碼
Object attribute = request.getSession().getAttribute("admin_login");
if(attribute == null){
return Result.error(CodeMsg.SESSION_EXPIRED);
}
//表示session未失效,進(jìn)一步判斷用戶填寫的驗證碼是否正確
if(!cpacha.equalsIgnoreCase(attribute.toString())){
return Result.error(CodeMsg.CPACHA_ERROR);
}
if(type == LoginType.ADMINISTRATOR.getCode()){
//表示驗證碼正確,開始查詢數(shù)據(jù)庫,檢驗密碼是否正確
User findByUsername = userService.findByUsername(username);
//判斷是否為空
if(findByUsername == null){
return Result.error(CodeMsg.ADMIN_USERNAME_NO_EXIST);
}
//表示用戶存在,進(jìn)一步對比密碼是否正確
if(!findByUsername.getPassword().equals(password)){
return Result.error(CodeMsg.ADMIN_PASSWORD_ERROR);
}
//表示密碼正確,接下來判斷用戶狀態(tài)是否可用
if(findByUsername.getStatus() == User.ADMIN_USER_STATUS_UNABLE){
return Result.error(CodeMsg.ADMIN_USER_UNABLE);
}
//檢查用戶所屬角色狀態(tài)是否可用
if(findByUsername.getRole() == null || findByUsername.getRole().getStatus() == Role.ADMIN_ROLE_STATUS_UNABLE){
return Result.error(CodeMsg.ADMIN_USER_ROLE_UNABLE);
}
//檢查用戶所屬角色的權(quán)限是否存在
if(findByUsername.getRole().getAuthorities() == null || findByUsername.getRole().getAuthorities().size() == 0){
return Result.error(CodeMsg.ADMIN_USER_ROLE_AUTHORITES_EMPTY);
}
//檢查一切符合,可以登錄,將用戶信息存放至session
request.getSession().setAttribute(SessionConstant.SESSION_USER_LOGIN_KEY, findByUsername);
request.getSession().setAttribute("loginType",type);
//銷毀session中的驗證碼
request.getSession().setAttribute("admin_login", null);
//將登陸記錄寫入日志庫
operaterLogService.add("用戶【"+username+"】于【" + StringUtil.getFormatterDate(new Date(), "yyyy-MM-dd HH:mm:ss") + "】登錄系統(tǒng)!");
log.info("用戶成功登錄,user = " + findByUsername);
}else{
Staff byJobNumber = staffService.findByNameAndIsStatus(username);
//判斷是否為空
if(byJobNumber == null){
return Result.error(CodeMsg.ADMIN_USERNAME_NO_EXIST);
}
//表示用戶存在,進(jìn)一步對比密碼是否正確
if(!byJobNumber.getPassword().equals(password)){
return Result.error(CodeMsg.ADMIN_PASSWORD_ERROR);
}
//檢查用戶所屬角色狀態(tài)是否可用
if(byJobNumber.getRole() == null || byJobNumber.getRole().getStatus() == Role.ADMIN_ROLE_STATUS_UNABLE){
return Result.error(CodeMsg.ADMIN_USER_ROLE_UNABLE);
}
//檢查用戶所屬角色的權(quán)限是否存在
if(byJobNumber.getRole().getAuthorities() == null || byJobNumber.getRole().getAuthorities().size() == 0){
return Result.error(CodeMsg.ADMIN_USER_ROLE_AUTHORITES_EMPTY);
}
//檢查一切符合,可以登錄,將用戶信息存放至session
request.getSession().setAttribute(SessionConstant.SESSION_STAFF_LOGIN_KEY, byJobNumber);
request.getSession().setAttribute("loginType",type);
//銷毀session中的驗證碼
request.getSession().setAttribute("admin_login", null);
//將登陸記錄寫入日志庫
operaterLogService.add("用戶【"+username+"】于【" + StringUtil.getFormatterDate(new Date(), "yyyy-MM-dd HH:mm:ss") + "】登錄系統(tǒng)!");
log.info("員工成功登錄,user = " + byJobNumber);
}
return Result.success(true);
}
/**
* 登錄成功后的系統(tǒng)主頁
* @param model
* @return
*/
@RequestMapping(value="/index")
public String index(Model model){
model.addAttribute("operatorLogs", operaterLogService.findLastestLog(10));
model.addAttribute("userTotal", userService.total());
model.addAttribute("operatorLogTotal", operaterLogService.total());
model.addAttribute("databaseBackupTotal", databaseBakService.total());
model.addAttribute("onlineUserTotal", SessionListener.onlineUserCount);
return "admin/system/index";
}
/**
* 注銷登錄
* @return
*/
@RequestMapping(value="/logout")
public String logout(){
Integer loginType = (Integer) SessionUtil.get("loginType");
if(loginType == LoginType.ADMINISTRATOR.getCode()){
User loginedUser = SessionUtil.getLoginedUser();
if(loginedUser != null){
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, null);
}
}else if(loginType == LoginType.STAFF.getCode()){
Staff loginedStaff = SessionUtil.getLoginedStaff();
if(loginedStaff != null){
SessionUtil.set(SessionConstant.SESSION_STAFF_LOGIN_KEY,null);
}
}
return "redirect:login";
}
/**
* 無權(quán)限提示頁面
* @return
*/
@RequestMapping(value="/no_right")
public String noRight(){
return "admin/system/no_right";
}
/**
* 修改用戶個人信息
* @return
*/
@RequestMapping(value="/update_userinfo",method=RequestMethod.GET)
public String updateUserInfo(){
return "admin/system/update_userinfo";
}
/**
* 修改個人信息保存
* @param user
* @return
*/
@RequestMapping(value="/update_userinfo",method=RequestMethod.POST)
public String updateUserInfo(User user){
User loginedUser = SessionUtil.getLoginedUser();
loginedUser.setEmail(user.getEmail());
loginedUser.setMobile(user.getMobile());
loginedUser.setHeadPic(user.getHeadPic());
//首先保存到數(shù)據(jù)庫
userService.save(loginedUser);
//更新session里的值
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, loginedUser);
return "redirect:update_userinfo";
}
/**
* 修改密碼頁面
* @return
*/
@RequestMapping(value="/update_pwd",method=RequestMethod.GET)
public String updatePwd(){
return "admin/system/update_pwd";
}
/**
* 修改密碼表單提交
* @param oldPwd
* @param newPwd
* @return
*/
@RequestMapping(value="/update_pwd",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> updatePwd(@RequestParam(name="oldPwd",required=true)String oldPwd,
@RequestParam(name="newPwd",required=true)String newPwd
){
Integer loginType = (Integer) SessionUtil.get("loginType");
if(loginType == LoginType.ADMINISTRATOR.getCode()){
User loginedUser = SessionUtil.getLoginedUser();
if(!loginedUser.getPassword().equals(oldPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);
}
if(StringUtils.isEmpty(newPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);
}
if(newPwd.length()<4 || newPwd.length()>32){
return Result.error(CodeMsg.ADMIN_USER_PWD_LENGTH_ERROR);
}
loginedUser.setPassword(newPwd);
//保存數(shù)據(jù)庫
userService.save(loginedUser);
//更新session
SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, loginedUser);
}else{
Staff loginedStaff = SessionUtil.getLoginedStaff();
Staff staff = staffService.find(loginedStaff.getId());
if(!staff.getPassword().equals(oldPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);
}
if(StringUtils.isEmpty(newPwd)){
return Result.error(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);
}
staff.setPassword(newPwd);
CodeMsg codeMsg = ValidateEntityUtil.validate(staff);
if (codeMsg.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(codeMsg);
}
loginedStaff.setPassword(newPwd);
//保存數(shù)據(jù)庫
staffService.save(loginedStaff);
//更新session
SessionUtil.set(SessionConstant.SESSION_STAFF_LOGIN_KEY, loginedStaff);
}
return Result.success(true);
}
/**
* 日志管理列表
* @param model
* @param operaterLog
* @param pageBean
* @return
*/
@RequestMapping(value="/operator_log_list")
public String operatorLogList(Model model,OperaterLog operaterLog,PageBean<OperaterLog> pageBean){
model.addAttribute("pageBean", operaterLogService.findList(operaterLog, pageBean));
model.addAttribute("operator", operaterLog.getOperator());
model.addAttribute("title", "日志列表");
return "admin/system/operator_log_list";
}
/**
* 刪除操作日志,可刪除多個
* @param ids
* @return
*/
@RequestMapping(value="/delete_operator_log",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(String ids){
if(!StringUtils.isEmpty(ids)){
String[] splitIds = ids.split(",");
for(String id : splitIds){
operaterLogService.delete(Long.valueOf(id));
}
}
return Result.success(true);
}
/**
* 清空整個日志
* @return
*/
@RequestMapping(value="/delete_all_operator_log",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> deleteAll(){
operaterLogService.deleteAll();
return Result.success(true);
}
}用戶控制:
/**
* 用戶控制
*/
@Controller("User")
@RequestMapping("/user")
public class UserController {
private final Logger logger = LoggerFactory.getLogger(UserController.class);
private final ResultMap resultMap;
@Autowired
private UserService userService;
@Autowired
private UserRoleService userRoleService;
@Autowired
public UserController(ResultMap resultMap) {
this.resultMap = resultMap;
}
/**
* 返回有權(quán)限信息
*/
@RequestMapping(value = "/getMessage", method = RequestMethod.GET)
public ResultMap getMessage() {
return resultMap.success().message("您擁有用戶權(quán)限,可以獲得該接口的信息!");
}
/**
* 修改用戶信息頁面user/userEdit.html
*/
@RequestMapping(value = "/editUserPage")
public String editUserPage(Long userId, Model model) {
model.addAttribute("manageUser", userId);
if (null != userId) {
User user = userService.selectByPrimaryKey(userId);
model.addAttribute("manageUser", user);
}
return "user/userEdit";
}
/**
* 更新數(shù)據(jù)庫
*/
@ResponseBody
@RequestMapping("/updateUser")
public String updateUser(User user) {
return userService.updateUser(user);
}
}健康評估控制層:
/**
* 健康評估
*/
@Controller("HealthController")
@RequestMapping("/health")
public class HealthController {
@Autowired
private DiagnosisService diagnosisService;
@Autowired
private AppointmentService appointmentService;
@Autowired
private PetService petService;
@Autowired
private PetDailyService petDailyService;
@Autowired
private UserService userService;
@Autowired
private StandardService standardService;
/**
* 分析頁面
*/
@RequestMapping("/assess")
public String applyListDoctor(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
Pet pet = new Pet();
pet.setUserId(user.getId());
pet.setPage(1);
pet.setLimit(100);
MMGridPageVoBean<Pet> voBean = (MMGridPageVoBean<Pet>) petService.getAllByLimit(pet);
List<Pet> rows = voBean.getRows();
// 獲取到該用戶下所有的寵物
model.addAttribute("pets", rows);
List<Long> applyCount = new ArrayList<>();
List<String> dsCount = new ArrayList<>();
List<String> tsCount = new ArrayList<>();
List<String> wsCount = new ArrayList<>();
List<String> hsCount = new ArrayList<>();
List<String> asCount = new ArrayList<>();
List<Double> pt = new ArrayList<>();
List<Double> pw = new ArrayList<>();
List<Double> ph = new ArrayList<>();
List<Double> pa = new ArrayList<>();
List<Double> mt = new ArrayList<>();
List<Double> mw = new ArrayList<>();
List<Double> mh = new ArrayList<>();
List<Double> ma = new ArrayList<>();
for(Pet p: rows){
// 獲取預(yù)約次數(shù)
Appointment appointment = new Appointment();
appointment.setPetId(p.getId());
appointment.setPage(1);
appointment.setLimit(1000);
MMGridPageVoBean<Appointment> as = (MMGridPageVoBean<Appointment>) appointmentService.getAllByLimit(appointment);
applyCount.add(as==null? 0L : as.getTotal());
// 獲取就診記錄
Diagnosis diagnosis = new Diagnosis();
diagnosis.setPetId(p.getId());
diagnosis.setPage(1);
diagnosis.setLimit(10);
MMGridPageVoBean<Diagnosis> ds = (MMGridPageVoBean<Diagnosis>) diagnosisService.getAllByLimit(diagnosis);
List<Diagnosis> dsRows = ds.getRows();
int diagnosisStatus = 0;
for (Diagnosis d: dsRows){
diagnosisStatus += d.getStatus();
}
int sw = diagnosisStatus / dsRows.size();
switch (sw){
case 1:dsCount.add(p.getName() + " 寵物健康,請繼續(xù)保持");break;
case 2:dsCount.add(p.getName() + " 寵物異常請及時就診!");break;
case 3:dsCount.add(p.getName() + " 寵物病情比較嚴(yán)重,請及時就醫(yī)!");break;
case 4:dsCount.add(p.getName() + " 很抱歉寵物已無法治療!");break;
default:dsCount.add(p.getName() + " 寵物基本健康,請繼續(xù)保持");break;
}
// 獲取寵物日志
PetDaily petDaily = new PetDaily();
petDaily.setPetId(p.getId());
petDaily.setPage(1);
petDaily.setLimit(10);
MMGridPageVoBean<PetDaily> ps = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(petDaily);
List<PetDaily> psRows = ps.getRows();
double t = 0;
double w = 0;
double h = 0;
double a = 0;
for (PetDaily petDaily1 : psRows){
t+=petDaily1.getTemperature();
w+=petDaily1.getWeight();
h+=petDaily1.getHeight();
a+=petDaily1.getAppetite();
}
t = t/psRows.size();
w = w/psRows.size();
h = h/psRows.size();
a = a/psRows.size();
pt.add(t);
pw.add(w);
ph.add(h);
pa.add(a);
// 獲取標(biāo)準(zhǔn)
Standard standard = new Standard();
// 對應(yīng)寵物類型
standard.setType(p.getType());
// 健康標(biāo)準(zhǔn)
standard.setStatus(1);
int petAge = MyUtils.get2DateDay(MyUtils.getDate2String(p.getBirthday(), "yyyy-MM-dd"), MyUtils.getDate2String(new Date(), "yyyy-MM-dd"));
petAge = (petAge<0? -petAge : petAge)/365;
// 年齡
standard.setAgeMax(petAge);
standard.setPage(1);
standard.setLimit(100);
MMGridPageVoBean<Standard> ss = (MMGridPageVoBean<Standard>) standardService.getAllByLimit(standard);
List<Standard> ssRows = ss.getRows();
double tsMin = 0;
double tsMax = 0;
double wsMin = 0;
double wsMax = 0;
double hsMin = 0;
double hsMax = 0;
double asMin = 0;
double asMax = 0;
for (Standard s : ssRows){
tsMin+=s.getTempMin();
tsMax+=s.getTempMax();
wsMin+=s.getWeightMin();
wsMax+=s.getWeightMax();
hsMin+=s.getHeightMin();
hsMax+=s.getHeightMax();
asMin+=s.getAppetiteMin();
asMax+=s.getAppetiteMax();
}
tsMin = tsMin / ssRows.size();
tsMax = tsMax / ssRows.size();
wsMin = wsMin / ssRows.size();
wsMax = wsMax / ssRows.size();
hsMin = hsMin / ssRows.size();
hsMax = hsMax / ssRows.size();
asMin = asMin / ssRows.size();
asMax = asMax / ssRows.size();
mt.add(tsMax);
mw.add(wsMax);
mh.add(hsMax);
ma.add(asMax);
if (t>=tsMin && t<=tsMax){
tsCount.add(" 體溫正常");
}else if (t<tsMin){
tsCount.add( " 體溫偏低");
}else if (t>tsMax){
tsCount.add( " 體溫偏高");
}
if (w>=wsMin && w<=wsMax){
wsCount.add( " 體重正常");
}else if (w<wsMin){
wsCount.add(" 體重偏低");
}else if (w>wsMax){
wsCount.add(" 體重偏高");
}
if (h>=hsMin && h<=hsMax){
hsCount.add(" 身高正常");
}else if (h<hsMin){
hsCount.add( " 身高偏低");
}else if (h>hsMax){
hsCount.add(" 身高偏高");
}
if (a>=asMin && a<=asMax){
asCount.add( " 飯量正常");
}else if (a<asMin){
asCount.add(" 飯量偏低");
}else if (a>asMax){
asCount.add(" 飯量偏高");
}
}
model.addAttribute("pets", rows);
model.addAttribute("tsCount", tsCount);
model.addAttribute("wsCount", wsCount);
model.addAttribute("hsCount", hsCount);
model.addAttribute("asCount", asCount);
model.addAttribute("dsCount", dsCount);
System.out.println(pt);
model.addAttribute("pt", pt);
model.addAttribute("ph", ph);
model.addAttribute("pw", pw);
model.addAttribute("pa", pa);
model.addAttribute("mt", mt);
model.addAttribute("mh", mh);
model.addAttribute("mw", mw);
model.addAttribute("ma", ma);
return "tj/assess";
}
/**
* 普通用戶預(yù)約統(tǒng)計
*/
@RequestMapping("/tjApply")
public String tjApply(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
Appointment appointment = new Appointment();
appointment.setUserId(user.getId());
appointment.setPage(1);
appointment.setLimit(99999);
MMGridPageVoBean<Appointment> voBean = (MMGridPageVoBean<Appointment>) appointmentService.getAllByLimit(appointment);
List<Appointment> rows = voBean.getRows();
Integer a1 = 0;
Integer a2 = 0;
Integer a3 = 0;
Integer a4 = 0;
for (Appointment a: rows){
switch (a.getStatus()){
case 1: a1++;break;
case 2: a2++;break;
case 3: a3++;break;
case 4: a4++;break;
}
}
model.addAttribute("a1", a1);
model.addAttribute("a2", a2);
model.addAttribute("a3", a3);
model.addAttribute("a4", a4);
return "tj/tjApply";
}
/**
* 醫(yī)生預(yù)約統(tǒng)計
*/
@RequestMapping("/tjApplyDoctor")
public String tjApplyDoctor(Model model) {
Appointment appointment = new Appointment();
appointment.setPage(1);
appointment.setLimit(99999);
MMGridPageVoBean<Appointment> voBean = (MMGridPageVoBean<Appointment>) appointmentService.getAllByLimit(appointment);
List<Appointment> rows = voBean.getRows();
Integer a1 = 0;
Integer a2 = 0;
Integer a3 = 0;
Integer a4 = 0;
for (Appointment a: rows){
switch (a.getStatus()){
case 1: a1++;break;
case 2: a2++;break;
case 3: a3++;break;
case 4: a4++;break;
}
}
model.addAttribute("a1", a1);
model.addAttribute("a2", a2);
model.addAttribute("a3", a3);
model.addAttribute("a4", a4);
return "tj/tjApplyDoctor";
}
/**
* 普通用戶寵物日志統(tǒng)計
*/
@RequestMapping("/tjDaily")
public String tjDaily(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
Pet pet = new Pet();
pet.setUserId(user.getId());
pet.setPage(1);
pet.setLimit(99999);
MMGridPageVoBean<Pet> voBean = (MMGridPageVoBean<Pet>) petService.getAllByLimit(pet);
List<Pet> rows = voBean.getRows();
model.addAttribute("pets", rows);
if (rows.size()>0){
pet = rows.get(0);
PetDaily daily = new PetDaily();
daily.setPetId(pet.getId());
daily.setPage(1);
daily.setLimit(99999);
MMGridPageVoBean<PetDaily> ppp = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(daily);
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
model.addAttribute("dailys", list);
}
return "tj/tjDaily";
}
/**
* 醫(yī)生寵物日志統(tǒng)計
*/
@RequestMapping("/tjDailyDoctor")
public String tjDailyDoctor(Model model) {
Pet pet = new Pet();
pet.setPage(1);
pet.setLimit(99999);
MMGridPageVoBean<Pet> voBean = (MMGridPageVoBean<Pet>) petService.getAllByLimit(pet);
List<Pet> rows = voBean.getRows();
model.addAttribute("pets", rows);
if (rows.size()>0){
pet = rows.get(0);
PetDaily daily = new PetDaily();
daily.setPetId(pet.getId());
daily.setPage(1);
daily.setLimit(99999);
MMGridPageVoBean<PetDaily> ppp = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(daily);
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
model.addAttribute("dailys", list);
}
return "tj/tjDailyDoctor";
}
/**
* 普通用戶查詢條件數(shù)據(jù)返回寵物日志
*/
@RequestMapping("/tjDailyData")
@ResponseBody
public Object tjDailyData(Long id){
PetDaily daily = new PetDaily();
daily.setPetId(id);
daily.setPage(1);
daily.setLimit(99999);
MMGridPageVoBean<PetDaily> ppp = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(daily);
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
return list;
}
/**
* 醫(yī)生查詢條件數(shù)據(jù)返回寵物日志
*/
@RequestMapping("/tjDailyDataDoctor")
@ResponseBody
public Object tjDailyDataDoctor(Long id){
PetDaily daily = new PetDaily();
daily.setPetId(id);
daily.setPage(1);
daily.setLimit(99999);
MMGridPageVoBean<PetDaily> ppp = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(daily);
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
return list;
}
/**
* 用戶查看醫(yī)生空閑時間
*/
@RequestMapping(value = "/freeTime")
public String freeTime(Model model) {
List<User> doctors = userService.listDoctor();
model.addAttribute("doctors", doctors);
Long docId = doctors.get(0).getId();
model.addAttribute("docName", doctors.get(0).getName());
String nowDateYMD = MyUtils.getNowDateYMD();
List<Map<String, Object>> map = appointmentService.getFreeTimeById(docId, nowDateYMD+MyUtils.START_HOUR);
List<String> time = new ArrayList<>();
List<Long> value = new ArrayList<>();
for (Map<String, Object> m : map){
String df = (String) m.get("df");
time.add(df);
Long v = (Long) m.get("c");
if (v == null) {
value.add(0L);
}else {
value.add(v);
}
}
model.addAttribute("time", time);
model.addAttribute("value", value);
return "tj/freeTime";
}
@RequestMapping(value = "/getFreeTime")
@ResponseBody
public Object getFreeTime(Long id, String date) {
User doctors = userService.selectByPrimaryKey(id);
Map<String, Object> result = new HashMap<>();
result.put("n", doctors.getName());
List<Map<String, Object>> map = appointmentService.getFreeTimeById(id, date+MyUtils.START_HOUR);
List<String> time = new ArrayList<>();
List<Long> value = new ArrayList<>();
for (Map<String, Object> m : map){
String df = (String) m.get("df");
time.add(df+"點");
Long v = (Long) m.get("c");
if (v == null) {
value.add(0L);
}else {
value.add(v);
}
}
result.put("t", time);
result.put("v", value);
return result;
}
}到此這篇關(guān)于Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程的文章就介紹到這了,更多相關(guān)Java 寵物在線交易內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Java 實戰(zhàn)項目錘煉之網(wǎng)上花店商城的實現(xiàn)流程
- Java實戰(zhàn)角色權(quán)限后臺腳手架系統(tǒng)的實現(xiàn)流程
- Java實戰(zhàn)權(quán)限管理系統(tǒng)的實現(xiàn)流程
- Java實戰(zhàn)個人博客系統(tǒng)的實現(xiàn)流程
- Java實戰(zhàn)寵物醫(yī)院預(yù)約掛號系統(tǒng)的實現(xiàn)流程
- Java實戰(zhàn)玩具商城的前臺與后臺實現(xiàn)流程
- Java實戰(zhàn)網(wǎng)上電子書城的實現(xiàn)流程
- Java實戰(zhàn)項目練習(xí)之球館在線預(yù)約系統(tǒng)的實現(xiàn)
- Java實戰(zhàn)花店商城系統(tǒng)的實現(xiàn)流程
相關(guān)文章
深度解析Spring內(nèi)置作用域及其在實踐中的應(yīng)用
這篇文章主要詳細(xì)介紹了Spring內(nèi)置的作用域類型及其在實踐中的應(yīng)用,文中有詳細(xì)的代碼示例,對我們的餓學(xué)習(xí)或工作有一定的參考價值,感興趣的同學(xué)可以借鑒閱讀2023-06-06
MyBatis?Generator快速生成實體類和映射文件的方法
這篇文章主要介紹了MyBatis?Generator快速生成實體類和映射文件的方法,通過示例代碼介紹了MyBatis?Generator?的使用,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-10-10
Javaweb EL自定義函數(shù)開發(fā)及代碼實例
這篇文章主要介紹了Javaweb EL自定義函數(shù)開發(fā)及代碼實例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-06-06

