| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.db.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.community.sanshuo.ComSanShuoIndustryCenterDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.user.AdministratorsUserVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.service_community.dao.ComSanshuoIndustryCenterDao; |
| | | import com.panzhihua.service_community.dao.SysUserDao; |
| | | import com.panzhihua.service_community.entity.ComSanshuoIndustryCenter; |
| | | import com.panzhihua.service_community.entity.SysUser; |
| | | import com.panzhihua.service_community.service.ComSanShuoIndustryCenterService; |
| | | import com.panzhihua.service_community.util.MyAESUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.util.Date; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | @Service |
| | | public class ComSanShuoIndustryCenterServiceImpl extends ServiceImpl<ComSanshuoIndustryCenterDao, ComSanshuoIndustryCenter> implements ComSanShuoIndustryCenterService { |
| | | |
| | | @Resource |
| | | private ComSanshuoIndustryCenterDao comSanshuoIndustryCenterDao; |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | /** |
| | | * 后台业务中心列表 |
| | |
| | | * */ |
| | | @Override |
| | | public R addOrUpdate(ComSanShuoIndustryCenterDTO comSanShuoIndustryCenterDTO) { |
| | | ComSanshuoIndustryCenter comSanshuoIndustryCenter = comSanshuoIndustryCenterDao.selectOne(new QueryWrapper<ComSanshuoIndustryCenter>().eq("name", comSanShuoIndustryCenterDTO.getName())); |
| | | if (isNull(comSanShuoIndustryCenterDTO.getId())){ |
| | | if (nonNull(comSanshuoIndustryCenter)){ |
| | | return R.fail("业务中心已存在"); |
| | | } |
| | | ComSanshuoIndustryCenter center=new ComSanshuoIndustryCenter(); |
| | | BeanUtil.copyProperties(comSanShuoIndustryCenterDTO,center); |
| | | //添加 |
| | |
| | | center.setCreateTime(new Date()); |
| | | int insert = comSanshuoIndustryCenterDao.insert(center); |
| | | if (insert>0){ |
| | | return R.ok(); |
| | | //创建后台登陆账号 |
| | | AdministratorsUserVO user=new AdministratorsUserVO(); |
| | | user.setUserId(Snowflake.getId()); |
| | | user.setAccount(comSanShuoIndustryCenterDTO.getAccount()); |
| | | user.setName(comSanShuoIndustryCenterDTO.getName()); |
| | | user.setType(12); |
| | | try { |
| | | user.setPassword(comSanShuoIndustryCenterDTO.getPassword()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return userService.sanShuoAddUser(user); |
| | | } |
| | | }else { |
| | | ComSanshuoIndustryCenter center=new ComSanshuoIndustryCenter(); |
| | |
| | | } |
| | | return R.fail("操作失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R resetPassword(ComSanshuoIndustryCenter center) { |
| | | try { |
| | | return userService.sanShuoResetPassword(center.getAccount(), center.getPassword()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | } |