From 68e1be69394f587a7591e2bd6301a371582dc3a4 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Wed, 30 Sep 2020 15:14:19 +0800 Subject: [PATCH] . --- .../java/com/cowr/model/CustomerPact.java | 14 ++ .../com/cowr/model/base/BaseCustomerPact.java | 200 ++++++++++++++++++ .../pact/CustomerPactPKValidator.java | 25 +++ .../customer/pact/CustomerPactService.java | 60 ++++++ .../customer/pact/CustomerPactValidator.java | 59 ++++++ .../src/main/java/generator/Main.java | 1 + .../customer/pact/CustomerPactController.java | 44 ++++ .../com/cowr/local/ssjygl/main/Config.java | 1 + .../customer/pact/CustomerPactController.java | 95 +++++++++ .../pact/CustomerPactSyncService.java | 23 ++ .../com/cowr/service/ssjygl/main/Config.java | 2 + 11 files changed, 524 insertions(+) create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerPact.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerPact.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactPKValidator.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactService.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactValidator.java create mode 100644 ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/customer/pact/CustomerPactController.java create mode 100644 ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactController.java create mode 100644 ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactSyncService.java diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerPact.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerPact.java new file mode 100644 index 0000000..d027bbd --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerPact.java @@ -0,0 +1,14 @@ +package com.cowr.model; + +import com.cowr.model.base.BaseCustomerPact; + +/** + * Generated by COWR Wed Sep 30 15:03:51 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +@SuppressWarnings("serial") +public class CustomerPact extends BaseCustomerPact { + public static final CustomerPact dao = new CustomerPact().dao(); +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerPact.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerPact.java new file mode 100644 index 0000000..183cf76 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerPact.java @@ -0,0 +1,200 @@ +package com.cowr.model.base; + +import com.cowr.common.base.BaseModel; +import com.jfinal.plugin.activerecord.IBean; +import com.alibaba.fastjson.annotation.JSONField; + +/** + * Generated by COWR Wed Sep 30 15:03:51 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +@SuppressWarnings("serial") +public abstract class BaseCustomerPact> extends BaseModel implements IBean { + + public static final String tablename = "customer_pact"; + + @JSONField(serialize=false) + public String getTablename(){ + return tablename; + } + + /** + * name: id + * type: INT(10) + * isNullable: NO + * isPrimaryKey: YES + * defaultValue: + * @param id + */ + @JSONField(name="id") + public void setId(Integer id) { + set("id", id); + } + + + /** + * @return id + */ + @JSONField(name="id") + public Integer getId() { + return getInt("id"); + } + + /** + * name: customer_id + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param customerId + */ + @JSONField(name="customer_id") + public void setCustomerId(Integer customerId) { + set("customer_id", customerId); + } + + + /** + * @return customer_id + */ + @JSONField(name="customer_id") + public Integer getCustomerId() { + return getInt("customer_id"); + } + + /** + * name: sign_time + * type: DATE(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param signTime 签订日期 + */ + @JSONField(name="sign_time") + public void setSignTime(java.util.Date signTime) { + set("sign_time", signTime); + } + + + /** + * @return sign_time 签订日期 + */ + @JSONField(name="sign_time") + public java.util.Date getSignTime() { + return get("sign_time"); + } + + /** + * name: sing_total_price + * type: DECIMAL(12,2) + * isNullable: YES + * isPrimaryKey: NO + * defaultValue: + * @param singTotalPrice 总价 + */ + @JSONField(name="sing_total_price") + public void setSingTotalPrice(java.math.BigDecimal singTotalPrice) { + set("sing_total_price", singTotalPrice); + } + + + /** + * @return sing_total_price 总价 + */ + @JSONField(name="sing_total_price") + public java.math.BigDecimal getSingTotalPrice() { + return get("sing_total_price"); + } + + /** + * name: sing_total_weight + * type: DECIMAL(12,2) + * isNullable: YES + * isPrimaryKey: NO + * defaultValue: + * @param singTotalWeight 总吨数 + */ + @JSONField(name="sing_total_weight") + public void setSingTotalWeight(java.math.BigDecimal singTotalWeight) { + set("sing_total_weight", singTotalWeight); + } + + + /** + * @return sing_total_weight 总吨数 + */ + @JSONField(name="sing_total_weight") + public java.math.BigDecimal getSingTotalWeight() { + return get("sing_total_weight"); + } + + /** + * name: sign_user_name + * type: VARCHAR(255) + * isNullable: YES + * isPrimaryKey: NO + * defaultValue: + * @param signUserName 签订人 + */ + @JSONField(name="sign_user_name") + public void setSignUserName(String signUserName) { + set("sign_user_name", signUserName); + } + + + /** + * @return sign_user_name 签订人 + */ + @JSONField(name="sign_user_name") + public String getSignUserName() { + return getStr("sign_user_name"); + } + + /** + * name: cutoff_time + * type: DATE(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param cutoffTime 截止时间 + */ + @JSONField(name="cutoff_time") + public void setCutoffTime(java.util.Date cutoffTime) { + set("cutoff_time", cutoffTime); + } + + + /** + * @return cutoff_time 截止时间 + */ + @JSONField(name="cutoff_time") + public java.util.Date getCutoffTime() { + return get("cutoff_time"); + } + + /** + * name: del + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: 0 + * @param del + */ + @JSONField(name="del") + public void setDel(Integer del) { + set("del", del); + } + + + /** + * @return del + */ + @JSONField(name="del") + public Integer getDel() { + return getInt("del"); + } + + +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactPKValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactPKValidator.java new file mode 100644 index 0000000..02eff1c --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactPKValidator.java @@ -0,0 +1,25 @@ +package com.cowr.ssjygl.customer.pact; + + +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.cowr.model.CustomerPact; +import com.jfinal.core.Controller; + +/** + * Generated by COWR Wed Sep 30 15:03:58 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +public class CustomerPactPKValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + validateRequired("id", "id", "id 必填"); + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + } + + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} \ No newline at end of file diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactService.java new file mode 100644 index 0000000..3636c50 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactService.java @@ -0,0 +1,60 @@ +package com.cowr.ssjygl.customer.pact; + +import com.cowr.common.Const; +import com.cowr.common.base.BaseService; +import com.cowr.common.view.PageParam; +import com.cowr.model.CustomerPact; +import com.jfinal.kit.StrKit; +import com.jfinal.plugin.activerecord.Db; +import com.jfinal.plugin.activerecord.Page; +import com.jfinal.plugin.activerecord.Record; +import java.util.ArrayList; +import java.util.List; + +/** + * Generated by COWR Wed Sep 30 15:03:58 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +public class CustomerPactService extends BaseService { + public static final CustomerPactService me = new CustomerPactService(); + + public Page find(PageParam pp, Integer customer_id, String customer_name) { + String selectsql = "select * "; + String fromsql = "from customer_pact t \n" + + " left join customer c on c.id = t.customer_id \n" + + " where 1=1 "; + List paraList = new ArrayList<>(); + + if(customer_id != null){ + fromsql += " and t.customer_id = ? \n"; + paraList.add(customer_id); + } + + if(StrKit.notBlank(customer_name)){ + fromsql += " and c.name like ? \n"; + paraList.add("%" + customer_name + "%"); + } + + String totalRowSql = "select count(*) " + fromsql; + String findSql = selectsql + fromsql; + + // 前端传了排序字段,并且排序字段存在相关表中 + if (StrKit.notBlank(pp.getSort_field()) && CustomerPact.dao.hasColunm(pp.getSort_field())) { + findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field(); + + if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) { + findSql += " " + Const.ORDER_BY_ASC; + } else { + findSql += " " + Const.ORDER_BY_DESC; + } + } + + return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); + } + + public List list() { + return CustomerPact.dao.find("select * from customer_pact"); + } +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactValidator.java new file mode 100644 index 0000000..f7fac69 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/pact/CustomerPactValidator.java @@ -0,0 +1,59 @@ +package com.cowr.ssjygl.customer.pact; + +import com.jfinal.core.Controller; +import com.jfinal.kit.StrKit; +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.cowr.model.CustomerPact; + +/** + * Generated by COWR Wed Sep 30 15:03:58 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +public class CustomerPactValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + // 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断 + if (!"save".equals(getActionMethodName())) { + validateRequired("id", "id", "id 必填"); + + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + } + + validateInteger("customer_id", 1, 2147483647, "customer_id", "customer_id 范围 1~2147483647"); + + + validateString("sign_time", 1, 10, "sign_time", "sign_time 长度 1~10"); + + validateDate("sign_time", "yyyy-MM-dd HH:mm:ss", false, "sign_time", "sign_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整 + if (StrKit.notBlank(c.get("sing_total_price"))) { // 可为空字段,当传入值时,才做验证 + validateBigDecimal("sing_total_price", new java.math.BigDecimal(-9.9999999999E10), new java.math.BigDecimal(9.9999999999E10), "sing_total_price", "sing_total_price 范围 -9.9999999999E10~9.9999999999E10"); + } + if (StrKit.notBlank(c.get("sing_total_weight"))) { // 可为空字段,当传入值时,才做验证 + validateBigDecimal("sing_total_weight", new java.math.BigDecimal(-9.9999999999E10), new java.math.BigDecimal(9.9999999999E10), "sing_total_weight", "sing_total_weight 范围 -9.9999999999E10~9.9999999999E10"); + } + + validateString("sign_user_name", 0, 255, "sign_user_name", "sign_user_name 长度 0~255"); + + + validateString("cutoff_time", 1, 10, "cutoff_time", "cutoff_time 长度 1~10"); + + validateDate("cutoff_time", "yyyy-MM-dd HH:mm:ss", false, "cutoff_time", "cutoff_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整 + + validateInteger("del", -2147483647, 2147483647, "del", "del 范围 -2147483647~2147483647"); + + + // 使用 model 更新时,model 不能只有主键有值 + // 这里用 getActionMethodName 写死,判断是 update 时,才做验证 + // 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段 + if ("edit".equals(getActionMethodName())) { + validateUpdateModel(CustomerPact.class, "", true); // 忽略不在model中的字段 + } + } + + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} \ No newline at end of file diff --git a/ssjygl-xsx-common/src/main/java/generator/Main.java b/ssjygl-xsx-common/src/main/java/generator/Main.java index 132a7c6..f0d6c60 100644 --- a/ssjygl-xsx-common/src/main/java/generator/Main.java +++ b/ssjygl-xsx-common/src/main/java/generator/Main.java @@ -74,6 +74,7 @@ public class Main { "invoice_log", "sms_log", "ossfile_log", + "customer_pact", }; PropKit.use("db.properties"); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/customer/pact/CustomerPactController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/customer/pact/CustomerPactController.java new file mode 100644 index 0000000..4d690a7 --- /dev/null +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/customer/pact/CustomerPactController.java @@ -0,0 +1,44 @@ +package com.cowr.local.ssjygl.customer.pact; + +import com.cowr.common.view.PageParam; +import com.cowr.common.view.Result; +import com.cowr.model.CustomerPact; +import com.cowr.ssjygl.customer.pact.CustomerPactPKValidator; +import com.cowr.ssjygl.customer.pact.CustomerPactService; +import com.cowr.ssjygl.customer.pact.CustomerPactValidator; +import com.jfinal.aop.Before; +import com.jfinal.core.Controller; + +/** + * Generated by COWR Wed Sep 30 15:03:58 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +public class CustomerPactController extends Controller { + /** + * 分页查找 customer_pact 客户相关 - 签订合同 + */ + public void find() { + PageParam pp = getBean(PageParam.class, "", true); + Integer customer_id = getInt("customer_id"); + String customer_name = get("customer_name"); + renderJson(Result.object(CustomerPactService.me.find(pp, customer_id, customer_name))); + } + + /** + * 按主键查找单个对象 customer_pact 客户相关 - 签订合同 + */ + @Before(CustomerPactPKValidator.class) + public void get() { + CustomerPact model = getModel(CustomerPact.class, "", true); // 忽略不在model中的字段 + renderJson(CustomerPactService.me.findByPk(model)); + } + + /** + * 返回所有 customer_pact 客户相关 - 签订合同 + */ + public void list() { + renderJson(Result.object(CustomerPactService.me.list())); + } +} diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java index 9606c93..8fbc034 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java @@ -192,6 +192,7 @@ public class Config extends JFinalConfig { me.add("/customer", CustomerController.class); me.add("/customer/contact", CustomerContactController.class); me.add("/customer/receiver", CustomerReceiverController.class); + me.add("/customer/pact", CustomerPactController.class); // -- 预付费 me.add("/prepay", PrepayController.class); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactController.java new file mode 100644 index 0000000..d18ab4a --- /dev/null +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactController.java @@ -0,0 +1,95 @@ +package com.cowr.service.ssjygl.customer.pact; + +import com.cowr.common.view.PageParam; +import com.cowr.common.view.Result; +import com.cowr.model.CustomerPact; +import com.cowr.model.Sysuser; +import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService; +import com.cowr.ssjygl.customer.pact.CustomerPactPKValidator; +import com.cowr.ssjygl.customer.pact.CustomerPactService; +import com.cowr.ssjygl.customer.pact.CustomerPactValidator; +import com.jfinal.aop.Before; +import com.jfinal.core.Controller; + +/** + * Generated by COWR Wed Sep 30 15:03:58 CST 2020 + * TableName: customer_pact + * Remarks: 客户相关 - 签订合同 + * PrimaryKey: id + */ +public class CustomerPactController extends Controller { + + /** + * 新增 customer_pact 客户相关 - 签订合同 + */ + @Before(CustomerPactValidator.class) + public void save() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + CustomerPact model = getModel(CustomerPact.class, "", true); // 忽略不在model中的字段 + renderJson(CustomerPactSyncService.me.save(model, tokenuser)); + } + + /** + * 删除 customer_pact 客户相关 - 签订合同 + */ + @Before(CustomerPactPKValidator.class) + public void del() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + CustomerPact model = getModel(CustomerPact.class, "", true); // 忽略不在model中的字段 + renderJson(CustomerPactSyncService.me.delete(model, tokenuser)); + } + + /** + * 恢复 customer_pact 客户相关 - 签订合同 + */ + @Before(CustomerPactPKValidator.class) + public void restore() { + Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); + + if (tokenuser == null) { + renderJson(Result.noauth()); + return; + } + + CustomerPact model = getModel(CustomerPact.class, "", true); // 忽略不在model中的字段 + renderJson(CustomerPactSyncService.me.restore(model, tokenuser)); + } + + /** + * 分页查找 customer_pact 客户相关 - 签订合同 + */ + public void find() { + PageParam pp = getBean(PageParam.class, "", true); + Integer customer_id = getInt("customer_id"); + String customer_name = get("customer_name"); + renderJson(Result.object(CustomerPactService.me.find(pp, customer_id, customer_name))); + } + + /** + * 按主键查找单个对象 customer_pact 客户相关 - 签订合同 + */ + @Before(CustomerPactPKValidator.class) + public void get() { + CustomerPact model = getModel(CustomerPact.class, "", true); // 忽略不在model中的字段 + renderJson(CustomerPactService.me.findByPk(model)); + } + + /** + * 返回所有 customer_pact 客户相关 - 签订合同 + */ + public void list() { + renderJson(Result.object(CustomerPactService.me.list())); + } +} diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactSyncService.java new file mode 100644 index 0000000..6a8fa11 --- /dev/null +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/customer/pact/CustomerPactSyncService.java @@ -0,0 +1,23 @@ +package com.cowr.service.ssjygl.customer.pact; + +import com.cowr.common.view.Result; +import com.cowr.model.Customer; +import com.cowr.model.CustomerPact; +import com.cowr.model.Sysuser; +import com.cowr.service.ssjygl.base.BaseSyncService; +import com.jfinal.log.Log; + +public class CustomerPactSyncService extends BaseSyncService { + private static Log log = Log.getLog(CustomerPactSyncService.class); + public static CustomerPactSyncService me = new CustomerPactSyncService(); + + public Result save(CustomerPact model, Sysuser sysuser) { + Customer customer = Customer.dao.findById(model.getCustomerId()); + + if (customer == null) { + return Result.failed("没有找到对应客户信息"); + } + + return super.save(model, sysuser); + } +} diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java index 155aa7c..dd8c9cf 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java @@ -7,6 +7,7 @@ import com.cowr.service.ssjygl.blacklist.BlacklistController; import com.cowr.service.ssjygl.cache.CacheController; import com.cowr.service.ssjygl.customer.CustomerController; import com.cowr.service.ssjygl.customer.contact.CustomerContactController; +import com.cowr.service.ssjygl.customer.pact.CustomerPactController; import com.cowr.service.ssjygl.customer.receiver.CustomerReceiverController; import com.cowr.service.ssjygl.customer.register.CustomerRegisterController; import com.cowr.service.ssjygl.driver.DriverController; @@ -162,6 +163,7 @@ public class Config extends JFinalConfig { me.add("/customer/contact", CustomerContactController.class); me.add("/customer/receiver", CustomerReceiverController.class); me.add("/customer/register", CustomerRegisterController.class); + me.add("/customer/pact", CustomerPactController.class); // -- 预付费 me.add("/prepay", PrepayController.class);