change to jpa
parent
16488f3c23
commit
9e4237513b
@ -0,0 +1,32 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.annotations.Proxy;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2023-08-28
|
||||||
|
*/
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Proxy(lazy = false)
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Userzy implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String nfc;
|
||||||
|
|
||||||
|
@Column( length = 32)
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.rehome.adminclientappmqttserver.config;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ Author : huangwenfei
|
|
||||||
* @ Date : Created in 2021/5/16 12:11 下午
|
|
||||||
* @ Version : $1.0.0.0
|
|
||||||
* @ Description: 配置分页插件
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class MybatisPlusConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* description: 分页插件
|
|
||||||
* create by: huangwenfei
|
|
||||||
* create time: 2021/5/16 12:11 下午
|
|
||||||
* @Param: null
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public PaginationInterceptor paginationInterceptor() {
|
|
||||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
|
||||||
paginationInterceptor.setDialectType("mysql");
|
|
||||||
return paginationInterceptor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.controller;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Useryf;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UseryfService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/useryf")
|
||||||
|
public class UseryfController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UseryfService userYfService;
|
||||||
|
|
||||||
|
public void saveUserYF(Useryf user){
|
||||||
|
userYfService.saveByUsernameYF(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.controller;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Useryf;
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Userzy;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UseryfService;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UserzyService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/useryf")
|
||||||
|
|
||||||
|
|
||||||
|
public class UserzyController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserzyService userzyService;
|
||||||
|
|
||||||
|
public void saveUserZY(Userzy user){
|
||||||
|
userzyService.saveByUsernameZY(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package com.rehome.adminclientappmqttserver.dao;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.rehome.adminclientappmqttserver.entity.User;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author huangwenfei
|
|
||||||
* @since 2021-08-17
|
|
||||||
*/
|
|
||||||
public interface UserMapper extends BaseMapper<User> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.annotations.Proxy;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Proxy(lazy = false)
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Useryf implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String nfc;
|
||||||
|
|
||||||
|
@Column( length = 32)
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.annotations.Proxy;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2023-08-29
|
||||||
|
*/
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Proxy(lazy = false)
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Userzy implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String nfc;
|
||||||
|
|
||||||
|
@Column( length = 32)
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.service;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Useryf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
public interface UseryfService {
|
||||||
|
public void saveByUsernameYF(Useryf user);
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Userzy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
public interface UserzyService {
|
||||||
|
public void saveByUsernameZY(Userzy user);
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.service.impl;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.dao.UseryfRepository;
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Useryf;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UseryfService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class UseryfServiceImpl implements UseryfService {
|
||||||
|
@Resource
|
||||||
|
private UseryfRepository useryfRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveByUsernameYF(Useryf user) {
|
||||||
|
// Useryf useryfDb = this.useryRepository.findByUsername(user.getUsername());
|
||||||
|
// if (useryfDb != null) {
|
||||||
|
// useryfDb.setDate(user.getDate());
|
||||||
|
// useryfDb.setPassword(user.getPassword());
|
||||||
|
// useryfDb.setNfc(user.getNfc());
|
||||||
|
// this.useryRepository.save(useryfDb);
|
||||||
|
// } else {
|
||||||
|
// this.useryRepository.save(user);
|
||||||
|
// }
|
||||||
|
this.useryfRepository.save(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.dao.UserzyRepository;
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.Userzy;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UserzyService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class UserzyServiceImpl implements UserzyService {
|
||||||
|
@Resource
|
||||||
|
private UserzyRepository userzyRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveByUsernameZY(Userzy user) {
|
||||||
|
// Useryf useryfDb = this.useryRepository.findByUsername(user.getUsername());
|
||||||
|
// if (useryfDb != null) {
|
||||||
|
// useryfDb.setDate(user.getDate());
|
||||||
|
// useryfDb.setPassword(user.getPassword());
|
||||||
|
// useryfDb.setNfc(user.getNfc());
|
||||||
|
// this.useryRepository.save(useryfDb);
|
||||||
|
// } else {
|
||||||
|
// this.useryRepository.save(user);
|
||||||
|
// }
|
||||||
|
this.userzyRepository.save(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,21 +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="com.rehome.adminclientappmqttserver.dao.UserMapper">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="com.rehome.adminclientappmqttserver.entity.User">
|
|
||||||
<id column="username" property="username" />
|
|
||||||
<result column="password" property="password" />
|
|
||||||
<result column="date" property="date" />
|
|
||||||
<result column="imeinum" property="imeinum" />
|
|
||||||
<result column="sysversion" property="sysversion" />
|
|
||||||
<result column="phonemodel" property="phonemodel" />
|
|
||||||
<result column="appversion" property="appversion" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
username, password, date, imeinum, sysversion, phonemodel
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
Loading…
Reference in New Issue