feat: 新增多个服务类及工具类,重构部分代码结构
重构服务类结构,将分散的服务统一整合到service包下 新增ProjectConstant常量类及多个实体服务类 添加SecurityUtils安全工具类和BeanCacher工具类 优化部分UI控件和转换器的实现
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package com.ecep.contract.ds.company;
|
||||
|
||||
import com.ecep.contract.ds.company.service.CompanyContactService;
|
||||
import com.ecep.contract.ds.converter.EntityStringConverter;
|
||||
import com.ecep.contract.model.CompanyContact;
|
||||
import com.ecep.contract.util.EntityStringConverter;
|
||||
|
||||
public class CompanyContactStringConverter extends EntityStringConverter<CompanyContact> {
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ecep.contract.ds.company.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.model.Company;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/company")
|
||||
public class CompanyController {
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@RequestMapping("/findById")
|
||||
public Company findById(Integer id) {
|
||||
return companyService.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Page<Company> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<Company> spec = null;
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return companyService.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public Company save(Company company) {
|
||||
return companyService.save(company);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
public void delete(Integer id) {
|
||||
Company company = companyService.findById(id);
|
||||
companyService.delete(company);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.cloud.rk.CloudRkService;
|
||||
import com.ecep.contract.cloud.tyc.CloudTycService;
|
||||
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.company.repository.CompanyRepository;
|
||||
@@ -374,7 +375,7 @@ public class CompanyService implements IEntityService<Company> {
|
||||
}
|
||||
|
||||
public File getCustomerBasePath() {
|
||||
return new File(confService.getString(CompanyCustomerService.KEY_BASE_PATH));
|
||||
return new File(confService.getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
|
||||
@@ -5,8 +5,8 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.converter.EntityStringConverter;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.util.EntityStringConverter;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
|
||||
@@ -32,27 +32,6 @@ import com.ecep.contract.model.ContractFileTypeLocal;
|
||||
@CacheConfig(cacheNames = "contract-file")
|
||||
public class ContractFileService implements IEntityService<ContractFile> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractFileService.class);
|
||||
/**
|
||||
* 销售成本核算审批表模板
|
||||
*/
|
||||
public static final String KEY_CUSTOMER_COST_TEMPLATE = "customer.contract.cost.template";
|
||||
/**
|
||||
* 项目投标审批表模板
|
||||
*/
|
||||
public static final String KEY_CUSTOMER_BID_TEMPLATE = "customer.contract.bid.template";
|
||||
/**
|
||||
* 销售合同审批表模板
|
||||
*/
|
||||
public static final String KEY_CUSTOMER_APPLY_TEMPLATE = "customer.contract.apply.template";
|
||||
/**
|
||||
* 投标报价表模板
|
||||
*/
|
||||
public static final String KEY_QUOTATION_TEMPLATE = "customer.contract.quotation.template";
|
||||
/**
|
||||
* 采购合同审批表模板
|
||||
*/
|
||||
public static final String KEY_VENDOR_APPLY_TEMPLATE = "vendor.contract.apply.template";
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractFileRepository contractFileRepository;
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.constant.ContractConstant;
|
||||
import com.ecep.contract.ds.contract.repository.ContractRepository;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.model.Company;
|
||||
@@ -51,7 +52,6 @@ import jakarta.persistence.criteria.Predicate;
|
||||
@CacheConfig(cacheNames = "contract")
|
||||
public class ContractService implements IEntityService<Contract> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
||||
public static final String CONTRACT_BASE_PATH = "contract.base.path";
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractCatalogService contractCatalogService;
|
||||
@@ -144,7 +144,7 @@ public class ContractService implements IEntityService<Contract> {
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
return new File(confService.getString(CONTRACT_BASE_PATH));
|
||||
return new File(confService.getString(ContractConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
public ContractGroup findGroupById(Integer id) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ecep.contract.ds.contract.service.ContractBidVendorService;
|
||||
import com.ecep.contract.ds.contract.service.ContractFileService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.contract.service.ExtendVendorInfoService;
|
||||
import com.ecep.contract.ds.converter.NumberStringConverter;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
@@ -18,10 +19,12 @@ import com.ecep.contract.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorGroupRequireFileTypeService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorGroupService;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.util.NumberStringConverter;
|
||||
import com.ecep.contract.util.SecurityUtils;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -397,7 +400,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
private void verifyVendorFile(VendorGroup group, boolean assignedProvider, Contract contract,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
@@ -492,7 +495,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
private void verifyAsCustomer(Company company, CompanyExtendInfo companyExtendInfo, Contract contract,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
boolean valiad = true;
|
||||
Project project = contract.getProject();
|
||||
if (project == null) {
|
||||
@@ -590,7 +593,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
private boolean verifyCustomerFileByContract(CompanyCustomer companyCustomer, Contract contract,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
List<LocalDate> verifyDates = new ArrayList<>();
|
||||
LocalDate minDate = LocalDate.of(2022, 1, 1);
|
||||
LocalDate developDate = companyCustomer.getDevelopDate();
|
||||
@@ -724,13 +727,8 @@ public class ContractVerifyComm {
|
||||
// 以下代码替换原有的获取当前用户逻辑,假设用户名即为员工 ID
|
||||
// 需根据实际业务调整 UserDetails 中的信息获取方式
|
||||
tasker.setCurrentUser(() -> {
|
||||
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
String username;
|
||||
if (principal instanceof UserDetails) {
|
||||
username = ((UserDetails) principal).getUsername();
|
||||
} else {
|
||||
username = principal.toString();
|
||||
}
|
||||
User currentUser = SecurityUtils.getCurrentUser();
|
||||
String username = currentUser.getUsername();
|
||||
try {
|
||||
return getEmployeeService().findByName(username);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.ecep.contract.ds.converter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import com.ecep.contract.model.BasedEntity;
|
||||
import com.ecep.contract.model.NamedEntity;
|
||||
|
||||
|
||||
public class EntityStringConverter<T> {
|
||||
|
||||
private Function<T, T> initialized;
|
||||
private Function<String, T> fromString;
|
||||
private Function<T, String> formater;
|
||||
private Function<String, List<T>> suggestion;
|
||||
|
||||
public String toString(T cc) {
|
||||
if (cc == null) {
|
||||
return "-";
|
||||
}
|
||||
cc = prefixObject(cc);
|
||||
return toPrettyString(cc);
|
||||
}
|
||||
|
||||
public T prefixObject(T cc) {
|
||||
if (cc == null) {
|
||||
return null;
|
||||
}
|
||||
if (initialized != null && !Hibernate.isInitialized(cc)) {
|
||||
cc = initialized.apply(cc);
|
||||
}
|
||||
return cc;
|
||||
}
|
||||
|
||||
public String toPrettyString(T cc) {
|
||||
if (formater != null) {
|
||||
return formater.apply(cc);
|
||||
}
|
||||
if (cc == null) {
|
||||
return null;
|
||||
}
|
||||
if (cc instanceof BasedEntity e) {
|
||||
return e.toPrettyString();
|
||||
}
|
||||
if (cc instanceof NamedEntity e) {
|
||||
return e.getName();
|
||||
}
|
||||
return cc.toString();
|
||||
}
|
||||
|
||||
public T fromString(String string) {
|
||||
if (fromString == null) {
|
||||
return null;
|
||||
}
|
||||
return fromString.apply(string);
|
||||
}
|
||||
|
||||
public void setFromString(Function<String, T> fromString) {
|
||||
this.fromString = fromString;
|
||||
}
|
||||
|
||||
public void setInitialized(Function<T, T> initialized) {
|
||||
this.initialized = initialized;
|
||||
}
|
||||
|
||||
public void setFormater(Function<T, String> formater) {
|
||||
this.formater = formater;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自动补全的数据提供方法
|
||||
*
|
||||
* @param suggestion 数据提供方法
|
||||
*/
|
||||
public void setSuggestion(Function<String, List<T>> suggestion) {
|
||||
this.suggestion = suggestion;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ecep.contract.ds;
|
||||
package com.ecep.contract.ds.converter;
|
||||
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.persistence.Converter;
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.ecep.contract.ds.converter;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
|
||||
public class NumberStringConverter {
|
||||
final Locale locale;
|
||||
final String pattern;
|
||||
final NumberFormat numberFormat;
|
||||
|
||||
public NumberStringConverter() {
|
||||
this(Locale.getDefault());
|
||||
}
|
||||
|
||||
public NumberStringConverter(Locale locale) {
|
||||
this(locale, null);
|
||||
}
|
||||
|
||||
public NumberStringConverter(String pattern) {
|
||||
this(Locale.getDefault(), pattern);
|
||||
}
|
||||
|
||||
public NumberStringConverter(Locale locale, String pattern) {
|
||||
this(locale, pattern, null);
|
||||
}
|
||||
|
||||
public NumberStringConverter(NumberFormat numberFormat) {
|
||||
this(null, null, numberFormat);
|
||||
}
|
||||
|
||||
NumberStringConverter(Locale locale, String pattern, NumberFormat numberFormat) {
|
||||
this.locale = locale;
|
||||
this.pattern = pattern;
|
||||
this.numberFormat = numberFormat;
|
||||
}
|
||||
|
||||
public Number fromString(String value) {
|
||||
try {
|
||||
// If the specified value is null or zero-length, return null
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
value = value.trim();
|
||||
|
||||
if (value.length() < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create and configure the parser to be used
|
||||
NumberFormat parser = getNumberFormat();
|
||||
|
||||
// Perform the requested parsing
|
||||
return parser.parse(value);
|
||||
} catch (ParseException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(Number value) {
|
||||
// If the specified value is null, return a zero-length String
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Create and configure the formatter to be used
|
||||
NumberFormat formatter = getNumberFormat();
|
||||
|
||||
// Perform the requested formatting
|
||||
return formatter.format(value);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "22")
|
||||
protected NumberFormat getNumberFormat() {
|
||||
Locale _locale = locale == null ? Locale.getDefault() : locale;
|
||||
|
||||
if (numberFormat != null) {
|
||||
return numberFormat;
|
||||
} else if (pattern != null) {
|
||||
DecimalFormatSymbols symbols = new DecimalFormatSymbols(_locale);
|
||||
return new DecimalFormat(pattern, symbols);
|
||||
} else {
|
||||
return NumberFormat.getNumberInstance(_locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import java.util.function.Function;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import com.ecep.contract.ds.converter.EntityStringConverter;
|
||||
import com.ecep.contract.model.CustomerCatalog;
|
||||
import com.ecep.contract.util.EntityStringConverter;
|
||||
|
||||
public class CustomerClassStringConverter extends EntityStringConverter<CustomerCatalog> {
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.CompanyCustomerFileType;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
||||
@@ -41,10 +42,6 @@ import jakarta.persistence.criteria.Path;
|
||||
@CacheConfig(cacheNames = "company-customer-file")
|
||||
public class CompanyCustomerFileService implements IEntityService<CompanyCustomerFile> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerFileService.class);
|
||||
/**
|
||||
* 客户资信评估表
|
||||
*/
|
||||
public static final String KEY_EVALUATION_FORM_TEMPLATE = "customer.evaluation.form.template";
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SysConfService confService;
|
||||
@@ -219,7 +216,7 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
||||
|
||||
|
||||
public File getEvaluationFormTemplate() {
|
||||
String path = confService.getString(KEY_EVALUATION_FORM_TEMPLATE);
|
||||
String path = confService.getString(CompanyCustomerConstant.KEY_EVALUATION_FORM_TEMPLATE);
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -59,9 +59,6 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
implements IEntityService<CompanyCustomer> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerService.class);
|
||||
|
||||
public static final String KEY_BASE_PATH = "customer.base.path";
|
||||
public static final String KEY_SALEBOOK_PATH = "customer.salebook.path";
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerRepository companyCustomerRepository;
|
||||
@@ -153,7 +150,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
return new File(confService.getString(KEY_BASE_PATH));
|
||||
return new File(confService.getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ecep.contract.ds.other.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.cloud.rk.CloudRkService;
|
||||
import com.ecep.contract.model.CloudRk;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cloudRk")
|
||||
public class CloudRkController {
|
||||
@Autowired
|
||||
private CloudRkService cloudRkService;
|
||||
|
||||
@RequestMapping("/findById")
|
||||
public CloudRk findById(Integer id) {
|
||||
return cloudRkService.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Page<CloudRk> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<CloudRk> spec = null;
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return cloudRkService.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public CloudRk save(CloudRk cloudRk) {
|
||||
return cloudRkService.save(cloudRk);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
public void delete(Integer id) {
|
||||
CloudRk cloudRk = cloudRkService.findById(id);
|
||||
cloudRkService.delete(cloudRk);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ecep.contract.ds.other.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.cloud.tyc.CloudTycService;
|
||||
import com.ecep.contract.model.CloudTyc;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cloudTyc")
|
||||
public class CloudTycController {
|
||||
@Autowired
|
||||
private CloudTycService cloudTycService;
|
||||
|
||||
@RequestMapping("/findById")
|
||||
public CloudTyc findById(Integer id) {
|
||||
return cloudTycService.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Page<CloudTyc> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<CloudTyc> spec = null;
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return cloudTycService.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public CloudTyc save(CloudTyc cloudTyc) {
|
||||
return cloudTycService.save(cloudTyc);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
public void delete(Integer id) {
|
||||
CloudTyc cloudTyc = cloudTycService.findById(id);
|
||||
cloudTycService.delete(cloudTyc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ecep.contract.ds.other.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.model.CloudYu;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cloudYu")
|
||||
public class CloudYuController {
|
||||
@Autowired
|
||||
private YongYouU8Service yongYouU8Service;
|
||||
|
||||
@RequestMapping("/findById")
|
||||
public CloudYu findById(Integer id) {
|
||||
return yongYouU8Service.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Page<CloudYu> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<CloudYu> spec = null;
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return yongYouU8Service.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public CloudYu save(CloudYu cloudYu) {
|
||||
return yongYouU8Service.save(cloudYu);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
public void delete(Integer id) {
|
||||
CloudYu cloudYu = yongYouU8Service.findById(id);
|
||||
yongYouU8Service.delete(cloudYu);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.ecep.contract.util.SecurityUtils;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/employee")
|
||||
@@ -31,8 +31,9 @@ public class EmployeeController {
|
||||
public Page<Employee> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<Employee> spec = null;
|
||||
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return employeeService.findAll(spec, pageable);
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.ecep.contract.ds.other.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ecep.contract.ds.other.service.EmployeeRoleService;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.util.SecurityUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/employeeRole")
|
||||
public class EmployeeRoleController {
|
||||
@Autowired
|
||||
private EmployeeRoleService employeeRoleService;
|
||||
|
||||
@RequestMapping("/findById")
|
||||
public EmployeeRole findById(Integer id) {
|
||||
return employeeRoleService.findById(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public Page<EmployeeRole> list(
|
||||
Map<String, Object> params,
|
||||
@RequestParam(defaultValue = "0", name = "page") int pageNumber,
|
||||
@RequestParam(defaultValue = "10", name = "size") int pageSize) {
|
||||
Specification<EmployeeRole> spec = null;
|
||||
if (!SecurityUtils.currentUserHasRole("ROLE_ADMIN")) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, cb) -> cb.equal(root.get("systemAdministrator"), false));
|
||||
}
|
||||
|
||||
String searchText = (String) params.get("searchText");
|
||||
if (StringUtils.hasText(searchText)) {
|
||||
spec = SpecificationUtils.andWith(searchText, (text) -> (root, query, cb) -> {
|
||||
return cb.like(root.get("name"), "%" + text + "%");
|
||||
});
|
||||
}
|
||||
|
||||
Sort sort = Sort.by(Sort.Order.desc("id"));
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
return employeeRoleService.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public EmployeeRole save(EmployeeRole role) {
|
||||
// 只有系统管理员才能保存角色
|
||||
if (!SecurityUtils.currentUserHasRole("ROLE_ADMIN")) {
|
||||
throw new SecurityException("无权限执行此操作");
|
||||
}
|
||||
return employeeRoleService.save(role);
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
public void delete(Integer id) {
|
||||
// 只有系统管理员才能删除角色
|
||||
if (!SecurityUtils.currentUserHasRole("ROLE_ADMIN")) {
|
||||
throw new SecurityException("无权限执行此操作");
|
||||
}
|
||||
EmployeeRole role = employeeRoleService.findById(id);
|
||||
if (role != null && role.isSystemAdministrator()) {
|
||||
throw new SecurityException("不能删除系统管理员角色");
|
||||
}
|
||||
employeeRoleService.delete(role);
|
||||
}
|
||||
|
||||
@RequestMapping("/getFunctionsByRoleId")
|
||||
public java.util.List<com.ecep.contract.model.Function> getFunctionsByRoleId(Integer roleId) {
|
||||
return employeeRoleService.getFunctionsByRoleId(roleId);
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,6 @@ import com.ecep.contract.model.CustomerSatisfactionSurvey;
|
||||
@Service
|
||||
public class CustomerSatisfactionSurveyService
|
||||
implements IEntityService<CustomerSatisfactionSurvey> {
|
||||
public final static String KEY_TEMPLATE = "project.customer-satisfaction-survey.template";
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CustomerSatisfactionSurveyRepository repository;
|
||||
|
||||
@@ -4,8 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ecep.contract.ds.converter.EntityStringConverter;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.util.EntityStringConverter;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user