Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程_第1頁
Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程_第2頁
Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程_第3頁
Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程_第4頁
Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程_第5頁
已閱讀5頁,還剩16頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

第Java實戰(zhàn)寵物店在線交易平臺的實現(xiàn)流程@RequestMapping(value=/login,method=RequestMethod.GET)

publicStringlogin(Modelmodel){

model.addAttribute(loginTypes,LoginType.values());

returnadmin/system/login

*用戶登錄提交表單處理方法

*@paramrequest

*@paramcpacha

*@return

@RequestMapping(value=/login,method=RequestMethod.POST)

@ResponseBody

publicResultBooleanlogin(HttpServletRequestrequest,Stringusername,Stringpassword,Stringcpacha,Integertype){

if(StringUtils.isEmpty(username)){

returnResult.error(CodeMsg.ADMIN_USERNAME_EMPTY);

if(StringUtils.isEmpty(password)){

returnResult.error(CodeMsg.ADMIN_PASSWORD_EMPTY);

//表示實體信息合法,開始驗證驗證碼是否為空

if(StringUtils.isEmpty(cpacha)){

returnResult.error(CodeMsg.CPACHA_EMPTY);

//說明驗證碼不為空,從session里獲取驗證碼

Objectattribute=request.getSession().getAttribute(admin_login

if(attribute==null){

returnResult.error(CodeMsg.SESSION_EXPIRED);

//表示session未失效,進一步判斷用戶填寫的驗證碼是否正確

if(!cpacha.equalsIgnoreCase(attribute.toString())){

returnResult.error(CodeMsg.CPACHA_ERROR);

if(type==LoginType.ADMINISTRATOR.getCode()){

//表示驗證碼正確,開始查詢數(shù)據(jù)庫,檢驗密碼是否正確

UserfindByUsername=userService.findByUsername(username);

//判斷是否為空

if(findByUsername==null){

returnResult.error(CodeMsg.ADMIN_USERNAME_NO_EXIST);

//表示用戶存在,進一步對比密碼是否正確

if(!findByUsername.getPassword().equals(password)){

returnResult.error(CodeMsg.ADMIN_PASSWORD_ERROR);

//表示密碼正確,接下來判斷用戶狀態(tài)是否可用

if(findByUsername.getStatus()==User.ADMIN_USER_STATUS_UNABLE){

returnResult.error(CodeMsg.ADMIN_USER_UNABLE);

//檢查用戶所屬角色狀態(tài)是否可用

if(findByUsername.getRole()==null||findByUsername.getRole().getStatus()==Role.ADMIN_ROLE_STATUS_UNABLE){

returnResult.error(CodeMsg.ADMIN_USER_ROLE_UNABLE);

//檢查用戶所屬角色的權限是否存在

if(findByUsername.getRole().getAuthorities()==null||findByUsername.getRole().getAuthorities().size()==0){

returnResult.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(newDate(),yyyy-MM-ddHH:mm:ss)+】登錄系統(tǒng)!

(用戶成功登錄,user=+findByUsername);

}else{

StaffbyJobNumber=staffService.findByNameAndIsStatus(username);

//判斷是否為空

if(byJobNumber==null){

returnResult.error(CodeMsg.ADMIN_USERNAME_NO_EXIST);

//表示用戶存在,進一步對比密碼是否正確

if(!byJobNumber.getPassword().equals(password)){

returnResult.error(CodeMsg.ADMIN_PASSWORD_ERROR);

//檢查用戶所屬角色狀態(tài)是否可用

if(byJobNumber.getRole()==null||byJobNumber.getRole().getStatus()==Role.ADMIN_ROLE_STATUS_UNABLE){

returnResult.error(CodeMsg.ADMIN_USER_ROLE_UNABLE);

//檢查用戶所屬角色的權限是否存在

if(byJobNumber.getRole().getAuthorities()==null||byJobNumber.getRole().getAuthorities().size()==0){

returnResult.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(newDate(),yyyy-MM-ddHH:mm:ss)+】登錄系統(tǒng)!

(員工成功登錄,user=+byJobNumber);

returnResult.success(true);

*登錄成功后的系統(tǒng)主頁

*@parammodel

*@return

@RequestMapping(value=/index)

publicStringindex(Modelmodel){

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);

returnadmin/system/index

*注銷登錄

*@return

@RequestMapping(value=/logout)

publicStringlogout(){

IntegerloginType=(Integer)SessionUtil.get(loginType

if(loginType==LoginType.ADMINISTRATOR.getCode()){

UserloginedUser=SessionUtil.getLoginedUser();

if(loginedUser!=null){

SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY,null);

}elseif(loginType==LoginType.STAFF.getCode()){

StaffloginedStaff=SessionUtil.getLoginedStaff();

if(loginedStaff!=null){

SessionUtil.set(SessionConstant.SESSION_STAFF_LOGIN_KEY,null);

returnredirect:login

*無權限提示頁面

*@return

@RequestMapping(value=/no_right)

publicStringnoRight(){

returnadmin/system/no_right

*修改用戶個人信息

*@return

@RequestMapping(value=/update_userinfo,method=RequestMethod.GET)

publicStringupdateUserInfo(){

returnadmin/system/update_userinfo

*修改個人信息保存

*@paramuser

*@return

@RequestMapping(value=/update_userinfo,method=RequestMethod.POST)

publicStringupdateUserInfo(Useruser){

UserloginedUser=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);

returnredirect:update_userinfo

*修改密碼頁面

*@return

@RequestMapping(value=/update_pwd,method=RequestMethod.GET)

publicStringupdatePwd(){

returnadmin/system/update_pwd

*修改密碼表單提交

*@paramoldPwd

*@paramnewPwd

*@return

@RequestMapping(value=/update_pwd,method=RequestMethod.POST)

@ResponseBody

publicResultBooleanupdatePwd(@RequestParam(name=oldPwd,required=true)StringoldPwd,

@RequestParam(name=newPwd,required=true)StringnewPwd

IntegerloginType=(Integer)SessionUtil.get(loginType

if(loginType==LoginType.ADMINISTRATOR.getCode()){

UserloginedUser=SessionUtil.getLoginedUser();

if(!loginedUser.getPassword().equals(oldPwd)){

returnResult.error(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);

if(StringUtils.isEmpty(newPwd)){

returnResult.error(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);

if(newPwd.length()4||newPwd.length()32){

returnResult.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{

StaffloginedStaff=SessionUtil.getLoginedStaff();

Staffstaff=staffService.find(loginedStaff.getId());

if(!staff.getPassword().equals(oldPwd)){

returnResult.error(CodeMsg.ADMIN_USER_UPDATE_PWD_ERROR);

if(StringUtils.isEmpty(newPwd)){

returnResult.error(CodeMsg.ADMIN_USER_UPDATE_PWD_EMPTY);

staff.setPassword(newPwd);

CodeMsgcodeMsg=ValidateEntityUtil.validate(staff);

if(codeMsg.getCode()!=CodeMsg.SUCCESS.getCode()){

returnResult.error(codeMsg);

loginedStaff.setPassword(newPwd);

//保存數(shù)據(jù)庫

staffService.save(loginedStaff);

//更新session

SessionUtil.set(SessionConstant.SESSION_STAFF_LOGIN_KEY,loginedStaff);

returnResult.success(true);

*日志管理列表

*@parammodel

*@paramoperaterLog

*@parampageBean

*@return

@RequestMapping(value=/operator_log_list)

publicStringoperatorLogList(Modelmodel,OperaterLogoperaterLog,PageBeanOperaterLogpageBean){

model.addAttribute(pageBean,operaterLogService.findList(operaterLog,pageBean));

model.addAttribute(operator,operaterLog.getOperator());

model.addAttribute(title,日志列表

returnadmin/system/operator_log_list

*刪除操作日志,可刪除多個

*@paramids

*@return

@RequestMapping(value=/delete_operator_log,method=RequestMethod.POST)

@ResponseBody

publicResultBooleandelete(Stringids){

if(!StringUtils.isEmpty(ids)){

String[]splitIds=ids.split(,

for(Stringid:splitIds){

operaterLogService.delete(Long.valueOf(id));

returnResult.success(true);

*清空整個日志

*@return

@RequestMapping(value=/delete_all_operator_log,method=RequestMethod.POST)

@ResponseBody

publicResultBooleandeleteAll(){

operaterLogService.deleteAll();

returnResult.success(true);

}

用戶控制:

*用戶控制

@Controller(User)

@RequestMapping(/user)

publicclassUserController{

privatefinalLoggerlogger=LoggerFactory.getLogger(UserController.class);

privatefinalResultMapresultMap;

@Autowired

privateUserServiceuserService;

@Autowired

privateUserRoleServiceuserRoleService;

@Autowired

publicUserController(ResultMapresultMap){

this.resultMap=resultMap;

*返回有權限信息

@RequestMapping(value=/getMessage,method=RequestMethod.GET)

publicResultMapgetMessage(){

returnresultMap.success().message(您擁有用戶權限,可以獲得該接口的信息!

*修改用戶信息頁面user/userEdit.html

@RequestMapping(value=/editUserPage)

publicStringeditUserPage(LonguserId,Modelmodel){

model.addAttribute(manageUser,userId);

if(null!=userId){

Useruser=userService.selectByPrimaryKey(userId);

model.addAttribute(manageUser,user);

returnuser/userEdit

*更新數(shù)據(jù)庫

@ResponseBody

@RequestMapping(/updateUser)

publicStringupdateUser(Useruser){

returnuserService.updateUser(user);

}

健康評估控制層:

*健康評估

@Controller(HealthController)

@RequestMapping(/health)

publicclassHealthController{

@Autowired

privateDiagnosisServicediagnosisService;

@Autowired

privateAppointmentServiceappointmentService;

@Autowired

privatePetServicepetService;

@Autowired

privatePetDailyServicepetDailyService;

@Autowired

privateUserServiceuserService;

@Autowired

privateStandardServicestandardService;

*分析頁面

@RequestMapping(/assess)

publicStringapplyListDoctor(Modelmodel){

Subjectsubject=SecurityUtils.getSubject();

Useruser=(User)subject.getPrincipal();

Petpet=newPet();

pet.setUserId(user.getId());

pet.setPage(1);

pet.setLimit(100);

MMGridPageVoBeanPetvoBean=(MMGridPageVoBeanPet)petService.getAllByLimit(pet);

ListPetrows=voBean.getRows();

//獲取到該用戶下所有的寵物

model.addAttribute(pets,rows);

ListLongapplyCount=newArrayList();

ListStringdsCount=newArrayList();

ListStringtsCount=newArrayList();

ListStringwsCount=newArrayList();

ListStringhsCount=newArrayList();

ListStringasCount=newArrayList();

ListDoublept=newArrayList();

ListDoublepw=newArrayList();

ListDoubleph=newArrayList();

ListDoublepa=newArrayList();

ListDoublemt=newArrayList();

ListDoublemw=newArrayList();

ListDoublemh=newArrayList();

ListDoublema=newArrayList();

for(Petp:rows){

//獲取預約次數(shù)

Appointmentappointment=newAppointment();

appointment.setPetId(p.getId());

appointment.setPage(1);

appointment.setLimit(1000);

MMGridPageVoBeanAppointmentas=(MMGridPageVoBeanAppointment)appointmentService.getAllByLimit(appointment);

applyCount.add(as==null0L:as.getTotal());

//獲取就診記錄

Diagnosisdiagnosis=newDiagnosis();

diagnosis.setPetId(p.getId());

diagnosis.setPage(1);

diagnosis.setLimit(10);

MMGridPageVoBeanDiagnosisds=(MMGridPageVoBeanDiagnosis)diagnosisService.getAllByLimit(diagnosis);

ListDiagnosisdsRows=ds.getRows();

intdiagnosisStatus=0;

for(Diagnosisd:dsRows){

diagnosisStatus+=d.getStatus();

intsw=diagnosisStatus/dsRows.size();

switch(sw){

case1:dsCount.add(p.getName()+寵物健康,請繼續(xù)保持break;

case2:dsCount.add(p.getName()+寵物異常請及時就診!break;

case3:dsCount.add(p.getName()+寵物病情比較嚴重,請及時就醫(yī)!break;

case4:dsCount.add(p.getName()+很抱歉寵物已無法治療!break;

default:dsCount.add(p.getName()+寵物基本健康,請繼續(xù)保持break;

//獲取寵物日志

PetDailypetDaily=newPetDaily();

petDaily.setPetId(p.getId());

petDaily.setPage(1);

petDaily.setLimit(10);

MMGridPageVoBeanPetDailyps=(MMGridPageVoBeanPetDaily)petDailyService.getAllByLimit(petDaily);

ListPetDailypsRows=ps.getRows();

doublet=0;

doublew=0;

doubleh=0;

doublea=0;

for(PetDailypetDaily1: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);

//獲取標準

Standardstandard=newStandard();

//對應寵物類型

standard.setType(p.getType());

//健康標準

standard.setStatus(1);

intpetAge=MyUtils.get2DateDay(MyUtils.getDate2String(p.getBirthday(),yyyy-MM-dd),MyUtils.getDate2String(newDate(),yyyy-MM-dd));

petAge=(petAge0-petAge:petAge)/365;

//年齡

standard.setAgeMax(petAge);

standard.setPage(1);

standard.setLimit(100);

MMGridPageVoBeanStandardss=(MMGridPageVoBeanStandard)standardService.getAllByLimit(standard);

ListStandardssRows=ss.getRows();

doubletsMin=0;

doubletsMax=0;

doublewsMin=0;

doublewsMax=0;

doublehsMin=0;

doublehsMax=0;

doubleasMin=0;

doubleasMax=0;

for(Standards: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=tsMint=tsMax){

tsCount.add(體溫正常

}elseif(ttsMin){

tsCount.add(體溫偏低

}elseif(ttsMax){

tsCount.add(體溫偏高

if(w=wsMinw=wsMax){

wsCount.add(體重正常

}elseif(wwsMin){

wsCount.add(體重偏低

}elseif(wwsMax){

wsCount.add(體重偏高

if(h=hsMinh=hsMax){

hsCount.add(身高正常

}elseif(hhsMin){

hsCount.add(身高偏低

}elseif(hhsMax){

hsCount.add(身高偏高

if(a=asMina=asMax){

asCount.add(飯量正常

}elseif(aasMin){

asCount.add(飯量偏低

}elseif(aasMax){

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);

returntj/assess

*普通用戶預約統(tǒng)計

@RequestMapping(/tjApply)

publicStringtjApply(Modelmodel){

Subjectsubject=SecurityUtils.getSubject();

Useruser=(User)subject.getPrincipal();

Appointmentappointment=newAppointment();

appointment.setUserId(user.getId());

appointment.setPage(1);

appointment.setLimit(99999);

MMGridPageVoBeanAppointmentvoBean=(MMGridPageVoBeanAppointment)appointmentService.getAllByLimit(appointment);

ListAppointmentrows=voBean.getRows();

Integera1=0;

Integera2=0;

Integera3=0;

Integera4=0;

for(Appointmenta:rows){

switch(a.getStatus()){

case1:a1++;break;

case2:a2++;break;

case3:a3++;break;

case4:a4++;break;

model.addAttribute(a1,a1);

model.addAttribute(a2,a2);

model.addAttribute(a3,a3);

model.addAttribute(a4,a4);

returntj/tjApply

*醫(yī)生預約統(tǒng)計

@RequestMapping(/tjApplyDoctor)

publicStringtjApplyDoctor(Modelmodel){

Appointmentappointment=newAppointment();

appointment.setPage(1);

appointment.setLimit(99999);

MMGridPageVoBeanAppointmentvoBean=(MMGridPageVoBeanAppointment)appointmentService.getAllByLimit(appointment);

ListAppointmentrows=voBean.getRows();

Integera1=0;

Integera2=0;

Integera3=0;

Integera4=0;

for(Appointmenta:rows){

switch(a.getStatus()){

case1:a1++;break;

case2:a2++;break;

case3:a3++;break;

case4:a4++;break;

model.addAttribute(a1,a1);

model.addAttribute(a2,a2);

model.addAttribute(a3,a3);

model.addAttribute(a4,a4);

returntj/tjApplyDoctor

*普通用戶寵物日志統(tǒng)計

@RequestMapping(/tjDaily)

publicStringtjDaily(Modelmodel){

Subjectsubject=SecurityUtils.getSubject();

Useruser=(User)subject.getPrincipal();

Petpet=newPet();

pet.setUserId(user.getId());

pet.setPage(1);

pet.setLimit(99999);

MMGridPageVoBeanPetvoBean=(MMGridPageVoBeanPet)petService.getAllByLimit(pet);

ListPetrows=voBean.getRows();

model.addAttribute(pets,rows);

if(rows.size()0){

pet=rows.get(0);

PetDailydaily=newPetDaily();

daily.setPetId(pet.getId());

daily.setPage(1);

daily.setLimit(99999);

MMGridPageVoBeanPetDailyppp=(MMGridPageVoBeanPetDaily)petDailyService.getAllByLimit(daily);

ListPetDailylist=ppp.ge

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論