lisai17@sina.com 2020-09-30 15:14:19 +08:00
parent 3f7ab546dd
commit 68e1be6939
11 changed files with 524 additions and 0 deletions

View File

@ -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<CustomerPact> {
public static final CustomerPact dao = new CustomerPact().dao();
}

View File

@ -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<M extends BaseCustomerPact<M>> extends BaseModel<M> 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");
}
}

View File

@ -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()));
}
}

View File

@ -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<Record> 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<Object> 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<CustomerPact> list() {
return CustomerPact.dao.find("select * from customer_pact");
}
}

View File

@ -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()));
}
}

View File

@ -74,6 +74,7 @@ public class Main {
"invoice_log",
"sms_log",
"ossfile_log",
"customer_pact",
};
PropKit.use("db.properties");

View File

@ -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()));
}
}

View File

@ -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);

View File

@ -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()));
}
}

View File

@ -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);
}
}

View File

@ -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);