权限校验

This commit is contained in:
ly19960718 2021-01-27 17:50:37 +08:00
parent 5a5cd82fdd
commit 6fcd8e958d
13 changed files with 304 additions and 367 deletions

View File

@ -2,6 +2,16 @@ package cn.com.tenlion.controller.apis.carduser;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.service.carduser.ICardUserService;
import cn.com.tenlion.util.check.CheckRequestBodyAnnotation;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.page.ListPage;
import cn.com.tenlion.util.result.ErrorResult;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.AbstractController;
@ -20,10 +30,8 @@ import java.util.Map;
@RestController
@RequestMapping("/carduser")
public class CardUserController {
/*
@Autowired
private ICardUserService cardUserService;*/
/*
private ICardUserService cardUserService;
@ApiOperation(value = "新增用户表", notes = "新增用户表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("savecarduser")
@ -63,7 +71,7 @@ public class CardUserController {
return cardUserService.getCardUserById(cardUserId);
}
@ApiOperation(value = "用户表列表", notes = "用户表列表接口")
/* @ApiOperation(value = "用户表列表", notes = "用户表列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listcarduser")
public List<CardUserDTO> listCardUser() throws SearchException {
@ -93,9 +101,9 @@ public class CardUserController {
SuccessResultData<Integer> countCardUser() throws SearchException {
Map<String, Object> params = requestParams();
return cardUserService.countCardUser(params);
}
}*/
@ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口")
/* @ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getcurrentuseridinfo")
public CurrentUserIdInfoDTO getCurrentUserIdInfo() {

View File

@ -1,25 +1,38 @@
/*
package cn.com.tenlion.controller.app.apis.carduser;
import cn.com.tenlion.accesstokenmanager.AccessTokenManager;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.dtos.weixinresult.WeiXinAuthResult;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.service.carduser.ICardUserService;
import cn.com.tenlion.util.AesUtil;
import cn.com.tenlion.util.check.CheckRequestBodyAnnotation;
import cn.com.tenlion.util.cons.ISystemConstant;
import cn.com.tenlion.util.exception.ParamsException;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.result.ErrorResult;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.vx.WxApiUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.AbstractController;
import cn.com.tenlion.controller.AbstractController;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
*/
/**
* @ClassName: CardUserAppController
* @Description: 用户表
* @Author: WenG
* @Author: LiuY
* @Date: 2021-01-26 10:55
* @Version: 1.0
**//*
**/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户表接口")
@RestController
@ -29,85 +42,95 @@ public class CardUserAppController extends AbstractController {
@Autowired
private ICardUserService cardUserService;
@ApiOperation(value = "新增用户表", notes = "新增用户表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("savecarduser")
@CheckRequestBodyAnnotation
public SuccessResult saveCardUser(@RequestHeader("token") String token, @RequestBody CardUserVO cardUserVO) throws Exception {
return cardUserService.saveCardUserByToken(token, cardUserVO);
/**
* 小程序登录
* @return
* @throws Exception
*/
@GetMapping("weiXinLoginBySmallRoutine"+ISystemConstant.RELEASE_SUFFIX+"/{vxCode}")
public SuccessResult weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception {
WxApiUtil wxapi = new WxApiUtil();
WeiXinAuthResult austerest = wxapi.weiXinLoginGetAuth(vxCode, ISystemConstant.VX_APP_ID, ISystemConstant.VX_APP_SECRET, ISystemConstant.VX_GRANT_TYPE);
if (austerest == null) {
throw new ParamsException("系统异常-1");
}
if (!austerest.getErrcode().equals("0")) {
throw new ParamsException("系统异常-2");
}
CardUserDTO carduserdto = cardUserService.getCardUserByVxOpenId(austerest.getOpenid());
String userId;
CardUserDTO userdto = null;
if (carduserdto != null) {
userId = carduserdto.getCardUserId();
userdto = carduserdto;
} else {
CardUserVO carduservo = new CardUserVO();
carduservo.setVxOpenId(austerest.getOpenid());
carduservo.setVxUnionId(austerest.getUnionid());
userId = cardUserService.saveCardUserReturnId(carduservo);
userdto = cardUserService.getCardUserByVxOpenId(userId);
}
String token = AesUtil.aesCommonEncoder(ISystemConstant.APP_TOKEN_AES_KEY, userId);
AccessTokenManager.getInstance().setKey(token, userdto);
AccessTokenManager.getInstance().updateLastActivityTime(token);
return new SuccessResultData<>(token);
}
@ApiOperation(value = "删除用户表(id列表)", notes = "删除用户表(id列表)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("removecarduser/{ids}")
public SuccessResult removeCardUser(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException {
return cardUserService.removeCardUserByToken(token, ids);
}
@ApiOperation(value = "修改用户表", notes = "修改用户表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("updatecarduser/{cardUserId}")
@CheckRequestBodyAnnotation
public SuccessResult updateCardUser(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId, @RequestBody CardUserVO cardUserVO) throws Exception {
return cardUserService.updateCardUserByToken(token, cardUserId, cardUserVO);
}
@ApiOperation(value = "用户表详情(通过ID)", notes = "用户表详情(通过ID)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getcarduserbyid/{cardUserId}")
public CardUserDTO getCardUserById(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId) throws SearchException {
return cardUserService.getCardUserById(cardUserId);
}
@ApiOperation(value = "用户表列表", notes = "用户表列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listcarduser")
public List<CardUserDTO> listCardUser(@RequestHeader("token") String token) throws SearchException {
Map<String, Object> params = requestParams();
return cardUserService.listCardUser(params);
}
@ApiOperation(value = "用户表分页列表", notes = "用户表分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagecarduser")
public SuccessResultList<List<CardUserDTO>> listPageCardUser(@RequestHeader("token") String token, ListPage page) throws SearchException {
Map<String, Object> params = requestParams();
page.setParams(params);
return cardUserService.listPageCardUser(page);
}
@ApiOperation(value = "用户表统计", notes = "用户表统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("countcarduser")
SuccessResultData<Integer> countCardUser() throws SearchException {
Map<String, Object> params = requestParams();
return cardUserService.countCardUser(params);
}
// @ApiOperation(value = "新增用户表", notes = "新增用户表接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @PostMapping("savecarduser")
// @CheckRequestBodyAnnotation
// public SuccessResult saveCardUser(@RequestHeader("token") String token, @RequestBody CardUserVO cardUserVO) throws Exception {
// return cardUserService.saveCardUserByToken(token, cardUserVO);
// }
//
// @ApiOperation(value = "删除用户表(id列表)", notes = "删除用户表(id列表)接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
// @ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @DeleteMapping("removecarduser/{ids}")
// public SuccessResult removeCardUser(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException {
// return cardUserService.removeCardUserByToken(token, ids);
// }
//
// @ApiOperation(value = "修改用户表", notes = "修改用户表接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
// @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @PutMapping("updatecarduser/{cardUserId}")
// @CheckRequestBodyAnnotation
// public SuccessResult updateCardUser(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId, @RequestBody CardUserVO cardUserVO) throws Exception {
// return cardUserService.updateCardUserByToken(token, cardUserId, cardUserVO);
// }
//
// @ApiOperation(value = "用户表详情(通过ID)", notes = "用户表详情(通过ID)接口")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "token", paramType = "header"),
// @ApiImplicitParam(name = "cardUserId", value = "用户表ID", paramType = "path")
// })
// @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
// @GetMapping("getcarduserbyid/{cardUserId}")
// public CardUserDTO getCardUserById(@RequestHeader("token") String token, @PathVariable("cardUserId") String cardUserId) throws SearchException {
// return cardUserService.getCardUserById(cardUserId);
// }
}*/
}

View File

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("app/datadictionary")
@RequestMapping("/app/datadictionary")
public class DataDictionaryAppController extends AbstractController {
@Autowired

View File

@ -1,41 +0,0 @@
package cn.com.tenlion.controller.app.apis.weixinlogin;
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 微信登录
* @version 1.0
* @author LY
* @date 2021/1/26 11:08
*/
@RestController
@RequestMapping("/weixinapplogin")
public class WeiXinLoginAppController {
@Autowired
private IWeiXinLoginService weiXinLoginService;
/**
* 小程序登录
* @return
* @throws Exception
*/
@GetMapping("weiXinLoginBySmallRoutine/{vxCode}")
public WeiXinLoginResult weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception{
return weiXinLoginService.weiXinLoginBySmallRoutine(vxCode);
}
}

View File

@ -1,7 +1,10 @@
package cn.com.tenlion.dao.carduser;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SaveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.exception.UpdateException;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -17,63 +20,73 @@ import java.util.Map;
@Repository
public interface ICardUserDao {
/**
* 根据微信open_id 获取用户信息
* @param params
* @return
* @throws SearchException
*/
CardUserDTO getCardUserByVxOpenId(Map<String,Object> params) throws SearchException;
/**
* 新增用户表
*
* @param params
* @throws Exception
* @throws SaveException
*/
void saveCardUser(Map<String, Object> params) throws Exception;
void saveCardUser(Map<String, Object> params) throws SaveException;
/**
* 删除用户表
*
* @param params
* @throws Exception
* @throws RemoveException
*/
void removeCardUser(Map<String, Object> params) throws Exception;
void removeCardUser(Map<String, Object> params) throws RemoveException;
/**
* 删除用户表物理
*
* @param params
* @throws Exception
* @throws RemoveException
*/
void deleteCardUser(Map<String, Object> params) throws Exception;
void deleteCardUser(Map<String, Object> params) throws RemoveException;
/**
* 修改用户表
*
* @param params
* @throws Exception
* @throws UpdateException
*/
void updateCardUser(Map<String, Object> params) throws Exception;
void updateCardUser(Map<String, Object> params) throws UpdateException;
/**
* 用户表详情
*
* @param params
* @return
* @throws Exception
* @throws SearchException
*/
CardUserDTO getCardUser(Map<String, Object> params) throws Exception;
CardUserDTO getCardUser(Map<String, Object> params) throws SearchException;
/**
* 用户表列表
*
* @param params
* @return
* @throws Exception
* @throws SearchException
*/
List<CardUserDTO> listCardUser(Map<String, Object> params) throws Exception;
List<CardUserDTO> listCardUser(Map<String, Object> params) throws SearchException;
/**
* 用户表统计
*
* @param params
* @return
* @throws Exception
* @throws SearchException
*/
Integer countCardUser(Map<String, Object> params) throws Exception;
Integer countCardUser(Map<String, Object> params) throws SearchException;
}

View File

@ -32,6 +32,11 @@ public class CardUserDTO {
*/
private String VxOpenId;
/**
* 账号最后活动时间用于token过期判断
*/
private long lastActivityTime;
public String getCardUserId() {
return cardUserId == null ? "" : cardUserId.trim();
}
@ -72,5 +77,11 @@ public class CardUserDTO {
this.VxOpenId = VxOpenId;
}
public long getLastActivityTime() {
return lastActivityTime;
}
public void setLastActivityTime(long lastActivityTime) {
this.lastActivityTime = lastActivityTime;
}
}

View File

@ -1,123 +1,112 @@
/*
package cn.com.tenlion.service.carduser;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.page.ListPage;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.result.SuccessResultList;
import java.util.List;
import java.util.Map;
*/
/**
* @ClassName: ICardUserService
* @Description: 用户表
* @Author: WenG
* @Date: 2021-01-26 10:55
* @Version: 1.0
**//*
**/
public interface ICardUserService {
/**
* 根据微信open_id获取用户详情
* @param vxOpenId
* @return
* @throws SearchException
*/
/**
CardUserDTO getCardUserByVxOpenId(String vxOpenId) throws SearchException;
/**
* 新增用户表
*
* @param cardUserVO
* @return
* @throws Exception
*//*
*/
SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception;
*/
/**
/**
* 新增用户表(APP)
*
* @param token
* @param cardUserVO
* @return
* @throws Exception
*//*
*/
SuccessResult saveCardUserByToken(String token, CardUserVO cardUserVO) throws Exception;
*/
/**
/**
* 新增用户表
*
* @param cardUserVO
* @return cardUserId
* @throws Exception
*//*
*/
String saveCardUserReturnId(CardUserVO cardUserVO) throws Exception;
*/
/**
/**
* 新增用户表(APP)
*
* @param token
* @param cardUserVO
* @return cardUserId
* @throws Exception
*//*
*/
String saveCardUserByTokenReturnId(String token, CardUserVO cardUserVO) throws Exception;
*/
/**
/**
* 删除用户表
*
* @param ids
* @return
* @throws RemoveException
*//*
*/
SuccessResult removeCardUser(String ids) throws RemoveException;
*/
/**
/**
* 删除用户表物理删除
*
* @param ids
* @throws RemoveException
*//*
*/
void deleteCardUser(String ids) throws RemoveException;
*/
/**
/**
* 删除用户表(APP)
*
* @param token
* @param ids
* @return
* @throws RemoveException
*//*
*/
SuccessResult removeCardUserByToken(String token, String ids) throws RemoveException;
*/
/**
/**
* 修改用户表
*
* @param cardUserId
* @param cardUserVO
* @return
* @throws Exception
*//*
*/
SuccessResult updateCardUser(String cardUserId, CardUserVO cardUserVO) throws Exception;
*/
/**
/**
* 修改用户表(APP)
*
* @param token
@ -125,63 +114,52 @@ public interface ICardUserService {
* @param cardUserVO
* @return
* @throws Exception
*//*
*/
SuccessResult updateCardUserByToken(String token, String cardUserId, CardUserVO cardUserVO) throws Exception;
*/
/**
/**
* 用户表详情(通过ID)
*
* @param cardUserId
* @return
* @throws SearchException
*//*
*/
CardUserDTO getCardUserById(String cardUserId) throws SearchException;
*/
/**
/**
* 用户表列表
*
* @param params
* @return
* @throws SearchException
*//*
*/
List<CardUserDTO> listCardUser(Map<String, Object> params) throws SearchException;
*/
/**
/**
* 用户表分页列表
*
* @param page
* @return
* @throws SearchException
*//*
*/
SuccessResultList<List<CardUserDTO>> listPageCardUser(ListPage page) throws SearchException;
*/
/**
/**
* 用户表统计
*
* @param params
* @return
* @throws SearchException
*//*
*/
Integer countNumberCardUser(Map<String, Object> params) throws SearchException;
*/
/**
/**
* 用户表统计
*
* @param params
* @return
* @throws SearchException
*//*
*/
SuccessResultData<Integer> countCardUser(Map<String, Object> params) throws SearchException;
}*/
}

View File

@ -1,32 +1,54 @@
/*
package cn.com.tenlion.service.carduser.impl;
import cn.com.tenlion.dao.carduser.ICardUserDao;
import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO;
import cn.com.tenlion.pojo.vos.carduser.CardUserVO;
import cn.com.tenlion.service.AbstractService;
import cn.com.tenlion.service.carduser.ICardUserService;
import cn.com.tenlion.util.base.DateUtil;
import cn.com.tenlion.util.base.HashMapUtil;
import cn.com.tenlion.util.base.UUIDUtil;
import cn.com.tenlion.util.exception.RemoveException;
import cn.com.tenlion.util.exception.SearchException;
import cn.com.tenlion.util.page.ListPage;
import cn.com.tenlion.util.result.SuccessResult;
import cn.com.tenlion.util.result.SuccessResultData;
import cn.com.tenlion.util.result.SuccessResultList;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
*/
/**
* @ClassName: CardUserServiceImpl
* @Description: 用户表
* @Author: WenG
* @Date: 2021-01-26 10:55
* @Version: 1.0
**//*
**/
@Service
public class CardUserServiceImpl implements ICardUserService {
public class CardUserServiceImpl extends AbstractService implements ICardUserService {
@Autowired
private ICardUserDao cardUserDao;
*/
/* @Override
/**
* 根据微信open_id获取用户详情
* @param vxOpenId
* @return
* @throws SearchException
*/
public CardUserDTO getCardUserByVxOpenId(String vxOpenId) throws SearchException{
Map<String, Object> params = new HashMap<>();
params.put("vxOpenId", vxOpenId);
return cardUserDao.getCardUserByVxOpenId(params);
}
@Override
public SuccessResult saveCardUser(CardUserVO cardUserVO) throws Exception {
saveCardUserInfo(null, cardUserVO);
return new SuccessResult();
@ -48,42 +70,35 @@ public class CardUserServiceImpl implements ICardUserService {
return saveCardUserInfoReturnId(token, cardUserVO);
}
*//*
*/
/**
/**
* 新增用户表
*
* @param token
* @param cardUserVO
* @throws Exception
*//*
*/
/*
*/
private void saveCardUserInfo(String token, CardUserVO cardUserVO) throws Exception {
saveCardUserInfoReturnId(token, cardUserVO);
}
*//*
*/
/**
/**
* 新增用户表
*
* @param token
* @param cardUserVO
* @return cardUserId
* @throws Exception
*//*
*/
/*
*/
private String saveCardUserInfoReturnId(String token, CardUserVO cardUserVO) throws Exception {
String cardUserId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(cardUserVO);
params.put("cardUserId", cardUserId);
if (token != null) {
params.put("gmtCreate", DateUtil.getTime());
/* if (token != null) {
setSaveInfo(token, params);
} else {
setSaveInfo(params);
}
}*/
cardUserDao.saveCardUser(params);
return cardUserId;
}
@ -100,29 +115,26 @@ public class CardUserServiceImpl implements ICardUserService {
return new SuccessResult();
}
*//*
*/
/**
/**
* 删除用户表
*
* @param token
* @param ids
*//*
*/
/*
*/
private void removeCardUserInfo(String token, String ids) {
Map<String, Object> params = getHashMap(3);
params.put("cardUserIds", Arrays.asList(ids.split("_")));
if (token != null) {
params.put("gmtModified",DateUtil.getTime());
/* if (token != null) {
setUpdateInfo(token, params);
} else {
setUpdateInfo(params);
}
}*/
cardUserDao.removeCardUser(params);
}
@Override
public void deleteCardUser(String ids) throws RemoveException {
public void deleteCardUser(String ids) throws RemoveException{
Map<String, Object> params = getHashMap(3);
params.put("cardUserIds", Arrays.asList(ids.split("_")));
cardUserDao.deleteCardUser(params);
@ -140,25 +152,22 @@ public class CardUserServiceImpl implements ICardUserService {
return new SuccessResult();
}
*//*
*/
/**
/**
* 修改用户表
*
* @param token
* @param cardUserId
* @param cardUserVO
*//*
*/
/*
*/
private void updateCardUserInfo(String token, String cardUserId, CardUserVO cardUserVO) throws Exception {
Map<String, Object> params = HashMapUtil.beanToMap(cardUserVO);
params.put("cardUserId", cardUserId);
if (token != null) {
params.put("gmtModified",DateUtil.getTime());
/* if (token != null) {
setUpdateInfo(token, params);
} else {
setUpdateInfo(params);
}
}*/
cardUserDao.updateCardUser(params);
}
@ -191,7 +200,6 @@ public class CardUserServiceImpl implements ICardUserService {
@Override
public SuccessResultData<Integer> countCardUser(Map<String, Object> params) throws SearchException {
return new SuccessResultData<>(countNumberCardUser(params));
}*//*
}
}*/
}

View File

@ -1,25 +0,0 @@
package cn.com.tenlion.service.weixinlogin;
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
import com.alibaba.fastjson.JSONObject;
/**
* TODO
* @version 1.0
* @author LY
* @date 2021/1/26 11:19
*/
public interface IWeiXinLoginService {
/**
* 微信小程序登录
* @param code
* @return
* @throws Exception
*/
WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception;
}

View File

@ -1,72 +0,0 @@
package cn.com.tenlion.service.weixinlogin.impl;
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
import cn.com.tenlion.util.AesUtil;
import cn.com.tenlion.util.WxUtil;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 微信登录
* @version 1.0
* @author LY
* @date 2021/1/26 11:20
*/
@Service
public class WeiXinLoginServiceImpl implements IWeiXinLoginService {
/**微信小程序获取session key 接口*/
private static String VX_SMALL_ROUTINE_SESSION_KEY = "https://api.weixin.qq.com/sns/jscode2session";
/**小程序 appId*/
private static String APP_ID = "wxa49a60262e53d305 ";
/**小程序 appSecret*/
private static String APP_SECRET = "fcb567e070d48fbb937b192fcc2a0b5b";
/**小程序授权类型*/
private static String GRANT_TYPE = "authorization_code";
/**
* 微信小程序登录
* @param code
* @return
* @throws Exception
*/
public WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception{
if(StringUtils.isEmpty(code)){
throw new Exception("code不能为空");
}
// 配置请求参数
Map<String, String> param = new HashMap<>();
param.put("appid", APP_ID);
param.put("secret", APP_SECRET);
param.put("js_code", code);
param.put("grant_type", GRANT_TYPE);
String str = WxUtil.doGet(VX_SMALL_ROUTINE_SESSION_KEY, param);
JSONObject json = JSONObject.parseObject(str);
Integer errcode = json.getInteger("errcode");
WeiXinLoginResult initResult = new WeiXinLoginResult();
if (errcode == 0) {
String skye = json.getString("session_key");
String openId = json.getString("openid");
String unionId = json.getString("unionid");
String token = AesUtil.aesCommonEncoder(skye,openId+unionId);
initResult.setCode("200");
initResult.setMsg("success");
initResult.setToken(token);
// json.getString("errmsg");
return initResult;
} else {
initResult.setCode("500");
initResult.setMsg("系统异常");
return initResult;
}
}
}

View File

@ -196,4 +196,18 @@ public interface ISystemConstant {
String DATE_FORMATTER_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
/**
* 小程序 appId*
*/
String VX_APP_ID = "wxa49a60262e53d305 ";
/**
* 小程序 appSecret
*/
String VX_APP_SECRET = "fcb567e070d48fbb937b192fcc2a0b5b";
/**
* 小程序授权类型
*/
String VX_GRANT_TYPE = "authorization_code";
}

View File

@ -1,4 +1,4 @@
package cn.com.tenlion.util;
package cn.com.tenlion.util.vx;
import com.sun.org.apache.xml.internal.security.utils.Base64;
import lombok.extern.slf4j.Slf4j;

View File

@ -10,9 +10,29 @@
<result column="vx_open_id" property="VxOpenId"/>
</resultMap>
<!-- 根据微信openId获取用户表详情 -->
<select id="getCardUserByVxOpenId" parameterType="map" resultMap="cardUserDTO">
SELECT
t1.user_name,
t1.user_phone,
t1.vx_union_id,
t1.vx_open_id,
t1.card_user_id
FROM
card_user t1
WHERE
t1.is_delete = 0
<if test="vxOpenId != null and vxOpenId != ''">
AND
t1.vx_open_id = #{vxOpenId}
</if>
</select>
<!-- 新增用户表 -->
<insert id="saveCardUser" parameterType="map">
INSERT INTO gen_card_user(
INSERT INTO card_user(
card_user_id,
user_name,
user_phone,
@ -40,7 +60,7 @@
<!-- 删除用户表 -->
<update id="removeCardUser" parameterType="map">
UPDATE
gen_card_user
card_user
SET
is_delete = 1,
modifier = #{modifier},
@ -55,7 +75,7 @@
<!-- 删除用户表(物理) -->
<update id="deleteCardUser" parameterType="map">
DELETE FROM
gen_card_user
card_user
WHERE
card_user_id IN
<foreach collection="cardUserIds" index="index" open="(" separator="," close=")">
@ -66,7 +86,7 @@
<!-- 修改用户表 -->
<update id="updateCardUser" parameterType="map">
UPDATE
gen_card_user
card_user
SET
<if test="userName != null and userName != ''">
user_name = #{userName},
@ -95,7 +115,7 @@
t1.vx_open_id,
t1.card_user_id
FROM
gen_card_user t1
card_user t1
WHERE
t1.is_delete = 0
<if test="cardUserId != null and cardUserId != ''">
@ -113,7 +133,7 @@
t1.vx_open_id,
t1.card_user_id
FROM
gen_card_user t1
card_user t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
@ -146,7 +166,7 @@
SELECT
COUNT(*)
FROM
gen_card_user t1
card_user t1
WHERE
t1.is_delete = 0
</select>