add delete customer

This commit is contained in:
Shaun Chyxion 2020-11-08 14:34:10 +08:00
parent aebbfa65ce
commit bf25b7489f
26 changed files with 196 additions and 181 deletions

View File

@ -17,7 +17,7 @@
<properties> <properties>
<project.build.finalName>ambition-crm</project.build.finalName> <project.build.finalName>ambition-crm</project.build.finalName>
<start-class>com.pudonghot.ambition.crm.AmbitionCRM</start-class> <spring-boot.run.main-class>com.pudonghot.ambition.crm.AmbitionCRM</spring-boot.run.main-class>
</properties> </properties>
<dependencies> <dependencies>
@ -99,6 +99,10 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
<fork>true</fork>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -11,6 +11,7 @@ import javax.validation.constraints.Min;
import me.chyxion.tigon.model.ListResult; import me.chyxion.tigon.model.ListResult;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import me.chyxion.tigon.webmvc.ResourceModel; import me.chyxion.tigon.webmvc.ResourceModel;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.pudonghot.ambition.crm.model.User; import com.pudonghot.ambition.crm.model.User;
@ -20,6 +21,7 @@ import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.pudonghot.ambition.crm.model.CustomerProperty; import com.pudonghot.ambition.crm.model.CustomerProperty;
import com.pudonghot.ambition.crm.service.CustomerService; import com.pudonghot.ambition.crm.service.CustomerService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -163,6 +165,12 @@ public class CustomerController
"text/csv; charset=gbk", null); "text/csv; charset=gbk", null);
} }
@RequiresRoles(User.ROLE_ADMIN)
@PostMapping("/delete")
public void delete(@NotBlank @RequestParam("id") String id) {
((CustomerService) queryService).delete(id);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -2,6 +2,7 @@ package com.pudonghot.ambition.crm.service.support;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import lombok.val;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -9,7 +10,6 @@ import me.chyxion.tigon.mybatis.Search;
import me.chyxion.tigon.model.ViewModel; import me.chyxion.tigon.model.ViewModel;
import org.apache.commons.csv.CSVRecord; import org.apache.commons.csv.CSVRecord;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import com.pudonghot.ambition.crm.model.*; import com.pudonghot.ambition.crm.model.*;
import me.chyxion.tigon.model.ListResult; import me.chyxion.tigon.model.ListResult;
import com.pudonghot.ambition.crm.mapper.*; import com.pudonghot.ambition.crm.mapper.*;
@ -82,20 +82,21 @@ public class CustomerServiceSupport
/** /**
* override find by id with find by search * override find by id with find by search
*
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public ViewModel<Customer> findViewModel(final String id) { public ViewModel<Customer> findViewModel(final String id) {
final Customer customer = mapper.findForShow(id); val customer = mapper.findForShow(id);
ViewModel<Customer> viewModel = null; ViewModel<Customer> viewModel = null;
if (customer != null) { if (customer != null) {
viewModel = toViewModel(customer); viewModel = toViewModel(customer);
// accounts // accounts
final List<CustomerPermission> permissions = customerPermissionMapper.list( val permissions = customerPermissionMapper.list(
new Search(CustomerPermission.CUSTOMER_ID, id) new Search(CustomerPermission.CUSTOMER_ID, id)
.eq(CustomerPermission.ENABLED, true)); .eq(CustomerPermission.ENABLED, true));
final List<String> accounts = new ArrayList<>(permissions.size()); val accounts = new ArrayList<>(permissions.size());
for (CustomerPermission permission : permissions) { for (CustomerPermission permission : permissions) {
accounts.add(permission.getUserAccount()); accounts.add(permission.getUserAccount());
} }
@ -113,6 +114,7 @@ public class CustomerServiceSupport
applicationMapper.list(new Search().asc(Application.NAME))); applicationMapper.list(new Search().asc(Application.NAME)));
} }
return viewModel; return viewModel;
} }
@ -122,7 +124,7 @@ public class CustomerServiceSupport
@Override @Override
public ListResult<ViewModel<Customer>> listViewModelsPage(Search search) { public ListResult<ViewModel<Customer>> listViewModelsPage(Search search) {
final String account = search.getAttr(User.ACCOUNT); final String account = search.getAttr(User.ACCOUNT);
final ListResult<ViewModel<Customer>> result = val result =
new ListResult<>(toViewModel( new ListResult<>(toViewModel(
mapper.listForShow(search, account)), mapper.listForShow(search, account)),
mapper.countForShow(search, account)); mapper.countForShow(search, account));
@ -136,12 +138,12 @@ public class CustomerServiceSupport
result.setAttr("cityList", mapper.listCity()); result.setAttr("cityList", mapper.listCity());
result.setAttr("salespersonList", mapper.listSalesperson()); result.setAttr("salespersonList", mapper.listSalesperson());
final List<CustomerProperty> statusList = val statusList =
customerPropertyMapper.list( customerPropertyMapper.list(
new Search(CustomerProperty.TYPE, new Search(CustomerProperty.TYPE,
CustomerProperty.Type.STATUS) CustomerProperty.Type.STATUS)
.asc(CustomerProperty.SORT)); .asc(CustomerProperty.SORT));
final CustomerProperty noneStatus = new CustomerProperty(); val noneStatus = new CustomerProperty();
noneStatus.setId("null"); noneStatus.setId("null");
noneStatus.setName("None"); noneStatus.setName("None");
noneStatus.setEnabled(true); noneStatus.setEnabled(true);
@ -161,26 +163,25 @@ public class CustomerServiceSupport
*/ */
@Override @Override
public ViewModel<Customer> update(final CustomerFormForUpdate form) { public ViewModel<Customer> update(final CustomerFormForUpdate form) {
final String customerId = form.getId(); val customerId = form.getId();
customerApplicationMapper.delete( customerApplicationMapper.delete(
new Search(CustomerApplication.CUSTOMER_ID, customerId)); new Search(CustomerApplication.CUSTOMER_ID, customerId));
customerPermissionMapper.delete( customerPermissionMapper.delete(
new Search(CustomerPermission.CUSTOMER_ID, customerId) new Search(CustomerPermission.CUSTOMER_ID, customerId)
.eq(CustomerPermission.TYPE, CustomerPermission.Type.APPLICATION)); .eq(CustomerPermission.TYPE, CustomerPermission.Type.APPLICATION));
final String[] applications = form.getApplications(); val applications = form.getApplications();
if (applications != null && applications.length > 0) { if (applications != null && applications.length > 0) {
final String operator = form.getUpdatedBy(); val operator = form.getUpdatedBy();
final Date now = new Date(); val now = new Date();
for (final String applicationId : applications) { for (val applicationId : applications) {
final Application application = val application = applicationMapper.find(applicationId);
applicationMapper.find(applicationId);
Assert.state(application != null, Assert.state(application != null,
"No application [" + applicationId + "] found"); "No application [" + applicationId + "] found");
Assert.state(application.isEnabled(), Assert.state(application.isEnabled(),
"Application [" + application.getName() + "] is disabled"); "Application [" + application.getName() + "] is disabled");
final CustomerApplication customerApplication = new CustomerApplication(); val customerApplication = new CustomerApplication();
customerApplication.setId(idSeq.get()); customerApplication.setId(idSeq.get());
customerApplication.setEnabled(true); customerApplication.setEnabled(true);
customerApplication.setCustomerId(customerId); customerApplication.setCustomerId(customerId);
@ -189,7 +190,7 @@ public class CustomerServiceSupport
customerApplication.setDateCreated(now); customerApplication.setDateCreated(now);
customerApplicationMapper.insert(customerApplication); customerApplicationMapper.insert(customerApplication);
final String applicationOwner = application.getOwner(); val applicationOwner = application.getOwner();
if (StringUtils.isNotBlank(applicationOwner)) { if (StringUtils.isNotBlank(applicationOwner)) {
log.info("Add application owner [{}] customer [{}] permission.", log.info("Add application owner [{}] customer [{}] permission.",
applicationOwner, customerId); applicationOwner, customerId);
@ -210,15 +211,15 @@ public class CustomerServiceSupport
List<Map<String, Object>> ytdSales = null; List<Map<String, Object>> ytdSales = null;
final String strYears = model.getYears(); val strYears = model.getYears();
final String strYtdSales = model.getYtdSales(); val strYtdSales = model.getYtdSales();
String[] years = null; String[] years = null;
if (StringUtils.isNotBlank(strYears) && if (StringUtils.isNotBlank(strYears) &&
StringUtils.isNotBlank(strYtdSales)) { StringUtils.isNotBlank(strYtdSales)) {
years = strYears.split(SPLITTER); years = strYears.split(SPLITTER);
final String[] sales = strYtdSales.split(SPLITTER); val sales = strYtdSales.split(SPLITTER);
ytdSales = new ArrayList<>(years.length); ytdSales = new ArrayList<>(years.length);
int i = 0; int i = 0;
for (final String year : years) { for (final String year : years) {
@ -233,26 +234,15 @@ public class CustomerServiceSupport
viewModel.setAttr("ytdSales", ytdSales != null ? viewModel.setAttr("ytdSales", ytdSales != null ?
ytdSales : Collections.emptyList()); ytdSales : Collections.emptyList());
// recent 3 issues val lastIssue = model.getLastIssue();
// final List<ViewModel<CustomerIssue>> recentIssues =
// customerIssueService.listRecent(model.getId(), 3);
final String lastIssue = model.getLastIssue();
if (StringUtils.isNotBlank(lastIssue)) { if (StringUtils.isNotBlank(lastIssue)) {
final String[] issueParts = lastIssue.split(SPLITTER); val issueParts = lastIssue.split(SPLITTER);
CustomerIssue issue = new CustomerIssue(); CustomerIssue issue = new CustomerIssue();
issue.setId(issueParts[0]); issue.setId(issueParts[0]);
issue.setIssue(issueParts[1]); issue.setIssue(issueParts[1]);
issue.setDateCreated(new Date(Long.parseLong(issueParts[2]))); issue.setDateCreated(new Date(Long.parseLong(issueParts[2])));
viewModel.setAttr("issue1", issue); viewModel.setAttr("issue1", issue);
} }
// if (!recentIssues.isEmpty()) {
// int i = 0;
// final Iterator<ViewModel<CustomerIssue>> it = recentIssues.iterator();
// while (it.hasNext()) {
// viewModel.setAttr("issue" + (++i), it.next());
// }
// }
} }
/** /**
@ -262,9 +252,8 @@ public class CustomerServiceSupport
@Override @Override
public void importCSV(final String operator, final InputStream csvIn) { public void importCSV(final String operator, final InputStream csvIn) {
final Date now = new Date(); val now = new Date();
val importRecord = new ImportRecord();
final ImportRecord importRecord = new ImportRecord();
importRecord.setId(idSeq.get()); importRecord.setId(idSeq.get());
importRecord.setType(ImportRecord.TYPE_CUSTOMER); importRecord.setType(ImportRecord.TYPE_CUSTOMER);
importRecord.setCompleted(false); importRecord.setCompleted(false);
@ -279,6 +268,32 @@ public class CustomerServiceSupport
private final User user = new User(); private final User user = new User();
private final CustomerPermission permission = new CustomerPermission(); private final CustomerPermission permission = new CustomerPermission();
/**
* {@inheritDoc}
*/
@Override
public void read(final CSVRecord record) {
val customerId = record.get(0).trim();
if (StringUtils.isBlank(customerId)) {
log.info("Blank customer id found, ignore.");
return;
}
customer.setId(customerId);
customer.setName(record.get(1).trim());
customer.setCountryCode(record.get(2).trim());
customer.setState(record.get(3).trim());
customer.setCity(record.get(4).trim());
customer.setMs(record.get(5).trim());
customer.setRegion(record.get(6).trim());
val employeeId = StringUtils.defaultIfBlank(record.get(7).trim(), null);
customer.setSalesperson(employeeId);
log.info("Customer [{}] read.", customer);
createUserIfNotExist(operator, employeeId, now);
createOrUpdateCustomer(operator, customer, now);
createOrUpdateCustomerPermissions(operator, customerId, record.get(8), now);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -298,32 +313,6 @@ public class CustomerServiceSupport
*/ */
} }
/**
* {@inheritDoc}
*/
@Override
public void read(final CSVRecord record) {
final String customerId = record.get(0).trim();
if (StringUtils.isBlank(customerId)) {
log.info("Blank customer id found, ignore.");
return;
}
customer.setId(customerId);
customer.setName(record.get(1).trim());
customer.setCountryCode(record.get(2).trim());
customer.setState(record.get(3).trim());
customer.setCity(record.get(4).trim());
customer.setMs(record.get(5).trim());
customer.setRegion(record.get(6).trim());
final String employeeId = StringUtils.defaultIfBlank(record.get(7).trim(), null);
customer.setSalesperson(employeeId);
log.info("Customer [{}] read.", customer);
createUserIfNotExist(operator, employeeId, now);
createOrUpdateCustomer(operator, customer, now);
createOrUpdateCustomerPermissions(operator, customerId, record.get(8), now);
}
// -- // --
// private methods // private methods
@ -336,7 +325,7 @@ public class CustomerServiceSupport
user.setAccount(employeeId); user.setAccount(employeeId);
user.setEmployeeId(employeeId); user.setEmployeeId(employeeId);
final String password = idSeq.get(); val password = idSeq.get();
user.setPassword(password); user.setPassword(password);
user.setGender(Constants.GENDER_MALE); user.setGender(Constants.GENDER_MALE);
user.setEnabled(true); user.setEnabled(true);
@ -351,10 +340,10 @@ public class CustomerServiceSupport
private void createOrUpdateCustomer(final String operator, final Customer customer, final Date date) { private void createOrUpdateCustomer(final String operator, final Customer customer, final Date date) {
log.info("User [{}] create or update customer [{}].", operator, customer); log.info("User [{}] create or update customer [{}].", operator, customer);
final String customerId = customer.getId(); val customerId = customer.getId();
final String ms = customer.getMs(); val ms = customer.getMs();
final Customer customerExisted = mapper.find(customerId); val customerExisted = mapper.find(customerId);
if (customerExisted != null) { if (customerExisted != null) {
log.info("Customer existed [{}] found, update.", customerExisted); log.info("Customer existed [{}] found, update.", customerExisted);
// basic props // basic props
@ -386,7 +375,7 @@ public class CustomerServiceSupport
if (customerIssueMapper.count( if (customerIssueMapper.count(
new Search(CustomerIssue.CUSTOMER_ID, customerId) new Search(CustomerIssue.CUSTOMER_ID, customerId)
.eq(CustomerIssue.ENABLED, true)) < 1) { .eq(CustomerIssue.ENABLED, true)) < 1) {
final CustomerIssue ci = new CustomerIssue(); val ci = new CustomerIssue();
ci.setId(idSeq.get()); ci.setId(idSeq.get());
ci.setArtificial(false); ci.setArtificial(false);
ci.setCustomerId(customerId); ci.setCustomerId(customerId);
@ -404,11 +393,11 @@ public class CustomerServiceSupport
log.info("User [{}] create or update customer [{}] permissions [{}].", operator, customerId, strAccounts); log.info("User [{}] create or update customer [{}] permissions [{}].", operator, customerId, strAccounts);
if (StringUtils.isNotBlank(strAccounts)) { if (StringUtils.isNotBlank(strAccounts)) {
for (final String account : new HashSet<>( for (val account : new HashSet<>(
Arrays.asList(strAccounts.trim().split("\\s*,\\s*")))) { Arrays.asList(strAccounts.trim().split("\\s*,\\s*")))) {
if (StringUtils.isNotBlank(account)) { if (StringUtils.isNotBlank(account)) {
final CustomerPermission permOld = customerPermissionMapper.find( val permOld = customerPermissionMapper.find(
new Search(CustomerPermission.CUSTOMER_ID, customerId) new Search(CustomerPermission.CUSTOMER_ID, customerId)
.eq(CustomerPermission.USER_ACCOUNT, account)); .eq(CustomerPermission.USER_ACCOUNT, account));
if (permOld != null) { if (permOld != null) {
@ -458,12 +447,12 @@ public class CustomerServiceSupport
*/ */
@Override @Override
public File exportCSV(final String operator) { public File exportCSV(final String operator) {
final File file = new File(FileUtils.getTempDirectory(), val file = new File(FileUtils.getTempDirectory(),
"Customers_" + DateFormatUtils.format(System.currentTimeMillis(), "Customers_" + DateFormatUtils.format(System.currentTimeMillis(),
"yyyy-MM-dd_HHmmss") + ".csv"); "yyyy-MM-dd_HHmmss") + ".csv");
try (final OutputStreamWriter fileWriter = try (val fileWriter =
new OutputStreamWriter(new FileOutputStream(file), CSVUtils.GBK); new OutputStreamWriter(new FileOutputStream(file), CSVUtils.GBK);
final CSVPrinter printer = EXPORT_FORMAT.print(fileWriter)) { val printer = EXPORT_FORMAT.print(fileWriter)) {
scan(512, new Search() scan(512, new Search()
// .setAttr("APPLICATION_NOT_NULL", true) // .setAttr("APPLICATION_NOT_NULL", true)
@ -545,12 +534,12 @@ public class CustomerServiceSupport
private String joinYtdSales(final String strYears, final String strYtdSales) { private String joinYtdSales(final String strYears, final String strYtdSales) {
if (StringUtils.isNotBlank(strYears) && if (StringUtils.isNotBlank(strYears) &&
StringUtils.isNotBlank(strYtdSales)) { StringUtils.isNotBlank(strYtdSales)) {
final String[] years = strYears.split(SPLITTER); val years = strYears.split(SPLITTER);
final String[] sales = strYtdSales.split(SPLITTER); val sales = strYtdSales.split(SPLITTER);
final List<String> ytdSales = new ArrayList<>(years.length); val ytdSales = new ArrayList<>(years.length);
int i = 0; int i = 0;
for (final String year : years) { for (val year : years) {
ytdSales.add(year + ": " + sales[i++]); ytdSales.add(year + ": " + sales[i++]);
} }
return StringUtils.join(ytdSales, "\n"); return StringUtils.join(ytdSales, "\n");
@ -561,4 +550,24 @@ public class CustomerServiceSupport
private String dateFormat(Date date, String pattern) { private String dateFormat(Date date, String pattern) {
return date != null ? DateFormatUtils.format(date, pattern) : ""; return date != null ? DateFormatUtils.format(date, pattern) : "";
} }
/**
* {@inheritDoc}
*/
@Override
public Customer delete(final String id) {
val customer = super.delete(id);
Assert.state(customer != null,
"No customer [" + id + "] found");
customerPermissionMapper.delete(
new Search(CustomerPermission.CUSTOMER_ID, id));
customerIssueMapper.delete(
new Search(CustomerIssue.CUSTOMER_ID, id));
customerYearToDateSaleMapper.delete(
new Search(CustomerYearToDateSale.CUSTOMER_ID, id));
customerApplicationMapper.delete(
new Search(CustomerApplication.CUSTOMER_ID, id));
return customer;
}
} }

28
server/launch.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# get real path of softlink
get_real_path() {
local f="$1"
while [ -h "$f" ]; do
ls=`ls -ld "$f"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
f="$link"
else
f=`dirname "$f"`/"$link"
fi
done
echo "$f"
}
prg_path=$(get_real_path "$0")
echo "Script path [$prg_path]"
# Service Home
pushd $(dirname "$prg_path")
WORK_DIR=$(pwd)
echo "Work dir [$WORK_DIR]"
mvn -T 4C clean -pl crm -am -DskipTests \
spring-boot:run

@ -1 +1 @@
Subproject commit 7a0c14ba3f821049872595609dbf278cf410cbd5 Subproject commit 40acef80b8af560cbf19a0a841748c0d63406dde

View File

@ -10,7 +10,7 @@
<properties> <properties>
<packaging>jar</packaging> <packaging>jar</packaging>
<tigon.webmvc.scrope>provided</tigon.webmvc.scrope> <tigon.webmvc.scope>provided</tigon.webmvc.scope>
</properties> </properties>
<parent> <parent>
@ -36,7 +36,7 @@
<dependency> <dependency>
<groupId>me.chyxion.tigon</groupId> <groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-web</artifactId> <artifactId>tigon-web</artifactId>
<scope>${tigon.webmvc.scrope}</scope> <scope>${tigon.webmvc.scope}</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
@ -67,7 +67,7 @@
</activation> </activation>
<properties> <properties>
<packaging>war</packaging> <packaging>war</packaging>
<tigon.webmvc.scrope>compile</tigon.webmvc.scrope> <tigon.webmvc.scope>compile</tigon.webmvc.scope>
<maven.tomcat.port>8088</maven.tomcat.port> <maven.tomcat.port>8088</maven.tomcat.port>
<log.level>DEBUG</log.level> <log.level>DEBUG</log.level>
<log.dir>${project.basedir}/.logs</log.dir> <log.dir>${project.basedir}/.logs</log.dir>

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
import me.chyxion.tigon.mybatis.UseGeneratedKeys; import me.chyxion.tigon.mybatis.UseGeneratedKeys;
/** /**
@ -15,17 +16,11 @@ import me.chyxion.tigon.mybatis.UseGeneratedKeys;
@Getter @Getter
@Setter @Setter
@UseGeneratedKeys @UseGeneratedKeys
@FieldNameConstants(prefix = "")
@Table("crm_auth_failed_log") @Table("crm_auth_failed_log")
public class AuthFailedLog extends M3<String, Long> { public class AuthFailedLog extends M3<String, Long> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String LOGIN_ID = "login_id";
public static final String PASSWORD = "password";
public static final String IP = "ip";
public static final String USER_AGENT = "user_agent";
public static final String EXT = "ext";
// Properties // Properties
private String loginId; private String loginId;
private String password; private String password;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
import me.chyxion.tigon.mybatis.UseGeneratedKeys; import me.chyxion.tigon.mybatis.UseGeneratedKeys;
/** /**
@ -16,19 +17,13 @@ import me.chyxion.tigon.mybatis.UseGeneratedKeys;
@Setter @Setter
@UseGeneratedKeys @UseGeneratedKeys
@Table("crm_auth_log") @Table("crm_auth_log")
@FieldNameConstants(prefix = "")
public class AuthLog extends M3<String, Long> { public class AuthLog extends M3<String, Long> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String USER_ID = "user_id";
public static final String USER_AGENT = "user_agent";
public static final String IP = "ip";
public static final String EXT = "ext";
// Properties // Properties
private String userId; private String userId;
private String userAgent; private String userAgent;
private String ip; private String ip;
private String ext; private String ext;
} }

View File

@ -2,6 +2,8 @@ package com.pudonghot.ambition.crm.model;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.FieldNameConstants;
import java.util.Date; import java.util.Date;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
@ -16,22 +18,10 @@ import me.chyxion.tigon.mybatis.Transient;
@Getter @Getter
@Setter @Setter
@Table("crm_customer") @Table("crm_customer")
@FieldNameConstants(prefix = "")
public class Customer extends M3<String, String> { public class Customer extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String SALESPERSON = "salesperson";
public static final String DATE_ADDED = "date_added";
public static final String NAME = "name";
public static final String COUNTRY_CODE = "country_code";
public static final String STATE = "state";
public static final String CITY = "city";
public static final String MS = "ms";
public static final String REGION = "region";
public static final String STATUS = "status";
public static final String SUM_YTD_SALES = "sum_ytd_sales";
public static final String COUNT_YTD_SALES = "count_ytd_sales";
// Properties // Properties
private String salesperson; private String salesperson;
private Date dateAdded; private Date dateAdded;

View File

@ -2,8 +2,9 @@ package com.pudonghot.ambition.crm.model;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.mybatis.Table;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
/** /**
* @version 0.0.1 * @version 0.0.1
@ -13,14 +14,11 @@ import me.chyxion.tigon.model.M3;
*/ */
@Getter @Getter
@Setter @Setter
@FieldNameConstants(prefix = "")
@Table("crm_customer_application") @Table("crm_customer_application")
public class CustomerApplication extends M3<String, String> { public class CustomerApplication extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String CUSTOMER_ID = "customer_id";
public static final String APPLICATION_ID = "application_id";
// Properties // Properties
private String customerId; private String customerId;
private String applicationId; private String applicationId;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
/** /**
* @version 0.0.1 * @version 0.0.1
@ -13,15 +14,11 @@ import me.chyxion.tigon.mybatis.Table;
*/ */
@Getter @Getter
@Setter @Setter
@FieldNameConstants(prefix = "")
@Table("crm_customer_issue") @Table("crm_customer_issue")
public class CustomerIssue extends M3<String, String> { public class CustomerIssue extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String CUSTOMER_ID = "customer_id";
public static final String ISSUE = "issue";
public static final String ARTIFICIAL = "artificial";
// Properties // Properties
private String customerId; private String customerId;
private String issue; private String issue;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
/** /**
* @version 0.0.1 * @version 0.0.1
@ -13,15 +14,11 @@ import me.chyxion.tigon.mybatis.Table;
*/ */
@Getter @Getter
@Setter @Setter
@FieldNameConstants(prefix = "")
@Table("crm_customer_permission") @Table("crm_customer_permission")
public class CustomerPermission extends M3<String, String> { public class CustomerPermission extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String USER_ACCOUNT = "user_account";
public static final String CUSTOMER_ID = "customer_id";
public static final String TYPE = "type";
public enum Type { public enum Type {
SYSTEM, SYSTEM,
APPLICATION APPLICATION

View File

@ -5,6 +5,7 @@ import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import me.chyxion.tigon.mybatis.NotUpdate; import me.chyxion.tigon.mybatis.NotUpdate;
import lombok.experimental.FieldNameConstants;
import me.chyxion.tigon.mybatis.NotUpdateWhenNull; import me.chyxion.tigon.mybatis.NotUpdateWhenNull;
/** /**
@ -15,6 +16,7 @@ import me.chyxion.tigon.mybatis.NotUpdateWhenNull;
*/ */
@Getter @Getter
@Setter @Setter
@FieldNameConstants(prefix = "")
@Table("crm_customer_property") @Table("crm_customer_property")
public class CustomerProperty extends M3<String, String> { public class CustomerProperty extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -24,8 +26,7 @@ public class CustomerProperty extends M3<String, String> {
*/ */
// public static final String TYPE_STATUS = "STATUS"; // public static final String TYPE_STATUS = "STATUS";
public enum Type { public enum Type {
STATUS, STATUS
// APPLICATION,
} }
// system status // system status
@ -38,11 +39,6 @@ public class CustomerProperty extends M3<String, String> {
public static final String STATUS_NA_ID = "STATUS_NA"; public static final String STATUS_NA_ID = "STATUS_NA";
public static final String STATUS_NA_NAME = "NA"; public static final String STATUS_NA_NAME = "NA";
// Column Names
public static final String TYPE = "type";
public static final String NAME = "name";
public static final String SORT = "sort";
// Properties // Properties
@NotUpdate @NotUpdate
private Type type; private Type type;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
/** /**
* @version 0.0.1 * @version 0.0.1
@ -13,15 +14,11 @@ import me.chyxion.tigon.mybatis.Table;
*/ */
@Getter @Getter
@Setter @Setter
@FieldNameConstants(prefix = "")
@Table("crm_customer_year_to_date_sale") @Table("crm_customer_year_to_date_sale")
public class CustomerYearToDateSale extends M3<String, String> { public class CustomerYearToDateSale extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String CUSTOMER_ID = "customer_id";
public static final String YEAR = "year";
public static final String YTD_SALE = "ytd_sale";
// Properties // Properties
private String customerId; private String customerId;
private String year; private String year;

View File

@ -5,6 +5,7 @@ import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import me.chyxion.tigon.mybatis.Transient; import me.chyxion.tigon.mybatis.Transient;
import lombok.experimental.FieldNameConstants;
/** /**
* @version 0.0.1 * @version 0.0.1
@ -16,17 +17,10 @@ import me.chyxion.tigon.mybatis.Transient;
@Getter @Getter
@Setter @Setter
@Table("crm_file_info") @Table("crm_file_info")
@FieldNameConstants(prefix = "")
public class FileInfo extends M3<String, String> { public class FileInfo extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String NAME = "name";
public static final String FILE_PATH = "file_path";
public static final String FORMAT = "format";
public static final String DOWNLOAD_NAME = "download_name";
public static final String CONTENT_LENGTH = "content_length";
public static final String CONTENT_TYPE = "content_type";
// Properties // Properties
private String name; private String name;
private String filePath; private String filePath;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import lombok.experimental.FieldNameConstants;
/** /**
* @version 0.0.1 * @version 0.0.1
@ -14,14 +15,10 @@ import me.chyxion.tigon.mybatis.Table;
@Getter @Getter
@Setter @Setter
@Table("crm_home_page") @Table("crm_home_page")
@FieldNameConstants(prefix = "")
public class HomePage extends M3<String, String> { public class HomePage extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String NAME = "name";
public static final String CONTENT = "content";
public static final String APPLYING = "applying";
// Properties // Properties
private String name; private String name;
private String content; private String content;

View File

@ -6,6 +6,7 @@ import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import me.chyxion.tigon.mybatis.NotUpdate; import me.chyxion.tigon.mybatis.NotUpdate;
import me.chyxion.tigon.mybatis.Transient; import me.chyxion.tigon.mybatis.Transient;
import lombok.experimental.FieldNameConstants;
/** /**
* @author Shaun Chyxion <br> * @author Shaun Chyxion <br>
@ -15,6 +16,7 @@ import me.chyxion.tigon.mybatis.Transient;
@Getter @Getter
@Setter @Setter
@Table("crm_import_record") @Table("crm_import_record")
@FieldNameConstants(prefix = "")
public class ImportRecord extends M3<String, String> { public class ImportRecord extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -22,11 +24,6 @@ public class ImportRecord extends M3<String, String> {
public static final String TYPE_CUSTOMER = "CUSTOMER"; public static final String TYPE_CUSTOMER = "CUSTOMER";
public static final String TYPE_YTD_SALES = "YTD_SALES"; public static final String TYPE_YTD_SALES = "YTD_SALES";
// Column Names
public static final String TYPE = "type";
public static final String COMPLETED = "completed";
public static final String SUCCESS = "success";
// Properties // Properties
@NotUpdate @NotUpdate
private String type; private String type;

View File

@ -5,6 +5,7 @@ import lombok.Setter;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
import me.chyxion.tigon.mybatis.NotUpdate; import me.chyxion.tigon.mybatis.NotUpdate;
import lombok.experimental.FieldNameConstants;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import me.chyxion.tigon.mybatis.NotUpdateWhenNull; import me.chyxion.tigon.mybatis.NotUpdateWhenNull;
@ -17,6 +18,7 @@ import me.chyxion.tigon.mybatis.NotUpdateWhenNull;
@Getter @Getter
@Setter @Setter
@Table("crm_user") @Table("crm_user")
@FieldNameConstants(prefix = "")
public class User extends M3<String, String> { public class User extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -25,17 +27,6 @@ public class User extends M3<String, String> {
public static final String ROLE_LELI = "leli"; public static final String ROLE_LELI = "leli";
public static final String ROLE_CHYXION = "chyxion"; public static final String ROLE_CHYXION = "chyxion";
// Column Names
public static final String ACCOUNT = "account";
public static final String EMPLOYEE_ID = "employee_id";
public static final String PASSWORD = "password";
public static final String MOBILE = "mobile";
public static final String EMAIL = "email";
public static final String NAME = "name";
public static final String EN_NAME = "en_name";
public static final String GENDER = "gender";
public static final String ADMIN = "admin";
// Properties // Properties
private String account; private String account;
@NotUpdate @NotUpdate

View File

@ -2,6 +2,8 @@ package com.pudonghot.ambition.crm.model;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.FieldNameConstants;
import java.util.Date; import java.util.Date;
import me.chyxion.tigon.model.M3; import me.chyxion.tigon.model.M3;
import me.chyxion.tigon.mybatis.Table; import me.chyxion.tigon.mybatis.Table;
@ -16,20 +18,10 @@ import me.chyxion.tigon.mybatis.Transient;
@Getter @Getter
@Setter @Setter
@Table("crm_week_goal") @Table("crm_week_goal")
@FieldNameConstants(prefix = "")
public class WeekGoal extends M3<String, String> { public class WeekGoal extends M3<String, String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Column Names
public static final String USER_ID = "user_id";
public static final String YEAR = "year";
public static final String QUARTER = "quarter";
public static final String DATE_START = "date_start";
public static final String DATE_END = "date_end";
public static final String MONTH_START = "month_start";
public static final String MONTH_END = "month_end";
public static final String GOAL = "goal";
public static final String DONE = "done";
// Properties // Properties
@NotUpdate @NotUpdate
private String userId; private String userId;

View File

@ -16,8 +16,10 @@
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding> <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
<start-class></start-class>
<tigon.version>0.0.1-SNAPSHOT</tigon.version> <tigon.version>0.0.1-SNAPSHOT</tigon.version>
<!--<jackson.version>2.9.9.20190807</jackson.version>-->
<!--<spring.version>5.2.5.RELEASE</spring.version>-->
<!--<spring-boot.version>2.2.6.RELEASE</spring-boot.version>-->
<spring-boot.version>2.0.3.RELEASE</spring-boot.version> <spring-boot.version>2.0.3.RELEASE</spring-boot.version>
<aspectj.version>1.8.10</aspectj.version> <aspectj.version>1.8.10</aspectj.version>
</properties> </properties>
@ -54,6 +56,11 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.pudonghot.ambition</groupId> <groupId>com.pudonghot.ambition</groupId>
<artifactId>crm-model</artifactId> <artifactId>crm-model</artifactId>
@ -170,6 +177,13 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins> </plugins>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
@ -179,8 +193,14 @@
<version>${spring-boot.version}</version> <version>${spring-boot.version}</version>
<configuration> <configuration>
<addResources>true</addResources> <addResources>true</addResources>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout> <layout>ZIP</layout>
<includeSystemScope>true</includeSystemScope>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>

View File

@ -1 +1 @@
<i class="{{get this 'icon-size-class'}} ace-icon fa fa-trash-o"></i> <i class="{{get this 'icon-size-class'}} ace-icon fa fa-trash-o red"></i>

View File

@ -1,7 +1,7 @@
<label class="{{get this 'label-class'}} control-label no-padding-right">{{label}}</label> <label class="{{get this 'label-class'}} control-label no-padding-right">{{label}}</label>
<div class="{{get this 'input-class'}} no-padding-right"> <div class="{{get this 'input-class'}} no-padding-right">
<div class="row col-xs-12 no-padding"> <div class="row col-xs-12 no-padding">
<div class="col-xs-{{get this 'col-width'}} no-padding-right"> <div class="col-xs-{{col-width}} no-padding-right">
<select multiple={{multiple}} <select multiple={{multiple}}
data-placeholder={{if placeholder placeholder label}} data-placeholder={{if placeholder placeholder label}}
class="select2" class="select2"

View File

@ -16,6 +16,7 @@
options=model.applicationList options=model.applicationList
value-field='id' value-field='id'
text-field='name' text-field='name'
col-width=12
}} }}
{{form-input-select2 {{form-input-select2

View File

@ -141,7 +141,7 @@
{{th-filter name='salesperson' text='Slspsn' label='Salesperson Filter' options=model.salespersonList}} {{th-filter name='salesperson' text='Slspsn' label='Salesperson Filter' options=model.salespersonList}}
{{/sortable-th}} {{/sortable-th}}
{{/if}} {{/if}}
<th> <th style="min-width: 106px;">
<i class="ace-icon fa fa-cogs bigger-110 hidden-480"></i> <i class="ace-icon fa fa-cogs bigger-110 hidden-480"></i>
Settings Settings
</th> </th>
@ -299,6 +299,10 @@
{{#link-to 'customer.edit' it.id class='btn btn-xs btn-info' data-rel='tooltip' title='Edit Customer'}} {{#link-to 'customer.edit' it.id class='btn btn-xs btn-info' data-rel='tooltip' title='Edit Customer'}}
<i class="ace-icon fa fa-pencil bigger-120"></i> <i class="ace-icon fa fa-pencil bigger-120"></i>
{{/link-to}} {{/link-to}}
{{#if ajax.user.admin}}
{{delete-btn model=it}}
{{/if}}
</div> </div>
<div class="hidden-md hidden-lg"> <div class="hidden-md hidden-lg">
<div class="inline pos-rel"> <div class="inline pos-rel">
@ -322,6 +326,11 @@
</span> </span>
{{/link-to}} {{/link-to}}
</li> </li>
{{#if ajax.user.admin}}
<li>
{{delete-btn model=it icon-only=true}}
</li>
{{/if}}
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -32,7 +32,7 @@
<i class="ace-icon fa fa-exchange bigger-110"></i> <i class="ace-icon fa fa-exchange bigger-110"></i>
Status Status
</th> </th>
<th> <th style="min-width: 106px;">
<i class="ace-icon fa fa-cogs bigger-110"></i> <i class="ace-icon fa fa-cogs bigger-110"></i>
Settings Settings
</th> </th>

View File

@ -8,7 +8,7 @@
"license": "MIT", "license": "MIT",
"homepage": "", "homepage": "",
"dependencies": { "dependencies": {
"bootstrap": "~3.3.5", "bootstrap": "3.4.1",
"bootbox": "~4.4.0", "bootbox": "~4.4.0",
"moment": ">= 2.8.0", "moment": ">= 2.8.0",
"moment-timezone": ">= 0.1.0", "moment-timezone": ">= 0.1.0",