cpupon-dev
parent
85e911a4cb
commit
2206ea32c1
@ -0,0 +1,68 @@ |
||||
package com.bweb.controller.api; |
||||
|
||||
import com.hfkj.api.ApiMerService; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.common.utils.IDGenerator; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.common.utils.WxUtils; |
||||
import com.hfkj.entity.ApiMer; |
||||
import com.hfkj.model.ResponseData; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
import java.util.Date; |
||||
|
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/apiMer") |
||||
@Api(value = "api商户") |
||||
public class ApiMerController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(ApiMerController.class); |
||||
|
||||
@Resource |
||||
private ApiMerService apiMerService; |
||||
|
||||
@RequestMapping(value="/insertMerchant",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "增加商户") |
||||
public ResponseData insertMer(@RequestBody ApiMer apiMer) { |
||||
try { |
||||
|
||||
|
||||
if (StringUtils.isBlank(apiMer.getMerName()) |
||||
|| StringUtils.isBlank(apiMer.getContact()) |
||||
|| StringUtils.isBlank(apiMer.getContactPhone()) |
||||
) { |
||||
log.error("ApiMerchantsController -> insertMerchant() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
apiMer.setCreateTime(new Date()); |
||||
apiMer.setUpdateTime(new Date()); |
||||
apiMer.setStatus(1); |
||||
apiMer.setAppId(DateUtil.date2String(new Date(), "yyyyMM") + IDGenerator.nextId(5)); |
||||
apiMer.setAppSecret(WxUtils.MD5(apiMer.getAppId() , true)); |
||||
apiMerService.create(apiMer); |
||||
|
||||
return ResponseMsgUtil.success("新增成功"); |
||||
} catch (Exception e) { |
||||
log.error("ApiMerchantsController -> insertMerchant() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,68 @@ |
||||
package com.hfkj.api; |
||||
|
||||
import com.hfkj.entity.ApiMer; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface ApiMerService { |
||||
|
||||
/** |
||||
* @MethodName create |
||||
* @Description: 创建api商户 |
||||
* @param apiMer |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/5 下午3:19 |
||||
*/ |
||||
void create(ApiMer apiMer); |
||||
|
||||
/** |
||||
* @MethodName update |
||||
* @Description: /** |
||||
* @Description: 更新api商户 |
||||
* @param apiMer |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/5 下午3:19 |
||||
*/ |
||||
void update(ApiMer apiMer); |
||||
|
||||
/** |
||||
* @MethodName delete |
||||
* @Description: 删除api商户 |
||||
* @param id |
||||
* @param fullDelete |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/5 下午3:19 |
||||
*/ |
||||
void delete(Long id , Boolean fullDelete); |
||||
|
||||
/** |
||||
* @MethodName queryDetail |
||||
* @Description: 查询api商户详情 |
||||
* @param id |
||||
* @return: com.hfkj.entity.ApiMer |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/5 下午3:19 |
||||
*/ |
||||
ApiMer queryDetail(Long id); |
||||
|
||||
/** |
||||
* @MethodName queryDetail |
||||
* @Description: 根据appId查询商户 |
||||
* @param appId |
||||
* @return: com.hfkj.entity.ApiMer |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/5 下午3:20 |
||||
*/ |
||||
ApiMer queryDetail(String appId); |
||||
|
||||
/** |
||||
* @MethodName queryList |
||||
* @Description: 查询api商户列表 |
||||
* @param apiMer |
||||
* @return: java.util.List<com.hfkj.entity.ApiMer> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/5 下午3:20 |
||||
*/ |
||||
List<ApiMer> queryList(ApiMer apiMer); |
||||
|
||||
} |
@ -0,0 +1,68 @@ |
||||
package com.hfkj.api.impl; |
||||
|
||||
import com.hfkj.api.ApiMerService; |
||||
import com.hfkj.dao.ApiMerMapper; |
||||
import com.hfkj.entity.ApiMer; |
||||
import com.hfkj.entity.ApiMerExample; |
||||
import com.hfkj.entity.BsOrderGoods; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Collections; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@Service("apiMerService") |
||||
public class ApiMerServiceImpl implements ApiMerService { |
||||
|
||||
@Resource |
||||
private ApiMerMapper apiMerMapper; |
||||
|
||||
@Override |
||||
public void create(ApiMer apiMer) { |
||||
apiMerMapper.insert(apiMer); |
||||
} |
||||
|
||||
@Override |
||||
public void update(ApiMer apiMer) { |
||||
apiMerMapper.updateByPrimaryKey(apiMer); |
||||
} |
||||
|
||||
@Override |
||||
public void delete(Long id, Boolean fullDelete) { |
||||
if (fullDelete) { |
||||
apiMerMapper.deleteByPrimaryKey(id); |
||||
} else { |
||||
ApiMer apiMer = queryDetail(id); |
||||
apiMer.setStatus(0); |
||||
apiMer.setUpdateTime(new Date()); |
||||
update(apiMer); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public ApiMer queryDetail(Long id) { |
||||
return apiMerMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public ApiMer queryDetail(String appId) { |
||||
ApiMerExample example = new ApiMerExample(); |
||||
ApiMerExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
criteria.andAppIdEqualTo(appId).andStatusEqualTo(1); |
||||
|
||||
List<ApiMer> list = apiMerMapper.selectByExample(example); |
||||
|
||||
if (!list.isEmpty()) { |
||||
return list.get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<ApiMer> queryList(ApiMer apiMer) { |
||||
return Collections.emptyList(); |
||||
} |
||||
} |
Loading…
Reference in new issue