账套信息,代码优化!
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.cwhelp.modules.business.domain;
|
||||
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.common.utils.StatusUtil;
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* @author yan.y
|
||||
* @date 2019/08/06
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="bss_enterprise")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Where(clause = StatusUtil.notDelete)
|
||||
public class BssEnterprise implements Serializable {
|
||||
// 主键ID
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
// 统一社会信用代码
|
||||
@Column(name = "credit_code")
|
||||
private String creditCode;
|
||||
// 所属平台
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="platform_id")
|
||||
@JsonIgnore
|
||||
private BssPlatform platform;
|
||||
// 所在地
|
||||
private String location;
|
||||
// 行业
|
||||
private String industry;
|
||||
// 增值税种类
|
||||
@Column(name = "vat_type")
|
||||
private String vatType;
|
||||
// 会计准则
|
||||
@Column(name = "accounting_standards")
|
||||
private String accountingStandards;
|
||||
// 创建时间
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
// 更新时间
|
||||
@LastModifiedDate
|
||||
private Date updateDate;
|
||||
// 创建者
|
||||
@CreatedBy
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="create_by")
|
||||
@JsonIgnore
|
||||
private User createBy;
|
||||
// 更新者
|
||||
@LastModifiedBy
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="update_by")
|
||||
@JsonIgnore
|
||||
private User updateBy;
|
||||
// 数据状态
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
// 备注
|
||||
private String remark;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cwhelp.modules.business.repository;
|
||||
|
||||
import com.cwhelp.modules.business.domain.BssEnterprise;
|
||||
import com.cwhelp.modules.business.domain.BssPlatform;
|
||||
import com.cwhelp.modules.system.repository.BaseRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yan.y
|
||||
* @date 2019/08/06
|
||||
*/
|
||||
public interface BssEnterpriseRepository extends BaseRepository<BssEnterprise, Long> {
|
||||
|
||||
List<BssEnterprise> findByPlatformEquals(BssPlatform bssPlatform);
|
||||
|
||||
BssEnterprise findByNameAndIdNot(String name, Long id);
|
||||
|
||||
BssEnterprise findByCreditCodeAndIdNot(String creditCode, Long id);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.cwhelp.modules.business.service;
|
||||
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.modules.business.domain.BssEnterprise;
|
||||
import com.cwhelp.modules.business.domain.BssPlatform;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yan.y
|
||||
* @date 2019/08/06
|
||||
*/
|
||||
public interface BssEnterpriseService {
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
Page<BssEnterprise> getPageList(Example<BssEnterprise> example);
|
||||
|
||||
/**
|
||||
* 根据ID查询数据
|
||||
* @param id 主键ID
|
||||
*/
|
||||
BssEnterprise getById(Long id);
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param bssEnterprise 实体对象
|
||||
*/
|
||||
BssEnterprise save(BssEnterprise bssEnterprise);
|
||||
|
||||
List<BssEnterprise> getListByPlatform(BssPlatform bssPlatform);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
|
||||
Boolean repeatByName(BssEnterprise bssEnterprise);
|
||||
|
||||
Boolean repeatByCreditCode(BssEnterprise bssEnterprise);
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.cwhelp.modules.business.service.impl;
|
||||
|
||||
import com.cwhelp.common.data.PageSort;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.modules.business.domain.BssEnterprise;
|
||||
import com.cwhelp.modules.business.domain.BssPlatform;
|
||||
import com.cwhelp.modules.business.repository.BssEnterpriseRepository;
|
||||
import com.cwhelp.modules.business.service.BssEnterpriseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yan.y
|
||||
* @date 2019/08/06
|
||||
*/
|
||||
@Service
|
||||
public class BssEnterpriseServiceImpl implements BssEnterpriseService {
|
||||
|
||||
@Autowired
|
||||
private BssEnterpriseRepository bssEnterpriseRepository;
|
||||
|
||||
/**
|
||||
* 根据ID查询数据
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public BssEnterprise getById(Long id) {
|
||||
return bssEnterpriseRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
@Override
|
||||
public Page<BssEnterprise> getPageList(Example<BssEnterprise> example) {
|
||||
// 创建分页对象
|
||||
PageRequest page = PageSort.pageRequest();
|
||||
return bssEnterpriseRepository.findAll(example, page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BssEnterprise> getListByPlatform(BssPlatform bssPlatform) {
|
||||
return bssEnterpriseRepository.findByPlatformEquals(bssPlatform);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param bssEnterprise 实体对象
|
||||
*/
|
||||
@Override
|
||||
public BssEnterprise save(BssEnterprise bssEnterprise) {
|
||||
return bssEnterpriseRepository.save(bssEnterprise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> idList) {
|
||||
return bssEnterpriseRepository.updateStatus(statusEnum.getCode(), idList) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean repeatByName(BssEnterprise bssEnterprise) {
|
||||
Long id = bssEnterprise.getId() != null ? bssEnterprise.getId() : Long.MIN_VALUE;
|
||||
return bssEnterpriseRepository.findByNameAndIdNot(bssEnterprise.getName(), id) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean repeatByCreditCode(BssEnterprise bssEnterprise) {
|
||||
Long id = bssEnterprise.getId() != null ? bssEnterprise.getId() : Long.MIN_VALUE;
|
||||
return bssEnterpriseRepository.findByCreditCodeAndIdNot(bssEnterprise.getCreditCode(), id) != null;
|
||||
}
|
||||
}
|
||||
+3
@@ -75,6 +75,9 @@ public class UserServiceImpl implements UserService {
|
||||
*/
|
||||
@Override
|
||||
public User getById(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return userRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user