Recently developed the Yidiandian small project

Hello everyone, I am Xiaomeng!

I've been so busy lately, with family on the one hand and work on the other.

In the early days, the child had tenosynovitis in his fingers and had a minor operation. I went to many hospitals, and finally confirmed that the minor operation was performed at the Women and Children's Hospital, and it went smoothly.

The moment I saw the child pushed out of the operating room, I really couldn't hold back. This may be the first time in recent years that I cried.

The last time I cried was when Grandpa left.

picture

insert image description here

The child was very strong and cried only once. The child who was undergoing the same operation next to him kept crying.

The more obedient the child was, the more uncomfortable I felt.

During the day, I have been going back and forth with the surgery procedures, and there are 2 customers who are developing in the middle, and they are also very anxious. Let me explain that the system will give it to you tomorrow.

Fortunately, Party A is reasonable!

The child slept very late at night, I coded in the hospital corridor, and stayed up all night to finish the development of the three modules! The nurse came to round the room and asked me:

It's half past three, why don't you go to sleep?

In the world of adults, nothing is easy.

Later, after the child was discharged from the hospital, my dad came to take care of it, and then I devoted myself to the development, and then developed a lot of projects with my friends!

These little friends are all the little friends who entered the previous private life VIP, and it is better to have fun alone than to have fun together! I hope to help some small partners earn more. Some friends have very good skills, but they don't know how to cash them out. What a pity!

insert image description here
insert image description here
insert image description here
insert image description here

We will continue to develop more projects, and some small partners have already taken off:

picture

There are a lot of fans in front of me, the technology is very good, but they don't understand the essence of business, and they have martial arts, which is useless. Brought some friends, they did really well!

The direction is right, get twice the result with half the effort! A buddy did it:

insert image description here

His next steps:

bold style

Core code sharing:

@RestController
public class AccountController {
    
    

    @Value("${authority.info}")
    private String authorityStr;
  //我的vx:codemeng
	@Resource
	private AdminInfoService adminInfoService;
	@Resource
	private SallerInfoService sallerInfoService;
	@Resource
	private UserInfoService userInfoService;


    @PostMapping("/login")
    public Result<Account> login(@RequestBody Account account, HttpServletRequest request) {
    
    
        if (StrUtil.isBlank(account.getName()) || StrUtil.isBlank(account.getPassword()) || account.getLevel() == null) {
    
    
            throw new CustomException(ResultCode.PARAM_LOST_ERROR);
        }
        String imgCode = (String) request.getSession().getAttribute("imgCode");
        if(!account.getCode().equalsIgnoreCase(imgCode)){
    
    
            throw new CustomException(ResultCode.CODE_ERROR);
        }
        Integer level = account.getLevel();
        Account login = new Account();
		if (1 == level) {
    
    
			login = adminInfoService.login(account.getName(), account.getPassword());
		}
		if (2 == level) {
    
    
			login = sallerInfoService.login(account.getName(), account.getPassword());
		}
		if (3 == level) {
    
    
			login = userInfoService.login(account.getName(), account.getPassword());
		}

        request.getSession().setAttribute("user", login);
        return Result.success(login);
    }

    @PostMapping("/register")
    public Result<Account> register(@RequestBody Account account) {
    
    
        Integer level = account.getLevel();
        Account login = new Account();
		if (1 == level) {
    
    
			AdminInfo info = new AdminInfo();
			BeanUtils.copyProperties(account, info);
			login = adminInfoService.add(info);
		}
		if (2 == level) {
    
    
			SallerInfo info = new SallerInfo();
			BeanUtils.copyProperties(account, info);
			login = sallerInfoService.add(info);
		}
		if (3 == level) {
    
    
			UserInfo info = new UserInfo();
			BeanUtils.copyProperties(account, info);
			login = userInfoService.add(info);
		}

        return Result.success(login);
    }

    @GetMapping("/logout")
    public Result logout(HttpServletRequest request) {
    
    
        request.getSession().setAttribute("user", null);
        return Result.success();
    }

    @GetMapping("/auth")
    public Result getAuth(HttpServletRequest request) {
    
    
        Object user = request.getSession().getAttribute("user");
        if(user == null) {
    
    
            return Result.error("401", "未登录");
        }
        return Result.success(user);
    }

    @GetMapping("/getAccountInfo")
    public Result<Object> getAccountInfo(HttpServletRequest request) {
    
    
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
    
    
            return Result.success(new Object());
        }
        Integer level = account.getLevel();
		if (1 == level) {
    
    
			return Result.success(adminInfoService.findById(account.getId()));
		}
		if (2 == level) {
    
    
			return Result.success(sallerInfoService.findById(account.getId()));
		}
		if (3 == level) {
    
    
			return Result.success(userInfoService.findById(account.getId()));
		}

        return Result.success(new Object());
    }

    @GetMapping("/getSession")
    public Result<Map<String, String>> getSession(HttpServletRequest request) {
    
    
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
    
    
            return Result.success(new HashMap<>(1));
        }
        Map<String, String> map = new HashMap<>(1);
        map.put("username", account.getName());
        return Result.success(map);
    }

    @GetMapping("/getAuthority")
    public Result<List<AuthorityInfo>> getAuthorityInfo() {
    
    
        List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
        return Result.success(authorityInfoList);
    }

    /**
    * 获取当前用户所能看到的模块信息
    * @param request
    * @return
    */
    @GetMapping("/authority")
    public Result<List<Integer>> getAuthorityInfo(HttpServletRequest request) {
    
    
        Account user = (Account) request.getSession().getAttribute("user");
        if (user == null) {
    
    
            return Result.success(new ArrayList<>());
        }
        JSONArray objects = JSONUtil.parseArray(authorityStr);
        for (Object object : objects) {
    
    
            JSONObject jsonObject = (JSONObject) object;
            if (user.getLevel().equals(jsonObject.getInt("level"))) {
    
    
                JSONArray array = JSONUtil.parseArray(jsonObject.getStr("models"));
                List<Integer> modelIdList = array.stream().map((o -> {
    
    
                    JSONObject obj = (JSONObject) o;
                    return obj.getInt("modelId");
                    })).collect(Collectors.toList());
                return Result.success(modelIdList);
            }
        }
        return Result.success(new ArrayList<>());
    }

    @GetMapping("/permission/{modelId}")
    public Result<List<Integer>> getPermission(@PathVariable Integer modelId, HttpServletRequest request) {
    
    
        List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
        Account user = (Account) request.getSession().getAttribute("user");
        if (user == null) {
    
    
            return Result.success(new ArrayList<>());
        }
        Optional<AuthorityInfo> optional = authorityInfoList.stream().filter(x -> x.getLevel().equals(user.getLevel())).findFirst();
        if (optional.isPresent()) {
    
    
            Optional<AuthorityInfo.Model> firstOption = optional.get().getModels().stream().filter(x -> x.getModelId().equals(modelId)).findFirst();
            if (firstOption.isPresent()) {
    
    
                List<Integer> info = firstOption.get().getOperation();
                return Result.success(info);
            }
        }
        return Result.success(new ArrayList<>());
    }

    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody Account info, HttpServletRequest request) {
    
    
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
    
    
            return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
        }
        String oldPassword = SecureUtil.md5(info.getPassword());
        if (!oldPassword.equals(account.getPassword())) {
    
    
            return Result.error(ResultCode.PARAM_PASSWORD_ERROR.code, ResultCode.PARAM_PASSWORD_ERROR.msg);
        }
        info.setPassword(SecureUtil.md5(info.getNewPassword()));
        Integer level = account.getLevel();
		if (1 == level) {
    
    
			AdminInfo adminInfo = new AdminInfo();
			BeanUtils.copyProperties(info, adminInfo);
			adminInfoService.update(adminInfo);
		}
		if (2 == level) {
    
    
			SallerInfo sallerInfo = new SallerInfo();
			BeanUtils.copyProperties(info, sallerInfo);
			sallerInfoService.update(sallerInfo);
		}
		if (3 == level) {
    
    
			UserInfo userInfo = new UserInfo();
			BeanUtils.copyProperties(info, userInfo);
			userInfoService.update(userInfo);
		}

        info.setLevel(level);
        info.setName(account.getName());
        // 清空session,让用户重新登录
        request.getSession().setAttribute("user", null);
        return Result.success();
    }

    @PostMapping("/resetPassword")
    public Result resetPassword(@RequestBody Account account) {
    
    
        Integer level = account.getLevel();
		if (1 == level) {
    
    
			AdminInfo info = adminInfoService.findByUserName(account.getName());
			if (info == null) {
    
    
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			adminInfoService.update(info);
		}
		if (2 == level) {
    
    
			SallerInfo info = sallerInfoService.findByUserName(account.getName());
			if (info == null) {
    
    
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			sallerInfoService.update(info);
		}
		if (3 == level) {
    
    
			UserInfo info = userInfoService.findByUserName(account.getName());
			if (info == null) {
    
    
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			userInfoService.update(info);
		}

        return Result.success();
    }
@RestController
@RequestMapping(value = "/addressInfo")
public class AddressInfoController {
    
    
    @Resource
    private AddressInfoService addressInfoService;

    @PostMapping
    public Result<AddressInfo> add(@RequestBody AddressInfoVo addressInfo, HttpServletRequest request) {
    
    
        Account account = (Account) request.getSession().getAttribute("user");
        addressInfo.setUserId(account.getId());
        addressInfoService.add(addressInfo);
        return Result.success(addressInfo);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Long id) {
    
    
        addressInfoService.delete(id);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody AddressInfoVo addressInfo) {
    
    
        addressInfoService.update(addressInfo);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result<AddressInfo> detail(@PathVariable Long id) {
    
    
        AddressInfo addressInfo = addressInfoService.findById(id);
        return Result.success(addressInfo);
    }

    @GetMapping
    public Result<List<AddressInfoVo>> all() {
    
    
        return Result.success(addressInfoService.findAll());
    }

    @GetMapping("/user/{userId}")
    public Result<List<AddressInfoVo>> findByUserId(@PathVariable Long userId, HttpServletRequest request) {
    
    
        Account account = (Account) request.getSession().getAttribute("user");
        if(account.getLevel() == 1 || account.getLevel() == 2) {
    
    
            return Result.success(new ArrayList<>());
        }
        return Result.success(addressInfoService.findByUserId(userId));
    }

    @GetMapping("/page/{name}")
    public Result<PageInfo<AddressInfoVo>> page(@PathVariable String name,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                HttpServletRequest request) {
    
    
        return Result.success(addressInfoService.findPage(name, pageNum, pageSize, request));
    }

    /**
    * 批量通过excel添加信息
    * @param file excel文件
    * @throws IOException
    */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
    
    

        List<AddressInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(AddressInfo.class);
        if (!CollectionUtil.isEmpty(infoList)) {
    
    
            // 处理一下空数据
            List<AddressInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getName())).collect(Collectors.toList());
            for (AddressInfo info : resultList) {
    
    
                addressInfoService.add(info);
            }
        }
        return Result.success();
    }

    @GetMapping("/getExcelModel")
    public void getExcelModel(HttpServletResponse response) throws IOException {
    
    
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
		row.put("name", "");
		row.put("phone", "");
		row.put("man", "");

        List<Map<String, Object>> list = CollUtil.newArrayList(row);

        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=addressInfoModel.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    }
}

There are also a few other small partners who have done a good job, so I won’t take screenshots one by one, let’s see our results later!

But this recruitment requires technical experience. If you don’t have more than 2 years of technical experience and want to learn, you can work hard to learn technology first:

insert image description here

This is a great era, stop complaining about PUA in the workplace, programmers are 35 years old, why a certain skin can make hundreds of W a year on a planet, why a software company can get hundreds of W a year, you have to find the right direction!

Anyone can learn, imitate, and execute!

We must improve our learning ability and execution ability!

I have worked on a large number of projects, up to seven figures. So as long as the channel is right, the developed project will be fine. The income must be nice.

Of course I have another idea:

In the future, we will share projects, so that we can be stronger and go further! Now there are several small partners who have developed 10 systems. If there are 10 people, there will be 100 systems.

Now I have accumulated 10,000 sets in my hand, so I develop so fast! Many are packaged!

Everyone huddled together, and it was so cool! A group of people can go further!

picture

Of course, I will also give you some of my things to operate my things and make money, because my own energy is really limited. For example, websites, official accounts, and small programs are all there, which is really a waste!

Come for an interview!

Of course, you can communicate at any time about the future of programmers. Which is better, technology or management?

Is it more fragrant to do self-media or private development as a side job?

In short, everyone should plan well in advance, so as to avoid the situation of no income even if they are laid off.

Work is not the whole of life, work is just a better life.

I am Xiaomeng, a programmer. Code words are not easy, welcome to like and follow, thank you! You can also contact me below!

Guess you like

Origin blog.csdn.net/mengchuan6666/article/details/130123643