Browse Source

测试服务器

detached2
huangqizhen 4 months ago
parent
commit
1f978728ad
  1. 3
      src/main/java/com/example/demo/mapper/AdminMapper.java
  2. 11
      src/main/java/com/example/demo/serviceImpl/AdminServiceImpl.java
  3. 12
      src/main/resources/application.yml

3
src/main/java/com/example/demo/mapper/AdminMapper.java

@ -23,12 +23,12 @@ public interface AdminMapper {
"UPDATE admin",
"<set>",
"<if test='name!=null and name.length()>0'>name =#{name},</if>",
"<if test='jwcode!=null and jwcode.length()>0'>jwcode =#{jwcode},</if>",
"<if test='password!=null and password.length()>0'>password =#{password},</if>",
"<if test='permission!=null and permission.length()>0'>permission =#{permission},</if>",
"<if test='area!=null and area.length()>0'>area =#{area},</if>",
"<if test='adminFlag!=null and adminFlag.length()>0'>admin_flag =#{adminFlag},</if>",
"</set>",
"where jwcode =#{jwcode}",
"</script>"
})
int update(Admin admin);
@ -46,6 +46,7 @@ public interface AdminMapper {
"<script>",
"SELECT * from admin",
"<where>",
"permission is not null",
"<if test='name!=null and name.length()>0'> and `name` like concat('%',#{name},'%')</if>",
"<if test='jwcode!=null and jwcode.length()>0'> and jwcode=#{jwcode}</if>",
"<if test='permission!=null'> and permission=#{permission}</if>",

11
src/main/java/com/example/demo/serviceImpl/AdminServiceImpl.java

@ -41,6 +41,17 @@ public class AdminServiceImpl implements AdminService {
@Override
public int add(Admin admin) {
//判断jwcode是否已存在
Admin admin1=adminMapper.selectByJwcode(admin);
if(!ObjectUtils.isEmpty(admin1)){
throw new RuntimeException("用户已存在");
}
//设置密码
if(ObjectUtils.isEmpty(admin.getPassword())){
admin.setPassword(passwordEncoder.encode("$2a$10$jKrLD.8RTPzk4oe6c27b0ec9QP4DodbCVQLrLIEXS0xeT2vsp9cJK"));
}else {
admin.setPassword(passwordEncoder.encode(admin.getPassword()));
}
return adminMapper.insert(admin);
}
@CacheEvict(value = "admin",allEntries = true)

12
src/main/resources/application.yml

@ -28,13 +28,13 @@ spring:
cache-null-values: true
data:
redis:
host: 39.99.159.73
port: 20001
password: 8912h12jhhajsd
timeout: 1000
# host: 127.0.0.1
# port: 6379
# host: 39.99.159.73
# port: 20001
# password: 8912h12jhhajsd
# timeout: 1000
host: 127.0.0.1
port: 6379
timeout: 1000
lettuce:
pool:
max-active: 20

Loading…
Cancel
Save