forked from dyf/fys-Multi-tenant
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@ -0,0 +1,75 @@
|
||||
// package com.fuyuanshen.app.controller.mp;
|
||||
//
|
||||
// import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
// import lombok.RequiredArgsConstructor;
|
||||
// import lombok.extern.slf4j.Slf4j;
|
||||
// import org.springframework.http.ResponseEntity;
|
||||
// import org.springframework.web.bind.annotation.GetMapping;
|
||||
// import org.springframework.web.bind.annotation.RequestBody;
|
||||
// import org.springframework.web.bind.annotation.RequestMapping;
|
||||
// import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
//
|
||||
// /**
|
||||
// * @author: 默苍璃
|
||||
// * @date: 2025-06-2313:56
|
||||
// */
|
||||
// @Slf4j
|
||||
// @RestController
|
||||
// @RequestMapping("/mp")
|
||||
// @RequiredArgsConstructor
|
||||
// @Tag(name = "小程序:相关接口")
|
||||
// public class MPController {
|
||||
// //
|
||||
// // private final TokenProvider tokenProvider;
|
||||
// // private final SecurityProperties properties;
|
||||
// // private final OnlineUserService onlineUserService;
|
||||
// // private final DeviceService deviceService;
|
||||
// // private final MPService mpService;
|
||||
// //
|
||||
// // @Log("小程序用户登录")
|
||||
// // @ApiOperation("小程序登录授权")
|
||||
// // @AnonymousPostMapping(value = "/login")
|
||||
// // public ResponseEntity<Object> login(@RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
// //
|
||||
// // // 获取用户信息
|
||||
// // User user = new User();
|
||||
// // user.setUsername("MP");
|
||||
// // user.setPassword("MP");
|
||||
// // AuthorityDto authorityDto = new AuthorityDto();
|
||||
// // authorityDto.setAuthority("MP");
|
||||
// // List<AuthorityDto> authorityDtos = new ArrayList<>();
|
||||
// // authorityDtos.add(authorityDto);
|
||||
// // user.setPhone(authUser.getPhoneNumber());
|
||||
// // JwtUserDto jwtUser = new JwtUserDto(null, user, null, authorityDtos);
|
||||
// //
|
||||
// // Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, authorityDtos);
|
||||
// // SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
// // // 生成令牌
|
||||
// // String token = tokenProvider.createToken(jwtUser);
|
||||
// // // 返回 token 与 用户信息
|
||||
// // Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
||||
// // put("token", properties.getTokenStartWith() + token);
|
||||
// // put("user", jwtUser);
|
||||
// // }};
|
||||
// //
|
||||
// // // 保存在线信息
|
||||
// // onlineUserService.save(jwtUser, token, request);
|
||||
// //
|
||||
// // // 返回登录信息
|
||||
// // return ResponseEntity.ok(authInfo);
|
||||
// // }
|
||||
// //
|
||||
// //
|
||||
// // @GetMapping("/queryDevice")
|
||||
// // @ApiOperation("是否存在设备MAC号")
|
||||
// // public ResponseVO<Boolean> queryDevice(@ApiParam("设备mac值") String mac) {
|
||||
// // return ResponseVO.success(mpService.queryDevice(mac));
|
||||
// // }
|
||||
//
|
||||
//
|
||||
// }
|
@ -30,6 +30,11 @@ public class UserApp extends TenantEntity {
|
||||
@TableId(value = "user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@ -42,6 +47,7 @@ public class UserApp extends TenantEntity {
|
||||
|
||||
/**
|
||||
* 用户类型(app_user系统用户)
|
||||
* 用户类型(app_user手机端,xcx_user小程序)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.fuyuanshen.equipment.enums;
|
||||
|
||||
/**
|
||||
* 用户类型枚举
|
||||
*
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-07-1210:31
|
||||
*/
|
||||
public enum AppUserTypeEnum {
|
||||
|
||||
APP_USER("app_user", "系统用户"),
|
||||
XCX_USER("xcx_user", "小程序用户");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
|
||||
AppUserTypeEnum(String code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserType{" +
|
||||
"code='" + code + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package com.fuyuanshen.equipment.service;
|
||||
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.equipment.domain.UserApp;
|
||||
import com.fuyuanshen.equipment.domain.bo.UserAppBo;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -23,5 +24,23 @@ public interface AppUserService {
|
||||
*/
|
||||
Boolean updateByBo(UserAppBo bo);
|
||||
|
||||
/**
|
||||
* 查询小程序用户信息
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return
|
||||
*/
|
||||
UserApp getMpUser(Long phoneNumber);
|
||||
|
||||
UserApp loadUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 新增小程序用户信息
|
||||
*
|
||||
* @param userApp
|
||||
* @return
|
||||
*/
|
||||
void saveMpUser(UserApp userApp);
|
||||
|
||||
|
||||
}
|
||||
|
@ -91,4 +91,11 @@ public interface DeviceService extends IService<Device> {
|
||||
|
||||
int unBindDevice(Long id);
|
||||
|
||||
/**
|
||||
* 检查设备MAC值是否存在
|
||||
*
|
||||
* @param mac
|
||||
* @return
|
||||
*/
|
||||
Boolean queryDevice(String mac);
|
||||
}
|
||||
|
@ -569,4 +569,24 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
return baseMapper.update(null, deviceUpdateWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备MAC号
|
||||
*
|
||||
* @param mac
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean queryDevice(String mac) {
|
||||
QueryWrapper<Device> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("device_mac", mac);
|
||||
List<Device> deviceList = deviceMapper.selectList(wrapper);
|
||||
if (CollectionUtil.isNotEmpty(deviceList)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.fuyuanshen.equipment.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.equipment.domain.UserApp;
|
||||
import com.fuyuanshen.equipment.domain.bo.UserAppBo;
|
||||
import com.fuyuanshen.equipment.enums.AppUserTypeEnum;
|
||||
import com.fuyuanshen.equipment.mapper.UserAppMapper;
|
||||
import com.fuyuanshen.equipment.service.AppUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -22,7 +24,7 @@ import java.util.Collection;
|
||||
@Service
|
||||
public class UserAppServiceImpl implements AppUserService {
|
||||
|
||||
private final UserAppMapper baseMapper;
|
||||
private final UserAppMapper userAppMapper;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,7 +36,42 @@ public class UserAppServiceImpl implements AppUserService {
|
||||
@Override
|
||||
public Boolean updateByBo(UserAppBo bo) {
|
||||
UserApp update = MapstructUtils.convert(bo, UserApp.class);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
return userAppMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询小程序用户信息
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public UserApp getMpUser(Long phoneNumber) {
|
||||
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("phonenumber", phoneNumber);
|
||||
queryWrapper.eq("user_type", AppUserTypeEnum.XCX_USER.getCode());
|
||||
return userAppMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserApp loadUserByUsername(String username) {
|
||||
QueryWrapper<UserApp> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_name", username);
|
||||
queryWrapper.eq("user_type", AppUserTypeEnum.XCX_USER.getCode());
|
||||
return userAppMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增小程序用户信息
|
||||
*
|
||||
* @param userApp
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void saveMpUser(UserApp userApp) {
|
||||
userAppMapper.insert(userApp);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user