Quellcode durchsuchen

服务管理-重复添加bug修复

huangzhiyong vor 7 Jahren
Ursprung
Commit
1a3f98bec9

+ 11 - 1
src/main/java/com/yihu/hos/system/dao/AppDao.java

@ -16,8 +16,9 @@ import java.util.Map;
 * Created by chenweida on 2016/1/21.
 */
@Repository("appDao")
public class AppDao extends SQLGeneralDAO  {
public class AppDao extends SQLGeneralDAO {
    public static final String BEAN_ID = "appDao";
    public Result getAppList(Map<String, Object> params) throws Exception {
        StringBuilder sb = new StringBuilder("from SystemApp t where 1=1 ");
        if (!StringUtils.isEmpty(params.get("status"))) //是否有效
@ -37,6 +38,15 @@ public class AppDao extends SQLGeneralDAO  {
        return (List<SystemApp>) super.hibernateTemplate.find("from SystemApp");
    }
    public SystemApp findByCode(String code) throws Exception {
        List<SystemApp> systemApps = (List<SystemApp>) super.hibernateTemplate.find("from SystemApp where code=?", code);
        if (systemApps != null && systemApps.size() > 0) {
            return systemApps.get(0);
        } else {
            return null;
        }
    }
    public List<SystemApp> getAllByIdList(List<String> idList) {
        Session session = getCurrentSession();
        Criteria criteria = session.createCriteria(SystemApp.class);

+ 27 - 17
src/main/java/com/yihu/hos/system/service/AppManager.java

@ -3,8 +3,6 @@ package com.yihu.hos.system.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.common.constants.ContextAttributes;
import com.yihu.hos.config.MongoConfig;
import com.yihu.hos.core.datatype.StringUtil;
import com.yihu.hos.core.encrypt.DES;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.interceptor.LocalContext;
@ -18,16 +16,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.zbus.broker.ZbusBroker;
import org.zbus.mq.Producer;
import org.zbus.net.http.Message;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import java.util.UUID;
/**
 * Created by chenweida on 2016/1/21.
@ -69,24 +64,39 @@ public class AppManager {
        return appDao.getEntity(SystemApp.class, id);
    }
    public SystemApp getAppByCode(String code) throws Exception {
        return appDao.findByCode(code);
    }
    @Transactional
    public Result addApp(SystemApp obj) throws Exception {
        appDao.saveEntity(obj);
        return Result.success("保存成功");
        SystemApp appByCode = getAppByCode(obj.getCode());
        if (appByCode == null) {
            appDao.saveEntity(obj);
            return Result.success("保存成功");
        } else {
            return Result.error("保存失败,应用Code已存在");
        }
    }
    @Transactional
    public Result updateApp(SystemApp obj) throws Exception {
        SystemApp systemApp = appDao.getEntity(SystemApp.class, obj.getId());
        systemApp.setName(obj.getName());
        systemApp.setCode(obj.getCode());
        systemApp.setAppKey(obj.getAppKey());
        systemApp.setAppSecret(obj.getAppSecret());
        systemApp.setAppUrl(obj.getAppUrl());
        systemApp.setDeveloper(obj.getDeveloper());
        systemApp.setIcon(obj.getIcon());
        systemApp.setStatus(obj.getStatus());
        return Result.success("更新成功");
        SystemApp appByCode = getAppByCode(obj.getCode());
        if (appByCode == null) {
            SystemApp systemApp = appDao.getEntity(SystemApp.class, obj.getId());
            systemApp.setName(obj.getName());
            systemApp.setCode(obj.getCode());
            systemApp.setAppKey(obj.getAppKey());
            systemApp.setAppSecret(obj.getAppSecret());
            systemApp.setAppUrl(obj.getAppUrl());
            systemApp.setDeveloper(obj.getDeveloper());
            systemApp.setIcon(obj.getIcon());
            systemApp.setStatus(obj.getStatus());
            return Result.success("更新成功");
        } else {
            return Result.error("更新失败,应用Code已存在");
        }
    }
    @Transactional

+ 1 - 1
src/main/webapp/WEB-INF/ehr/jsp/system/app/app.jsp

@ -9,7 +9,7 @@
    <div class="m-form-inline">
        <div class="m-form-group">
            <div class="m-form-control">
                <input type="text" id="txtName" class="l-text-field" placeholder="请输入服务名称"/>
                <input type="text" id="txtName" class="l-text-field" placeholder="请输入应用名称"/>
            </div>
            <div class="m-form-control" >