Commit 0de53321ae8cc5c0d05a513ddb8945efedb56a94
1 parent
c5984e0d
merchant测试
Showing
16 changed files
with
241 additions
and
140 deletions
pom.xml
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | </properties> | 26 | </properties> |
27 | 27 | ||
28 | <dependencies> | 28 | <dependencies> |
29 | - | 29 | + |
30 | <dependency> | 30 | <dependency> |
31 | <groupId>com.diligrp</groupId> | 31 | <groupId>com.diligrp</groupId> |
32 | <artifactId>xtrade-shared-spring-boot-starter</artifactId> | 32 | <artifactId>xtrade-shared-spring-boot-starter</artifactId> |
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | <artifactId>xxl-job-core</artifactId> | 38 | <artifactId>xxl-job-core</artifactId> |
39 | <version>${xxl-job.version}</version> | 39 | <version>${xxl-job.version}</version> |
40 | </dependency> --> | 40 | </dependency> --> |
41 | - | 41 | + |
42 | <dependency> | 42 | <dependency> |
43 | <groupId>com.alibaba.cloud</groupId> | 43 | <groupId>com.alibaba.cloud</groupId> |
44 | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> | 44 | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
@@ -54,13 +54,13 @@ | @@ -54,13 +54,13 @@ | ||
54 | <artifactId>nacos-client</artifactId> | 54 | <artifactId>nacos-client</artifactId> |
55 | <version>${nacos-client.version}</version> | 55 | <version>${nacos-client.version}</version> |
56 | </dependency> | 56 | </dependency> |
57 | - | 57 | + |
58 | <dependency> | 58 | <dependency> |
59 | <groupId>com.alibaba.nacos</groupId> | 59 | <groupId>com.alibaba.nacos</groupId> |
60 | <artifactId>nacos-api</artifactId> | 60 | <artifactId>nacos-api</artifactId> |
61 | <version>${nacos-client.version}</version> | 61 | <version>${nacos-client.version}</version> |
62 | </dependency> | 62 | </dependency> |
63 | - | 63 | + |
64 | <dependency> | 64 | <dependency> |
65 | <groupId>org.springframework.boot</groupId> | 65 | <groupId>org.springframework.boot</groupId> |
66 | <artifactId>spring-boot-configuration-processor</artifactId> | 66 | <artifactId>spring-boot-configuration-processor</artifactId> |
@@ -118,12 +118,6 @@ | @@ -118,12 +118,6 @@ | ||
118 | <groupId>org.springframework.boot</groupId> | 118 | <groupId>org.springframework.boot</groupId> |
119 | <artifactId>spring-boot-starter-test</artifactId> | 119 | <artifactId>spring-boot-starter-test</artifactId> |
120 | <scope>test</scope> | 120 | <scope>test</scope> |
121 | - <exclusions> | ||
122 | - <exclusion> | ||
123 | - <groupId>org.junit.vintage</groupId> | ||
124 | - <artifactId>junit-vintage-engine</artifactId> | ||
125 | - </exclusion> | ||
126 | - </exclusions> | ||
127 | </dependency> | 121 | </dependency> |
128 | </dependencies> | 122 | </dependencies> |
129 | 123 |
src/main/java/com/diligrp/xtrade/product/domain/converter/MerchantConverter.java renamed to src/main/java/com/diligrp/xtrade/product/domain/builder/MerchantBuilder.java
1 | -package com.diligrp.xtrade.product.domain.converter; | 1 | +package com.diligrp.xtrade.product.domain.builder; |
2 | 2 | ||
3 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | 3 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; |
4 | import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; | 4 | import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; |
@@ -15,23 +15,23 @@ import java.util.Optional; | @@ -15,23 +15,23 @@ import java.util.Optional; | ||
15 | * @Date: 2020/4/22 09:10 | 15 | * @Date: 2020/4/22 09:10 |
16 | * @Description: 用于merchant的实体转换 | 16 | * @Description: 用于merchant的实体转换 |
17 | */ | 17 | */ |
18 | -@Component | ||
19 | -public class MerchantConverter { | 18 | +public class MerchantBuilder { |
20 | 19 | ||
21 | - public Merchant request2Entity(MerchantRequestDto requestDto) { | 20 | + public static Merchant request2Entity(MerchantRequestDto requestDto) { |
22 | Integer type = Optional.ofNullable(requestDto.getAccountType()) | 21 | Integer type = Optional.ofNullable(requestDto.getAccountType()) |
23 | .map(AccountType::getCode) | 22 | .map(AccountType::getCode) |
24 | .orElse(0); | 23 | .orElse(0); |
25 | Merchant merchant = new Merchant(); | 24 | Merchant merchant = new Merchant(); |
26 | merchant.setMerName(requestDto.getMerchantName()); | 25 | merchant.setMerName(requestDto.getMerchantName()); |
27 | merchant.setAccountId(requestDto.getAccountId()); | 26 | merchant.setAccountId(requestDto.getAccountId()); |
27 | + merchant.setAccountName(requestDto.getAccountName()); | ||
28 | merchant.setType(type); | 28 | merchant.setType(type); |
29 | merchant.setDescription(requestDto.getAddress()); | 29 | merchant.setDescription(requestDto.getAddress()); |
30 | merchant.setStatus(MerchantStatus.NORMAL.getType()); | 30 | merchant.setStatus(MerchantStatus.NORMAL.getType()); |
31 | return merchant; | 31 | return merchant; |
32 | } | 32 | } |
33 | 33 | ||
34 | - public MerchantResponseDto entity2Response(Merchant merchant){ | 34 | + public static MerchantResponseDto entity2Response(Merchant merchant){ |
35 | MerchantResponseDto responseDto = new MerchantResponseDto(); | 35 | MerchantResponseDto responseDto = new MerchantResponseDto(); |
36 | BeanUtils.copyProperties(merchant,responseDto); | 36 | BeanUtils.copyProperties(merchant,responseDto); |
37 | responseDto.setType(AccountType.getAccountType(merchant.getType())); | 37 | responseDto.setType(AccountType.getAccountType(merchant.getType())); |
src/main/java/com/diligrp/xtrade/product/domain/dto/MerchantRequestDto.java
@@ -18,12 +18,15 @@ public class MerchantRequestDto implements Serializable { | @@ -18,12 +18,15 @@ public class MerchantRequestDto implements Serializable { | ||
18 | /**真实名字*/ | 18 | /**真实名字*/ |
19 | private transient String realName; | 19 | private transient String realName; |
20 | /**用户名字*/ | 20 | /**用户名字*/ |
21 | - @NotBlank(message = "{merchant.user_name.not.blank}", groups = Constant.InsertGroup.class) | 21 | + @NotBlank(message = "{account_name.not.blank}", groups = Constant.InsertGroup.class) |
22 | @Pattern(regexp = "^[a-zA-Z0-9\u4E00-\u9FA5._,:-]*$",message = "{illegal.pattern}",groups = Constant.InsertGroup.class) | 22 | @Pattern(regexp = "^[a-zA-Z0-9\u4E00-\u9FA5._,:-]*$",message = "{illegal.pattern}",groups = Constant.InsertGroup.class) |
23 | - private String userName; | 23 | + private String accountName; |
24 | /**密码*/ | 24 | /**密码*/ |
25 | + @NotBlank(message = "{account_password.not.blank}", groups = Constant.InsertGroup.class) | ||
26 | + @Pattern(regexp = "^[a-zA-Z0-9\u4E00-\u9FA5._,:-]*$",message = "{illegal.pattern}",groups = Constant.InsertGroup.class) | ||
25 | private String password; | 27 | private String password; |
26 | /**电话*/ | 28 | /**电话*/ |
29 | + @Pattern(regexp = "^[1][3,4,5,8][0-9]{9}$",message = "{phone.pattern}",groups = Constant.InsertGroup.class) | ||
27 | private String mobile; | 30 | private String mobile; |
28 | /**账户类型*/ | 31 | /**账户类型*/ |
29 | @NotNull(message = "{account_type.not.null}", groups = Constant.InsertGroup.class) | 32 | @NotNull(message = "{account_type.not.null}", groups = Constant.InsertGroup.class) |
@@ -51,12 +54,12 @@ public class MerchantRequestDto implements Serializable { | @@ -51,12 +54,12 @@ public class MerchantRequestDto implements Serializable { | ||
51 | this.accountId = accountId; | 54 | this.accountId = accountId; |
52 | } | 55 | } |
53 | 56 | ||
54 | - public String getUserName() { | ||
55 | - return userName; | 57 | + public String getAccountName() { |
58 | + return accountName; | ||
56 | } | 59 | } |
57 | 60 | ||
58 | - public void setUserName(String userName) { | ||
59 | - this.userName = userName; | 61 | + public void setAccountName(String accountName) { |
62 | + this.accountName = accountName; | ||
60 | } | 63 | } |
61 | 64 | ||
62 | public String getPassword() { | 65 | public String getPassword() { |
src/main/java/com/diligrp/xtrade/product/domain/emuns/AccountType.java
@@ -16,7 +16,7 @@ public enum AccountType implements IEnumType { | @@ -16,7 +16,7 @@ public enum AccountType implements IEnumType { | ||
16 | PUBLIC(20, "对公账户"), | 16 | PUBLIC(20, "对公账户"), |
17 | 17 | ||
18 | /**临时卡用*/ | 18 | /**临时卡用*/ |
19 | - Anonymous(30, "不记名"); | 19 | + ANONYMOUS(30, "不记名"); |
20 | 20 | ||
21 | private int code; | 21 | private int code; |
22 | private String name; | 22 | private String name; |
src/main/java/com/diligrp/xtrade/product/domain/emuns/IKeyGeneratorKeys.java
@@ -8,6 +8,7 @@ package com.diligrp.xtrade.product.domain.emuns; | @@ -8,6 +8,7 @@ package com.diligrp.xtrade.product.domain.emuns; | ||
8 | * @date 2020年4月21日 | 8 | * @date 2020年4月21日 |
9 | */ | 9 | */ |
10 | public enum IKeyGeneratorKeys { | 10 | public enum IKeyGeneratorKeys { |
11 | + CATEGORY_SEQUENCE("category_sequence","品类id"), | ||
11 | SHOP_SEQUENCE("SHOP_SEQUENCE","店铺id"), | 12 | SHOP_SEQUENCE("SHOP_SEQUENCE","店铺id"), |
12 | MERCHANT_SEQUENCE("MERCHANT_SEQUENCE","市场id"), | 13 | MERCHANT_SEQUENCE("MERCHANT_SEQUENCE","市场id"), |
13 | ACCOUNT_SEQUENCE("ACCOUNT_SEQUENCE","账号id") | 14 | ACCOUNT_SEQUENCE("ACCOUNT_SEQUENCE","账号id") |
src/main/java/com/diligrp/xtrade/product/repository/AccountRepository.java
@@ -17,7 +17,13 @@ public class AccountRepository implements IAccountRepository { | @@ -17,7 +17,13 @@ public class AccountRepository implements IAccountRepository { | ||
17 | private final static List<Account> ACCOUNTS = new ArrayList<>(); | 17 | private final static List<Account> ACCOUNTS = new ArrayList<>(); |
18 | @Override | 18 | @Override |
19 | public Operator getOperator() { | 19 | public Operator getOperator() { |
20 | - return new Operator(); | 20 | + Operator operator = new Operator(); |
21 | + operator.setAccount("miao"); | ||
22 | + operator.setName("缪"); | ||
23 | + operator.setAccountId(1L); | ||
24 | + operator.setMerAccountId(10000L); | ||
25 | + operator.setAdmin(true); | ||
26 | + return operator; | ||
21 | } | 27 | } |
22 | 28 | ||
23 | @Override | 29 | @Override |
src/main/java/com/diligrp/xtrade/product/service/impl/AccountServiceImpl.java
1 | package com.diligrp.xtrade.product.service.impl; | 1 | package com.diligrp.xtrade.product.service.impl; |
2 | 2 | ||
3 | +import com.alibaba.nacos.common.utils.Md5Utils; | ||
3 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | 4 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; |
4 | import com.diligrp.xtrade.product.domain.emuns.AccountStatus; | 5 | import com.diligrp.xtrade.product.domain.emuns.AccountStatus; |
5 | import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | 6 | import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; |
@@ -28,11 +29,12 @@ public class AccountServiceImpl implements AccountService { | @@ -28,11 +29,12 @@ public class AccountServiceImpl implements AccountService { | ||
28 | 29 | ||
29 | @Override | 30 | @Override |
30 | public Account build(MerchantRequestDto requestDto, Merchant merchant) throws Exception { | 31 | public Account build(MerchantRequestDto requestDto, Merchant merchant) throws Exception { |
32 | + String password = String.format("%s_%s", | ||
33 | + requestDto.getAccountName(), requestDto.getPassword()); | ||
31 | Account newAccount = new Account(); | 34 | Account newAccount = new Account(); |
32 | - newAccount.setName(requestDto.getUserName()); | 35 | + newAccount.setName(requestDto.getAccountName()); |
33 | newAccount.setRealName(requestDto.getRealName()); | 36 | newAccount.setRealName(requestDto.getRealName()); |
34 | - newAccount.setPassword(PasswordUtils.encrypt(requestDto.getPassword(), | ||
35 | - requestDto.getUserName())); | 37 | + newAccount.setPassword(Md5Utils.getMD5(password, "UTF-8")); |
36 | newAccount.setMobile(requestDto.getMobile()); | 38 | newAccount.setMobile(requestDto.getMobile()); |
37 | newAccount.setStatus(AccountStatus.NORMAL.getCode()); | 39 | newAccount.setStatus(AccountStatus.NORMAL.getCode()); |
38 | newAccount.setIsAdmin(1); | 40 | newAccount.setIsAdmin(1); |
@@ -48,4 +50,5 @@ public class AccountServiceImpl implements AccountService { | @@ -48,4 +50,5 @@ public class AccountServiceImpl implements AccountService { | ||
48 | Account newAccount = this.build(requestDto, merchant); | 50 | Account newAccount = this.build(requestDto, merchant); |
49 | accountRepository.add(newAccount); | 51 | accountRepository.add(newAccount); |
50 | } | 52 | } |
53 | + | ||
51 | } | 54 | } |
src/main/java/com/diligrp/xtrade/product/service/impl/CategoryServiceImpl.java
1 | -package com.diligrp.xtrade.product.service.impl; | ||
2 | - | ||
3 | -import java.util.List; | ||
4 | - | ||
5 | -import org.apache.commons.lang3.StringUtils; | ||
6 | -import org.springframework.beans.BeanUtils; | ||
7 | -import org.springframework.beans.factory.annotation.Autowired; | ||
8 | -import org.springframework.stereotype.Service; | ||
9 | - | ||
10 | -import com.diligrp.xtrade.product.dao.CategoryDao; | ||
11 | -import com.diligrp.xtrade.product.domain.dto.CategoryDto; | ||
12 | -import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | ||
13 | -import com.diligrp.xtrade.product.domain.entity.CategoryDo; | ||
14 | -import com.diligrp.xtrade.product.service.CategoryService; | ||
15 | -import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager; | ||
16 | - | ||
17 | -/** | ||
18 | - * @ClassName: CategoryServiceImpl | ||
19 | - * @Description TODO(用一句话描述该文件做什么) | ||
20 | - * @author yangfan | ||
21 | - * @date 2020年4月20日 | ||
22 | - */ | ||
23 | -@Service("categoryService") | ||
24 | -public class CategoryServiceImpl implements CategoryService { | ||
25 | - | ||
26 | - @Autowired | ||
27 | - private KeyGeneratorManager keyGeneratorManager; | ||
28 | - @Autowired | ||
29 | - private CategoryDao categoryDao; | ||
30 | - | ||
31 | - @Override | ||
32 | - public void insert(CategoryDto category) { | ||
33 | - CategoryDo categoryDo = new CategoryDo(); | ||
34 | - BeanUtils.copyProperties(category, categoryDo); | ||
35 | - long id = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.CATEGORY_SEQUENCE).nextId(); | ||
36 | - String cateCode = ""+id; | ||
37 | - if (StringUtils.isNotBlank(category.getParentId())) { | ||
38 | - CategoryDo pCategoryDo = selectEntityById(Long.valueOf(category.getParentId())); | ||
39 | - cateCode = String.format("%s_%d", pCategoryDo.getCateCode(),id); | ||
40 | - } | ||
41 | - categoryDo.setCateCode(cateCode); | ||
42 | - categoryDao.insert(categoryDo); | ||
43 | - } | ||
44 | - | ||
45 | - @Override | ||
46 | - public void update(CategoryDto category) { | ||
47 | - CategoryDo categoryDo = new CategoryDo(); | ||
48 | - BeanUtils.copyProperties(category, categoryDo); | ||
49 | - categoryDao.update(categoryDo); | ||
50 | - } | ||
51 | - | ||
52 | - @Override | ||
53 | - public void delectById(Long id) { | ||
54 | - // TODO Auto-generated method stub | ||
55 | - | ||
56 | - } | ||
57 | - | ||
58 | - @Override | ||
59 | - public CategoryDo selectEntityById(Long id) { | ||
60 | - // TODO Auto-generated method stub | ||
61 | - return null; | ||
62 | - } | ||
63 | - | ||
64 | - @Override | ||
65 | - public List<CategoryDo> selectList(CategoryDto category) { | ||
66 | - // TODO Auto-generated method stub | ||
67 | - return null; | ||
68 | - } | ||
69 | - | ||
70 | -} | 1 | +package com.diligrp.xtrade.product.service.impl; |
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import org.apache.commons.lang3.StringUtils; | ||
6 | +import org.springframework.beans.BeanUtils; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Service; | ||
9 | + | ||
10 | +import com.diligrp.xtrade.product.dao.CategoryDao; | ||
11 | +import com.diligrp.xtrade.product.domain.dto.CategoryDto; | ||
12 | +import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | ||
13 | +import com.diligrp.xtrade.product.domain.entity.CategoryDo; | ||
14 | +import com.diligrp.xtrade.product.service.CategoryService; | ||
15 | +import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager; | ||
16 | + | ||
17 | +/** | ||
18 | + * @ClassName: CategoryServiceImpl | ||
19 | + * @Description TODO(用一句话描述该文件做什么) | ||
20 | + * @author yangfan | ||
21 | + * @date 2020年4月20日 | ||
22 | + */ | ||
23 | +@Service("categoryService") | ||
24 | +public class CategoryServiceImpl implements CategoryService { | ||
25 | + | ||
26 | + @Autowired | ||
27 | + private KeyGeneratorManager keyGeneratorManager; | ||
28 | + @Autowired | ||
29 | + private CategoryDao categoryDao; | ||
30 | + | ||
31 | + @Override | ||
32 | + public void insert(CategoryDto category) { | ||
33 | + CategoryDo categoryDo = new CategoryDo(); | ||
34 | + BeanUtils.copyProperties(category, categoryDo); | ||
35 | + long id = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.CATEGORY_SEQUENCE).nextId(); | ||
36 | + String cateCode = ""+id; | ||
37 | + if (StringUtils.isNotBlank(category.getParentId())) { | ||
38 | + CategoryDo pCategoryDo = selectEntityById(Long.valueOf(category.getParentId())); | ||
39 | + cateCode = String.format("%s_%d", pCategoryDo.getCateCode(),id); | ||
40 | + } | ||
41 | + categoryDo.setCateCode(cateCode); | ||
42 | + categoryDao.insert(categoryDo); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public void update(CategoryDto category) { | ||
47 | + CategoryDo categoryDo = new CategoryDo(); | ||
48 | + BeanUtils.copyProperties(category, categoryDo); | ||
49 | + categoryDao.update(categoryDo); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public void delectById(Long id) { | ||
54 | + // TODO Auto-generated method stub | ||
55 | + | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public CategoryDo selectEntityById(Long id) { | ||
60 | + // TODO Auto-generated method stub | ||
61 | + return null; | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public List<CategoryDo> selectList(CategoryDto category) { | ||
66 | + // TODO Auto-generated method stub | ||
67 | + return null; | ||
68 | + } | ||
69 | + | ||
70 | +} |
src/main/java/com/diligrp/xtrade/product/service/impl/MerchantServiceImpl.java
1 | package com.diligrp.xtrade.product.service.impl; | 1 | package com.diligrp.xtrade.product.service.impl; |
2 | 2 | ||
3 | -import com.diligrp.xtrade.product.domain.converter.MerchantConverter; | 3 | +import com.diligrp.xtrade.product.domain.builder.MerchantBuilder; |
4 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | 4 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; |
5 | import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; | 5 | import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; |
6 | import com.diligrp.xtrade.product.domain.emuns.AccountType; | 6 | import com.diligrp.xtrade.product.domain.emuns.AccountType; |
@@ -24,8 +24,6 @@ public class MerchantServiceImpl implements MerchantService { | @@ -24,8 +24,6 @@ public class MerchantServiceImpl implements MerchantService { | ||
24 | @Autowired | 24 | @Autowired |
25 | private IMerchantRepository merchantRepository; | 25 | private IMerchantRepository merchantRepository; |
26 | @Autowired | 26 | @Autowired |
27 | - private MerchantConverter merchantConverter; | ||
28 | - @Autowired | ||
29 | private AccountService accountService; | 27 | private AccountService accountService; |
30 | 28 | ||
31 | @Override | 29 | @Override |
@@ -34,13 +32,13 @@ public class MerchantServiceImpl implements MerchantService { | @@ -34,13 +32,13 @@ public class MerchantServiceImpl implements MerchantService { | ||
34 | Operator operator = accountRepository.getOperator(); | 32 | Operator operator = accountRepository.getOperator(); |
35 | requestDto.setAccountId(operator.getAccountId()); | 33 | requestDto.setAccountId(operator.getAccountId()); |
36 | requestDto.setRealName(operator.getName()); | 34 | requestDto.setRealName(operator.getName()); |
37 | - Account account = accountRepository.getAccountByName(requestDto.getUserName()); | 35 | + Account account = accountRepository.getAccountByName(requestDto.getAccountName()); |
38 | if (account != null) { | 36 | if (account != null) { |
39 | throw new ProductException(ResponseCode.ACCOUNT_EXIST); | 37 | throw new ProductException(ResponseCode.ACCOUNT_EXIST); |
40 | } | 38 | } |
41 | Merchant merchant = merchantRepository.getByAccountId(requestDto.getAccountId()); | 39 | Merchant merchant = merchantRepository.getByAccountId(requestDto.getAccountId()); |
42 | if (merchant == null){ | 40 | if (merchant == null){ |
43 | - merchant = merchantConverter.request2Entity(requestDto); | 41 | + merchant = MerchantBuilder.request2Entity(requestDto); |
44 | merchantRepository.add(merchant); | 42 | merchantRepository.add(merchant); |
45 | } else { | 43 | } else { |
46 | if (AccountType.PERSONAL.getCode() != merchant.getType()){ | 44 | if (AccountType.PERSONAL.getCode() != merchant.getType()){ |
@@ -50,7 +48,7 @@ public class MerchantServiceImpl implements MerchantService { | @@ -50,7 +48,7 @@ public class MerchantServiceImpl implements MerchantService { | ||
50 | } | 48 | } |
51 | //创建市场管理员账户 | 49 | //创建市场管理员账户 |
52 | accountService.create(requestDto,merchant); | 50 | accountService.create(requestDto,merchant); |
53 | - return merchantConverter.entity2Response(merchant); | 51 | + return MerchantBuilder.entity2Response(merchant); |
54 | } | 52 | } |
55 | 53 | ||
56 | } | 54 | } |
src/main/java/com/diligrp/xtrade/product/service/impl/ProductServiceImpl.java
@@ -14,7 +14,7 @@ public class ProductServiceImpl implements ProductService { | @@ -14,7 +14,7 @@ public class ProductServiceImpl implements ProductService { | ||
14 | 14 | ||
15 | @Override | 15 | @Override |
16 | public void createProduct(ProductCreateRequestDto productCreateRequestDto) { | 16 | public void createProduct(ProductCreateRequestDto productCreateRequestDto) { |
17 | - | 17 | + |
18 | } | 18 | } |
19 | 19 | ||
20 | @Override | 20 | @Override |
src/main/java/com/diligrp/xtrade/product/service/impl/ShopServiceImpl.java
@@ -20,7 +20,7 @@ public class ShopServiceImpl implements ShopService { | @@ -20,7 +20,7 @@ public class ShopServiceImpl implements ShopService { | ||
20 | private ShopDao shopDao; | 20 | private ShopDao shopDao; |
21 | @Autowired | 21 | @Autowired |
22 | private KeyGeneratorManager KeyGeneratorManager; | 22 | private KeyGeneratorManager KeyGeneratorManager; |
23 | - | 23 | + |
24 | @Override | 24 | @Override |
25 | public void insert(ShopDto shop) { | 25 | public void insert(ShopDto shop) { |
26 | ShopDo shopDo = new ShopDo(); | 26 | ShopDo shopDo = new ShopDo(); |
src/main/resources/ValidationMessages.properties
0 → 100644
1 | +illegal.pattern=\u542B\u6709\u975E\u6CD5\u5B57\u7B26 | ||
2 | +phone.pattern=\u7535\u8BDD\u53F7\u7801\u4E0D\u6B63\u786E | ||
3 | +account_name.not.blank=\u8D26\u6237\u540D\u5B57\u4E0D\u80FD\u4E3A\u7A7A | ||
4 | +account_password.not.blank=\u8D26\u6237\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A | ||
5 | +account_type.not.null=\u8D26\u6237\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A | ||
6 | +merchant_name.not.blank=\u5E02\u573A\u540D\u5B57\u4E0D\u80FD\u4E3A\u7A7A |
src/main/resources/mapping/com/diligrp/xtrade/product/MerchantDao.xml
@@ -28,37 +28,67 @@ | @@ -28,37 +28,67 @@ | ||
28 | created_time, | 28 | created_time, |
29 | modified_time | 29 | modified_time |
30 | </sql> | 30 | </sql> |
31 | - <sql id="Base_Condition_Column"> | ||
32 | - <if test="merId != null"> | 31 | + <sql id="UPDATE_Column"> |
32 | + <set> <if test="merId != null"> | ||
33 | mer_id = #{merId}, | 33 | mer_id = #{merId}, |
34 | </if> | 34 | </if> |
35 | - <if test="merName != null and merName != ''"> | ||
36 | - mer_name = #{merName}, | ||
37 | - </if> | ||
38 | - <if test="marketId != null and marketId != ''"> | ||
39 | - market_id = #{marketId}, | ||
40 | - </if> | ||
41 | - <if test="accountId != null"> | ||
42 | - account_id = #{accountId}, | ||
43 | - </if> | ||
44 | - <if test="accountName != null and accountName != ''"> | ||
45 | - account_name = #{accountName}, | ||
46 | - </if> | ||
47 | - <if test="type != null"> | ||
48 | - type = #{type}, | ||
49 | - </if> | ||
50 | - <if test="status != null"> | ||
51 | - `status` = #{status}, | ||
52 | - </if> | ||
53 | - <if test="description != null and description != ''"> | ||
54 | - `description` = #{description}, | ||
55 | - </if> | ||
56 | - <if test="createdTime != null"> | ||
57 | - created_time = #{createdTime}, | ||
58 | - </if> | ||
59 | - <if test="modifiedTime != null"> | ||
60 | - modified_time = #{modifiedTime}, | ||
61 | - </if> | 35 | + <if test="merName != null and merName != ''"> |
36 | + mer_name = #{merName}, | ||
37 | + </if> | ||
38 | + <if test="marketId != null and marketId != ''"> | ||
39 | + market_id = #{marketId}, | ||
40 | + </if> | ||
41 | + <if test="accountId != null"> | ||
42 | + account_id = #{accountId}, | ||
43 | + </if> | ||
44 | + <if test="accountName != null and accountName != ''"> | ||
45 | + account_name = #{accountName}, | ||
46 | + </if> | ||
47 | + <if test="type != null"> | ||
48 | + type = #{type}, | ||
49 | + </if> | ||
50 | + <if test="status != null"> | ||
51 | + `status` = #{status}, | ||
52 | + </if> | ||
53 | + <if test="description != null and description != ''"> | ||
54 | + `description` = #{description}, | ||
55 | + </if> | ||
56 | + <if test="createdTime != null"> | ||
57 | + created_time = #{createdTime}, | ||
58 | + </if> | ||
59 | + <if test="modifiedTime != null"> | ||
60 | + modified_time = #{modifiedTime}, | ||
61 | + </if> | ||
62 | + </set> | ||
63 | + </sql> | ||
64 | + | ||
65 | + <sql id="WHERE_COLUMN"> | ||
66 | + <where> | ||
67 | + <if test="merId != null"> | ||
68 | + and mer_id = #{merId} | ||
69 | + </if> | ||
70 | + <if test="merName != null and merName != ''"> | ||
71 | + and mer_name = #{merName} | ||
72 | + </if> | ||
73 | + <if test="marketId != null and marketId != ''"> | ||
74 | + and market_id = #{marketId} | ||
75 | + </if> | ||
76 | + <if test="accountId != null"> | ||
77 | + and account_id = #{accountId} | ||
78 | + </if> | ||
79 | + <if test="accountName != null and accountName != ''"> | ||
80 | + and account_name = #{accountName} | ||
81 | + </if> | ||
82 | + <if test="type != null"> | ||
83 | + and type = #{type} | ||
84 | + </if> | ||
85 | + <if test="status != null"> | ||
86 | + and `status` = #{status} | ||
87 | + </if> | ||
88 | + <if test="description != null and description != ''"> | ||
89 | + and `description` = #{description} | ||
90 | + </if> | ||
91 | + </where> | ||
62 | </sql> | 92 | </sql> |
63 | 93 | ||
64 | <!--查询单个--> | 94 | <!--查询单个--> |
@@ -81,15 +111,13 @@ | @@ -81,15 +111,13 @@ | ||
81 | SELECT | 111 | SELECT |
82 | <include refid="Base_Column"/> | 112 | <include refid="Base_Column"/> |
83 | from xt_merchant | 113 | from xt_merchant |
84 | - <where> | ||
85 | - <include refid="Base_Condition_Column"/> | ||
86 | - </where> | 114 | + <include refid="WHERE_COLUMN"/> |
87 | </select> | 115 | </select> |
88 | 116 | ||
89 | <!--新增所有列--> | 117 | <!--新增所有列--> |
90 | <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | 118 | <insert id="insert" keyProperty="id" useGeneratedKeys="true"> |
91 | insert into xt_merchant(mer_id, mer_name, market_id, account_id, account_name, type, status, description, | 119 | insert into xt_merchant(mer_id, mer_name, market_id, account_id, account_name, type, status, description, |
92 | - created_time, modified_time) | 120 | + created_time, modified_time) |
93 | values (#{merId}, #{merName}, #{marketId}, #{accountId}, #{accountName}, #{type}, #{status}, #{description}, | 121 | values (#{merId}, #{merName}, #{marketId}, #{accountId}, #{accountName}, #{type}, #{status}, #{description}, |
94 | #{createdTime}, #{modifiedTime}) | 122 | #{createdTime}, #{modifiedTime}) |
95 | </insert> | 123 | </insert> |
@@ -97,9 +125,7 @@ | @@ -97,9 +125,7 @@ | ||
97 | <!--通过主键修改数据--> | 125 | <!--通过主键修改数据--> |
98 | <update id="update"> | 126 | <update id="update"> |
99 | update xt_merchant | 127 | update xt_merchant |
100 | - <set> | ||
101 | - <include refid="Base_Condition_Column"/> | ||
102 | - </set> | 128 | + <include refid="UPDATE_Column"/> |
103 | where id = #{id} | 129 | where id = #{id} |
104 | </update> | 130 | </update> |
105 | 131 |
src/test/java/com/diligrp/BaseTests.java
0 → 100644
1 | +package com.diligrp; | ||
2 | + | ||
3 | +import org.junit.runner.RunWith; | ||
4 | +import org.springframework.boot.test.context.SpringBootTest; | ||
5 | +import org.springframework.test.context.junit4.SpringRunner; | ||
6 | + | ||
7 | +/** | ||
8 | + * @Auther: miaoguoxin | ||
9 | + * @Date: 2019/7/18 21:42 | ||
10 | + */ | ||
11 | +@RunWith(SpringRunner.class) | ||
12 | +@SpringBootTest | ||
13 | +public class BaseTests { | ||
14 | + | ||
15 | +} |
src/test/java/com/diligrp/xtrade/product/controllor/MerchantControllerTest.java
0 → 100644
1 | +package com.diligrp.xtrade.product.controllor; | ||
2 | + | ||
3 | +import com.diligrp.BaseTests; | ||
4 | +import org.junit.jupiter.api.Test; | ||
5 | + | ||
6 | +/** | ||
7 | + * @Auther: miaoguoxin | ||
8 | + * @Date: 2020/4/22 13:58 | ||
9 | + */ | ||
10 | +class MerchantControllerTest extends BaseTests { | ||
11 | + | ||
12 | + @Test | ||
13 | + void save() { | ||
14 | + | ||
15 | + } | ||
16 | +} |
src/test/java/com/diligrp/xtrade/product/service/MerchantServiceTest.java
0 → 100644
1 | +package com.diligrp.xtrade.product.service; | ||
2 | + | ||
3 | +import com.diligrp.BaseTests; | ||
4 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
5 | +import com.diligrp.xtrade.product.service.MerchantService; | ||
6 | +import com.diligrp.xtrade.shared.util.JsonUtils; | ||
7 | +import org.junit.jupiter.api.Test; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | + | ||
10 | +import static org.junit.jupiter.api.Assertions.*; | ||
11 | + | ||
12 | +/** | ||
13 | + * @Auther: miaoguoxin | ||
14 | + * @Date: 2020/4/22 13:59 | ||
15 | + * @Description: | ||
16 | + */ | ||
17 | +class MerchantServiceTest extends BaseTests { | ||
18 | + @Autowired | ||
19 | + private MerchantService merchantService; | ||
20 | + @Test | ||
21 | + void create() throws Exception { | ||
22 | + String mockJson = "{\n" + | ||
23 | + " \"accountName\": \"test1\",\n" + | ||
24 | + " \"password\": \"123456\",\n" + | ||
25 | + " \"mobile\": \"135446546546\",\n" + | ||
26 | + " \"accountType\": 20,\n" + | ||
27 | + " \"merchantName\": \"测试商户\",\n" + | ||
28 | + " \"address\": \"成都市\"\n" + | ||
29 | + "}"; | ||
30 | + MerchantRequestDto requestDto = JsonUtils.fromJsonString(mockJson, MerchantRequestDto.class); | ||
31 | + merchantService.create(requestDto); | ||
32 | + } | ||
33 | +} |