mirror of https://github.com/elunez/eladmin
股票管理
parent
164ce50bb0
commit
84d6f1587d
|
@ -5,3 +5,4 @@
|
||||||
*/*.iml
|
*/*.iml
|
||||||
/.gradle/
|
/.gradle/
|
||||||
/application.pid
|
/application.pid
|
||||||
|
.vscode/
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>eladmin</artifactId>
|
||||||
|
<groupId>me.zhengjie</groupId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>eladmin-fin</artifactId>
|
||||||
|
<name>理财模块</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhengjie</groupId>
|
||||||
|
<artifactId>eladmin-tools</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @website https://eladmin.vip
|
||||||
|
* @description /
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-07
|
||||||
|
**/
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name = "stock")
|
||||||
|
public class Stock implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "`id`")
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(name = "`stock_code`", unique = true, nullable = false)
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "stockCode")
|
||||||
|
private String stockCode;
|
||||||
|
|
||||||
|
@Column(name = "`stock_name`", unique = true, nullable = false)
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "stockName")
|
||||||
|
private String stockName;
|
||||||
|
|
||||||
|
@Column(name = "`hold_amount`")
|
||||||
|
@ApiModelProperty(value = "holdAmount")
|
||||||
|
private Float holdAmount;
|
||||||
|
|
||||||
|
@Column(name = "`hold_share`", nullable = false)
|
||||||
|
@NotNull
|
||||||
|
@ApiModelProperty(value = "holdShare")
|
||||||
|
private Float holdShare;
|
||||||
|
|
||||||
|
@Column(name = "`current_price`")
|
||||||
|
@ApiModelProperty(value = "currentPrice")
|
||||||
|
private Float currentPrice;
|
||||||
|
|
||||||
|
@Column(name = "`price_time`")
|
||||||
|
@ApiModelProperty(value = "priceTime")
|
||||||
|
private Timestamp priceTime;
|
||||||
|
|
||||||
|
@Column(name = "`create_by`")
|
||||||
|
@ApiModelProperty(value = "createBy")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@Column(name = "`create_time`")
|
||||||
|
@ApiModelProperty(value = "createTime")
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
@Column(name = "`update_by`")
|
||||||
|
@ApiModelProperty(value = "updateBy")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@Column(name = "`update_time`")
|
||||||
|
@ApiModelProperty(value = "updateTime")
|
||||||
|
private Timestamp updateTime;
|
||||||
|
|
||||||
|
public void copy(Stock source) {
|
||||||
|
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.repository;
|
||||||
|
|
||||||
|
import me.zhengjie.fin.stock.domain.Stock;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-15
|
||||||
|
*/
|
||||||
|
public interface StockRepository extends JpaRepository<Stock, Long>, JpaSpecificationExecutor<Stock> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询
|
||||||
|
*
|
||||||
|
* @param id /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
Stock findById(String id);
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.rest;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.zhengjie.annotation.Log;
|
||||||
|
import me.zhengjie.fin.stock.domain.Stock;
|
||||||
|
import me.zhengjie.fin.stock.service.StockService;
|
||||||
|
import me.zhengjie.fin.stock.service.dto.StockQueryCriteria;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
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 javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "理财:股票")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/api/stock")
|
||||||
|
public class StockController {
|
||||||
|
|
||||||
|
private final StockService stockService;
|
||||||
|
|
||||||
|
@ApiOperation("导出股票数据")
|
||||||
|
@GetMapping(value = "/download")
|
||||||
|
@PreAuthorize("@el.check('stock:list')")
|
||||||
|
public void exportStock(HttpServletResponse response, StockQueryCriteria criteria) throws IOException {
|
||||||
|
stockService.download(stockService.queryAll(criteria), response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "查询服务器")
|
||||||
|
@GetMapping
|
||||||
|
@PreAuthorize("@el.check('Stock:list')")
|
||||||
|
public ResponseEntity<Object> queryStock(StockQueryCriteria criteria, Pageable pageable) {
|
||||||
|
return new ResponseEntity<>(stockService.queryAll(criteria, pageable), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("新增服务器")
|
||||||
|
@ApiOperation(value = "新增服务器")
|
||||||
|
@PostMapping
|
||||||
|
@PreAuthorize("@el.check('Stock:add')")
|
||||||
|
public ResponseEntity<Object> createStock(@Validated @RequestBody Stock resources) {
|
||||||
|
stockService.create(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("修改服务器")
|
||||||
|
@ApiOperation(value = "修改服务器")
|
||||||
|
@PutMapping
|
||||||
|
@PreAuthorize("@el.check('Stock:edit')")
|
||||||
|
public ResponseEntity<Object> updateStock(@Validated @RequestBody Stock resources) {
|
||||||
|
stockService.update(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("删除服务器")
|
||||||
|
@ApiOperation(value = "删除Server")
|
||||||
|
@DeleteMapping
|
||||||
|
@PreAuthorize("@el.check('Stock:del')")
|
||||||
|
public ResponseEntity<Object> deleteStock(@RequestBody Set<Long> ids) {
|
||||||
|
stockService.delete(ids);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("测试连接服务器")
|
||||||
|
@ApiOperation(value = "测试连接服务器")
|
||||||
|
@PostMapping("/testConnect")
|
||||||
|
@PreAuthorize("@el.check('Stock:add')")
|
||||||
|
public ResponseEntity<Object> testConnectStock(@Validated @RequestBody Stock resources) {
|
||||||
|
return new ResponseEntity<>(stockService.testConnect(resources), HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.service;
|
||||||
|
|
||||||
|
import me.zhengjie.fin.stock.domain.Stock;
|
||||||
|
import me.zhengjie.fin.stock.service.dto.StockDto;
|
||||||
|
import me.zhengjie.fin.stock.service.dto.StockQueryCriteria;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-15
|
||||||
|
*/
|
||||||
|
public interface StockService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param criteria 条件
|
||||||
|
* @param pageable 分页参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
Object queryAll(StockQueryCriteria criteria, Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部数据
|
||||||
|
*
|
||||||
|
* @param criteria 条件
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
List<StockDto> queryAll(StockQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询
|
||||||
|
*
|
||||||
|
* @param id /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
StockDto findById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
*
|
||||||
|
* @param resources /
|
||||||
|
*/
|
||||||
|
void create(Stock resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param resources /
|
||||||
|
*/
|
||||||
|
void update(Stock resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
|
void delete(Set<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据IP查询
|
||||||
|
*
|
||||||
|
* @param ip /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
StockDto findByIp(String ip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试登录服务器
|
||||||
|
*
|
||||||
|
* @param resources /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
Boolean testConnect(Stock resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*
|
||||||
|
* @param queryAll /
|
||||||
|
* @param response /
|
||||||
|
* @throws IOException /
|
||||||
|
*/
|
||||||
|
void download(List<StockDto> queryAll, HttpServletResponse response) throws IOException;
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.service.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.zhengjie.base.BaseDTO;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-15
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class StockDto extends BaseDTO implements Serializable {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String stockCode;
|
||||||
|
|
||||||
|
private String stockName;
|
||||||
|
|
||||||
|
private Float holdAmount;
|
||||||
|
|
||||||
|
private Float holdShare;
|
||||||
|
|
||||||
|
private Float currentPrice;
|
||||||
|
|
||||||
|
private Timestamp priceTime;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
private Timestamp updateTime;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
StockDto that = (StockDto) o;
|
||||||
|
return Objects.equals(id, that.id) &&
|
||||||
|
Objects.equals(stockCode, that.stockCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, stockCode);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.annotation.Query;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StockQueryCriteria {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊
|
||||||
|
*/
|
||||||
|
@Query(blurry = "name,ip,account")
|
||||||
|
private String blurry;
|
||||||
|
|
||||||
|
@Query(type = Query.Type.BETWEEN)
|
||||||
|
private List<Timestamp> createTime;
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.service.impl;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.zhengjie.fin.stock.domain.Stock;
|
||||||
|
import me.zhengjie.fin.stock.repository.StockRepository;
|
||||||
|
import me.zhengjie.fin.stock.service.StockService;
|
||||||
|
import me.zhengjie.fin.stock.service.dto.StockDto;
|
||||||
|
import me.zhengjie.fin.stock.service.dto.StockQueryCriteria;
|
||||||
|
import me.zhengjie.fin.stock.service.mapstruct.StockMapper;
|
||||||
|
import me.zhengjie.utils.FileUtil;
|
||||||
|
import me.zhengjie.utils.PageUtil;
|
||||||
|
import me.zhengjie.utils.QueryHelp;
|
||||||
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-15
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class StockServiceImpl implements StockService {
|
||||||
|
|
||||||
|
private final StockRepository stockRepository;
|
||||||
|
private final StockMapper stockMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object queryAll(StockQueryCriteria criteria, Pageable pageable) {
|
||||||
|
Page<Stock> page = stockRepository.findAll(
|
||||||
|
(root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder),
|
||||||
|
pageable);
|
||||||
|
return PageUtil.toPage(page.map(stockMapper::toDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StockDto> queryAll(StockQueryCriteria criteria) {
|
||||||
|
return stockMapper.toDto(stockRepository.findAll(
|
||||||
|
(root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StockDto findById(Long id) {
|
||||||
|
Stock server = stockRepository.findById(id).orElseGet(Stock::new);
|
||||||
|
ValidationUtil.isNull(server.getId(), "Stock", "id", id);
|
||||||
|
return stockMapper.toDto(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StockDto findByIp(String ip) {
|
||||||
|
Stock deploy = stockRepository.findByIp(ip);
|
||||||
|
return stockMapper.toDto(deploy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void create(Stock resources) {
|
||||||
|
stockRepository.save(resources);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void update(Stock resources) {
|
||||||
|
Stock stock = stockRepository.findById(resources.getId()).orElseGet(Stock::new);
|
||||||
|
ValidationUtil.isNull(stock.getId(), "Stock", "id", resources.getId());
|
||||||
|
stock.copy(resources);
|
||||||
|
stockRepository.save(stock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(Set<Long> ids) {
|
||||||
|
for (Long id : ids) {
|
||||||
|
stockRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void download(List<StockDto> queryAll, HttpServletResponse response) throws IOException {
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
for (StockDto deployDto : queryAll) {
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("服务器名称", deployDto.getName());
|
||||||
|
map.put("服务器IP", deployDto.getIp());
|
||||||
|
map.put("端口", deployDto.getPort());
|
||||||
|
map.put("账号", deployDto.getAccount());
|
||||||
|
map.put("创建日期", deployDto.getCreateTime());
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
FileUtil.downloadExcel(list, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean testConnect(Stock resources) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* 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.fin.stock.service.mapstruct;
|
||||||
|
|
||||||
|
import me.zhengjie.base.BaseMapper;
|
||||||
|
import me.zhengjie.fin.stock.domain.Stock;
|
||||||
|
import me.zhengjie.fin.stock.service.dto.StockDto;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhangjc
|
||||||
|
* @date 2023-02-15
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring", uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
public interface StockMapper extends BaseMapper<StockDto, Stock> {
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,12 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.zhengjie</groupId>
|
||||||
|
<artifactId>eladmin-fin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 代码生成模块 -->
|
<!-- 代码生成模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
|
|
|
@ -5,8 +5,8 @@ spring:
|
||||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:eladmin}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:eladmin}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||||
username: ${DB_USER:root}
|
username: eladmin
|
||||||
password: ${DB_PWD:123456}
|
password: Eladmin@12#
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
initial-size: 5
|
initial-size: 5
|
||||||
# 最小连接数
|
# 最小连接数
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -15,6 +15,7 @@
|
||||||
<module>eladmin-system</module>
|
<module>eladmin-system</module>
|
||||||
<module>eladmin-tools</module>
|
<module>eladmin-tools</module>
|
||||||
<module>eladmin-generator</module>
|
<module>eladmin-generator</module>
|
||||||
|
<module>eladmin-fin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<name>ELADMIN 后台管理</name>
|
<name>ELADMIN 后台管理</name>
|
||||||
|
|
Loading…
Reference in New Issue