| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.dubbo.common.utils.PojoUtils ; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | //public class UserSv extends MPJBaseServiceImpl<BaUserMapper, BaUser> { |
| | | public class UserSv { |
| | | |
| | | private BaUserMapper dao; |
| | |
| | | */ |
| | | public BaUser selectById(Long id){ |
| | | return this.dao.selectById(id) ; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param vo 查询条件值对象 |
| | | * @return 片区实体 |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public QueryResultVo<List<BaUser>> selectSome(QueryVo vo){ |
| | | // MPJLambdaWrapper<BaUser> wrapper = new MPJLambdaWrapper<BaUser>() |
| | | // .selectAll(BaUser.class)//查询user表全部字段 |
| | | // .select(BaRole::getId, BaRole::getName) |
| | | // .leftJoin(BaUserRole.class, BaUserRole::getUserId, BaUser::getId) |
| | | // .leftJoin(BaRole.class, BaRole::getId, BaUserRole::getRoleId); |
| | | // |
| | | // wrapper.like(StringUtils.isNotEmpty(vo.name), "t.name", vo.name) ; |
| | | // wrapper.eq(StringUtils.isNotEmpty(vo.name), "t.phone", vo.phone) ; |
| | | // wrapper.eq(!Objects.isNull(vo.roleId), "t1.id", vo.roleId) ; |
| | | // |
| | | // Page<BaUser> page = new Page<>(vo.pageCurr, vo.pageSize) ; |
| | | // |
| | | // IPage<BaUser> iPage = this.dao.selectJoinPage(page, BaUser.class, wrapper) ; |
| | | // |
| | | // List<BaUser> list = iPage.getRecords() ; |
| | | // |
| | | // return (QueryResultVo.<List<BaUser>>builder().content(list)).build() ; |
| | | return null ; |
| | | Map<String, Object> params = (Map<String, Object>)PojoUtils.generalize(vo) ; |
| | | Long itemTotal = this.dao.selectTotal(params) ; |
| | | |
| | | QueryResultVo<List<BaUser>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = vo.pageSize ; |
| | | rsVo.pageCurr = vo.pageCurr ; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = this.dao.selectSome(params) ; |
| | | |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 保存实体 |
| | | * @param po 实体 |
| | | * @return 影响记录数量 |
| | | */ |
| | | @Transactional |
| | | public int save(BaUser po){ |
| | | return this.dao.insert(po) ; |
| | | } |
| | | |
| | | /** |
| | | * 保存修改实体 |
| | | * @param po 实体 |
| | | * @return 影响记录数量 |
| | | */ |
| | | @Transactional |
| | | public int update(BaUser po){ |
| | | return this.dao.updateByPrimaryKeySelective(po) ; |
| | | } |
| | | |
| | | /** |
| | | * 修改密码 |
| | | * @param id 用户ID |
| | | * @param password 新密码 |
| | | * @return 影响记录数量 |
| | | */ |
| | | public int changePassword(Long id, String password){ |
| | | return this.dao.changePassword(id, password) ; |
| | | } |
| | | |
| | | /** |
| | | * 保存修改实体 |
| | | * @param id 实体ID |
| | | * @return 影响记录数量 |
| | | */ |
| | | @Transactional |
| | | public int delete(Long id){ |
| | | return this.dao.deleteLogicById(id) ; |
| | | } |
| | | |
| | | } |