提交
This commit is contained in:
parent
ab7163eea2
commit
b64e9a4e0d
@ -21,7 +21,7 @@
|
||||
<ul class="user-info">
|
||||
<li><div style="height: 100%"><svg-icon icon-class="login" /> 登录账号<div class="user-right">{{ user.username }}</div></div></li>
|
||||
<li><svg-icon icon-class="user1" /> 用户昵称 <div class="user-right">{{ user.nickName }}</div></li>
|
||||
<li><svg-icon icon-class="dept" /> 所属医院 <div class="user-right"> {{ user.dept.name }}</div></li>
|
||||
<li><svg-icon icon-class="dept" /> 所属部门 <div class="user-right"> {{ user.dept.name }}</div></li>
|
||||
<li><svg-icon icon-class="phone" /> 手机号码 <div class="user-right">{{ user.phone }}</div></li>
|
||||
<li><svg-icon icon-class="email" /> 用户邮箱 <div class="user-right">{{ user.email }}</div></li>
|
||||
<li>
|
||||
|
@ -17,9 +17,13 @@ package me.zhengjie.config.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import me.zhengjie.utils.ElConstant;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Tz
|
||||
*/
|
||||
@ -43,6 +47,16 @@ public class FileProperties {
|
||||
public ElPath getPath(){
|
||||
String os = System.getProperty("os.name");
|
||||
if(os.toLowerCase().startsWith(ElConstant.WIN)) {
|
||||
String dir = System.getProperty("user.dir");
|
||||
dir = dir.replace("\\","/");
|
||||
String path = windows.getPath();
|
||||
String avatar = windows.getAvatar();
|
||||
if (path.indexOf(dir) == -1) {
|
||||
windows.setPath(dir + path);
|
||||
}
|
||||
if (avatar.indexOf(dir) == -1) {
|
||||
windows.setAvatar(dir + avatar);
|
||||
}
|
||||
return windows;
|
||||
} else if(os.toLowerCase().startsWith(ElConstant.MAC)){
|
||||
return mac;
|
||||
|
@ -14,8 +14,8 @@ public class LoginVo {
|
||||
@ApiModelProperty(value = "状态:login-登录,register-注册")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "注册key")
|
||||
private String key;
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "登录用户Uid")
|
||||
private Long uid;
|
||||
|
@ -7,6 +7,8 @@ import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.annotation.rest.AnonymousPostMapping;
|
||||
import me.zhengjie.modules.front.domain.dto.LoginVo;
|
||||
import me.zhengjie.modules.front.service.WeChatService;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -26,7 +28,7 @@ public class WeChatController {
|
||||
/**
|
||||
* 微信登录小程序授权登录
|
||||
*/
|
||||
@Log("C端用户登录")
|
||||
@Log("用户授权登录")
|
||||
@ApiOperation(value = "微信登录小程序授权登录")
|
||||
@AnonymousPostMapping(value = "/authorize/login")
|
||||
public ResponseEntity<LoginVo> authorizeLogin(@RequestParam String code, HttpServletRequest request){
|
||||
@ -34,9 +36,18 @@ public class WeChatController {
|
||||
return new ResponseEntity<>(loginVo, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/hello")
|
||||
public ResponseEntity<String> hello() {
|
||||
return new ResponseEntity<>("Hello", HttpStatus.OK);
|
||||
@Log("用户信息")
|
||||
@ApiOperation("获取用户信息")
|
||||
@GetMapping(value = "/info")
|
||||
public ResponseEntity<LoginVo> getLoginInfo() {
|
||||
JwtUserDto jwtUser = (JwtUserDto) SecurityUtils.getCurrentUser();
|
||||
LoginVo loginVo = new LoginVo();
|
||||
loginVo.setType("login");
|
||||
loginVo.setUid(jwtUser.getUser().getId());
|
||||
loginVo.setNikeName(jwtUser.getUser().getNickName());
|
||||
loginVo.setAvatar(jwtUser.getUser().getAvatarPath());
|
||||
loginVo.setPhone(jwtUser.getUser().getPhone());
|
||||
return new ResponseEntity<>(loginVo, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
package me.zhengjie.modules.front.service;
|
||||
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.CusUser;
|
||||
|
||||
public interface CusUserService {
|
||||
|
||||
JwtUserDto addUserCache(CusUser cusUser);
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package me.zhengjie.modules.front.service.impl;
|
||||
|
||||
import me.zhengjie.modules.front.service.CusUserService;
|
||||
import me.zhengjie.modules.security.service.UserCacheManager;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.CusUser;
|
||||
import me.zhengjie.modules.system.domain.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Service
|
||||
public class CusUserServiceImpl implements CusUserService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(CusUserServiceImpl.class);
|
||||
|
||||
@Autowired private UserCacheManager userCacheManager;
|
||||
|
||||
@Override
|
||||
public JwtUserDto addUserCache(CusUser cusUser) {
|
||||
String openId = cusUser.getToken();
|
||||
JwtUserDto jwtUserDto = userCacheManager.getUserCache(openId);
|
||||
if (null == jwtUserDto) {
|
||||
User user = new User();
|
||||
user.setId(cusUser.getId());
|
||||
user.setUsername(cusUser.getToken());
|
||||
user.setNickName(cusUser.getNickname());
|
||||
user.setAvatarPath(cusUser.getAvatar());
|
||||
user.setPhone(cusUser.getPhone());
|
||||
user.setFlag(2);
|
||||
jwtUserDto = new JwtUserDto(user, new ArrayList<>(), new ArrayList<>());
|
||||
userCacheManager.addUserCache(cusUser.getToken(), jwtUserDto);
|
||||
}
|
||||
return jwtUserDto;
|
||||
}
|
||||
|
||||
}
|
@ -11,11 +11,9 @@ import me.zhengjie.modules.front.service.WeChatService;
|
||||
import me.zhengjie.modules.security.config.SecurityProperties;
|
||||
import me.zhengjie.modules.security.security.TokenProvider;
|
||||
import me.zhengjie.modules.security.service.OnlineUserService;
|
||||
import me.zhengjie.modules.security.service.UserCacheManager;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.CusUser;
|
||||
import me.zhengjie.modules.system.domain.User;
|
||||
import me.zhengjie.modules.system.mapper.CusUserMapper;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.mapper.BusUserMapper;
|
||||
import me.zhengjie.utils.DateUtil;
|
||||
import me.zhengjie.utils.RestTemplateUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -27,7 +25,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
public class WeChatServiceImpl implements WeChatService {
|
||||
@ -40,14 +38,14 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
@Value("${weChat.secret}")
|
||||
private String secret;
|
||||
|
||||
@Autowired private CusUserMapper cusUserMapper;
|
||||
@Autowired private BusUserMapper BusUserMapper;
|
||||
@Autowired private RestTemplateUtils restTemplateUtil;
|
||||
@Autowired private TokenProvider tokenProvider;
|
||||
@Autowired private UserCacheManager userCacheManager;
|
||||
@Autowired private SecurityProperties properties;
|
||||
@Autowired private OnlineUserService onlineUserService;
|
||||
@Autowired private CusUserService cusUserService;
|
||||
public static final String WECHAT_MINI_SNS_AUTH_CODE2SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session?appid={}&secret={}&js_code={}&grant_type=authorization_code";
|
||||
@Autowired private CusUserService BusUserService;
|
||||
private static final String WECHAT_MINI_SNS_AUTH_CODE2SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session?appid={}&secret={}&js_code={}&grant_type=authorization_code";
|
||||
private static final String DEFAULT_AVATAR = "/avatar/avatar.png";
|
||||
|
||||
@Override
|
||||
public LoginVo authorizeLogin(String code, HttpServletRequest request) {
|
||||
@ -56,25 +54,27 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
response.setOpenId("123456");
|
||||
String openId = response.getOpenId();
|
||||
String type = "login";
|
||||
CusUser cusUser = cusUserMapper.getUserByOpenId(openId);
|
||||
if (ObjectUtil.isNotNull(cusUser)) {
|
||||
if (cusUser.getStatus().equals(0)) { throw new BadRequestException("当前账户已禁用,请联系管理员!"); }
|
||||
BusUser BusUser = BusUserMapper.getUserByOpenId(openId);
|
||||
if (ObjectUtil.isNotNull(BusUser)) {
|
||||
if (BusUser.getStatus().equals(0)) { throw new BadRequestException("当前账户已禁用,请联系管理员!"); }
|
||||
} else {
|
||||
CusUser add = new CusUser();
|
||||
BusUser add = new BusUser();
|
||||
add.setSex(0);
|
||||
add.setRealName(DateUtil.localDateTimeFormat(LocalDateTime.now(), DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")));
|
||||
add.setNickname("微信用户");
|
||||
add.setNickname("用户_" + new Random().nextInt(900000) + 100000);
|
||||
add.setToken(openId);
|
||||
cusUserMapper.insert(add);
|
||||
cusUser = add;
|
||||
add.setAvatar(DEFAULT_AVATAR);
|
||||
BusUserMapper.insert(add);
|
||||
BusUser = add;
|
||||
type = "register";
|
||||
}
|
||||
loginVo.setType(type);
|
||||
loginVo.setUid(cusUser.getId());
|
||||
loginVo.setNikeName(cusUser.getNickname());
|
||||
loginVo.setPhone(cusUser.getPhone());
|
||||
loginVo.setUid(BusUser.getId());
|
||||
loginVo.setNikeName(BusUser.getNickname());
|
||||
loginVo.setPhone(BusUser.getPhone());
|
||||
loginVo.setAvatar(BusUser.getAvatar());
|
||||
// 生成令牌
|
||||
JwtUserDto jwtUserDto = cusUserService.addUserCache(cusUser);
|
||||
JwtUserDto jwtUserDto = BusUserService.addUserCache(BusUser);
|
||||
String token = tokenProvider.createToken(jwtUserDto);
|
||||
loginVo.setToken(properties.getTokenStartWith() + token);
|
||||
// 保存在线信息
|
||||
|
@ -18,12 +18,12 @@ package me.zhengjie.modules.security.service;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.front.service.CusUserService;
|
||||
import me.zhengjie.modules.security.service.dto.AuthorityDto;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.CusUser;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.User;
|
||||
import me.zhengjie.modules.system.mapper.CusUserMapper;
|
||||
import me.zhengjie.modules.system.mapper.BusUserMapper;
|
||||
import me.zhengjie.modules.system.service.BusUserService;
|
||||
import me.zhengjie.modules.system.service.DataService;
|
||||
import me.zhengjie.modules.system.service.RoleService;
|
||||
import me.zhengjie.modules.system.service.UserService;
|
||||
@ -31,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -46,8 +45,8 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
private final RoleService roleService;
|
||||
private final DataService dataService;
|
||||
private final UserCacheManager userCacheManager;
|
||||
@Autowired private CusUserService cusUserService;
|
||||
@Autowired private CusUserMapper cusUserMapper;
|
||||
@Autowired private BusUserService busUserService;
|
||||
@Autowired private BusUserMapper BusUserMapper;
|
||||
|
||||
@Override
|
||||
public JwtUserDto loadUserByUsername(String username) {
|
||||
@ -56,13 +55,13 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
User user = userService.getLoginData(username);
|
||||
if (user == null) {
|
||||
String openId = username;
|
||||
CusUser cusUser = cusUserMapper.getUserByOpenId(openId);
|
||||
if (null == cusUser) {
|
||||
BusUser BusUser = BusUserMapper.getUserByOpenId(openId);
|
||||
if (null == BusUser) {
|
||||
throw new BadRequestException("用户不存在");
|
||||
} else if (!cusUser.getStatus().equals(1)) {
|
||||
} else if (!BusUser.getStatus().equals(1)) {
|
||||
throw new BadRequestException("账号已注销!");
|
||||
}
|
||||
cusUserService.addUserCache(cusUser);
|
||||
busUserService.addUserCache(BusUser);
|
||||
} else {
|
||||
if (!user.getEnabled()) {
|
||||
throw new BadRequestException("账号未激活!");
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@ -28,8 +30,8 @@ import java.sql.Timestamp;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cus_user")
|
||||
public class CusUser extends BaseEntity implements Serializable {
|
||||
@TableName("bus_user")
|
||||
public class BusUser extends BaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
@ -47,7 +49,7 @@ public class CusUser extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "token")
|
||||
@ApiModelProperty(value = "openId")
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty(value = "1为正常,0为禁止")
|
||||
@ -59,4 +61,8 @@ public class CusUser extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Timestamp createTime;
|
||||
|
||||
public void copy(BusUser source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Tz
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.system.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @author tz
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Data
|
||||
public class BusUserQueryCriteria{
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
@ -16,11 +16,12 @@
|
||||
package me.zhengjie.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import me.zhengjie.modules.system.domain.CusUser;
|
||||
import me.zhengjie.modules.system.domain.Menu;
|
||||
import me.zhengjie.modules.system.domain.dto.DashboardDataVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.dto.BusUserQueryCriteria;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -29,8 +30,12 @@ import java.util.List;
|
||||
* @date 2023-06-19
|
||||
*/
|
||||
@Mapper
|
||||
public interface CusUserMapper extends BaseMapper<CusUser> {
|
||||
public interface BusUserMapper extends BaseMapper<BusUser> {
|
||||
|
||||
CusUser getUserByOpenId(@Param("openId") String openId);
|
||||
BusUser getUserByOpenId(@Param("openId") String openId);
|
||||
|
||||
IPage<BusUser> findAll(@Param("criteria") BusUserQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
List<BusUser> findAll(@Param("criteria") BusUserQueryCriteria criteria);
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Tz
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.system.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.dto.BusUserQueryCriteria;
|
||||
import me.zhengjie.modules.system.service.BusUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import java.util.List;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import me.zhengjie.utils.PageResult;
|
||||
|
||||
/**
|
||||
* @author tz
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "busUser")
|
||||
@RequestMapping("/api/busUser")
|
||||
public class BusUserController {
|
||||
|
||||
private final BusUserService busUserService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询busUser")
|
||||
@PreAuthorize("@el.check('busUser:list')")
|
||||
public ResponseEntity<PageResult<BusUser>> queryBusUser(BusUserQueryCriteria criteria){
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(busUserService.queryAll(criteria,page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增busUser")
|
||||
@ApiOperation("新增busUser")
|
||||
@PreAuthorize("@el.check('busUser:add')")
|
||||
public ResponseEntity<Object> createBusUser(@Validated @RequestBody BusUser resources){
|
||||
busUserService.create(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改busUser")
|
||||
@ApiOperation("修改busUser")
|
||||
@PreAuthorize("@el.check('busUser:edit')")
|
||||
public ResponseEntity<Object> updateBusUser(@Validated @RequestBody BusUser resources){
|
||||
busUserService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除busUser")
|
||||
@ApiOperation("删除busUser")
|
||||
@PreAuthorize("@el.check('busUser:del')")
|
||||
public ResponseEntity<Object> deleteBusUser(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
|
||||
busUserService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Tz
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.system.service;
|
||||
|
||||
import me.zhengjie.domain.BusUser;
|
||||
import me.zhengjie.domain.dto.BusUserQueryCriteria;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.dto.BusUserQueryCriteria;
|
||||
import me.zhengjie.utils.PageResult;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author tz
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
public interface BusUserService extends IService<BusUser> {
|
||||
|
||||
JwtUserDto addUserCache(BusUser BusUser);
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return PageResult
|
||||
*/
|
||||
PageResult<BusUser> queryAll(BusUserQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<BusUserDto>
|
||||
*/
|
||||
List<BusUser> queryAll(BusUserQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
*/
|
||||
void create(BusUser resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(BusUser resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(List<Long> ids);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Tz
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.system.service.impl;
|
||||
|
||||
import me.zhengjie.modules.security.service.UserCacheManager;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.domain.BusUser;
|
||||
import me.zhengjie.modules.system.domain.User;
|
||||
import me.zhengjie.modules.system.domain.dto.BusUserQueryCriteria;
|
||||
import me.zhengjie.modules.system.mapper.BusUserMapper;
|
||||
import me.zhengjie.modules.system.service.BusUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import me.zhengjie.utils.PageResult;
|
||||
|
||||
/**
|
||||
* @description 服务实现
|
||||
* @author tz
|
||||
* @date 2025-05-19
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BusUserServiceImpl extends ServiceImpl<BusUserMapper, BusUser> implements BusUserService {
|
||||
|
||||
private final BusUserMapper busUserMapper;
|
||||
@Autowired private UserCacheManager userCacheManager;
|
||||
|
||||
@Override
|
||||
public PageResult<BusUser> queryAll(BusUserQueryCriteria criteria, Page<Object> page){
|
||||
return PageUtil.toPage(busUserMapper.findAll(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusUser> queryAll(BusUserQueryCriteria criteria){
|
||||
return busUserMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(BusUser resources) {
|
||||
busUserMapper.insert(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(BusUser resources) {
|
||||
BusUser busUser = getById(resources.getId());
|
||||
busUser.copy(resources);
|
||||
busUserMapper.updateById(busUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(List<Long> ids) {
|
||||
busUserMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JwtUserDto addUserCache(BusUser BusUser) {
|
||||
String openId = BusUser.getToken();
|
||||
JwtUserDto jwtUserDto = userCacheManager.getUserCache(openId);
|
||||
if (null == jwtUserDto) {
|
||||
User user = new User();
|
||||
user.setId(BusUser.getId());
|
||||
user.setUsername(BusUser.getToken());
|
||||
user.setNickName(BusUser.getNickname());
|
||||
user.setAvatarPath(BusUser.getAvatar());
|
||||
user.setPhone(BusUser.getPhone());
|
||||
user.setFlag(2);
|
||||
jwtUserDto = new JwtUserDto(user, new ArrayList<>(), new ArrayList<>());
|
||||
userCacheManager.addUserCache(BusUser.getToken(), jwtUserDto);
|
||||
}
|
||||
return jwtUserDto;
|
||||
}
|
||||
|
||||
}
|
@ -116,8 +116,8 @@ file:
|
||||
path: /home/eladmin/file/
|
||||
avatar: /home/eladmin/avatar/
|
||||
windows:
|
||||
path: C:\eladmin\file\
|
||||
avatar: C:\eladmin\avatar\
|
||||
path: /eladmin/eladmin-upload/file/
|
||||
avatar: /eladmin/eladmin-upload/avatar/
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="me.zhengjie.modules.system.mapper.BusUserMapper">
|
||||
<resultMap id="BaseResultMap" type="me.zhengjie.modules.system.domain.BusUser">
|
||||
<id column="id" property="id"/>
|
||||
<result column="real_name" property="realName"/>
|
||||
<result column="nickname" property="nickname"/>
|
||||
<result column="avatar" property="avatar"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="token" property="token"/>
|
||||
<result column="sex" property="sex"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="update_by" property="updateBy"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, real_name, nickname, avatar, phone, status, token, sex, create_by, update_by, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<select id="findAll" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from bus_user
|
||||
<where>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="getUserByOpenId" resultType="me.zhengjie.modules.system.domain.BusUser">
|
||||
select id, real_name realName, nickname, avatar, phone, status, token, sex, create_time createTime
|
||||
from bus_user where token = #{openId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="me.zhengjie.modules.system.mapper.CusUserMapper">
|
||||
|
||||
<select id="getUserByOpenId" resultType="me.zhengjie.modules.system.domain.CusUser">
|
||||
select id, real_name realName, nickname, avatar, phone, status, token, sex, create_time createTime
|
||||
from cus_user where token = #{openId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -15,7 +15,7 @@
|
||||
UNION ALL
|
||||
select 'role' text, count(*) value from sys_role
|
||||
UNION ALL
|
||||
select 'law' text, count(*) value from bus_law_enforcement
|
||||
select 'law' text, count(*) value from bus_user
|
||||
</select>
|
||||
|
||||
<select id="getLineChartData" resultType="me.zhengjie.modules.system.domain.dto.DashboardDataVo">
|
||||
|
@ -10,6 +10,7 @@
|
||||
<modules>
|
||||
<module>eladmin-common</module>
|
||||
<module>eladmin-logging</module>
|
||||
<module>eladmin-tools</module>
|
||||
<module>eladmin-system</module>
|
||||
<module>eladmin-generator</module>
|
||||
</modules>
|
||||
|
Loading…
Reference in New Issue
Block a user