Search in sources :

Example 1 with StoreEmployee

use of com.ikoori.vip.common.persistence.model.StoreEmployee in project vip by guangdada.

the class StoreEmployeeController method storeEmployeeUpdate.

/**
 * 跳转到修改员工管理
 */
@Permission
@RequestMapping("/storeEmployee_update/{storeEmployeeId}")
public String storeEmployeeUpdate(@PathVariable Long storeEmployeeId, Model model) {
    StoreEmployee storeEmployee = storeEmployeeService.selectById(storeEmployeeId);
    // 当前登录账号
    Long createUserId = Long.valueOf(ShiroKit.getUser().getId());
    Merchant merchant = merchantService.getMerchantUserId(createUserId);
    Role role = roleService.selectById(storeEmployee.getRoleId());
    User user = userMapper.selectById(storeEmployee.getUserId());
    Map<String, Object> condition = new HashMap<String, Object>();
    condition.put("merchantId", merchant.getId());
    List<Store> stores = storeService.selectByCondition(condition);
    // 查询店铺
    model.addAttribute("stores", stores);
    model.addAttribute("roles", RoleType.values());
    model.addAttribute(user);
    model.addAttribute(role);
    model.addAttribute(storeEmployee);
    model.addAttribute(merchant);
    return PREFIX + "storeEmployee_edit.html";
}
Also used : Role(com.ikoori.vip.common.persistence.model.Role) User(com.ikoori.vip.common.persistence.model.User) Merchant(com.ikoori.vip.common.persistence.model.Merchant) HashMap(java.util.HashMap) Store(com.ikoori.vip.common.persistence.model.Store) StoreEmployee(com.ikoori.vip.common.persistence.model.StoreEmployee) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with StoreEmployee

use of com.ikoori.vip.common.persistence.model.StoreEmployee in project vip by guangdada.

the class StoreEmployeeServiceImpl method deleteEmployee.

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteEmployee(long storeEmployeeId) {
    // TODO Auto-generated method stub
    StoreEmployee storeEmployee = storeEmployeeService.selectById(storeEmployeeId);
    userMapper.deleteById(storeEmployee.getUserId().intValue());
    storeEmployeeService.deleteById(storeEmployeeId);
}
Also used : StoreEmployee(com.ikoori.vip.common.persistence.model.StoreEmployee) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with StoreEmployee

use of com.ikoori.vip.common.persistence.model.StoreEmployee in project vip by guangdada.

the class StoreEmployeeServiceImpl method saveEmployee.

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void saveEmployee(StoreEmployee storeEmployee, String password, String sex) {
    if (storeEmployee.getId() == null) {
        User user = new User();
        user.setSalt(ShiroKit.getRandomSalt(5));
        user.setPassword(ShiroKit.md5(password, user.getSalt()));
        user.setName(storeEmployee.getName());
        user.setAccount(storeEmployee.getMobile());
        user.setRoleid(storeEmployee.getRoleId() + "");
        user.setPhone(storeEmployee.getMobile());
        user.setSex(Integer.valueOf(sex));
        user.setStatus(ManagerStatus.OK.getCode());
        user.setCreatetime(new Date());
        userMapper.insert(user);
        long userId = user.getId().longValue();
        storeEmployee.setUserId(userId);
        this.insert(storeEmployee);
    } else {
        StoreEmployee dbEmp = storeEmployeeMapper.selectById(storeEmployee.getId());
        User dbUser = userMapper.selectById(dbEmp.getUserId());
        dbUser.setName(storeEmployee.getName());
        dbUser.setRoleid(storeEmployee.getRoleId() + "");
        dbUser.setPhone(storeEmployee.getMobile());
        dbUser.setSex(Integer.valueOf(sex));
        userMapper.updateById(dbUser);
        storeEmployeeMapper.updateById(storeEmployee);
    }
}
Also used : User(com.ikoori.vip.common.persistence.model.User) StoreEmployee(com.ikoori.vip.common.persistence.model.StoreEmployee) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StoreEmployee (com.ikoori.vip.common.persistence.model.StoreEmployee)3 User (com.ikoori.vip.common.persistence.model.User)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Permission (com.ikoori.vip.common.annotion.Permission)1 Merchant (com.ikoori.vip.common.persistence.model.Merchant)1 Role (com.ikoori.vip.common.persistence.model.Role)1 Store (com.ikoori.vip.common.persistence.model.Store)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1