Commit 0de53321ae8cc5c0d05a513ddb8945efedb56a94
1 parent
c5984e0d
merchant测试
Showing
16 changed files
with
241 additions
and
140 deletions
pom.xml
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | </properties> |
27 | 27 | |
28 | 28 | <dependencies> |
29 | - | |
29 | + | |
30 | 30 | <dependency> |
31 | 31 | <groupId>com.diligrp</groupId> |
32 | 32 | <artifactId>xtrade-shared-spring-boot-starter</artifactId> |
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | <artifactId>xxl-job-core</artifactId> |
39 | 39 | <version>${xxl-job.version}</version> |
40 | 40 | </dependency> --> |
41 | - | |
41 | + | |
42 | 42 | <dependency> |
43 | 43 | <groupId>com.alibaba.cloud</groupId> |
44 | 44 | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
... | ... | @@ -54,13 +54,13 @@ |
54 | 54 | <artifactId>nacos-client</artifactId> |
55 | 55 | <version>${nacos-client.version}</version> |
56 | 56 | </dependency> |
57 | - | |
57 | + | |
58 | 58 | <dependency> |
59 | 59 | <groupId>com.alibaba.nacos</groupId> |
60 | 60 | <artifactId>nacos-api</artifactId> |
61 | 61 | <version>${nacos-client.version}</version> |
62 | 62 | </dependency> |
63 | - | |
63 | + | |
64 | 64 | <dependency> |
65 | 65 | <groupId>org.springframework.boot</groupId> |
66 | 66 | <artifactId>spring-boot-configuration-processor</artifactId> |
... | ... | @@ -118,12 +118,6 @@ |
118 | 118 | <groupId>org.springframework.boot</groupId> |
119 | 119 | <artifactId>spring-boot-starter-test</artifactId> |
120 | 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 | 121 | </dependency> |
128 | 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 | 3 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; |
4 | 4 | import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; |
... | ... | @@ -15,23 +15,23 @@ import java.util.Optional; |
15 | 15 | * @Date: 2020/4/22 09:10 |
16 | 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 | 21 | Integer type = Optional.ofNullable(requestDto.getAccountType()) |
23 | 22 | .map(AccountType::getCode) |
24 | 23 | .orElse(0); |
25 | 24 | Merchant merchant = new Merchant(); |
26 | 25 | merchant.setMerName(requestDto.getMerchantName()); |
27 | 26 | merchant.setAccountId(requestDto.getAccountId()); |
27 | + merchant.setAccountName(requestDto.getAccountName()); | |
28 | 28 | merchant.setType(type); |
29 | 29 | merchant.setDescription(requestDto.getAddress()); |
30 | 30 | merchant.setStatus(MerchantStatus.NORMAL.getType()); |
31 | 31 | return merchant; |
32 | 32 | } |
33 | 33 | |
34 | - public MerchantResponseDto entity2Response(Merchant merchant){ | |
34 | + public static MerchantResponseDto entity2Response(Merchant merchant){ | |
35 | 35 | MerchantResponseDto responseDto = new MerchantResponseDto(); |
36 | 36 | BeanUtils.copyProperties(merchant,responseDto); |
37 | 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 | 18 | /**真实名字*/ |
19 | 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 | 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 | 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 | 30 | private String mobile; |
28 | 31 | /**账户类型*/ |
29 | 32 | @NotNull(message = "{account_type.not.null}", groups = Constant.InsertGroup.class) |
... | ... | @@ -51,12 +54,12 @@ public class MerchantRequestDto implements Serializable { |
51 | 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 | 65 | public String getPassword() { | ... | ... |
src/main/java/com/diligrp/xtrade/product/domain/emuns/AccountType.java
src/main/java/com/diligrp/xtrade/product/domain/emuns/IKeyGeneratorKeys.java
... | ... | @@ -8,6 +8,7 @@ package com.diligrp.xtrade.product.domain.emuns; |
8 | 8 | * @date 2020年4月21日 |
9 | 9 | */ |
10 | 10 | public enum IKeyGeneratorKeys { |
11 | + CATEGORY_SEQUENCE("category_sequence","品类id"), | |
11 | 12 | SHOP_SEQUENCE("SHOP_SEQUENCE","店铺id"), |
12 | 13 | MERCHANT_SEQUENCE("MERCHANT_SEQUENCE","市场id"), |
13 | 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 | 17 | private final static List<Account> ACCOUNTS = new ArrayList<>(); |
18 | 18 | @Override |
19 | 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 | 29 | @Override | ... | ... |
src/main/java/com/diligrp/xtrade/product/service/impl/AccountServiceImpl.java
1 | 1 | package com.diligrp.xtrade.product.service.impl; |
2 | 2 | |
3 | +import com.alibaba.nacos.common.utils.Md5Utils; | |
3 | 4 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; |
4 | 5 | import com.diligrp.xtrade.product.domain.emuns.AccountStatus; |
5 | 6 | import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; |
... | ... | @@ -28,11 +29,12 @@ public class AccountServiceImpl implements AccountService { |
28 | 29 | |
29 | 30 | @Override |
30 | 31 | public Account build(MerchantRequestDto requestDto, Merchant merchant) throws Exception { |
32 | + String password = String.format("%s_%s", | |
33 | + requestDto.getAccountName(), requestDto.getPassword()); | |
31 | 34 | Account newAccount = new Account(); |
32 | - newAccount.setName(requestDto.getUserName()); | |
35 | + newAccount.setName(requestDto.getAccountName()); | |
33 | 36 | newAccount.setRealName(requestDto.getRealName()); |
34 | - newAccount.setPassword(PasswordUtils.encrypt(requestDto.getPassword(), | |
35 | - requestDto.getUserName())); | |
37 | + newAccount.setPassword(Md5Utils.getMD5(password, "UTF-8")); | |
36 | 38 | newAccount.setMobile(requestDto.getMobile()); |
37 | 39 | newAccount.setStatus(AccountStatus.NORMAL.getCode()); |
38 | 40 | newAccount.setIsAdmin(1); |
... | ... | @@ -48,4 +50,5 @@ public class AccountServiceImpl implements AccountService { |
48 | 50 | Account newAccount = this.build(requestDto, merchant); |
49 | 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 | 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 | 4 | import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; |
5 | 5 | import com.diligrp.xtrade.product.domain.dto.MerchantResponseDto; |
6 | 6 | import com.diligrp.xtrade.product.domain.emuns.AccountType; |
... | ... | @@ -24,8 +24,6 @@ public class MerchantServiceImpl implements MerchantService { |
24 | 24 | @Autowired |
25 | 25 | private IMerchantRepository merchantRepository; |
26 | 26 | @Autowired |
27 | - private MerchantConverter merchantConverter; | |
28 | - @Autowired | |
29 | 27 | private AccountService accountService; |
30 | 28 | |
31 | 29 | @Override |
... | ... | @@ -34,13 +32,13 @@ public class MerchantServiceImpl implements MerchantService { |
34 | 32 | Operator operator = accountRepository.getOperator(); |
35 | 33 | requestDto.setAccountId(operator.getAccountId()); |
36 | 34 | requestDto.setRealName(operator.getName()); |
37 | - Account account = accountRepository.getAccountByName(requestDto.getUserName()); | |
35 | + Account account = accountRepository.getAccountByName(requestDto.getAccountName()); | |
38 | 36 | if (account != null) { |
39 | 37 | throw new ProductException(ResponseCode.ACCOUNT_EXIST); |
40 | 38 | } |
41 | 39 | Merchant merchant = merchantRepository.getByAccountId(requestDto.getAccountId()); |
42 | 40 | if (merchant == null){ |
43 | - merchant = merchantConverter.request2Entity(requestDto); | |
41 | + merchant = MerchantBuilder.request2Entity(requestDto); | |
44 | 42 | merchantRepository.add(merchant); |
45 | 43 | } else { |
46 | 44 | if (AccountType.PERSONAL.getCode() != merchant.getType()){ |
... | ... | @@ -50,7 +48,7 @@ public class MerchantServiceImpl implements MerchantService { |
50 | 48 | } |
51 | 49 | //创建市场管理员账户 |
52 | 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
src/main/java/com/diligrp/xtrade/product/service/impl/ShopServiceImpl.java
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 | 28 | created_time, |
29 | 29 | modified_time |
30 | 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 | 33 | mer_id = #{merId}, |
34 | 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 | 92 | </sql> |
63 | 93 | |
64 | 94 | <!--查询单个--> |
... | ... | @@ -81,15 +111,13 @@ |
81 | 111 | SELECT |
82 | 112 | <include refid="Base_Column"/> |
83 | 113 | from xt_merchant |
84 | - <where> | |
85 | - <include refid="Base_Condition_Column"/> | |
86 | - </where> | |
114 | + <include refid="WHERE_COLUMN"/> | |
87 | 115 | </select> |
88 | 116 | |
89 | 117 | <!--新增所有列--> |
90 | 118 | <insert id="insert" keyProperty="id" useGeneratedKeys="true"> |
91 | 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 | 121 | values (#{merId}, #{merName}, #{marketId}, #{accountId}, #{accountName}, #{type}, #{status}, #{description}, |
94 | 122 | #{createdTime}, #{modifiedTime}) |
95 | 123 | </insert> |
... | ... | @@ -97,9 +125,7 @@ |
97 | 125 | <!--通过主键修改数据--> |
98 | 126 | <update id="update"> |
99 | 127 | update xt_merchant |
100 | - <set> | |
101 | - <include refid="Base_Condition_Column"/> | |
102 | - </set> | |
128 | + <include refid="UPDATE_Column"/> | |
103 | 129 | where id = #{id} |
104 | 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 | +} | ... | ... |