no message
parent
78e7ebd901
commit
f16130e86e
|
|
@ -29,6 +29,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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 com.youchain.basicdata.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.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="base_studen")
|
||||
public class Studen implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "序号")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`code`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "代码")
|
||||
private String code;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`enabled`")
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean enabled;
|
||||
|
||||
@Column(name = "`creator`")
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Column(name = "`creation_time`")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Timestamp creationTime;
|
||||
|
||||
@Column(name = "`modifier`")
|
||||
@ApiModelProperty(value = "修改人")
|
||||
private String modifier;
|
||||
|
||||
@Column(name = "`modification_time`")
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Timestamp modificationTime;
|
||||
|
||||
public void copy(Studen 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 com.youchain.basicdata.repository;
|
||||
|
||||
import com.youchain.basicdata.domain.Studen;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
public interface StudenRepository extends JpaRepository<Studen, Integer>, JpaSpecificationExecutor<Studen> {
|
||||
|
||||
@Query(value = "SELECT count(*) FROM base_studen WHERE code=?1", nativeQuery = true)
|
||||
public Integer getKyPointList(String code);
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* 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 com.youchain.basicdata.rest;
|
||||
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.domain.Studen;
|
||||
import com.youchain.basicdata.service.StudenService;
|
||||
import com.youchain.basicdata.service.dto.StudenQueryCriteria;
|
||||
import com.youchain.config.FileProperties;
|
||||
import com.youchain.exception.handler.ApiError;
|
||||
import com.youchain.modules.system.domain.Dept;
|
||||
import com.youchain.utils.BaseStatus;
|
||||
import com.youchain.utils.FileUtil;
|
||||
import com.youchain.utils.UserUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "studen管理")
|
||||
@Slf4j
|
||||
@RequestMapping("/api/studen")
|
||||
public class StudenController {
|
||||
|
||||
private final StudenService studenService;
|
||||
|
||||
//导入
|
||||
private final FileProperties properties;
|
||||
|
||||
@Log("导入点位")
|
||||
@PostMapping(value = "/import_studen")
|
||||
@ApiOperation("导入点位")
|
||||
@PreAuthorize("@el.check('studen:importStuden')")
|
||||
public ResponseEntity<Object> importPoint(@RequestParam("file") MultipartFile multipartFile) {
|
||||
|
||||
System.out.println("multipartFile:"+multipartFile);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
|
||||
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||
|
||||
Dept dept = UserUtils.getDept();
|
||||
|
||||
System.out.println("dept:"+dept);
|
||||
|
||||
ExcelReader reader = ExcelUtil.getReader(file);
|
||||
int i = 0;
|
||||
int edit_len = 0;
|
||||
int new_len = 0;
|
||||
try {
|
||||
List<Map<String, Object>> readAll = reader.readAll();
|
||||
System.out.println("list:"+readAll);
|
||||
for (i = 0; i < readAll.size(); i++) {
|
||||
String code = readAll.get(i).get("代码").toString().trim();
|
||||
String name = readAll.get(i).get("名称").toString().trim();
|
||||
String enabled = readAll.get(i).get("是否启用").toString().trim();
|
||||
String creator = readAll.get(i).get("创建人").toString().trim();
|
||||
String modifier = readAll.get(i).get("修改人").toString().trim();
|
||||
Timestamp creationTime =Timestamp.valueOf(readAll.get(i).get("创建时间").toString().trim());
|
||||
Timestamp modificationTime =Timestamp.valueOf(readAll.get(i).get("修改时间").toString().trim());
|
||||
boolean flay = studenService.findBycode(code);
|
||||
System.out.println("flay"+flay);
|
||||
if(!flay){
|
||||
Studen stu = new Studen();
|
||||
stu.setCode(code);
|
||||
stu.setName(name);
|
||||
if (enabled.equals("true")) {
|
||||
stu.setEnabled(true);
|
||||
} else {
|
||||
stu.setEnabled(false);
|
||||
}
|
||||
stu.setCreator(creator);
|
||||
stu.setModifier(modifier);
|
||||
stu.setCreationTime(creationTime);
|
||||
stu.setModificationTime(modificationTime);
|
||||
studenService.create(stu);
|
||||
System.out.println("stu"+stu);
|
||||
new_len++;
|
||||
log.info("导入" + (i + 1) + "行");
|
||||
}else{
|
||||
log.info("第" + (i + 1) + "行已存在");
|
||||
edit_len++;
|
||||
new_len--;
|
||||
}
|
||||
|
||||
// if (area == null) {
|
||||
// ApiError apiError = ApiError.errorJosn(BAD_REQUEST.value(), "找不到库区" + areaCode);
|
||||
// return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
|
||||
// }
|
||||
// Point point = pointService.getPoint(code, null, null, null);
|
||||
// if (point == null) {
|
||||
|
||||
// } else {
|
||||
// point.setCode(code);
|
||||
// point.setName(code);
|
||||
// String lx = "";
|
||||
// if (types.equals("缓存点")) {
|
||||
// lx = BaseStatus.STORAGE;
|
||||
//
|
||||
// } else if (types.equals("线边点位")) {
|
||||
// lx = BaseStatus.BOX;
|
||||
// }
|
||||
// point.setType(lx);
|
||||
// point.setArea(area);
|
||||
// point.setDept(dept);
|
||||
// point.setDescription(ccTYPE);
|
||||
// point.setPosX(x);
|
||||
// point.setPosY(y);
|
||||
// pointService.update(point);
|
||||
// edit_len++;
|
||||
// }
|
||||
|
||||
if(new_len<0){
|
||||
new_len=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
ApiError apiError = ApiError.errorJosn(HttpStatus.BAD_REQUEST.value(), "导入异常---第" + (i + 1) + "行:" + e.toString());
|
||||
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
|
||||
}
|
||||
|
||||
|
||||
ApiError apiError = ApiError.errorJosn(HttpStatus.OK.value(), "导入成功:" + (i) + "行 新增(" + new_len + ")重复(" + edit_len + ")");
|
||||
return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('studen:list')")
|
||||
public void exportStuden(HttpServletResponse response, StudenQueryCriteria criteria) throws IOException {
|
||||
studenService.download(studenService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询studen")
|
||||
@ApiOperation("查询studen")
|
||||
@PreAuthorize("@el.check('studen:list')")
|
||||
public ResponseEntity<Object> queryStuden(StudenQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(studenService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增studen")
|
||||
@ApiOperation("新增studen")
|
||||
@PreAuthorize("@el.check('studen:add')")
|
||||
public ResponseEntity<Object> createStuden(@Validated @RequestBody Studen resources){
|
||||
return new ResponseEntity<>(studenService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改studen")
|
||||
@ApiOperation("修改studen")
|
||||
@PreAuthorize("@el.check('studen:edit')")
|
||||
public ResponseEntity<Object> updateStuden(@Validated @RequestBody Studen resources){
|
||||
studenService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除studen")
|
||||
@ApiOperation("删除studen")
|
||||
@PreAuthorize("@el.check('studen:del')")
|
||||
public ResponseEntity<Object> deleteStuden(@RequestBody Integer[] ids) {
|
||||
studenService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* 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 com.youchain.basicdata.service;
|
||||
|
||||
import com.youchain.basicdata.domain.Studen;
|
||||
import com.youchain.basicdata.service.dto.StudenDto;
|
||||
import com.youchain.basicdata.service.dto.StudenQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
public interface StudenService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(StudenQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<StudenDto>
|
||||
*/
|
||||
List<StudenDto> queryAll(StudenQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return StudenDto
|
||||
*/
|
||||
StudenDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 根据代码查询
|
||||
* @param code code
|
||||
* @return StudenDto
|
||||
*/
|
||||
boolean findBycode(String code);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return StudenDto
|
||||
*/
|
||||
StudenDto create(Studen resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(Studen resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<StudenDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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 com.youchain.basicdata.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
@Data
|
||||
public class StudenDto implements Serializable {
|
||||
|
||||
/** 序号 */
|
||||
private Integer id;
|
||||
|
||||
/** 代码 */
|
||||
private String code;
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 是否启用 */
|
||||
private Boolean enabled;
|
||||
|
||||
/** 创建人 */
|
||||
private String creator;
|
||||
|
||||
/** 创建时间 */
|
||||
private Timestamp creationTime;
|
||||
|
||||
/** 修改人 */
|
||||
private String modifier;
|
||||
|
||||
/** 修改时间 */
|
||||
private Timestamp modificationTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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 com.youchain.basicdata.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import com.youchain.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
@Data
|
||||
public class StudenQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String code;
|
||||
|
||||
//模糊
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -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 com.youchain.basicdata.service.impl;
|
||||
|
||||
import com.youchain.basicdata.domain.Studen;
|
||||
import com.youchain.basicdata.repository.PointRepository;
|
||||
import com.youchain.utils.FileUtil;
|
||||
import com.youchain.utils.PageUtil;
|
||||
import com.youchain.utils.QueryHelp;
|
||||
import com.youchain.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.youchain.basicdata.repository.StudenRepository;
|
||||
import com.youchain.basicdata.service.StudenService;
|
||||
import com.youchain.basicdata.service.dto.StudenDto;
|
||||
import com.youchain.basicdata.service.dto.StudenQueryCriteria;
|
||||
import com.youchain.basicdata.service.mapstruct.StudenMapper;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StudenServiceImpl implements StudenService {
|
||||
|
||||
private final StudenRepository studenRepository;
|
||||
private final StudenMapper studenMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(StudenQueryCriteria criteria, Pageable pageable){
|
||||
Page<Studen> page = studenRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(studenMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StudenDto> queryAll(StudenQueryCriteria criteria){
|
||||
return studenMapper.toDto(studenRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public StudenDto findById(Integer id) {
|
||||
Studen studen = studenRepository.findById(id).orElseGet(Studen::new);
|
||||
ValidationUtil.isNull(studen.getId(),"Studen","id",id);
|
||||
return studenMapper.toDto(studen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean findBycode(String code) {
|
||||
return studenRepository.getKyPointList(code) >= 1 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public StudenDto create(Studen resources) {
|
||||
return studenMapper.toDto(studenRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Studen resources) {
|
||||
Studen studen = studenRepository.findById(resources.getId()).orElseGet(Studen::new);
|
||||
ValidationUtil.isNull( studen.getId(),"Studen","id",resources.getId());
|
||||
studen.copy(resources);
|
||||
studenRepository.save(studen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
studenRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<StudenDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (StudenDto studen : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("代码", studen.getCode());
|
||||
map.put("名称", studen.getName());
|
||||
map.put("是否启用", studen.getEnabled());
|
||||
map.put("创建人", studen.getCreator());
|
||||
map.put("创建时间", studen.getCreationTime());
|
||||
map.put("修改人", studen.getModifier());
|
||||
map.put("修改时间", studen.getModificationTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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 com.youchain.basicdata.service.mapstruct;
|
||||
|
||||
import com.youchain.base.BaseMapper;
|
||||
import com.youchain.basicdata.domain.Studen;
|
||||
import com.youchain.basicdata.service.dto.StudenDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author LY
|
||||
* @date 2024-04-16
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface StudenMapper extends BaseMapper<StudenDto, Studen> {
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue