This is the 28th day of my participation in the First Challenge 2022

background

I personally don’t like the idea of spending my time writing routine code in my spare time. I think that time could be better spent elsewhere, improving myself and having fun. However, due to the epidemic in recent months, I have not gone out to work and have been idle at home, so I have to write code.

Years ago, my friend mentioned to me that I was engaged in software, and could I get a management system of member information? At that time, I was still working and did not take the time. Recently, I stole a busy job in my spare time, and this time I got it.

His barber shop I know, I’ve spent more than 20 days there to wash hair (the end of the year is busy, there are many, so in the winter vacation time to stay a period of time), the barber shop when they were small, record the member information is to give you a card (can take away), and then store book (save vice card, etc.) where records. Anyone who gets a haircut finds the corresponding information in the book and takes a mark. That’s about it. Manual paper operation.

demand

  1. Can save member information can query on the line

  2. If you can change your membership information

  3. As long as you can fix the money yourself

  4. Can back up data in case something goes wrong with the computer

Here are some additional things I need to consider:

  1. Safe, but not too concerned

Listen for the loopback address, as long as the traffic doesn’t come in. Don’t worry about login and authorization, because it’s on his own computer at the cashier’s desk, in the same place as the notebook where he records his membership information. Security level, level.

  1. Operation Log

At the very least, you need to record when, who was charged or added to, or changed the information. In case they need it

  1. About Data Backup

Single application, cross-host backup data, the initial consideration is to backup to Baidu network disk, but looked at the agreement or calculated, so informal project like a course design, audit do not know can not pass, also trouble.

Later, I thought of a different plan.

  1. The deployment of

Deployment is simple, do not let others install and configure too many dependent environment, such as database, Java runtime environment.

In addition, is deployed in the PC Windows system (Win10).

Whatever the requirements are, there are actually very few of them, just like a basic curriculum design.

implementation

  1. Write a web server application first

In fact, this implementation should write a PC side software is more suitable, but at the beginning, I did not think too much, thinking that I did not write win32 program for more than two years, do not want to bother to write Java Web application.

Front end selected an open source background management template (AdminLTE), delete, delete, change, with the home page on 3 pages, do not need what, about the following looks like (barber shop called Bai ***).

We used Springboot + JPA to store nearly 1W user information and 1W operation records for testing, which may be the maximum amount of data per day in the recent 60 days (actually it cannot be reached, there are not so many members, operation records of 60 days ago will be deleted, and only 150 records per day can reach 9K in 60 days. Even up to 2W will not be much more), the amount of data is not large, using h2 embedded database to persist data to the local, convenient packaging, backup and recovery is also convenient.

The problem was that Java Web was being deployed on his computer, requiring him to configure a Java runtime environment, and he was embarrassed every time he started. And there isn’t a server that can deploy the Web service application without having to start and stop every day.

Think about it, write a client can start the Web bar, for small white user friendly point as far as possible, and then the Java runtime environment, database packaging to the installation program, a key installation is also convenient.

Duilib interface library, after all, is easier to write, than GDI, GDI +, MFC implementation is more efficient.

Something like this:

Write very clear, after open, click the start button and start a local web service, start, after the completion of automatic open the default browser, go to http://127.0.0.1:8080/index.html.

If the system does not set the default browser, or some other unexpected reasons, for example, the browser is closed, the user can follow the red prompt above after the startup, click the copy button to copy the address to the clipboard, manually open the browser, paste the address to open, etc.

(The little girl in the background picture is found on Baidu, there are a lot of portrait pictures, I feel this one is very good, and the watermark can not see it is used)

Of course, some details should also be considered, such as the service port has occupied the problem, closing the server application when the client exits, closing the client and restarting the server before the client exits, the client singleton, data remote backup and other small details.

The next step is to type an installation package, write some startup scripts, and include the java8 jre as well as the dynamic library used by the client, skin images, and other basic things.

Package tools used by NSIS, the latest under the official, I read a small document for a long time did not resist to read, and finally find a low version of the enhanced version to generate a script and then change it to save trouble.

Below is the script I adjusted, if the latest, used for learning can consider first copy this past and modify where necessary.

; The script is generated using the HM VNISEdit script editor wizard; Setup defines constants initially! define PRODUCT_NAME "BaishunStarter" ! Define PRODUCT_VERSION "1.0"! Define PRODUCT_PUBLISHER "Xu Xiaodong!" define PRODUCT_WEB_SITE "http://www.xiaodonggg.top" ! define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall${PRODUCT_NAME}" ! define PRODUCT_UNINST_ROOT_KEY "HKLM" SetCompressor lzma ; ------ MUI Modern Interface definitions (compatible with version 1.67 and above) ------! include "MUI.nsh" ; MUI predefined constants! define MUI_ABORTWARNING ! define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" ! define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Welcome page! insertmacro MUI_PAGE_WELCOME ; Installation directory selection page! insertmacro MUI_PAGE_DIRECTORY ; Installation process page! insertmacro MUI_PAGE_INSTFILES ; Installation complete page! insertmacro MUI_PAGE_FINISH ; Install and uninstall process page! insertmacro MUI_UNPAGE_INSTFILES ; Setup interface includes language Settings! insertmacro MUI_LANGUAGE "SimpChinese" ; Install the pre-release file! insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; ------ MUI Modern interface definition end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "baishunstarter_nobak_setup.exe" InstallDir  "$PROGRAMFILES\BaishunStarter" ShowInstDetails show ShowUnInstDetails show Section "MainSection" SEC01 ; SetShellVarContext all; Specified as the current user; SetShellVarContext current SetOutPath "$INSTDIR*.*" SetOverwrite ifnewer File /r "baishun_setup*.*" CreateShortCut "$DESKTOP\BaishunStarter.lnk" "$INSTDIR\BaishunStart.exe" "" "$INSTDIR\favicon.ico" SectionEnd Section -AdditionalIcons SetOutPath $INSTDIR CreateDirectory "$SMPROGRAMS\BaishunStarter" CreateShortCut "$SMPROGRAMS\BaishunStarter\Uninstall.lnk" "$INSTDIR\uninst.exe" SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * the following is unloading part of the installation program * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / Section Uninstall. SetShellVarContext all Delete "$INSTDIR\uninst.exe" Delete "$SMPROGRAMS\BaishunStarter\ uninstall. LNK "RMDir "$SMPROGRAMS\BaishunStarter" RMDir /r "$INSTDIR*.*" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY}" SetAutoClose true SectionEnd #-- According to NSIS script editing rules, all Function sections must be written after the Section Section, To avoid unforeseen problems with the installation program. -- # Function the UN. The onInit MessageBox MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2 "do you want to completely remove $^ (Name), and all of its components?" IDYES +2 Abort FunctionEnd Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) Has been successfully removed from your computer." FunctionEndCopy the code

And then, something like that. Into the installation package a bit big 90 more m, mainly jar package a bit big.

conclusion

This project is available on github: github.com/xxd76379515… If there are students in school to do the usual course design needs a ready-made implementation of the Web part can be referred to.

Doesn’t highlight the function of this thing, I proud of is that make a Java web seems to be a the PC standalone application to use this idea, the realization for many people is supposed to be meaningless, PC standalone software written in c + + or c # to write lines, generally not so.

This project is as small as a course design, with few functions that are not even worthy of graduation design.

But the final package is made up for me when do you have a small tail, then spent more than two months to write you a examination management, part for students, written in Java, B/S architecture web application (generating test paper to test, the result of query and so on, and then in practice, the function will use a lot of technology, Shiro for security, a Redis cluster sharing sesion memory, engineering layering using Dubbo for RPC calls, etc.).

The other part of the C/S structure is written in C ++ mainly for teachers to use, import question banks, automatic/manual grading, grade generation and so on. The server side uses the IOCP network model. The protocol format of the communication data is still custom, although very low. At that time also bought an Ali cloud server deployment. But at that time, I only considered to show the function of the client to the teacher, without considering the practicability, and I did not study how to make the installation program under Windows, so I just took this opportunity to study it.