Commit 475bb004 by zzrdark

1.fix设备模块 生产配置

2.个人信息
parent b242d937
...@@ -231,8 +231,8 @@ CREATE TABLE `sys_user` ( ...@@ -231,8 +231,8 @@ CREATE TABLE `sys_user` (
`user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户id', `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户id',
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名', `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
`password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
`salt` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '加密盐',
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '邮箱', `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '邮箱',
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '简介',
`mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '手机', `mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '手机',
`status` int(11) DEFAULT NULL COMMENT '账户状态 0:禁用 1:正常', `status` int(11) DEFAULT NULL COMMENT '账户状态 0:禁用 1:正常',
`create_time` date DEFAULT NULL COMMENT '创建时间', `create_time` date DEFAULT NULL COMMENT '创建时间',
......
...@@ -32,10 +32,12 @@ public class SysUserEntity implements Serializable { ...@@ -32,10 +32,12 @@ public class SysUserEntity implements Serializable {
* 密码 * 密码
*/ */
private String password; private String password;
/** /**
* 加密盐 * 简介
*/ */
private String salt; private String remark;
/** /**
* 邮箱 * 邮箱
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<result property="userId" column="user_id"/> <result property="userId" column="user_id"/>
<result property="username" column="username"/> <result property="username" column="username"/>
<result property="password" column="password"/> <result property="password" column="password"/>
<result property="salt" column="salt"/> <result property="remark" column="remark"/>
<result property="email" column="email"/> <result property="email" column="email"/>
<result property="mobile" column="mobile"/> <result property="mobile" column="mobile"/>
<result property="status" column="status"/> <result property="status" column="status"/>
......
...@@ -15,12 +15,24 @@ ...@@ -15,12 +15,24 @@
<artifactId>cneeds-common-pojo</artifactId> <artifactId>cneeds-common-pojo</artifactId>
<!--<dependencies> <dependencies>
<dependency> <!--<dependency>
<groupId>com.mx.cneeds</groupId> <groupId>com.mx.cneeds</groupId>
<artifactId>cneeds-common-utils</artifactId> <artifactId>cneeds-common-utils</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>compile</scope>
</dependency> </dependency>
</dependencies>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
package com.mx.cneeds.common.dto;
import lombok.Data;
import java.util.Date;
/**
* @ClassName DeviceDto
* @Author zzrdark
* @Date 2020-03-25 18:51
* @Description TODO
**/
@Data
public class DeviceInfoDto {
/**
* 设备id
*/
private Long deviceId;
/**
*
*/
private Long deptId;
/**
* imei
*/
private String imei;
/**
* iccid
*/
private String iccid;
/**
* 状态0未激活,1已激活
*/
private String status;
/**
* 设备版本
*/
private String deviceVersion;
/**
* 产品系列
*/
private Long seriesId;
/**
* 创建时间
*/
private Date createTime;
/**
* 激活时间
*/
private Date activeTime;
/**
* 渠道号
*/
private String channelNums;
/**
* 渠道号提示信息
*/
private String channelNumsMessage;
/**
* 0:黑名单,1:白名单
*/
private Integer channelRules;
/**
* 产品系列号
*/
private String seriesNum;
}
...@@ -26,10 +26,12 @@ public class UserDto implements Serializable { ...@@ -26,10 +26,12 @@ public class UserDto implements Serializable {
* 密码 * 密码
*/ */
private String password; private String password;
/** /**
* 加密盐 * 简介
*/ */
private String salt; private String remark;
/** /**
* 邮箱 * 邮箱
*/ */
...@@ -52,9 +54,21 @@ public class UserDto implements Serializable { ...@@ -52,9 +54,21 @@ public class UserDto implements Serializable {
*/ */
private Date createTime; private Date createTime;
private List<Long> funcIdList; /**
* 用户模块Id
*/
private List<Long> userFuncIdList;
/**
* 用户部门Id
*/
private List<Long> userDeptIdList;
/**
* 模块权限名
*/
private List<String> funcPerms;
private List<Long> deptIdList;
private Long roleId; private Long roleId;
} }
...@@ -27,10 +27,12 @@ public class UserVo implements Serializable { ...@@ -27,10 +27,12 @@ public class UserVo implements Serializable {
* 密码 * 密码
*/ */
private String password; private String password;
/** /**
* 加密盐 * 简介
*/ */
private String salt; private String remark;
/** /**
* 邮箱 * 邮箱
*/ */
...@@ -55,9 +57,9 @@ public class UserVo implements Serializable { ...@@ -55,9 +57,9 @@ public class UserVo implements Serializable {
private Date createTime; private Date createTime;
private List<Long> funcIdList; private List<Long> userFuncIdList;
private List<Long> deptIdList; private List<Long> userDeptIdList;
private Long roleId; private Long roleId;
} }
...@@ -43,6 +43,11 @@ ...@@ -43,6 +43,11 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>${commons.io.version}</version> <version>${commons.io.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.mx.cneeds</groupId> <groupId>com.mx.cneeds</groupId>
......
...@@ -7,9 +7,9 @@ mvn clean package -Dmaven.test.skip=true -U ...@@ -7,9 +7,9 @@ mvn clean package -Dmaven.test.skip=true -U
#docker push hub.c.163.com/springcloud/eureka #docker push hub.c.163.com/springcloud/eureka
docker build -t zzrdark/eureka . #docker build -t zzrdark/eureka .
docker push zzrdark/eureka #docker push zzrdark/eureka
# docker build -t 192.168.2.244:5000/eureka . docker build -t 192.168.2.244:5000/springcloud_authorization .
# docker push 192.168.2.244:5000/eureka docker push 192.168.2.244:5000/springcloud_authorization
\ No newline at end of file \ No newline at end of file
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
<mysql.version>8.0.16</mysql.version> <mysql.version>8.0.16</mysql.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- eureka-client --> <!-- eureka-client -->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
......
spring: spring:
profiles: profiles:
active: prod active: dev
application: application:
name: cneeds-server-authorization name: cneeds-server-authorization
server: server:
......
...@@ -10,7 +10,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; ...@@ -10,7 +10,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
**/ **/
public class PasswordEncode { public class PasswordEncode {
public static void main(String[] args) { public static void main(String[] args) {
String password = "admin"; String password = "123456";
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String enPassword1 = encoder.encode(password); String enPassword1 = encoder.encode(password);
String enPassword2 = encoder.encode(password); String enPassword2 = encoder.encode(password);
......
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
...@@ -53,6 +56,17 @@ ...@@ -53,6 +56,17 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.mx.cneeds.server.datashow.client; package com.mx.cneeds.server.datashow.client;
import com.mx.cneeds.common.dto.DeviceInfoDto;
import com.mx.cneeds.common.dto.DevicesDto; import com.mx.cneeds.common.dto.DevicesDto;
import com.mx.cneeds.common.dto.PageDto; import com.mx.cneeds.common.dto.PageDto;
import com.mx.cneeds.common.dto.SeriesDto; import com.mx.cneeds.common.dto.SeriesDto;
...@@ -38,12 +39,17 @@ public interface DeviceClient { ...@@ -38,12 +39,17 @@ public interface DeviceClient {
void deleteSeries(@RequestBody List<Long> ids); void deleteSeries(@RequestBody List<Long> ids);
@PostMapping("device/info/list") @PostMapping("device/info/list")
PageDto deviceList(@RequestParam Integer page, PageDto deviceList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize, @RequestParam("limit") Integer pageSize,
@RequestParam("sidx") String orderField, @RequestParam("sidx") String orderField,
@RequestParam("order") String order); @RequestParam("order") String order);
@PostMapping("/device/info/infoByImei")
DeviceInfoDto queryDeviceByImei(@RequestParam String imei);
@PostMapping("/device/info/importDevice") @PostMapping("/device/info/importDevice")
void importDevice(@RequestBody DevicesDto dto); void importDevice(@RequestBody DevicesDto dto);
......
...@@ -3,6 +3,7 @@ package com.mx.cneeds.server.datashow.config; ...@@ -3,6 +3,7 @@ package com.mx.cneeds.server.datashow.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
...@@ -49,4 +50,9 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter { ...@@ -49,4 +50,9 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
converter.setSigningKey("imooc"); converter.setSigningKey("imooc");
return converter; return converter;
} }
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder(){
return new BCryptPasswordEncoder();
}
} }
\ No newline at end of file
...@@ -34,8 +34,9 @@ public class DeviceController { ...@@ -34,8 +34,9 @@ public class DeviceController {
@GetMapping("/device/getChannel") @GetMapping("/device/getChannel")
public R getChannel_nums(String imei){ public R getChannel_nums(String imei){
DeviceChannelVo channelVo = new DeviceChannelVo("123456,112233,654321", "提示的信息", 0); DeviceChannelVo channelVo = new DeviceChannelVo();
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(imei);
BeanUtils.copyProperties(deviceInfoDto,channelVo);
return new R().put("data",channelVo); return new R().put("data",channelVo);
} }
......
...@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -31,6 +32,9 @@ public class SystemController { ...@@ -31,6 +32,9 @@ public class SystemController {
@Autowired @Autowired
private UserClient userClient; private UserClient userClient;
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
@PostMapping("/module/list") @PostMapping("/module/list")
public R funcList(@RequestParam(required = false) Integer page, public R funcList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize, @RequestParam(required = false) Integer pageSize,
...@@ -348,7 +352,6 @@ public class SystemController { ...@@ -348,7 +352,6 @@ public class SystemController {
} }
PageDto pageDto = userClient.userList(page,pageSize,orderField,order); PageDto pageDto = userClient.userList(page,pageSize,orderField,order);
return new R().put("data",pageDto); return new R().put("data",pageDto);
} }
...@@ -361,6 +364,7 @@ public class SystemController { ...@@ -361,6 +364,7 @@ public class SystemController {
@RequestMapping("/user/add") @RequestMapping("/user/add")
public R addUser(UserVo vo){ public R addUser(UserVo vo){
UserDto dto = new UserDto(); UserDto dto = new UserDto();
vo.setPassword(bCryptPasswordEncoder.encode(vo.getPassword()));
BeanUtils.copyProperties(vo,dto); BeanUtils.copyProperties(vo,dto);
userClient.addUser(dto); userClient.addUser(dto);
return R.ok(); return R.ok();
...@@ -369,6 +373,10 @@ public class SystemController { ...@@ -369,6 +373,10 @@ public class SystemController {
@PostMapping("/user/update") @PostMapping("/user/update")
public R editUser(UserVo vo){ public R editUser(UserVo vo){
UserDto dto = new UserDto(); UserDto dto = new UserDto();
if (StringUtils.isNotEmpty(vo.getPassword())
&& StringUtils.isNotBlank(vo.getPassword().trim())) {
vo.setPassword(bCryptPasswordEncoder.encode(vo.getPassword()));
}
BeanUtils.copyProperties(vo,dto); BeanUtils.copyProperties(vo,dto);
userClient.updateUser(dto); userClient.updateUser(dto);
return R.ok(); return R.ok();
......
package com.mx.cneeds.server.datashow.web.system; package com.mx.cneeds.server.datashow.web.system;
import com.mx.cneeds.common.UserUtils;
import com.mx.cneeds.common.dto.UserDto;
import com.mx.cneeds.common.result.R; import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.UserInfoVo; import com.mx.cneeds.common.vo.UserInfoVo;
import com.mx.cneeds.server.datashow.client.AuthorizationClient; import com.mx.cneeds.server.datashow.client.AuthorizationClient;
...@@ -49,10 +51,24 @@ public class UserController { ...@@ -49,10 +51,24 @@ public class UserController {
@RequestMapping("/info") @RequestMapping("/info")
public R getInfo(){ public R getInfo(){
UserDto userDto = userClient.userInfo(UserUtils.getUserName());
UserInfoVo userInfoVo = new UserInfoVo(); UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setName("admin");
if (userDto.getUserId()==1){
userInfoVo.setRoles("admin");
}else {
StringBuffer sb = new StringBuffer();
userDto.getFuncPerms().forEach(perms -> {
sb.append(perms+",");
});
sb.substring(0,sb.length()-2);
userInfoVo.setRoles(sb.toString());
}
userInfoVo.setName(userDto.getUsername());
userInfoVo.setIntroduction("manager"); userInfoVo.setIntroduction("manager");
userInfoVo.setRoles("book:editor,admin");
userInfoVo.setAvatar("avatar"); userInfoVo.setAvatar("avatar");
return new R().put("data",userInfoVo); return new R().put("data",userInfoVo);
} }
......
spring: spring:
profiles: profiles:
active: prod active: dev
application: application:
name: cneeds-server-datashow name: cneeds-server-datashow
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -19,5 +19,7 @@ public interface DeviceInfoService extends IService<DeviceInfoEntity> { ...@@ -19,5 +19,7 @@ public interface DeviceInfoService extends IService<DeviceInfoEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
void updateBatchByImei(List<DeviceInfoEntity> deviceInfoEntityList); void updateBatchByImei(List<DeviceInfoEntity> deviceInfoEntityList);
DeviceInfoEntity queryDeviceByImei(String imei);
} }
...@@ -60,4 +60,11 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoDao, DeviceInfo ...@@ -60,4 +60,11 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoDao, DeviceInfo
}); });
} }
@Override
public DeviceInfoEntity queryDeviceByImei(String imei){
DeviceInfoEntity deviceInfoEntity = getBaseMapper().selectOne(new QueryWrapper<DeviceInfoEntity>()
.eq("imei", imei));
return deviceInfoEntity;
}
} }
...@@ -2,12 +2,14 @@ package com.mx.cneeds.server.device.web; ...@@ -2,12 +2,14 @@ package com.mx.cneeds.server.device.web;
import java.util.*; import java.util.*;
import com.mx.cneeds.common.dto.DeviceInfoDto;
import com.mx.cneeds.common.dto.DevicesDto; import com.mx.cneeds.common.dto.DevicesDto;
import com.mx.cneeds.common.pager.PageUtils; import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.result.R; import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.validator.ValidatorUtils; import com.mx.cneeds.common.validator.ValidatorUtils;
import com.mx.cneeds.server.device.service.DeviceInfoService; import com.mx.cneeds.server.device.service.DeviceInfoService;
import com.mx.cneeds.server.entity.DeviceInfoEntity; import com.mx.cneeds.server.entity.DeviceInfoEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -52,6 +54,17 @@ public class DeviceInfoController { ...@@ -52,6 +54,17 @@ public class DeviceInfoController {
} }
/** /**
* 信息
*/
@RequestMapping("/infoByImei")
public DeviceInfoDto infoByimei(String imei){
DeviceInfoEntity deviceInfoEntity = deviceInfoService.queryDeviceByImei(imei);
DeviceInfoDto deviceInfoDto = new DeviceInfoDto();
BeanUtils.copyProperties(deviceInfoEntity,deviceInfoDto);
return deviceInfoDto;
}
/**
* 保存 * 保存
*/ */
@RequestMapping("/save") @RequestMapping("/save")
......
spring: spring:
profiles: profiles:
active: prod active: dev
application: application:
name: cneeds-server-device name: cneeds-server-device
......
...@@ -19,12 +19,6 @@ ...@@ -19,12 +19,6 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
......
...@@ -6,7 +6,8 @@ eureka: ...@@ -6,7 +6,8 @@ eureka:
## 单机的时候开启 ## 单机的时候开启
register-with-eureka: false register-with-eureka: false
fetch-registry: 'false'
 fetch-registry: 'false'

# server: server:
use-read-only-response-cache: false
# enable-self-preservation: false # enable-self-preservation: false
instance: instance:
prefer-ip-address: true prefer-ip-address: true
spring: spring:
profiles: profiles:
active: prod active: dev
application: application:
name: cneeds-server-eureka name: cneeds-server-eureka
server: server:
......
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.2.244:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
password: cneeds!QAZ1qaz
username: root
# hikari:
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://192.168.2.244:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
# username: root
# password: cneeds!QAZ1qaz
# datasource:
# type: com.alibaba.druid.pool.DruidDataSource
# druid:
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://192.168.2.244:3306/cneeds_server?useUnicode=true&characterEncoding=UTF-8&useSSL=false
# username: root
# password: cneeds!QAZ1qaz
# initial-size: 10
# max-active: 100
# min-idle: 10
# max-wait: 60000
# pool-prepared-statements: true
# max-pool-prepared-statement-per-connection-size: 20
# time-between-eviction-runs-millis: 60000
# min-evictable-idle-time-millis: 300000
# #Oracle需要打开注释
# #validation-query: SELECT 1 FROM DUAL
# test-while-idle: true
# test-on-borrow: false
# test-on-return: false
# stat-view-servlet:
# enabled: true
# url-pattern: /druid/*
# #login-username: admin
# #login-password: admin
# filter:
# stat:
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: false
# wall:
# config:
# multi-statement-allow: true
eureka:
client:
service-url:
defaultZone: http://192.168.2.244:8761/eureka/
instance:
prefer-ip-address: true
ip-address: 192.168.2.244
spring:
profiles:
active: dev
application:
name: cneeds-server-logupload
server:
port: 9003
servlet:
context-path: /
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.mx.cneeds.server.entity
global-config:
#数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy: NOT_NULL
#驼峰下划线转换
column-underline: true
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
#原生配置
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.mx.cneeds.common.pager.PageUtils; import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.server.entity.SysFuncEntity; import com.mx.cneeds.server.entity.SysFuncEntity;
import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -16,5 +18,7 @@ import java.util.Map; ...@@ -16,5 +18,7 @@ import java.util.Map;
public interface SysFuncService extends IService<SysFuncEntity> { public interface SysFuncService extends IService<SysFuncEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
List<SysFuncEntity> queryFuncByIds(Collection<Long> funcId);
} }
...@@ -23,6 +23,6 @@ public interface SysUserFuncService extends IService<SysUserFuncEntity> { ...@@ -23,6 +23,6 @@ public interface SysUserFuncService extends IService<SysUserFuncEntity> {
void saveOrUpdate(Long userId, List<Long> menuIdList); void saveOrUpdate(Long userId, List<Long> menuIdList);
List<Long> queryFuncIdList(Long user); List<Long> queryFuncIdList(Long userId);
} }
...@@ -29,6 +29,8 @@ public interface SysUserService extends IService<SysUserEntity> { ...@@ -29,6 +29,8 @@ public interface SysUserService extends IService<SysUserEntity> {
void update(SysUserEntity user, List<Long> funcIdList, List<Long> deptIdList); void update(SysUserEntity user, List<Long> funcIdList, List<Long> deptIdList);
List<String> getUserPerms(String username);
String genDataFilter(DataFilterDto dataFilterDto); String genDataFilter(DataFilterDto dataFilterDto);
} }
...@@ -6,6 +6,9 @@ import com.mx.cneeds.server.dao.SysFuncDao; ...@@ -6,6 +6,9 @@ import com.mx.cneeds.server.dao.SysFuncDao;
import com.mx.cneeds.server.entity.SysFuncEntity; import com.mx.cneeds.server.entity.SysFuncEntity;
import com.mx.cneeds.server.user.service.SysFuncService; import com.mx.cneeds.server.user.service.SysFuncService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -22,8 +25,13 @@ public class SysFuncServiceImpl extends ServiceImpl<SysFuncDao, SysFuncEntity> i ...@@ -22,8 +25,13 @@ public class SysFuncServiceImpl extends ServiceImpl<SysFuncDao, SysFuncEntity> i
new Query<SysFuncEntity>().getPage(params), new Query<SysFuncEntity>().getPage(params),
new QueryWrapper<SysFuncEntity>() new QueryWrapper<SysFuncEntity>()
); );
return new PageUtils(page); return new PageUtils(page);
} }
@Override
public List<SysFuncEntity> queryFuncByIds(Collection<Long> funcId){
List<SysFuncEntity> sysFuncEntities = getBaseMapper().selectBatchIds(funcId);
return sysFuncEntities;
}
} }
...@@ -5,6 +5,7 @@ import com.mx.cneeds.common.dto.DataFilterDto; ...@@ -5,6 +5,7 @@ import com.mx.cneeds.common.dto.DataFilterDto;
import com.mx.cneeds.common.pager.PageUtils; import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.pager.Query; import com.mx.cneeds.common.pager.Query;
import com.mx.cneeds.server.dao.SysUserDao; import com.mx.cneeds.server.dao.SysUserDao;
import com.mx.cneeds.server.entity.SysFuncEntity;
import com.mx.cneeds.server.entity.SysUserEntity; import com.mx.cneeds.server.entity.SysUserEntity;
import com.mx.cneeds.server.user.service.*; import com.mx.cneeds.server.user.service.*;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -37,6 +38,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i ...@@ -37,6 +38,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
@Autowired @Autowired
private SysRoleDeptService sysRoleDeptService; private SysRoleDeptService sysRoleDeptService;
@Autowired
private SysRoleFuncService sysRoleFuncService;
@Autowired
private SysFuncService sysFuncService;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
...@@ -79,7 +86,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i ...@@ -79,7 +86,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
//保存用户与角色关系 //保存用户与角色关系
sysUserRoleService.saveOrUpdate(user.getUserId(), roleId); sysUserRoleService.saveOrUpdate(user.getUserId(), roleId);
//保存角色与菜单关系 //保存角色与菜单关系
sysUserFuncService.saveOrUpdate(user.getUserId(), funcIdList); sysUserFuncService.saveOrUpdate(user.getUserId(), funcIdList);
...@@ -91,12 +97,47 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i ...@@ -91,12 +97,47 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(SysUserEntity user, List<Long> funcIdList, List<Long> deptIdList) { public void update(SysUserEntity user, List<Long> funcIdList, List<Long> deptIdList) {
this.updateById(user); this.updateById(user);
if (funcIdList!=null && funcIdList.size()!=0){
//更新用户与菜单关系
sysUserFuncService.saveOrUpdate(user.getUserId(), funcIdList);
}
//更新用户与菜单关系 if (deptIdList!=null && deptIdList.size()!=0){
sysUserFuncService.saveOrUpdate(user.getUserId(), funcIdList); //保存用户与部门关系
sysUserDeptService.saveOrUpdate(user.getUserId(), deptIdList);
}
}
@Override
public List<String> getUserPerms(String username){
SysUserEntity sysUserEntity = queryUserByUsername(username);
// 模块Id
Set<Long> funcIdList = new HashSet<>();
// 模块权限字段
List<String> funcPermsList = new ArrayList<>();
//用户角色对应的模块区权限
Long roleId = sysUserRoleService.queryRoleId(sysUserEntity.getUserId());
List<Long> funcList = sysRoleFuncService.queryFuncId(roleId);
funcIdList.addAll(funcList);
List<Long> userFuncList = sysUserFuncService.queryFuncIdList(sysUserEntity.getUserId());
userFuncList.forEach(funcId -> {
funcIdList.add(funcId);
});
if (funcIdList.size() !=0){
List<SysFuncEntity> sysFuncEntities = sysFuncService.queryFuncByIds(funcIdList);
sysFuncEntities.forEach(entity -> {
funcPermsList.add(entity.getPerms());
});
return funcPermsList;
}else {
return null;
}
//保存用户与部门关系
sysUserDeptService.saveOrUpdate(user.getUserId(), deptIdList);
} }
@Override @Override
......
...@@ -75,8 +75,9 @@ public class SysUserController { ...@@ -75,8 +75,9 @@ public class SysUserController {
UserDto userDto = new UserDto(); UserDto userDto = new UserDto();
BeanUtils.copyProperties(sysUser,userDto); BeanUtils.copyProperties(sysUser,userDto);
userDto.setRoleId(roleId); userDto.setRoleId(roleId);
userDto.setDeptIdList(sysUserDeptService.queryDeptIdList(sysUser.getUserId())); userDto.setUserDeptIdList(sysUserDeptService.queryDeptIdList(sysUser.getUserId()));
userDto.setFuncIdList(sysUserFuncService.queryFuncIdList(sysUser.getUserId())); userDto.setUserFuncIdList(sysUserFuncService.queryFuncIdList(sysUser.getUserId()));
userDto.setFuncPerms(sysUserService.getUserPerms(userDto.getUsername()));
return userDto; return userDto;
} }
...@@ -90,7 +91,7 @@ public class SysUserController { ...@@ -90,7 +91,7 @@ public class SysUserController {
BeanUtils.copyProperties(dto,sysUser); BeanUtils.copyProperties(dto,sysUser);
sysUserService.saveUser(sysUser, dto.getFuncIdList(), dto.getDeptIdList(), dto.getRoleId()); sysUserService.saveUser(sysUser, dto.getUserFuncIdList(), dto.getUserDeptIdList(), dto.getRoleId());
return R.ok(); return R.ok();
} }
...@@ -103,7 +104,7 @@ public class SysUserController { ...@@ -103,7 +104,7 @@ public class SysUserController {
BeanUtils.copyProperties(dto,sysUser); BeanUtils.copyProperties(dto,sysUser);
ValidatorUtils.validateEntity(sysUser); ValidatorUtils.validateEntity(sysUser);
sysUserService.update(sysUser, dto.getFuncIdList(), dto.getDeptIdList()); sysUserService.update(sysUser, dto.getUserFuncIdList(), dto.getUserDeptIdList());
return R.ok(); return R.ok();
} }
......
...@@ -50,7 +50,7 @@ eureka: ...@@ -50,7 +50,7 @@ eureka:
defaultZone: http://192.168.2.244:8761/eureka/ defaultZone: http://192.168.2.244:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
ip-address: 192.168.2.244 # ip-address: 192.168.2.244
......
spring: spring:
profiles: profiles:
active: prod active: dev
application: application:
name: cneeds-server-user name: cneeds-server-user
......
...@@ -57,27 +57,6 @@ ...@@ -57,27 +57,6 @@
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
</dependencies> </dependencies>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment