Commit 41bd5cd179e45047bfd2b487746b6b1f8c2d7d06
1 parent
b3d92023
代码优化
Showing
11 changed files
with
101 additions
and
73 deletions
src/main/java/com/diligrp/xtrade/product/dao/ShopDao.java
@@ -6,24 +6,26 @@ import org.apache.ibatis.annotations.Mapper; | @@ -6,24 +6,26 @@ import org.apache.ibatis.annotations.Mapper; | ||
6 | 6 | ||
7 | import com.diligrp.xtrade.product.domain.dto.ShopQueryDto; | 7 | import com.diligrp.xtrade.product.domain.dto.ShopQueryDto; |
8 | import com.diligrp.xtrade.product.domain.entity.ShopDo; | 8 | import com.diligrp.xtrade.product.domain.entity.ShopDo; |
9 | +import org.apache.ibatis.annotations.Param; | ||
10 | + | ||
9 | /** | 11 | /** |
10 | - * | 12 | + * @author yangfan |
11 | * @ClassName: ShopDao | 13 | * @ClassName: ShopDao |
12 | * @Description 店铺dao | 14 | * @Description 店铺dao |
13 | - * @author yangfan | ||
14 | * @date 2020年4月21日 | 15 | * @date 2020年4月21日 |
15 | */ | 16 | */ |
16 | @Mapper | 17 | @Mapper |
17 | public interface ShopDao { | 18 | public interface ShopDao { |
18 | - | ||
19 | - void insert(ShopDo shop); | ||
20 | - | ||
21 | - void update(ShopDo shop); | ||
22 | - | ||
23 | - ShopDo selectByShopId(Long shopId); | ||
24 | - | ||
25 | - List<ShopDo> selectByMerId(Long merId); | ||
26 | - | ||
27 | - List<ShopDo> selectShop(ShopQueryDto shopQueryDto); | ||
28 | - | 19 | + |
20 | + void insert(ShopDo shop); | ||
21 | + | ||
22 | + void update(ShopDo shop); | ||
23 | + | ||
24 | + ShopDo selectByShopId(Long shopId); | ||
25 | + | ||
26 | + List<ShopDo> selectByMerId(Long merId); | ||
27 | + | ||
28 | + List<ShopDo> selectShop(ShopQueryDto shopQueryDto); | ||
29 | + | ||
30 | + void updateTypeByMerId(@Param("type") Integer type, @Param("merId") Long merId); | ||
29 | } | 31 | } |
src/main/java/com/diligrp/xtrade/product/domain/builder/MerchantAccountBuilder.java
0 → 100644
1 | +package com.diligrp.xtrade.product.domain.builder; | ||
2 | + | ||
3 | +import com.alibaba.nacos.common.utils.Md5Utils; | ||
4 | +import com.diligrp.xtrade.product.domain.dto.MerchantRequestDto; | ||
5 | +import com.diligrp.xtrade.product.domain.emuns.AccountStatus; | ||
6 | +import com.diligrp.xtrade.product.domain.entity.AccountDo; | ||
7 | + | ||
8 | +import java.time.LocalDateTime; | ||
9 | + | ||
10 | +/** | ||
11 | + * @Auther: miaoguoxin | ||
12 | + * @Date: 2020/4/23 09:23 | ||
13 | + */ | ||
14 | +public class MerchantAccountBuilder { | ||
15 | + | ||
16 | + public static AccountDo buildDoFromMerchant(MerchantRequestDto requestDto, Long merId) { | ||
17 | + String password = String.format("%s_%s", | ||
18 | + requestDto.getAccountName(), requestDto.getPassword()); | ||
19 | + AccountDo newAccountDo = new AccountDo(); | ||
20 | + newAccountDo.setName(requestDto.getAccountName()); | ||
21 | + newAccountDo.setRealName(requestDto.getRealName()); | ||
22 | + newAccountDo.setPassword(Md5Utils.getMD5(password, "UTF-8")); | ||
23 | + newAccountDo.setMobile(requestDto.getMobile()); | ||
24 | + newAccountDo.setStatus(AccountStatus.NORMAL.getCode()); | ||
25 | + newAccountDo.setIsAdmin(1); | ||
26 | + newAccountDo.setMerId(merId); | ||
27 | + newAccountDo.setCreatedTime(LocalDateTime.now()); | ||
28 | + return newAccountDo; | ||
29 | + } | ||
30 | +} |
src/main/java/com/diligrp/xtrade/product/domain/builder/MerchantBuilder.java
@@ -16,7 +16,7 @@ import java.util.Optional; | @@ -16,7 +16,7 @@ import java.util.Optional; | ||
16 | */ | 16 | */ |
17 | public class MerchantBuilder { | 17 | public class MerchantBuilder { |
18 | 18 | ||
19 | - public static MerchantDo request2Entity(MerchantRequestDto requestDto) { | 19 | + public static MerchantDo buildDoFromRequest(MerchantRequestDto requestDto) { |
20 | Integer type = Optional.ofNullable(requestDto.getAccountType()) | 20 | Integer type = Optional.ofNullable(requestDto.getAccountType()) |
21 | .map(AccountType::getCode) | 21 | .map(AccountType::getCode) |
22 | .orElse(0); | 22 | .orElse(0); |
@@ -30,7 +30,7 @@ public class MerchantBuilder { | @@ -30,7 +30,7 @@ public class MerchantBuilder { | ||
30 | return merchantDo; | 30 | return merchantDo; |
31 | } | 31 | } |
32 | 32 | ||
33 | - public static MerchantResponseDto entity2Response(MerchantDo merchantDo){ | 33 | + public static MerchantResponseDto buildResponseFromDo(MerchantDo merchantDo){ |
34 | MerchantResponseDto responseDto = new MerchantResponseDto(); | 34 | MerchantResponseDto responseDto = new MerchantResponseDto(); |
35 | BeanUtils.copyProperties(merchantDo,responseDto); | 35 | BeanUtils.copyProperties(merchantDo,responseDto); |
36 | responseDto.setType(AccountType.getAccountType(merchantDo.getType())); | 36 | responseDto.setType(AccountType.getAccountType(merchantDo.getType())); |
src/main/java/com/diligrp/xtrade/product/repository/AccountRepository.java
1 | package com.diligrp.xtrade.product.repository; | 1 | package com.diligrp.xtrade.product.repository; |
2 | 2 | ||
3 | +import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | ||
3 | import com.diligrp.xtrade.product.domain.entity.AccountDo; | 4 | import com.diligrp.xtrade.product.domain.entity.AccountDo; |
4 | import com.diligrp.xtrade.product.domain.entity.OperatorDo; | 5 | import com.diligrp.xtrade.product.domain.entity.OperatorDo; |
6 | +import com.diligrp.xtrade.shared.sequence.IKeyGenerator; | ||
7 | +import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
5 | import org.springframework.stereotype.Repository; | 9 | import org.springframework.stereotype.Repository; |
6 | 10 | ||
7 | import java.util.ArrayList; | 11 | import java.util.ArrayList; |
@@ -15,6 +19,8 @@ import java.util.List; | @@ -15,6 +19,8 @@ import java.util.List; | ||
15 | @Repository | 19 | @Repository |
16 | public class AccountRepository implements IAccountRepository { | 20 | public class AccountRepository implements IAccountRepository { |
17 | private final static List<AccountDo> ACCOUNT_DOS = new ArrayList<>(); | 21 | private final static List<AccountDo> ACCOUNT_DOS = new ArrayList<>(); |
22 | + @Autowired | ||
23 | + private KeyGeneratorManager keyGeneratorManager; | ||
18 | @Override | 24 | @Override |
19 | public OperatorDo getOperator() { | 25 | public OperatorDo getOperator() { |
20 | OperatorDo operatorDo = new OperatorDo(); | 26 | OperatorDo operatorDo = new OperatorDo(); |
@@ -35,6 +41,8 @@ public class AccountRepository implements IAccountRepository { | @@ -35,6 +41,8 @@ public class AccountRepository implements IAccountRepository { | ||
35 | 41 | ||
36 | @Override | 42 | @Override |
37 | public void add(AccountDo accountDo) { | 43 | public void add(AccountDo accountDo) { |
44 | + IKeyGenerator keyGenerator = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.ACCOUNT_SEQUENCE); | ||
45 | + accountDo.setId(keyGenerator.nextId()); | ||
38 | ACCOUNT_DOS.add(accountDo); | 46 | ACCOUNT_DOS.add(accountDo); |
39 | } | 47 | } |
40 | } | 48 | } |
src/main/java/com/diligrp/xtrade/product/repository/MerchantRepository.java
@@ -48,10 +48,6 @@ public class MerchantRepository implements IMerchantRepository { | @@ -48,10 +48,6 @@ public class MerchantRepository implements IMerchantRepository { | ||
48 | 48 | ||
49 | @Override | 49 | @Override |
50 | public void update(MerchantDo merchantDo) { | 50 | public void update(MerchantDo merchantDo) { |
51 | - merchantDo.setModifiedTime(LocalDateTime.now()); | ||
52 | - ShopDo shopDo = new ShopDo(); | ||
53 | - shopDo.setType(AccountType.PUBLIC.getCode()); | ||
54 | - shopDo.setMerId(merchantDo.getMerId()); | ||
55 | - shopDao.update(shopDo); | 51 | + |
56 | } | 52 | } |
57 | } | 53 | } |
src/main/java/com/diligrp/xtrade/product/service/AccountService.java
@@ -10,7 +10,5 @@ import com.diligrp.xtrade.product.domain.entity.MerchantDo; | @@ -10,7 +10,5 @@ import com.diligrp.xtrade.product.domain.entity.MerchantDo; | ||
10 | */ | 10 | */ |
11 | public interface AccountService { | 11 | public interface AccountService { |
12 | 12 | ||
13 | - AccountDo build(MerchantRequestDto requestDto, MerchantDo merchantDo) throws Exception; | ||
14 | - | ||
15 | - void create(MerchantRequestDto requestDto, MerchantDo merchantDo) throws Exception; | 13 | + void create(MerchantRequestDto requestDto, MerchantDo merchantDo); |
16 | } | 14 | } |
src/main/java/com/diligrp/xtrade/product/service/ShopService.java
@@ -4,10 +4,11 @@ import java.util.List; | @@ -4,10 +4,11 @@ import java.util.List; | ||
4 | 4 | ||
5 | import com.diligrp.xtrade.product.domain.dto.ShopDto; | 5 | import com.diligrp.xtrade.product.domain.dto.ShopDto; |
6 | import com.diligrp.xtrade.product.domain.dto.ShopQueryDto; | 6 | import com.diligrp.xtrade.product.domain.dto.ShopQueryDto; |
7 | +import com.diligrp.xtrade.product.domain.entity.MerchantDo; | ||
7 | import com.diligrp.xtrade.product.domain.entity.ShopDo; | 8 | import com.diligrp.xtrade.product.domain.entity.ShopDo; |
8 | 9 | ||
9 | public interface ShopService { | 10 | public interface ShopService { |
10 | - | 11 | + |
11 | /** | 12 | /** |
12 | * @Title insert | 13 | * @Title insert |
13 | * @Description 保存shop | 14 | * @Description 保存shop |
@@ -15,18 +16,18 @@ public interface ShopService { | @@ -15,18 +16,18 @@ public interface ShopService { | ||
15 | * @throws | 16 | * @throws |
16 | */ | 17 | */ |
17 | void insert(ShopDto shop); | 18 | void insert(ShopDto shop); |
18 | - | 19 | + |
19 | /** | 20 | /** |
20 | - * | 21 | + * |
21 | * @Title update | 22 | * @Title update |
22 | * @Description 修改 | 23 | * @Description 修改 |
23 | * @param shop | 24 | * @param shop |
24 | * @throws | 25 | * @throws |
25 | */ | 26 | */ |
26 | void update(ShopDto shop); | 27 | void update(ShopDto shop); |
27 | - | 28 | + |
28 | /** | 29 | /** |
29 | - * | 30 | + * |
30 | * @Title selectByMerId | 31 | * @Title selectByMerId |
31 | * @Description 店铺id查询 | 32 | * @Description 店铺id查询 |
32 | * @param merId | 33 | * @param merId |
@@ -34,9 +35,9 @@ public interface ShopService { | @@ -34,9 +35,9 @@ public interface ShopService { | ||
34 | * @throws | 35 | * @throws |
35 | */ | 36 | */ |
36 | ShopDo selectByShopId(Long shopId); | 37 | ShopDo selectByShopId(Long shopId); |
37 | - | 38 | + |
38 | /** | 39 | /** |
39 | - * | 40 | + * |
40 | * @Title selectByMerId | 41 | * @Title selectByMerId |
41 | * @Description 根据商户id获取名下全部商铺 | 42 | * @Description 根据商户id获取名下全部商铺 |
42 | * @param merId | 43 | * @param merId |
@@ -44,9 +45,9 @@ public interface ShopService { | @@ -44,9 +45,9 @@ public interface ShopService { | ||
44 | * @throws | 45 | * @throws |
45 | */ | 46 | */ |
46 | List<ShopDo> selectShopByMerId(Long merId); | 47 | List<ShopDo> selectShopByMerId(Long merId); |
47 | - | 48 | + |
48 | /** | 49 | /** |
49 | - * | 50 | + * |
50 | * @Title selectShop | 51 | * @Title selectShop |
51 | * @Description 商铺查询 | 52 | * @Description 商铺查询 |
52 | * @param shopQuery | 53 | * @param shopQuery |
@@ -54,4 +55,6 @@ public interface ShopService { | @@ -54,4 +55,6 @@ public interface ShopService { | ||
54 | * @throws | 55 | * @throws |
55 | */ | 56 | */ |
56 | List<ShopDo> selectShop(ShopQueryDto shopQuery); | 57 | List<ShopDo> selectShop(ShopQueryDto shopQuery); |
58 | + | ||
59 | + void updateShopTypeWithMerchant(MerchantDo merchantDo); | ||
57 | } | 60 | } |
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.builder.MerchantAccountBuilder; |
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.emuns.AccountStatus; | ||
6 | -import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys; | ||
7 | import com.diligrp.xtrade.product.domain.entity.AccountDo; | 5 | import com.diligrp.xtrade.product.domain.entity.AccountDo; |
8 | import com.diligrp.xtrade.product.domain.entity.MerchantDo; | 6 | import com.diligrp.xtrade.product.domain.entity.MerchantDo; |
9 | import com.diligrp.xtrade.product.repository.IAccountRepository; | 7 | import com.diligrp.xtrade.product.repository.IAccountRepository; |
10 | import com.diligrp.xtrade.product.service.AccountService; | 8 | import com.diligrp.xtrade.product.service.AccountService; |
11 | -import com.diligrp.xtrade.shared.sequence.IKeyGenerator; | ||
12 | -import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
15 | 11 | ||
16 | -import java.time.LocalDateTime; | ||
17 | - | ||
18 | /** | 12 | /** |
19 | * @Auther: miaoguoxin | 13 | * @Auther: miaoguoxin |
20 | * @Date: 2020/4/22 11:10 | 14 | * @Date: 2020/4/22 11:10 |
@@ -23,30 +17,10 @@ import java.time.LocalDateTime; | @@ -23,30 +17,10 @@ import java.time.LocalDateTime; | ||
23 | public class AccountServiceImpl implements AccountService { | 17 | public class AccountServiceImpl implements AccountService { |
24 | @Autowired | 18 | @Autowired |
25 | private IAccountRepository accountRepository; | 19 | private IAccountRepository accountRepository; |
26 | - @Autowired | ||
27 | - private KeyGeneratorManager keyGeneratorManager; | ||
28 | - | ||
29 | - @Override | ||
30 | - public AccountDo build(MerchantRequestDto requestDto, MerchantDo merchantDo) throws Exception { | ||
31 | - String password = String.format("%s_%s", | ||
32 | - requestDto.getAccountName(), requestDto.getPassword()); | ||
33 | - AccountDo newAccountDo = new AccountDo(); | ||
34 | - newAccountDo.setName(requestDto.getAccountName()); | ||
35 | - newAccountDo.setRealName(requestDto.getRealName()); | ||
36 | - newAccountDo.setPassword(Md5Utils.getMD5(password, "UTF-8")); | ||
37 | - newAccountDo.setMobile(requestDto.getMobile()); | ||
38 | - newAccountDo.setStatus(AccountStatus.NORMAL.getCode()); | ||
39 | - newAccountDo.setIsAdmin(1); | ||
40 | - newAccountDo.setMerId(merchantDo.getMerId()); | ||
41 | - newAccountDo.setCreatedTime(LocalDateTime.now()); | ||
42 | - IKeyGenerator keyGenerator = keyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.ACCOUNT_SEQUENCE); | ||
43 | - newAccountDo.setId(keyGenerator.nextId()); | ||
44 | - return newAccountDo; | ||
45 | - } | ||
46 | 20 | ||
47 | @Override | 21 | @Override |
48 | - public void create(MerchantRequestDto requestDto, MerchantDo merchantDo) throws Exception { | ||
49 | - AccountDo newAccountDo = this.build(requestDto, merchantDo); | 22 | + public void create(MerchantRequestDto requestDto, MerchantDo merchantDo) { |
23 | + AccountDo newAccountDo = MerchantAccountBuilder.buildDoFromMerchant(requestDto, merchantDo.getMerId()); | ||
50 | accountRepository.add(newAccountDo); | 24 | accountRepository.add(newAccountDo); |
51 | } | 25 | } |
52 | 26 |
src/main/java/com/diligrp/xtrade/product/service/impl/MerchantServiceImpl.java
@@ -13,6 +13,7 @@ import com.diligrp.xtrade.product.repository.IAccountRepository; | @@ -13,6 +13,7 @@ import com.diligrp.xtrade.product.repository.IAccountRepository; | ||
13 | import com.diligrp.xtrade.product.repository.IMerchantRepository; | 13 | import com.diligrp.xtrade.product.repository.IMerchantRepository; |
14 | import com.diligrp.xtrade.product.service.AccountService; | 14 | import com.diligrp.xtrade.product.service.AccountService; |
15 | import com.diligrp.xtrade.product.service.MerchantService; | 15 | import com.diligrp.xtrade.product.service.MerchantService; |
16 | +import com.diligrp.xtrade.product.service.ShopService; | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
17 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
18 | import org.springframework.transaction.annotation.Transactional; | 19 | import org.springframework.transaction.annotation.Transactional; |
@@ -25,6 +26,8 @@ public class MerchantServiceImpl implements MerchantService { | @@ -25,6 +26,8 @@ public class MerchantServiceImpl implements MerchantService { | ||
25 | private IMerchantRepository merchantRepository; | 26 | private IMerchantRepository merchantRepository; |
26 | @Autowired | 27 | @Autowired |
27 | private AccountService accountService; | 28 | private AccountService accountService; |
29 | + @Autowired | ||
30 | + private ShopService shopService; | ||
28 | 31 | ||
29 | @Override | 32 | @Override |
30 | @Transactional(rollbackFor = Exception.class) | 33 | @Transactional(rollbackFor = Exception.class) |
@@ -38,17 +41,17 @@ public class MerchantServiceImpl implements MerchantService { | @@ -38,17 +41,17 @@ public class MerchantServiceImpl implements MerchantService { | ||
38 | } | 41 | } |
39 | MerchantDo merchantDo = merchantRepository.getByAccountId(requestDto.getAccountId()); | 42 | MerchantDo merchantDo = merchantRepository.getByAccountId(requestDto.getAccountId()); |
40 | if (merchantDo == null){ | 43 | if (merchantDo == null){ |
41 | - merchantDo = MerchantBuilder.request2Entity(requestDto); | 44 | + merchantDo = MerchantBuilder.buildDoFromRequest(requestDto); |
42 | merchantRepository.add(merchantDo); | 45 | merchantRepository.add(merchantDo); |
43 | } else { | 46 | } else { |
44 | if (AccountType.PERSONAL.getCode() != merchantDo.getType()){ | 47 | if (AccountType.PERSONAL.getCode() != merchantDo.getType()){ |
45 | throw new ProductException(ExceptionEnum.CARD_MERCHANT_CREATED); | 48 | throw new ProductException(ExceptionEnum.CARD_MERCHANT_CREATED); |
46 | } | 49 | } |
47 | - merchantRepository.update(merchantDo); | 50 | + shopService.updateShopTypeWithMerchant(merchantDo); |
48 | } | 51 | } |
49 | //创建市场管理员账户 | 52 | //创建市场管理员账户 |
50 | accountService.create(requestDto, merchantDo); | 53 | accountService.create(requestDto, merchantDo); |
51 | - return MerchantBuilder.entity2Response(merchantDo); | 54 | + return MerchantBuilder.buildResponseFromDo(merchantDo); |
52 | } | 55 | } |
53 | 56 | ||
54 | } | 57 | } |
src/main/java/com/diligrp/xtrade/product/service/impl/ShopServiceImpl.java
1 | package com.diligrp.xtrade.product.service.impl; | 1 | package com.diligrp.xtrade.product.service.impl; |
2 | 2 | ||
3 | +import java.time.LocalDateTime; | ||
3 | import java.util.List; | 4 | import java.util.List; |
4 | 5 | ||
6 | +import com.diligrp.xtrade.product.domain.emuns.AccountType; | ||
7 | +import com.diligrp.xtrade.product.domain.entity.MerchantDo; | ||
5 | import org.springframework.beans.BeanUtils; | 8 | import org.springframework.beans.BeanUtils; |
6 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
7 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
@@ -68,4 +71,9 @@ public class ShopServiceImpl implements ShopService { | @@ -68,4 +71,9 @@ public class ShopServiceImpl implements ShopService { | ||
68 | return shops; | 71 | return shops; |
69 | } | 72 | } |
70 | 73 | ||
74 | + @Override | ||
75 | + public void updateShopTypeWithMerchant(MerchantDo merchantDo) { | ||
76 | + shopDao.updateTypeByMerId(AccountType.PUBLIC.getCode(), merchantDo.getMerId()); | ||
77 | + } | ||
78 | + | ||
71 | } | 79 | } |
src/main/resources/mapping/com/diligrp/xtrade/product/ShopDao.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | <mapper namespace="com.diligrp.xtrade.product.dao.ShopDao"> | 3 | <mapper namespace="com.diligrp.xtrade.product.dao.ShopDao"> |
4 | - | 4 | + |
5 | <sql id="QUERY_COLUMN_LIST"> | 5 | <sql id="QUERY_COLUMN_LIST"> |
6 | <![CDATA[ | 6 | <![CDATA[ |
7 | `id`, `shop_id` AS shopId, `shop_name` AS shopName, `address`, `mer_id` AS merId, `type`, `status`, | 7 | `id`, `shop_id` AS shopId, `shop_name` AS shopName, `address`, `mer_id` AS merId, `type`, `status`, |
@@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
33 | <if test="selfShop != null and selfShop != ''"><![CDATA[AND self_shop = #{selfShop}]]></if> | 33 | <if test="selfShop != null and selfShop != ''"><![CDATA[AND self_shop = #{selfShop}]]></if> |
34 | </where> | 34 | </where> |
35 | </sql> | 35 | </sql> |
36 | - | 36 | + |
37 | <insert id="insert" parameterType="com.diligrp.xtrade.product.domain.entity.ShopDo"> | 37 | <insert id="insert" parameterType="com.diligrp.xtrade.product.domain.entity.ShopDo"> |
38 | <![CDATA[ | 38 | <![CDATA[ |
39 | INSERT INTO `xt_shop`(`id`, `shop_id`, `shop_name`, `self_shop`, `mer_id`, `main_biz`, `type`, `status`, `address`, `description`, `created_time`, `modified_time`) | 39 | INSERT INTO `xt_shop`(`id`, `shop_id`, `shop_name`, `self_shop`, `mer_id`, `main_biz`, `type`, `status`, `address`, `description`, `created_time`, `modified_time`) |
@@ -42,21 +42,27 @@ | @@ -42,21 +42,27 @@ | ||
42 | </insert> | 42 | </insert> |
43 | <select id="selectByShopId" parameterType="long" resultType="com.diligrp.xtrade.product.domain.entity.ShopDo"> | 43 | <select id="selectByShopId" parameterType="long" resultType="com.diligrp.xtrade.product.domain.entity.ShopDo"> |
44 | <![CDATA[ | 44 | <![CDATA[ |
45 | - SELECT | 45 | + SELECT |
46 | ]]> | 46 | ]]> |
47 | <include refid="QUERY_COLUMN_LIST" /> | 47 | <include refid="QUERY_COLUMN_LIST" /> |
48 | <![CDATA[ | 48 | <![CDATA[ |
49 | FROM `xt_shop` WHERE shop_id = #{shopId} | 49 | FROM `xt_shop` WHERE shop_id = #{shopId} |
50 | ]]> | 50 | ]]> |
51 | </select> | 51 | </select> |
52 | - <update id="update" parameterType="com.diligrp.xtrade.product.domain.entity.ShopDo"> | 52 | + <update id="update" parameterType="com.diligrp.xtrade.product.domain.entity.ShopDo"> |
53 | <![CDATA[UPDATE `xt_shop`]]> | 53 | <![CDATA[UPDATE `xt_shop`]]> |
54 | <include refid="UPDATE_COLUMN_SET" /> | 54 | <include refid="UPDATE_COLUMN_SET" /> |
55 | <![CDATA[WHERE shop_id = #{shopId}]]> | 55 | <![CDATA[WHERE shop_id = #{shopId}]]> |
56 | </update> | 56 | </update> |
57 | - <select id="selectByMerId" parameterType="long" resultType="com.diligrp.xtrade.product.domain.entity.ShopDo"> | 57 | + <update id="updateTypeByMerId"> |
58 | + UPDATE xt_shop | ||
59 | + SET type = #{type}, | ||
60 | + modified_time = now() | ||
61 | + WHERE mer_id = #{merId} | ||
62 | + </update> | ||
63 | + <select id="selectByMerId" parameterType="long" resultType="com.diligrp.xtrade.product.domain.entity.ShopDo"> | ||
58 | <![CDATA[ | 64 | <![CDATA[ |
59 | - SELECT | 65 | + SELECT |
60 | ]]> | 66 | ]]> |
61 | <include refid="QUERY_COLUMN_LIST" /> | 67 | <include refid="QUERY_COLUMN_LIST" /> |
62 | <![CDATA[ | 68 | <![CDATA[ |
@@ -65,12 +71,12 @@ | @@ -65,12 +71,12 @@ | ||
65 | </select> | 71 | </select> |
66 | <select id="selectShop" parameterType="com.diligrp.xtrade.product.domain.dto.ShopQueryDto" resultType="com.diligrp.xtrade.product.domain.entity.ShopDo"> | 72 | <select id="selectShop" parameterType="com.diligrp.xtrade.product.domain.dto.ShopQueryDto" resultType="com.diligrp.xtrade.product.domain.entity.ShopDo"> |
67 | <![CDATA[ | 73 | <![CDATA[ |
68 | - SELECT | 74 | + SELECT |
69 | ]]> | 75 | ]]> |
70 | <include refid="QUERY_COLUMN_LIST" /> | 76 | <include refid="QUERY_COLUMN_LIST" /> |
71 | <![CDATA[ | 77 | <![CDATA[ |
72 | - FROM `xt_shop` | 78 | + FROM `xt_shop` |
73 | ]]> | 79 | ]]> |
74 | <include refid="QUERY_WHERE_CLAUSE" /> | 80 | <include refid="QUERY_WHERE_CLAUSE" /> |
75 | </select> | 81 | </select> |
76 | -</mapper> | ||
77 | \ No newline at end of file | 82 | \ No newline at end of file |
83 | +</mapper> |