利润率配置修改
parent
8ee5c1fe64
commit
8947505fac
|
@ -1,44 +0,0 @@
|
|||
package cn.palmte.work.controller.backend;
|
||||
|
||||
import cn.palmte.work.model.ProfitMarginConfig;
|
||||
import cn.palmte.work.model.ProfitMarginConfigRepository;
|
||||
import cn.palmte.work.service.ProfitMarginConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/profitMarginConfig")
|
||||
public class ProfitMarginConfigController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private ProfitMarginConfigService profitMarginConfigService;
|
||||
|
||||
@Autowired
|
||||
private ProfitMarginConfigRepository profitMarginConfigRepository;
|
||||
|
||||
/**
|
||||
* 跳转到编辑页面
|
||||
*/
|
||||
@RequestMapping("/edit")
|
||||
public String edit(Map<String, Object> model) {
|
||||
ProfitMarginConfig profitMarginConfig = profitMarginConfigRepository.findOne(1);
|
||||
model.put("profitMarginConfig", profitMarginConfig);
|
||||
return "/admin/profit_marfin_config_input";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/save")
|
||||
public String save(ProfitMarginConfig profitMarginConfig,Map<String, Object> model){
|
||||
try {
|
||||
profitMarginConfigService.saveOrUpdate(profitMarginConfig);
|
||||
} catch (Exception e) {
|
||||
model.put("errorMessage", e.getMessage());
|
||||
return "/common/error";
|
||||
}
|
||||
return "redirect:/profitMarginConfig/edit";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.palmte.work.controller.backend;
|
||||
|
||||
import cn.palmte.work.model.SysConfigRepository;
|
||||
import cn.palmte.work.pojo.SysConfigRequest;
|
||||
import cn.palmte.work.service.SysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/sys/config")
|
||||
public class SysConfigController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
@Autowired
|
||||
private SysConfigRepository sysConfigRepository;
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(Map<String, Object> model) {
|
||||
model.put("underwrittenTaxRate",sysConfigRepository.findByCodeEquals("underwrittenTaxRate").getValue());
|
||||
model.put("projectContributionProfitRateThreshold",sysConfigRepository.findByCodeEquals("projectContributionProfitRateThreshold").getValue());
|
||||
return "admin/profit_marfin_config_input";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public String save(SysConfigRequest sysConfigRequest, Map<String, Object> model) {
|
||||
sysConfigService.saveOrUpdate(sysConfigRequest);
|
||||
return "redirect:/sys/config/edit";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* 利润率配置
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "profit_margin_config")
|
||||
public class ProfitMarginConfig {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "year_profit_margin")
|
||||
private String yearProfitMargin;
|
||||
|
||||
@Column(name = "threshold_value")
|
||||
private String thresholdValue;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getYearProfitMargin() {
|
||||
return yearProfitMargin;
|
||||
}
|
||||
|
||||
public void setYearProfitMargin(String yearProfitMargin) {
|
||||
this.yearProfitMargin = yearProfitMargin;
|
||||
}
|
||||
|
||||
public String getThresholdValue() {
|
||||
return thresholdValue;
|
||||
}
|
||||
|
||||
public void setThresholdValue(String thresholdValue) {
|
||||
this.thresholdValue = thresholdValue;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ProfitMarginConfigRepository extends JpaRepository<ProfitMarginConfig,Integer> {
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sys_config")
|
||||
public class SysConfig {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
|
||||
private Integer id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updateTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SysConfigRepository extends JpaRepository<SysConfig,Integer> {
|
||||
|
||||
SysConfig findByCodeEquals(String code);
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package cn.palmte.work.pojo;
|
||||
|
||||
public class SysConfigRequest {
|
||||
|
||||
/**
|
||||
* 项目年利润率(资金利率)
|
||||
*/
|
||||
private String underwrittenTaxRate;
|
||||
|
||||
/**
|
||||
* 项目贡献利润率阀值
|
||||
*/
|
||||
private String projectContributionProfitRateThreshold;
|
||||
|
||||
|
||||
public String getUnderwrittenTaxRate() {
|
||||
return underwrittenTaxRate;
|
||||
}
|
||||
|
||||
public void setUnderwrittenTaxRate(String underwrittenTaxRate) {
|
||||
this.underwrittenTaxRate = underwrittenTaxRate;
|
||||
}
|
||||
|
||||
public String getProjectContributionProfitRateThreshold() {
|
||||
return projectContributionProfitRateThreshold;
|
||||
}
|
||||
|
||||
public void setProjectContributionProfitRateThreshold(String projectContributionProfitRateThreshold) {
|
||||
this.projectContributionProfitRateThreshold = projectContributionProfitRateThreshold;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cn.palmte.work.service;
|
||||
|
||||
import cn.palmte.work.model.ProfitMarginConfig;
|
||||
import cn.palmte.work.model.ProfitMarginConfigRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ProfitMarginConfigService {
|
||||
|
||||
@Autowired
|
||||
private ProfitMarginConfigRepository profitMarginConfigRepository;
|
||||
|
||||
|
||||
public void saveOrUpdate(ProfitMarginConfig profitMarginConfig) {
|
||||
ProfitMarginConfig obj = profitMarginConfigRepository.findOne(1);
|
||||
obj.setThresholdValue(profitMarginConfig.getThresholdValue());
|
||||
obj.setYearProfitMargin(profitMarginConfig.getYearProfitMargin());
|
||||
profitMarginConfigRepository.saveAndFlush(obj);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package cn.palmte.work.service;
|
||||
|
||||
import cn.palmte.work.model.SysConfig;
|
||||
import cn.palmte.work.model.SysConfigRepository;
|
||||
import cn.palmte.work.pojo.SysConfigRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SysConfigService {
|
||||
|
||||
@Autowired
|
||||
private SysConfigRepository sysConfigRepository;
|
||||
|
||||
|
||||
public void saveOrUpdate(SysConfigRequest sysConfigRequest) {
|
||||
SysConfig underwrittenTaxRate = sysConfigRepository.findByCodeEquals("underwrittenTaxRate");
|
||||
underwrittenTaxRate.setValue(sysConfigRequest.getUnderwrittenTaxRate());
|
||||
sysConfigRepository.saveAndFlush(underwrittenTaxRate);
|
||||
|
||||
SysConfig projectContributionProfitRateThreshold = sysConfigRepository.findByCodeEquals("projectContributionProfitRateThreshold");
|
||||
projectContributionProfitRateThreshold.setValue(sysConfigRequest.getProjectContributionProfitRateThreshold());
|
||||
sysConfigRepository.saveAndFlush(projectContributionProfitRateThreshold);
|
||||
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
<div class="am-cf am-padding">
|
||||
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /项目利润率配置</div>
|
||||
</div>
|
||||
<form method="post" class="am-form" id="tmpForm" action="${base}/profitMarginConfig/save">
|
||||
<form method="post" class="am-form" id="tmpForm" action="${base}/sys/config/save">
|
||||
<!--选项卡(tabs)begin-->
|
||||
<div class="am-tabs am-margin" data-am-tabs>
|
||||
<ul class="am-tabs-nav am-nav am-nav-tabs">
|
||||
|
@ -28,10 +28,10 @@
|
|||
项目贡献利润率阀值:
|
||||
</div>
|
||||
<div class="am-u-sm-6 am-u-md-6">
|
||||
<input name="thresholdValue" class="js-ajax-validate"
|
||||
<input name="projectContributionProfitRateThreshold" class="js-ajax-validate"
|
||||
data-validate-async data-validation-message="请输入项目贡献利润率阀值"
|
||||
type="number" step="0.01" id="thresholdValue"
|
||||
value="${profitMarginConfig.thresholdValue!}" minlength="1"
|
||||
type="number" step="0.01" id="projectContributionProfitRateThreshold"
|
||||
value="${projectContributionProfitRateThreshold!}" minlength="1"
|
||||
maxlength="4" oninput="if(value.length>4)value=value.slice(0,4)"
|
||||
placeholder="请输入项目贡献利润率阀值" required/>
|
||||
<p>注:请注意保留小数点后两位</p>
|
||||
|
@ -45,10 +45,10 @@
|
|||
项目年利润率:
|
||||
</div>
|
||||
<div class="am-u-sm-6 am-u-md-6">
|
||||
<input name="yearProfitMargin" class="js-ajax-validate"
|
||||
<input name="underwrittenTaxRate" class="js-ajax-validate"
|
||||
data-validate-async data-validation-message="请输入项目年利润率"
|
||||
type="number" step="0.01" id="yearProfitMargin"
|
||||
value="${profitMarginConfig.yearProfitMargin!}" minlength="1"
|
||||
type="number" step="0.01" id="underwrittenTaxRate"
|
||||
value="${underwrittenTaxRate!}" minlength="1"
|
||||
maxlength="4" oninput="if(value.length>4)value=value.slice(0,4)"
|
||||
placeholder="请输入项目年利润率" required/>
|
||||
<p>注:请注意保留小数点后两位</p>
|
||||
|
|
Loading…
Reference in New Issue