My friend asked me to help write a member information management system for a barber shop...

background

Let me explain first that this is not a private job, it is just a free help. In fact, for spending time to do this: I write some very conventional code in my spare time. I personally don't like it. I think I can spend this time in other places, such as improving myself and entertaining my life. However, I have not been working at home for a few months and have been idle, so I have to write code.

A friend mentioned it to me a year ago, saying I’m a software developer, can I get a membership information management system or something. I was still working and didn’t have time for it. I’ve been busy recently when I’m free. Time is up.

I know his barbershop. I used to stay there for more than 20 days to wash the hair of the guests (the end of the year was busy and there were many people, so I stayed for a while during the winter vacation). Their barbershop is very small, record Member information is to give you a card (you can take it away), and there is a book (save the secondary card, etc.) in the store to record it there. Whoever cuts his hair, find the corresponding information in the notebook, and deduct a sum. Probably that's it, it's a manual paper operation.

By the way, I've never forgotten a story: I encountered many things and people in those 20 days and it was not easy to forget, so I picked one that I could tell. It was the winter vacation of the sophomore year. I went there after taking the exam before the holiday. So during the holiday, I could already wash my long hair proficiently (mostly for girls’ hair). During the first two days of the holiday, One morning a little girl came. When I was washing her hair, people kept chatting to me. I didn’t have many conversations. In the morning, people said that I would listen, and when I asked, I would reply (hair washing Slower, longer time). Then they said to me, I think you don't like to talk, that's what it means. At that time, I listened to her original words, and I just um um, who's the kid in my heart, so amazing, very good at chatting. She asked me, how old do you think I am. I thought about it and wanted to say 14. I wanted to say 12. After thinking about it, I didn’t dare to say small, afraid of being unhappy, and I didn’t dare to say too big, it didn’t look like. She said that I am 21~~~~~, I am studying at the University of Light Industry~~~~. . . . I'm obedient, and I thought about it in my heart, I was 22, one year older than others, and then I didn't dare to say anything. She went on to say that she was said to be a baby face, well~~~ I really understood the definition of a baby face when I saw someone. Well, of course, as a straight man, another thought in my heart at that time was that the light industry was so far away from here that Zhengda was so far away. It wouldn’t have come here, right? There should be a hairdresser at the University of Light Industry, right? However, I really don't talk a lot. People didn't ask about this when they should blow their hair.

Closer to home.

demand

1. Member information can be saved and you can query it

2. Just be able to modify member information

3. You can modify the money yourself

4. Ability to back up data, in case the computer has a problem

The above is mentioned by others, and the following are additional considerations for me:

1. Safe, but don't pay too much attention

Just listen to the local loopback address, as long as the traffic cannot come in. There is no need to consider login or authorization, because it is on the computer at his own cash register and in the same place as the book where he records the member information, and the security level is the same.

2. Operation log record

At least you need to record when, who deducted money or added money, or changed the information. In case they need it

3. About data backup

Stand-alone application, cross-host backup data, the initial consideration is to back up to Baidu network disk, but after reading the agreement, it is fine. Such an informal project is just like a course design. I don't know if the review can be passed and it is troublesome.

Later, I thought about individual plans.

4. Deployment

The deployment is simple, and you can't let people install and configure too many dependent environments, such as the database and the java operating environment.

In addition, it is deployed on the windows system of a personal computer (win10).

Regardless of the needs, these needs are actually very few, just like a basic course design.

achieve

1. First write a web server application

In fact, this implementation should be written as a PC-side software is more appropriate, but I didn't think too much at first, thinking that I hadn't written a win32 program for more than two years, and I didn't want to bother to write it as a java web application.

The front end chose an open source back-end management template (AdminLTE), deleted, deleted, and changed. There are only 3 pages with the homepage. Nothing is needed. It looks like the following (the barber shop is called Bai***).

I used springboot + jpa, stored nearly 1w pieces of user information and 1w pieces of operation records for testing. This may be the maximum amount of data per day in the past 60 days (actually it must not be reached, there are not so many members, the operation records will be deleted 60 Days ago, only 150 records per day can reach 9k records in 60 days, even if it reaches 2w records, there will be no more), the amount of data is not large, and the h2 embedded database is used to persist the data to the local, convenient packaging, backup and recovery Also convenient.

That's the problem. It is written as java web to deploy to his computer, and he needs to configure a Java runtime environment first, and he is embarrassed to start it every time. And there is not a server that can deploy this web service application, and it does not need to be started and stopped every day.

After thinking about it, write a client to start this web, be as friendly as possible to Xiaobai users, and then package the java runtime environment and database into the installation program, which is also convenient for one-click installation.

The duilib used in the interface library, after all, is better to write, it is more efficient than gdi, gdi+, mfc and so on.

It looks like this:

The above is very clear. After opening, click the start button to start the local web service. After the start is completed, the default browser is automatically opened and enter 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 also follow the red letter prompt after the startup is completed, click the copy button to copy the address to the clipboard, manually open the browser, and paste Address opens and so on.

(The little girl in the background picture was searched on Baidu. There are many portrait pictures. I think this one is very good. Besides, the watermark is invisible, so I used it)

Of course, some details should be considered. For example, the service port is already occupied, the server application is closed when the client exits, the client closes the server without exiting and restarts the end, the client's singleton, remote data backup, etc. The details or something.

Next, make an installation package, write some startup scripts, and then arrange the jre of java8 and package the very basic things such as the dynamic library used by the client and the skin picture together. The NSIS packaging tool used is the latest one under the official website, which made me read the document for a long time and couldn't resist reading it. In the end, I found a lower version and increased version to generate a script and then changed it to save trouble. The following is my adjusted script. If you download the latest one, you can consider copying it and changing it to play if necessary.

; 该脚本使用 HM VNISEdit 脚本编辑器向导产生

; 安装程序初始定义常量
!define PRODUCT_NAME "BaishunStarter"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "许晓东."
!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 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"

; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!insertmacro MUI_PAGE_FINISH

; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES

; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"

; 安装预释放文件
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "BaishunStarter_NoBak_Setup.exe"
InstallDir "$PROGRAMFILES\BaishunStarter"
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
; 指定为所有用户
  SetShellVarContext all

; 指定为当前用户
;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

/******************************
 *  以下是安装程序的卸载部分  *
 ******************************/

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

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
  Abort
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
FunctionEnd

Then, it's probably like this. The installation package is a bit larger than 90 m, mainly because the jar package is a bit larger.

Concluding remarks

There is no bright spot in the function of this thing. What I am proud of is the idea of ​​making a java web like a stand-alone PC application to use this idea. This kind of realization should be meaningless to many people. Write The PC-side stand-alone software can be written in c++ or c#, and it is generally not necessary to go around this way.

This project is small like a course design, and the function points are not even worthy of complete design. But the final packaging is to make up for the shortcomings of a small tail that I did when I did the design. The design that took more than two months to write was for exam management, and part of it was for students. It was a B/S architecture written in Java. Web application (generating test papers for examinations, querying results, etc., and then in the internship at that time, I used a lot of technical skills, security shiro, shared sesion external storage and built a redis cluster, and engineering hierarchical use dubbo A lot of rpc calls and so on...), another part of the C/S structure is written in C++, mainly for teachers, importing the question bank, automatically judging questions/manually judging questions, generating scores, etc., the server uses IOCP Network model. The protocol format of the communication data is still self-defined, although it is very low. At that time, I also bought an Alibaba Cloud server deployment. But at that time, I only considered showing the function of the client to the teacher. I didn't consider the practicability. I didn't study how to make an installation program under windows. I just took the opportunity to study it this time.

If there are students in school who do ordinary course design and need the ready-made implementation of the web part for reference, you can privately trust me.

Guess you like

Origin blog.csdn.net/x763795151/article/details/105441054