| | |
| | | package com.ks.goldcorn.service.remote; |
| | | |
| | | import com.ks.goldcorn.exception.GoldAppException; |
| | | import com.ks.goldcorn.mapper.GoldCornAppInfoMapper; |
| | | import com.ks.goldcorn.pojo.DO.GoldCornAppInfo; |
| | | import com.ks.goldcorn.query.AppQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import org.yeshi.utils.StringUtil; |
| | | import com.ks.goldcorn.service.GoldCornAppManager; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @Service(version = "1.0" ) |
| | | public class GoldCornAppServiceImpl implements GoldCornAppService { |
| | | |
| | | @Resource |
| | | private GoldCornAppInfoMapper goldCornAppInfoMapper; |
| | | |
| | | @Override |
| | | public List<GoldCornAppInfo> searchByName(String name, int page, int pageSize) { |
| | | AppQuery query = new AppQuery(); |
| | | query.setNameKey(name); |
| | | query.setStart((page - 1) * pageSize); |
| | | query.setCount(pageSize); |
| | | |
| | | List<String> sortList = new ArrayList<>(); |
| | | sortList.add("create_time desc"); |
| | | query.setSortList(sortList); |
| | | return goldCornAppInfoMapper.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countSearchByName(String name) { |
| | | AppQuery query = new AppQuery(); |
| | | query.setNameKey(name); |
| | | return goldCornAppInfoMapper.count(query); |
| | | } |
| | | private GoldCornAppManager goldCornAppManager; |
| | | |
| | | @Override |
| | | public GoldCornAppInfo selectByCode(String code) { |
| | | return goldCornAppInfoMapper.selectByAppCode(code); |
| | | } |
| | | |
| | | @Override |
| | | public void addApp(GoldCornAppInfo goldCornAppInfo) throws GoldAppException { |
| | | if (goldCornAppInfo == null || StringUtil.isNullOrEmpty(goldCornAppInfo.getAppCode()) || StringUtil.isNullOrEmpty(goldCornAppInfo.getAppName())) { |
| | | throw new GoldAppException(GoldAppException.CODE_PARAMS_NOT_ENOUGH, "参数不完整"); |
| | | } |
| | | GoldCornAppInfo app = selectByCode(goldCornAppInfo.getAppCode()); |
| | | if (app != null) { |
| | | throw new GoldAppException(GoldAppException.CODE_EXIST, "应用code已经存在"); |
| | | } |
| | | |
| | | if (goldCornAppInfo.getCreateTime() == null) { |
| | | goldCornAppInfo.setCreateTime(new Date()); |
| | | } |
| | | goldCornAppInfo.setId(null); |
| | | goldCornAppInfoMapper.insertSelective(goldCornAppInfo); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteApp(Long id) throws GoldAppException { |
| | | goldCornAppInfoMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public void updateApp(GoldCornAppInfo appInfo) { |
| | | if (appInfo == null || appInfo.getId() == null) { |
| | | return; |
| | | } |
| | | appInfo.setUpdateTime(new Date()); |
| | | goldCornAppInfoMapper.updateByPrimaryKeySelective(appInfo); |
| | | return goldCornAppManager.selectByAppCode(code); |
| | | } |
| | | } |