开发微信打卡系统
This commit is contained in:
@ -1,25 +1,22 @@
|
||||
package com.stdiet.web.controller.custom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.stdiet.common.annotation.Log;
|
||||
import com.stdiet.common.core.controller.BaseController;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.service.ISysWxUserInfoService;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.common.core.page.TableDataInfo;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.custom.domain.SysOrder;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.page.WxServeInfo;
|
||||
import com.stdiet.custom.service.ISysOrderService;
|
||||
import com.stdiet.custom.service.ISysWxUserInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信用户Controller
|
||||
@ -33,6 +30,9 @@ public class SysWxUserInfoController extends BaseController {
|
||||
@Autowired
|
||||
private ISysWxUserInfoService sysWxUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISysOrderService sysOrderService;
|
||||
|
||||
/**
|
||||
* 查询微信用户列表
|
||||
*/
|
||||
@ -95,17 +95,41 @@ public class SysWxUserInfoController extends BaseController {
|
||||
return toAjax(sysWxUserInfoService.deleteSysWxUserInfoByIds(openids));
|
||||
}
|
||||
|
||||
@PostMapping("/wx/adduser")
|
||||
@PostMapping("/wx/serveinfo")
|
||||
public AjaxResult addUser(@RequestBody SysWxUserInfo sysWxUserInfo) {
|
||||
|
||||
// 查询微信用户
|
||||
SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserInfo.getOpenid());
|
||||
int resultCode = 0;
|
||||
if (userInfo == null) {
|
||||
resultCode = sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
|
||||
} else {
|
||||
sysWxUserInfo.setPhone(userInfo.getPhone());
|
||||
resultCode = sysWxUserInfoService.updateSysWxUserInfo(sysWxUserInfo);
|
||||
if (StringUtils.isNull(userInfo) && StringUtils.isEmpty(sysWxUserInfo.getPhone())
|
||||
|| StringUtils.isEmpty(userInfo.getPhone()) && StringUtils.isEmpty(sysWxUserInfo.getPhone())) {
|
||||
return AjaxResult.error(5001, "没有手机号");
|
||||
}
|
||||
return toAjax(resultCode);
|
||||
|
||||
// 插入/更新用户信息
|
||||
if (StringUtils.isNull(userInfo)) {
|
||||
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(userInfo.getPhone())) {
|
||||
sysWxUserInfo.setPhone(userInfo.getPhone());
|
||||
}
|
||||
sysWxUserInfoService.updateSysWxUserInfo(sysWxUserInfo);
|
||||
}
|
||||
|
||||
// 查找订单记录
|
||||
SysOrder querySysOrder = new SysOrder();
|
||||
querySysOrder.setPhone(sysWxUserInfo.getPhone());
|
||||
List<SysOrder> list = sysOrderService.selectSysOrderList(querySysOrder);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return AjaxResult.error(5002, "没有订单信息");
|
||||
}
|
||||
|
||||
WxServeInfo wxServeInfo = new WxServeInfo();
|
||||
wxServeInfo.setServeStatus(list.get(0).getStatus());
|
||||
wxServeInfo.setServeTime(list.get(0).getServeTime());
|
||||
wxServeInfo.setStartTime(list.get(list.size() - 1).getStartTime());
|
||||
wxServeInfo.setWeight(list.get(list.size() - 1).getWeight());
|
||||
|
||||
return AjaxResult.success(wxServeInfo);
|
||||
}
|
||||
}
|
@ -1,23 +1,23 @@
|
||||
package com.stdiet.web.controller.custom;
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.stdiet.common.annotation.Log;
|
||||
import com.stdiet.common.core.controller.BaseController;
|
||||
import com.stdiet.common.core.domain.AjaxResult;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.custom.domain.SysWxUserLog;
|
||||
import com.stdiet.custom.service.ISysWxUserLogService;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.common.core.page.TableDataInfo;
|
||||
import com.stdiet.common.enums.BusinessType;
|
||||
import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.poi.ExcelUtil;
|
||||
import com.stdiet.custom.domain.SysOrder;
|
||||
import com.stdiet.custom.domain.SysWxUserInfo;
|
||||
import com.stdiet.custom.domain.SysWxUserLog;
|
||||
import com.stdiet.custom.service.ISysOrderService;
|
||||
import com.stdiet.custom.service.ISysWxUserInfoService;
|
||||
import com.stdiet.custom.service.ISysWxUserLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信用户记录Controller
|
||||
@ -27,18 +27,21 @@ import com.stdiet.common.core.page.TableDataInfo;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/custom/wxUserLog")
|
||||
public class SysWxUserLogController extends BaseController
|
||||
{
|
||||
public class SysWxUserLogController extends BaseController {
|
||||
@Autowired
|
||||
private ISysWxUserLogService sysWxUserLogService;
|
||||
|
||||
@Autowired
|
||||
private ISysWxUserInfoService sysWxUserInfoService;
|
||||
|
||||
private ISysOrderService sysOrderService;
|
||||
|
||||
/**
|
||||
* 查询微信用户记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public TableDataInfo list(SysWxUserLog sysWxUserLog) {
|
||||
startPage();
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(sysWxUserLog);
|
||||
return getDataTable(list);
|
||||
@ -50,8 +53,7 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:export')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public AjaxResult export(SysWxUserLog sysWxUserLog) {
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(sysWxUserLog);
|
||||
ExcelUtil<SysWxUserLog> util = new ExcelUtil<SysWxUserLog>(SysWxUserLog.class);
|
||||
return util.exportExcel(list, "wxUserLog");
|
||||
@ -62,8 +64,7 @@ public class SysWxUserLogController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:query')")
|
||||
@GetMapping(value = "/{openid}")
|
||||
public AjaxResult getInfo(@PathVariable("openid") String openid)
|
||||
{
|
||||
public AjaxResult getInfo(@PathVariable("openid") String openid) {
|
||||
return AjaxResult.success(sysWxUserLogService.selectSysWxUserLogById(openid));
|
||||
}
|
||||
|
||||
@ -73,8 +74,7 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:add')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public AjaxResult add(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
return toAjax(sysWxUserLogService.insertSysWxUserLog(sysWxUserLog));
|
||||
}
|
||||
|
||||
@ -84,8 +84,7 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:edit')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysWxUserLog sysWxUserLog)
|
||||
{
|
||||
public AjaxResult edit(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
|
||||
}
|
||||
|
||||
@ -95,17 +94,28 @@ public class SysWxUserLogController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:remove')")
|
||||
@Log(title = "微信用户记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{openids}")
|
||||
public AjaxResult remove(@PathVariable String[] openids)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable String[] openids) {
|
||||
return toAjax(sysWxUserLogService.deleteSysWxUserLogByIds(openids));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/wx/logs/{openid}")
|
||||
public TableDataInfo getLogInfo(@PathVariable("openid") String openid)
|
||||
{
|
||||
SysWxUserLog sysWxUserLog = new SysWxUserLog();
|
||||
sysWxUserLog.setOpenid(openid);
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(sysWxUserLog);
|
||||
return getDataTable(list);
|
||||
public AjaxResult getLogs(@PathVariable String openId) {
|
||||
SysWxUserLog querySysWxUserLog = new SysWxUserLog();
|
||||
querySysWxUserLog.setOpenid(openId);
|
||||
List<SysWxUserLog> list = sysWxUserLogService.selectSysWxUserLogList(querySysWxUserLog);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/wx/logs/add")
|
||||
public AjaxResult addLog(@RequestBody SysWxUserLog sysWxUserLog) {
|
||||
// 查询微信用户
|
||||
SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserLog.getOpenid());
|
||||
if(StringUtils.isNull(userInfo)) {
|
||||
return AjaxResult.error(5003, "没有用户信息");
|
||||
}
|
||||
// 提取有用值
|
||||
sysWxUserLog.setAvatarUrl(userInfo.getAvatarUrl());
|
||||
sysWxUserLog.setPhone(userInfo.getPhone());
|
||||
return add(sysWxUserLog);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user