Commit 914b8a90 by flyxiaozhu

erp module

parent 425afdff
......@@ -5,9 +5,7 @@ import com.maile.erp.core.libs.ErrorCode;
import com.maile.erp.core.libs.JSONResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.core.serializer.support.SerializationFailedException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.BindException;
......
自定义原生查询结果绑定到指定类上
--
1. 创建接收结果的类(Pojo),设置一个无惨构造函数和一个全参构造函数
2. 在实体类上添加@NamedNativeQuery和@SqlResultSetMapping注解,NamedNativeQuery的名字为“实体类名.Repository方法名”,设置resultSetMapping为体SqlResultSetMapping的name,具体查看案例
3. 在实体类对应的Repository类上添加对应的方法(NamedNativeQuery的名字,不含实体类名),添加@Query注解,设置nativeQuery值为true
4. 返回类型为Pojo类或者Pojo类的列表
案例:
```java
//Pojo类
@JsonIgnoreProperties({"handler", "hibernateLazyInitializer"})
@Data
public class AccessAppPojo {
private String name;
@JsonIgnore
private String desc;
public AccessAppPojo() {
}
public AccessAppPojo(String name, String desc) {
this.name = name;
this.desc = desc;
}
}
```
```java
//实体类
@Entity
@Data
@DynamicInsert
@DynamicUpdate
@JsonIgnoreProperties({"handler", "hibernateLazyInitializer"})
@NamedNativeQuery(
name = Application,
query = "select name, `desc` from access_app as a where a.id = 1 limit 1",
resultSetMapping = "gg"
)
@SqlResultSetMapping(
name = "gg",
classes = @ConstructorResult(
targetClass = AccessAppPojo.class,
columns = {
@ColumnResult(name = "name"),
@ColumnResult(name = "desc")
}
)
)
public class AccessApp extends BaseEntity {
@Column(columnDefinition = "varchar(32) not null default '' comment '应用名称'")
private String name;
@Column(name = "`desc`", columnDefinition = "varchar(255) not null default '' comment '应用描述'")
private String desc;
@Column(name = "`key`", columnDefinition = "varchar(32) not null default '' comment '应用key'")
private String key;
@Column(columnDefinition = "varchar(32) not null default '' comment '应用secret'")
private String secret;
@Column(columnDefinition = "tinyint(11) not null default 0 comment '状态'")
private int status;
}
```
```java
//Repository类
public interface AccessAppRepository extends JpaRepository<AccessApp, Long> {
@Query(nativeQuery = true)
AccessAppPojo test();
}
```
```java
//实际运用
@RestController
public class WelcomeController {
@Autowired
AccessAppRepository accessAppRepository;
@RequestMapping("/")
public JSONResult index() throws AppException {
AccessAppPojo app = accessAppRepository.test();
return new JSONResult().put("app", app);
}
}
```
\ No newline at end of file
#售后系统流程图
![img](afterSale.png)
\ No newline at end of file
#订单系统流程图
![img](order.png)
\ No newline at end of file
框架相关技术文档
--
本目录包含了一些框架上的技术文档
\ No newline at end of file
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 sign in to comment