Skip to content

Commit

Permalink
🔖 V.1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
oddfar committed Aug 4, 2023
1 parent f854a3f commit f683425
Show file tree
Hide file tree
Showing 46 changed files with 2,022 additions and 565 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,40 @@

## 项目介绍

i茅台app,每日自动预约茅台,可添加多个用户,可选本市出货量最大的门店,或预约你的位置附近门店

软件会在每日9点05开始批量预约,并 [pushplus](https://www.pushplus.plus/) 推送消息
i茅台app,每日自动预约茅台

- [x] 平台注册账号(可用i茅台)
- [x] 添加多个用户
- [x] 自动预约
- [x] 类型选择(本市出货量最大的门店,或位置附近门店)
- [x] 自动旅行
- [x] 首次旅行分享
- [x] 获取申购耐力值
- [x] 自定义时间/随机时间预约或旅行
- [x] 结果消息推送

此项目使用 **Campus** 进行编写:<https://github.com/oddfar/campus>

## 使用教程

- 部署项目:[点击此处](https://github.com/oddfar/campus-imaotai/wiki/%E9%A1%B9%E7%9B%AE%E4%BD%BF%E7%94%A8#%E9%83%A8%E7%BD%B2%E9%A1%B9%E7%9B%AE)
- 使用项目:[点击此处](https://github.com/oddfar/campus-imaotai/wiki/%E9%A1%B9%E7%9B%AE%E4%BD%BF%E7%94%A8#%E9%A1%B9%E7%9B%AE%E4%BD%BF%E7%94%A8)
- 常见问题:[点击此处](https://github.com/oddfar/campus-imaotai/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
- 文档

<https://github.com/oddfar/campus-imaotai/wiki>

有问题请查看文档,查找 [issues](https://github.com/oddfar/campus-imaotai/issues) 上是否有相同问题!

若没有则提交 [issues](https://github.com/oddfar/campus-imaotai/issues) ,附带详细的错误原因

不会Docker部署的,可使用客户端:<https://github.com/lisongkun/hygge-imaotai>

## 关注&交流

欢迎各位老哥进群进行**技术交流**(只交流技术,不谈茅台),为了防止广告进入,请添加我微信(备注:**Campus**),我会直接将你拉进**Campus交流群**

**私信不解决项目使用问题,请提交 issues!**

<img src="https://note.oddfar.com/img/my-wechat.jpg" alt="wechat" style="height:280px;" />

## 贡献代码

若您有好的想法,发现一些 **BUG** 并修复了,欢迎提交 **Pull Request** 参与开源贡献
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.oddfar.campus.common.domain.entity.SysUserEntity;
import com.oddfar.campus.common.domain.entity.SysUserRoleEntity;
import com.oddfar.campus.common.exception.ServiceException;
import com.oddfar.campus.common.utils.SecurityUtils;
import com.oddfar.campus.common.utils.StringUtils;
import com.oddfar.campus.framework.api.sysconfig.ConfigExpander;
import com.oddfar.campus.framework.mapper.SysRoleMapper;
Expand Down Expand Up @@ -97,6 +98,7 @@ public int insertUser(SysUserEntity user) {
&& !(checkEmailUnique(user))) {
throw new ServiceException("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
// 新增用户信息
int rows = userMapper.insert(user);
// 新增用户与角色管理
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.Set;

/**
* 注册校验方法
*/
Expand All @@ -32,6 +35,9 @@ public class SysRegisterService {
@Autowired
private RedisCache redisCache;

@Autowired
private SysPermissionService permissionService;

/**
* 注册
*/
Expand All @@ -56,7 +62,7 @@ public String register(RegisterBody registerBody) {
} else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
msg = "密码长度必须在5到20个字符之间";
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(sysUser))) {
} else if (!(userService.checkUserNameUnique(sysUser))) {
msg = "保存用户'" + username + "'失败,注册账号已存在";
} else {
sysUser.setNickName(username);
Expand All @@ -65,7 +71,15 @@ public String register(RegisterBody registerBody) {
if (!regFlag) {
msg = "注册失败,请联系系统管理人员";
} else {
//注册失败异步记录信息
//注册成功
//添加 imaotai 角色
SysUserEntity userEntity = userService.selectUserByUserName(username);
Set<String> roleSet = new HashSet<>();
roleSet.add("imaotai");
userService.insertUserAuth(userEntity.getUserId(), roleSet);
//更新redis缓存
permissionService.resetUserRoleAuthCache(userEntity.getUserId());

AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, null, Constants.REGISTER, MessageUtils.message("user.register.success")));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* @author zhiyuan
* GitHub: https://github.com/oddfar/campus-imaotai
* @author oddfar
*/
@SpringBootApplication
public class CampusApplication {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.oddfar.campus.business.api;

import cn.hutool.http.HttpUtil;
import com.oddfar.campus.business.entity.ILog;
import com.oddfar.campus.business.entity.IUser;
import com.oddfar.campus.common.domain.entity.SysOperLogEntity;
import com.oddfar.campus.common.utils.StringUtils;
import com.oddfar.campus.framework.manager.AsyncManager;

Expand All @@ -16,21 +16,21 @@
public class PushPlusApi {


public static void sendNotice(IUser iUser, SysOperLogEntity operLog) {
public static void sendNotice(IUser iUser, ILog operLog) {
String token = iUser.getPushPlusToken();
if (StringUtils.isEmpty(token)) {
return;
}
String title, content;
if (operLog.getStatus() == 0) {
//预约成功
title = iUser.getMobile() + "-i茅台预约成功";
content = operLog.getJsonResult();
AsyncManager.me().execute(sendNotice(token, title, content, "json"));
title = iUser.getRemark() + "-i茅台执行成功";
content = iUser.getMobile() + System.lineSeparator() + operLog.getLogContent();
AsyncManager.me().execute(sendNotice(token, title, content, "txt"));
} else {
//预约失败
title = iUser.getMobile() + "-i茅台预约失败";
content = title;
title = iUser.getRemark() + "-i茅台执行失败";
content = iUser.getMobile() + System.lineSeparator() + operLog.getLogContent();
AsyncManager.me().execute(sendNotice(token, title, content, "txt"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.oddfar.campus.common.annotation.ApiResource;
import com.oddfar.campus.common.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -42,6 +43,7 @@ public R list() {
* 刷新i茅台预约商品列表
*/
@GetMapping(value = "/refresh", name = "刷新i茅台预约商品列表")
@PreAuthorize("@ss.resourceAuth()")
public R refreshItem() {
iShopService.refreshItem();
return R.ok();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.oddfar.campus.business.controller;

import com.oddfar.campus.business.entity.ILog;
import com.oddfar.campus.business.service.IMTLogService;
import com.oddfar.campus.common.annotation.ApiResource;
import com.oddfar.campus.common.domain.PageResult;
import com.oddfar.campus.common.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
* I茅台日志Controller
*
* @author oddfar
* @date 2023-08-01
*/
@RestController
@RequestMapping("/imt/log")
@ApiResource(name = "I茅台日志Controller")
public class ILogController {
@Autowired
private IMTLogService logService;

@PreAuthorize("@ss.resourceAuth()")
@GetMapping(value = "/list", name = "操作日志-分页")
public R list(ILog log) {
PageResult<ILog> page = logService.page(log);
return R.ok().put(page);
}

@PreAuthorize("@ss.resourceAuth()")
@DeleteMapping(value = "/{operIds}", name = "操作日志-删除")
public R remove(@PathVariable Long[] operIds) {
return R.ok(logService.deleteLogByIds(operIds));
}

@PreAuthorize("@ss.resourceAuth()")
@DeleteMapping(value = "/clean", name = "操作日志-清空")
public R clean() {
logService.cleanLog();
return R.ok();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.oddfar.campus.common.domain.PageResult;
import com.oddfar.campus.common.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -42,6 +43,7 @@ public R list(IShop iShop) {
* 刷新i茅台商品列表
*/
@GetMapping(value = "/refresh", name = "刷新i茅台商品列表")
@PreAuthorize("@ss.resourceAuth()")
public R refreshShop() {
iShopService.refreshShop();
return R.ok();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.oddfar.campus.business.controller;

import com.oddfar.campus.business.entity.IShop;
import com.oddfar.campus.business.entity.IUser;
import com.oddfar.campus.business.mapper.IUserMapper;
import com.oddfar.campus.business.service.IMTService;
import com.oddfar.campus.business.service.IShopService;
import com.oddfar.campus.business.service.IUserService;
import com.oddfar.campus.common.annotation.ApiResource;
import com.oddfar.campus.common.domain.PageResult;
import com.oddfar.campus.common.domain.R;
import com.oddfar.campus.common.exception.ServiceException;
import com.oddfar.campus.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -30,11 +33,14 @@ public class IUserController {
private IUserMapper iUserMapper;
@Autowired
private IMTService imtService;
@Autowired
private IShopService iShopService;

/**
* 查询I茅台用户列表
*/
@GetMapping("/list")
@GetMapping(value = "/list", name = "查询I茅台用户列表")
@PreAuthorize("@ss.resourceAuth()")
public R list(IUser iUser) {
PageResult<IUser> page = iUserService.page(iUser);

Expand All @@ -44,17 +50,19 @@ public R list(IUser iUser) {
/**
* 发送验证码
*/
@GetMapping("/sendCode")
public R sendCode(String mobile) {
imtService.sendCode(mobile);
@GetMapping(value = "/sendCode", name = "发送验证码")
@PreAuthorize("@ss.resourceAuth()")
public R sendCode(String mobile, String deviceId) {
imtService.sendCode(mobile, deviceId);

return R.ok();
}

/**
* 预约
*/
@GetMapping("/reservation")
@GetMapping(value = "/reservation", name = "预约")
@PreAuthorize("@ss.resourceAuth()")
public R reservation(String mobile) {
IUser user = iUserMapper.selectById(mobile);
if (user == null || StringUtils.isEmpty(user.getItemCode())) {
Expand All @@ -63,15 +71,30 @@ public R reservation(String mobile) {
imtService.reservation(user);
return R.ok();
}
}

/**
* 小茅运旅行活动
*/
@GetMapping(value = "/travelReward", name = "旅行")
@PreAuthorize("@ss.resourceAuth()")
public R travelReward(String mobile) {
IUser user = iUserMapper.selectById(mobile);
if (user == null) {
return R.error("用户不存在");
} else {
imtService.getTravelReward(user);
return R.ok();
}
}

/**
* 登录
*/
@GetMapping("/login")
public R login(String mobile, String code) {
imtService.login(mobile, code);
@GetMapping(value = "/login", name = "登录")
@PreAuthorize("@ss.resourceAuth()")
public R login(String mobile, String code, String deviceId) {
imtService.login(mobile, code, deviceId);

return R.ok();
}
Expand All @@ -80,34 +103,45 @@ public R login(String mobile, String code) {
/**
* 获取I茅台用户详细信息
*/
@GetMapping(value = "/{mobile}")
@PreAuthorize("@ss.resourceAuth()")
@GetMapping(value = "/{mobile}", name = "获取I茅台用户详细信息")
public R getInfo(@PathVariable("mobile") Long mobile) {
return R.ok(iUserMapper.selectById(mobile));
}

/**
* 新增I茅台用户
*/
@PreAuthorize("@ss.hasPermi('campus:user:add')")
@PostMapping
@PreAuthorize("@ss.resourceAuth()")
@PostMapping(name = "新增I茅台用户")
public R add(@RequestBody IUser iUser) {

IShop iShop = iShopService.selectByIShopId(iUser.getIshopId());
if (iShop == null) {
throw new ServiceException("门店商品id不存在");
}

return R.ok(iUserService.insertIUser(iUser));
}

/**
* 修改I茅台用户
*/
@PreAuthorize("@ss.hasPermi('campus:user:edit')")
@PutMapping
@PreAuthorize("@ss.resourceAuth()")
@PutMapping(name = "修改I茅台用户")
public R edit(@RequestBody IUser iUser) {
IShop iShop = iShopService.selectByIShopId(iUser.getIshopId());
if (iShop == null) {
throw new ServiceException("门店商品id不存在");
}
return R.ok(iUserService.updateIUser(iUser));
}

/**
* 删除I茅台用户
*/
@PreAuthorize("@ss.hasPermi('campus:user:remove')")
@DeleteMapping("/{mobiles}")
@PreAuthorize("@ss.resourceAuth()")
@DeleteMapping(value = "/{mobiles}", name = "删除I茅台用户")
public R remove(@PathVariable Long[] mobiles) {
return R.ok(iUserMapper.deleteBatchIds(Arrays.asList(mobiles)));
}
Expand Down
Loading

0 comments on commit f683425

Please sign in to comment.